fix(server): preserve historical latest turn - #4402
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved Single-line bug fix using null coalescing to preserve You can customize Macroscope's approvability policy. Learn more. |
1309294 to
4bf18f1
Compare
0e3f702 to
8687011
Compare
|
Closing in favor of #2829 (orchestration V2). #2829 deletes the V1 orchestration layer this PR builds on — This is not a judgement on the change itself. Several of these are real gaps we still want fixed; the base just moved out from under them. Once #2829 merges, please rebase onto |
Fixes #4399
Summary
Why it was intermittent
ProjectionSnapshotQuery joins the latest turn through projection_threads.latest_turn_id. A terminal session event could clear that pointer, while a later thread.turn-diff-completed event restored it. Event ordering therefore determined whether shell snapshots retained the completed turn.
Commit 501ce27 correctly clears stale session active-turn state for inactive sessions and should remain. This fix changes only the thread projection so historical latest-turn state survives that correct session transition.
Tests
Commands run:
Note
Preserve
latestTurnIdon threads whenthread.session-sethas no active turnWhen a
thread.session-setevent carries a nullactiveTurnId(e.g. on session transitions to idle, stopped, or ready), the projection previously clearedthreads.latestTurnId. The fix in ProjectionPipeline.ts usesactiveTurnId ?? existingRow.value.latestTurnIdso the last known turn is retained. New tests in ProjectionPipeline.test.ts cover completed-turn preservation, no-active-turn session statuses, and sequential turn replacement.Macroscope summarized 8687011.