Repository navigation
Replies: 1 comment
|
Confirmed — the durable event genuinely carries only the turn number, and the package says so in its own doc comment, which makes this a design boundary rather than an oversight.
So the event is a notification, not a record: it tells a live client "turn N changed something, ask the service for details". The details live in Your 79/4044 measurement across 549 files is the right way to establish this and is more convincing than any single reproduction, because it also shows the feature is used sparingly (about 2% of turns) rather than being an edge case nobody hits. Three things I would add to the report
On the scope You filed it under Ideas; the observable ("every historical changed-files card 404s after restart") is a bug, and the persistence change is the fix. Splitting it that way usually gets a faster response than presenting it as a feature request — the client-side contract change in point 2 above needs no schema work at all and can ship independently. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
After a Host restart (or after a Session is disposed and later reopened), every historical changed-files card 404s. The conversation itself is fine. The browser console fills with:
The Web client treats the 404 as an expected miss (
ChangesSummaryStoremaps 404 to'missing',retryable: () => false), so the card silently disappears. Chrome still logs the failed fetch in red. Same root cause hits all three routes:ctx.workspaceChanges.summary(sessionId, seq)returnsundefined, andhandleChangesSummary/handleChangesOpenanswerChange summary unavailable.Seen on Web
0.2.1-rc.2, Windows, profileweb.What is durable, and what is not
workspace/changesis appended to the session log. I decoded the multi-frame zstd logs under~/.dsh/sessions(single-framezstdDecompressSynconly returns the header frame; the real events are in later frames). Across 549 session files:turn/endworkspace/changesEvery one of those events carries only the turn number:
{"type":"workspace/changes","seq":942,"data":{"turn":2}}The file list, line counts,
cwd, and snapshot tree ids live only inTurnRecorder.records(Map), keyed by the event seq. Snapshot objects and whole-file captures live underos.tmpdir()/dsh-workspace-changes-*and arerm -rf'd indispose(). On this machine that scratch set was 43 directories / ~50 MB, and it does not survive process exit.So the log can prove "turn N was summarized", but it cannot reconstruct the summary. After restart the client still replays the event and fetches
/api/changes.summary?seq=<old seq>. The new process has an emptybyIdmap, so the route 404s.Why a listener cannot rebuild it on open
Sessionconstruction documents this explicitly: seed events never publish onsession/event. Opening a stored session replays the log into the seed and does not re-emitturn/start,tool/result,turn/end, orworkspace/changes.workspace-changesonly creates a recorder on a liveturn/start(recorderFor), andsummary()isbyId.get(sessionId)?.summary(seq). A reopened session therefore has no recorder even while the announcing event is still insession.snapshotEvents().eligible()also skipsorigin === 'subagent'anddelegationDepth > 0, so those sessions never record. That part is intentional; the 404s in question are ordinary top-level sessions whose events are already on disk.Suggested fix
Keep the event as the durable source of truth, matching the comment on
Session.append. Two layers:Persist the summary in the event data (small, fixes the card and
changes.open).Widen
'workspace/changes'from{ turn: number }to also carryfiles,total,added,deleted, andcwd(the publicChangesSummaryshape; omit private snapshot tree ids).recorder.record()already has that object in hand atsession.append(...).On
summary(sessionId, seq)miss, read the live session (ctx.sessions.get) and, ifeventAt(seq)is aworkspace/changeswith the richer data, return it. Old logs stay{ turn }only — those keep 404ing, which is fine; new turns survive restart.changes.openalready resolveschanges.cwd+files[index].paththroughworkspaceFiles.stat, so it comes back for free oncesummary()can answer from the log.Leave diffs ephemeral, or persist them separately.
diff()needs the turn-start/turn-end git trees (or the capture copies). Those objects are content-addressed under tmpdir and deleted on dispose, so a richer event does not restore comparisons. Options, in increasing cost:scratchDir()fromos.tmpdir()to a durable directory under the session dir (sessionDir(root, cwd, id)is already documented as available for session-local artifacts) and stop deleting it indispose(). Needs a retention cap; the private object store grows per turn (maxFiles500,maxFileBytes2 MB).(1) alone removes the console spam for the summary route and restores the card. (2) is only needed if comparisons must also survive restart.
Why a profile plugin cannot paper over this
ctx.provide('workspaceChanges', …)throwsproperty "workspaceChanges" is already declaredwhile the official plugin is loaded, and the fetch routes are registered once inside the connection fence (duplicate … route). A drop-in replacement has to disable the officialworkspace-changesbundle entry and re-provide the service. That is a reasonable local workaround, but the data should be in the log so every client (Web, a future TUI, a plugin) can read it without a private scratch directory.Repro
workspace-changesappendsworkspace/changes)./api/changes.summary?sessionId=…&seq=…returns 200.dsh web), reopen the same session.404 Change summary unavailable.The card is gone.changes.diffandchanges.openfor that seq 404 as well.Code pointers (0.2.1-rc.2)
packages/deliverables/workspace-changes/src/recorder.ts—recordsMap;session.append('workspace/changes', { turn })around therecord()tail; scratch dir created withmkdtempundertmpdir()and removed indispose().packages/deliverables/workspace-changes/src/types.ts—SessionEventMap['workspace/changes']is{ turn: number };WorkspaceChangesSummaryalready has the fields the route returns.packages/deliverables/workspace-changes/src/index.ts—summary()/diff()readbyIdonly; recorder is created lazily onturn/start.packages/client/ui-deliverables/src/present-open.ts—handleChangesSummary/handleChangesDiff/handleChangesOpenmap a missing summary to 404.packages/core/session/src/index.ts— seed events never publish onsession/event.All reactions