Skip to content

fix(server): let stopped threads settle immediately - #5553

Merged
t3dotgg merged 2 commits into
mainfrom
t3code/fix-thread-settlement-failure
Aug 7, 2026
Merged

fix(server): let stopped threads settle immediately#5553
t3dotgg merged 2 commits into
mainfrom
t3code/fix-thread-settlement-failure

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Aug 6, 2026

Copy link
Copy Markdown
Member

Stopping or interrupting a thread could make Settle fail for two minutes. The SQLite projection cleared the latest turn when the session returned to ready, so clients misclassified the last user message as a queued turn.

Keep the previous latest turn when a session has no active turn. The lifecycle test now verifies that turn history remains linked after the session ends.

Tested:

  • vp test run apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
  • vp run --filter t3 typecheck
  • targeted format and lint checks

Made by GPT-5.6 Sol in T3 Code using the Codex harness.


Note

Medium Risk
Changes orchestration projection semantics for all threads when sessions clear activeTurnId; low blast radius but affects settle and client turn classification.

Overview
Fixes Settle timing out and clients treating the last user message as a queued turn when a thread is stopped or interrupted.

On thread.session-set, the threads projector no longer writes latestTurnId from session.activeTurnId when that value is null. It keeps the existing projection_threads.latest_turn_id so a terminal session (e.g. ready with no active turn) does not wipe turn history.

The turn lifecycle test now asserts latest_turn_id stays set after the session ends.

Reviewed by Cursor Bugbot for commit 6374e09. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Preserve latestTurnId in projection when session.activeTurnId is null

When handling a thread.session-set event, the projector in ProjectionPipeline.ts previously overwrote latestTurnId with null if session.activeTurnId was absent. It now falls back to the existing latestTurnId value using null-coalescing. A corresponding test assertion was added to verify projection_threads.latest_turn_id is preserved correctly.

Macroscope summarized 6374e09.

@coderabbitai

coderabbitai Bot commented Aug 6, 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: f81de630-678e-47d3-be90-7affd3185534

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.

@macroscopeapp

macroscopeapp Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 26db156

Small defensive bug fix using nullish coalescing to preserve latestTurnId when a session terminates (activeTurnId becomes null). Clear intent, limited scope, and includes test verification.

No code changes detected at 6374e09. Prior analysis still applies.

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

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Aug 7, 2026
@t3dotgg
t3dotgg merged commit 7aad791 into main Aug 7, 2026
17 checks passed
@t3dotgg
t3dotgg deleted the t3code/fix-thread-settlement-failure branch August 7, 2026 01:43
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:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant