The open source coding agent.
TypeScript
core: update session summary after revert to show file changes
Dax Raad65938baf00f5
diff --git a/packages/opencode/src/session/revert.ts b/packages/opencode/src/session/revert.tsindex 35c7b9a607e..7afe44e2ce3 100644--- a/packages/opencode/src/session/revert.ts+++ b/packages/opencode/src/session/revert.ts@@ -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 sessiondiff --git a/packages/opencode/src/session/summary.ts b/packages/opencode/src/session/summary.tsindex dbca218f9c6..c03100c9bfb 100644--- a/packages/opencode/src/session/summary.ts+++ b/packages/opencode/src/session/summary.ts@@ -120,7 +120,7 @@ export namespace SessionSummary {},)- async function computeDiff(input: { messages: MessageV2.WithParts[] }) {+ export async function computeDiff(input: { messages: MessageV2.WithParts[] }) {let from: string | undefinedlet to: string | undefined