fix(server): preserve latest turn after session completion - #5445
fix(server): preserve latest turn after session completion#5445sungsoo-han wants to merge 2 commits into
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:
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 9d15f0d Straightforward bug fix that adds a nullish coalescing fallback to preserve You can customize Macroscope's approvability policy. Learn more. |
Before:
Completed threads briefly lost their latest turn reference, causing Settle to incorrectly report that work was still pending.

After:
Completed threads preserve their latest turn reference when the session becomes ready, allowing them to settle immediately.
Note
Low Risk
Single-field fallback in one projection handler with a targeted regression test; no auth or broad API changes.
Overview
Fixes
projection_threads.latest_turn_idbeing cleared when a thread’s session moves to a non-running state (e.g.ready) with noactiveTurnId.On
thread.session-set, the threads projector no longer overwriteslatestTurnIdwith a nullishactiveTurnId; it keeps the existing value instead. That stops completed threads from briefly losing their last turn reference, which had caused Settle to treat work as still pending.A projection test now asserts
latest_turn_idstays set after the session leavesrunningand the turn is marked completed.Reviewed by Cursor Bugbot for commit da525fb. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
projection_threads.latest_turn_idto preserve value on session completionIn the
thread.session-setevent handler in ProjectionPipeline.ts,latestTurnIdwas unconditionally set toevent.payload.session.activeTurnId, which could overwrite the stored value withnullorundefinedwhen the session ended. It now falls back toexistingRow.value.latestTurnIdwhenactiveTurnIdis absent.Macroscope summarized da525fb.