Skip to content

Commit 2c12f74

Browse files
author
Oğuz Eray Orhan
committed
fix: session changes panel always empty — restore diff computation
Two bugs prevent the TUI right-panel 'Session Changes' tab and Desktop review panel from showing modified files: 1. session.ts: Session.diff() is a hardcoded stub returning [] always. 2. summary.ts: SessionSummary.diff() only reads cached per-message diffs. Root cause: regression from older working version (51e310c) to current dev where summarize() publishes empty events and stores only per-message diffs, never computing the full session diff. Related: anomalyco#32852, anomalyco#30877, anomalyco#13981, anomalyco#13065, anomalyco#11856, anomalyco#10920, anomalyco#10716, anomalyco#7555
1 parent 743f641 commit 2c12f74

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

‎packages/opencode/src/session/session.ts‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ export type Patch = Omit<Partial<Info>, "time" | "share" | "summary" | "revert"
488488
const layer: Layer.Layer<
489489
Service,
490490
never,
491-
BackgroundJob.Service | RuntimeFlags.Service | Database.Service | EventV2Bridge.Service
491+
BackgroundJob.Service | RuntimeFlags.Service | Database.Service | EventV2Bridge.Service | Snapshot.Service
492492
> = Layer.effect(
493493
Service,
494494
Effect.gen(function* () {
@@ -497,6 +497,7 @@ const layer: Layer.Layer<
497497
const background = yield* BackgroundJob.Service
498498
const events = yield* EventV2Bridge.Service
499499
const flags = yield* RuntimeFlags.Service
500+
const shot = yield* Snapshot.Service
500501

501502
const createNext = Effect.fn("Session.createNext")(function* (input: {
502503
id?: SessionID
@@ -823,8 +824,24 @@ const layer: Layer.Layer<
823824
})
824825

825826
const diff = Effect.fn("Session.diff")(function* (sessionID: SessionID) {
826-
void sessionID
827-
return [] as Snapshot.FileDiff[]
827+
const msgs = yield* messages({ sessionID }).pipe(Effect.orDie)
828+
let from: string | undefined
829+
let to : string | undefined
830+
for (const item of msgs) {
831+
if (!from) {
832+
for (const part of item.parts) {
833+
if (part.type === "step-start" && part.snapshot) {
834+
from = part.snapshot
835+
break
836+
}
837+
}
838+
}
839+
for (const part of item.parts) {
840+
if (part.type === "step-finish" && part.snapshot) to = part.snapshot
841+
}
842+
}
843+
if (from && to) return yield* shot.diffFull(from, to)
844+
return []
828845
})
829846

830847
const messages: Interface["messages"] = Effect.fn("Session.messages")(function* (input) {
@@ -1012,7 +1029,7 @@ function listByProject(
10121029
export const node = LayerNode.make({
10131030
service: Service,
10141031
layer: layer,
1015-
deps: [BackgroundJob.node, RuntimeFlags.node, Database.node, EventV2Bridge.node],
1032+
deps: [BackgroundJob.node, RuntimeFlags.node, Database.node, EventV2Bridge.node, Snapshot.node],
10161033
})
10171034

10181035
export * as Session from "./session"

‎packages/opencode/src/session/summary.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,16 @@ const layer = Layer.effect(
127127
})
128128

129129
const diff = Effect.fn("SessionSummary.diff")(function* (input: { sessionID: SessionID; messageID?: MessageID }) {
130-
if (!input.messageID) return []
131-
const message = (yield* sessions.messages({ sessionID: input.sessionID }).pipe(Effect.orDie)).find(
132-
(item) => item.info.id === input.messageID,
133-
)
130+
if (!input.messageID) {
131+
const all = yield* sessions.messages({ sessionID: input.sessionID }).pipe(Effect.orDie)
132+
if (!all.length) return []
133+
return yield* computeDiff({ messages: all })
134+
}
135+
const all = yield* sessions.messages({ sessionID: input.sessionID }).pipe(Effect.orDie)
136+
const message = all.find((item) => item.info.id === input.messageID)
134137
if (!message || message.info.role !== "user") return []
135138
const diffs = message.info.summary?.diffs ?? []
139+
if (diffs.length === 0) return yield* computeDiff({ messages: all })
136140
return diffs.map((item) => {
137141
if (item.file === undefined) return item
138142
const file = unquoteGitPath(item.file)

0 commit comments

Comments
 (0)