perf(server): skip shell refresh for streaming deltas #4009
main fromrefs/pull/4009/head·opened View on GitHubWhat Changed#
Skip refreshThreadShellSummary for streaming assistant messages while preserving message projection and the thread updatedAt. Add a regression test that fails if this hot path reads thread activity history.
Why#
Large threads can retain hundreds of MB of tool activity. Rebuilding the shell summary for every text delta made projection time proportional to the full thread history and throttled visible streaming to about one delta per second.
Fixes #4008.
This is the minimal shell-refresh subset of #2631; it does not change message repository APIs or persistence behavior.
UI Changes#
No UI code changed; this fixes streaming timing.
- Before: slow TPS demo in #4008
- After:
https://github.com/user-attachments/assets/539ec50b-8ecc-40db-832c-11dc806cfc77
Testing#
vp test apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts(22 passed)vp check(passes; 9 pre-existing warnings)vp run typecheck- Reproduced and verified against the original affected thread
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes
- I included a video for animation/interaction changes
Note
Medium Risk Changes projection hot-path behavior so thread shell summary fields may lag during streaming until a non-streaming event refreshes them; scoped change with test coverage.
Overview
Streaming assistant deltas no longer trigger a full thread shell summary rebuild on each thread.message-sent projection. The threads projector still bumps updated_at, but it skips refreshThreadShellSummary when the event is an assistant message with streaming: true, avoiding repeated scans of messages, activities, and pending approvals on every text chunk.
A regression test seeds invalid activity JSON for the thread and projects a streaming assistant delta; if the hot path reads activity history, projection fails. It also asserts the streamed message and thread timestamp still update correctly.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 69d5c69b864dcd84caa8cc920099cec9fe6491dc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).Note
Skip shell summary refresh for streaming assistant messages in projection pipeline#
When processing a thread.message-sent event where the role is assistant and the message is marked as streaming, the projector in ProjectionPipeline.ts now skips the shell summary refresh. The thread updated_at is still updated. A new test verifies no historical activity scan occurs during streaming delta handling.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved
A small, well-tested performance optimization that conditionally skips shell summary refresh for streaming assistant message deltas. The change is self-contained with clear intent and comprehensive test coverage.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Closing in favor of #2829 (orchestration V2).
#2829 deletes the V1 orchestration layer this PR builds on —
apps/server/src/orchestration/**,provider/Layers/*Adapter.tsandprovider/Services/**are removed and replaced byapps/server/src/orchestration-v2/**, with the IPC surface renamed toORCHESTRATION_V2_WS_METHODS. The files this PR touches either no longer exist or are rewritten, so it can't be rebased — it would need reimplementing against the V2 adapters.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
main, port the change to the V2 equivalent, and reopen (or open a fresh PR). Ping me and I'll prioritise the review.juliusmarminge closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
0e60cad3-1893-46d1-b51f-64bd6fd523e5You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share