|
|
@@ -8,6 +8,7 @@ import { splitWhen } from "remeda"
|
|
|
import { Storage } from "../storage/storage"
|
|
|
import { Bus } from "../bus"
|
|
|
import { SessionPrompt } from "./prompt"
|
|
|
+import { SessionSummary } from "./summary"
|
|
|
|
|
|
export namespace SessionRevert {
|
|
|
const log = Log.create({ service: "session.revert" })
|
|
|
@@ -57,8 +58,20 @@ export namespace SessionRevert {
|
|
|
revert.snapshot = session.revert?.snapshot ?? (await Snapshot.track())
|
|
|
await Snapshot.revert(patches)
|
|
|
if (revert.snapshot) revert.diff = await Snapshot.diff(revert.snapshot)
|
|
|
+ const rangeMessages = all.filter((msg) => msg.info.id >= revert!.messageID)
|
|
|
+ const diffs = await SessionSummary.computeDiff({ messages: rangeMessages })
|
|
|
+ await Storage.write(["session_diff", input.sessionID], diffs)
|
|
|
+ Bus.publish(Session.Event.Diff, {
|
|
|
+ sessionID: input.sessionID,
|
|
|
+ diff: diffs,
|
|
|
+ })
|
|
|
return Session.update(input.sessionID, (draft) => {
|
|
|
draft.revert = revert
|
|
|
+ draft.summary = {
|
|
|
+ additions: diffs.reduce((sum, x) => sum + x.additions, 0),
|
|
|
+ deletions: diffs.reduce((sum, x) => sum + x.deletions, 0),
|
|
|
+ files: diffs.length,
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
return session
|