Skip to content

Add queued thread turn orchestration#2724

Closed
justsomelegs wants to merge 8 commits into
pingdotgg:mainfrom
justsomelegs:t3code/b38165eb
Closed

Add queued thread turn orchestration#2724
justsomelegs wants to merge 8 commits into
pingdotgg:mainfrom
justsomelegs:t3code/b38165eb

Conversation

@justsomelegs
Copy link
Copy Markdown
Contributor

@justsomelegs justsomelegs commented May 16, 2026

Summary

  • add queued thread turn orchestration across contracts, decider/projector, provider runtime ingestion, drain reactor, persistence projections, and web dispatch
  • split queued user sends onto thread.turn.queue while keeping thread.turn.start for immediate/provider-directed sends
  • persist queued turn request snapshots and project queue lifecycle state through a shared @t3tools/shared/orchestrationQueue helper
  • consolidate the unshipped queue feature database shape into migration 31

Audit notes

  • Reviewed changed Effect/server surfaces against the repo Effect guidance: schema-first contracts, Effect services/layers, typed persistence errors, and scoped reactor startup.
  • No merge-blocking issues found in the final diff.
  • Main intentional tradeoff: the feature migration was consolidated because this queue work has not shipped or been run locally; existing experimental migration IDs 32/33 are removed from this branch.
  • Existing lint warnings remain in unrelated/currently pre-existing areas: ChatView hook dependency warnings, catalog test function scoping, and client persistence map spread.

Verification

  • bun run test --filter=@t3tools/contracts -- orchestration
  • bun run test --filter=t3 -- QueuedTurnDrainReactor ProviderCommandReactor decider.projectScripts
  • bun fmt
  • bun lint pass with existing warnings only
  • bun typecheck

Note

Add queued thread turn orchestration for sending messages during active sessions

  • Adds a full turn queuing system so users can send messages while a session is running; the message is enqueued rather than immediately starting a new turn (thread.turn.queue command).
  • Introduces queued turn lifecycle events (thread.turn-queued, thread.queued-turn-send-started, thread.queued-turn-send-failed, thread.queued-turn-requeued, thread.queued-turn-resolved) handled in the decider, projector, and store.
  • Adds QueuedTurnDrainReactor — a background reactor that dispatches thread.queued-turn.send.start when a thread's session becomes ready, with recovery for previously-sending items.
  • Surfaces queued turn status in the chat composer via banners showing sending/pending counts and failed turns with a Retry action (handleRetryQueuedTurn dispatches thread.queued-turn.retry).
  • Adds migration 031_ProjectionQueuedTurns.ts creating projection_queued_turns table and adding queue_item_id column to projection_turns.
  • Risk: thread.turn.start now always emits a thread.message-sent event before thread.turn-start-requested, changing the event sequence for existing turn starts.

Macroscope summarized ec2441f.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

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

Run ID: a22d00c4-6097-4551-be61-0ff830300357

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels May 16, 2026
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 16, 2026

Approvability

Verdict: Needs human review

This PR adds a complete queued turn orchestration feature, introducing new user-facing behavior (ability to queue messages during active threads), new backend services (QueuedTurnDrainReactor), database schema changes, and substantial UI modifications. The scope and cross-cutting nature of this new capability warrants thorough human review.

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:XXL 1,000+ 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