Skip to content

fix(server): preserve latest turn after session completion - #5445

Open
sungsoo-han wants to merge 2 commits into
pingdotgg:mainfrom
sungsoo-han:bugfix/sidebar-maintenance
Open

fix(server): preserve latest turn after session completion#5445
sungsoo-han wants to merge 2 commits into
pingdotgg:mainfrom
sungsoo-han:bugfix/sidebar-maintenance

Conversation

@sungsoo-han

@sungsoo-han sungsoo-han commented Aug 5, 2026

Copy link
Copy Markdown

Before:

Completed threads briefly lost their latest turn reference, causing Settle to incorrectly report that work was still pending.
SCR-20260805-nyyy

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_id being cleared when a thread’s session moves to a non-running state (e.g. ready) with no activeTurnId.

On thread.session-set, the threads projector no longer overwrites latestTurnId with a nullish activeTurnId; 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_id stays set after the session leaves running and 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_id to preserve value on session completion

In the thread.session-set event handler in ProjectionPipeline.ts, latestTurnId was unconditionally set to event.payload.session.activeTurnId, which could overwrite the stored value with null or undefined when the session ended. It now falls back to existingRow.value.latestTurnId when activeTurnId is absent.

Macroscope summarized da525fb.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ba82661-7f26-4bea-8289-c356ab3c5fba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Aug 5, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 9d15f0d

Straightforward bug fix that adds a nullish coalescing fallback to preserve latestTurnId when activeTurnId is null during session completion. Clear intent, limited scope, includes test coverage.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant