fix(server): stop routine events from rescanning thread history #7356
main fromrefs/pull/7356/head·opened View on GitHubFixes #5719.
What Changed#
The threads projector no longer calls refreshThreadShellSummary for assistant messages or routine activities. Those events still update their normal projections and advance the thread's updatedAt, but they skip the second operation that reloads the thread's complete message, proposed-plan, activity, and approval histories.
The existing full refresh remains in place for events that can change the current shell summary:
- user messages
- approval and user-input lifecycle activities
- proposed plans and explicit approval/user-input responses
- session and latest-turn changes
- thread reverts
A focused projection-pipeline regression test verifies that an assistant message and a routine tool.updated activity each produce only the expected thread timestamp update, rather than that update followed by a summary rewrite.
Why#
refreshThreadShellSummary derives four fields: the latest user-message time, pending approval count, pending user-input count, and actionable-plan state. Assistant messages and ordinary tool/context activities cannot change any of them, but every such event currently reloads all four backing collections.
On a high-activity thread with 27,303 activities and 23,778 messages, activity projection averaged 734 ms per event. A burst of 526 routine activity and assistant-message events therefore accounted for approximately 386 seconds of serialized projection work, delaying unrelated threads behind the same global ingestion worker.
This change removes that measured hot path without changing summary derivation or introducing incremental counters.
Related: #5855 and #6608 address the same projection cost with broader changes. This PR intentionally keeps the existing summary implementation and only avoids invoking it for events that cannot affect its result.
Verification#
vp test run apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts— 22 passed- server typecheck passed
- targeted lint and formatting passed
- server bundle build passed
git diff --checkpassed
No schema, projector cursor, transaction, replay, queue, client, or UI changes.
Checklist#
- This PR is small and focused
- I explained what changed and why
- No UI changes; screenshots are not applicable
- No animation or interaction changes; video is not applicable
Model and harness: GPT-5.6 Sol using the Codex harness in T3 Code.
Note
Stop assistant messages and routine activities from rescanning thread history#
- Adds
eventCanChangeThreadShellSummaryin ProjectionPipeline.ts to gate calls torefreshThreadShellSummary. Only user messages and specific activity kinds (approval.requested,approval.resolved,user-input.requested, etc.) qualify. - Assistant messages and routine activities (e.g.
tool.updated) now only update the thread shellupdatedAttimestamp instead of triggering a full summary refresh. - Behavioral Change: previously every
thread.message-sentandthread.activity-appendedevent caused a summary rescan; now only a subset does.
Note
Medium Risk Changes which events recompute thread list/shell summary fields; incorrect gating could leave stale pending counts or user-message timestamps, though existing tests cover approval/user-input paths and the new assistant/tool cases.
Overview
Skips expensive thread shell summary rescans for assistant messages and routine activities (e.g. tool.updated) during orchestration projection, while still bumping the thread shell updatedAt.
Adds eventCanChangeThreadShellSummary in ProjectionPipeline.ts so refreshThreadShellSummary runs only when an event can change derived fields (latest user message time, pending approvals/user input, actionable plans). User messages and approval/user-input lifecycle activities still trigger a full refresh; proposed plans and explicit response events behave as before.
A regression test uses a SQLite trigger on projection_threads to assert assistant messages and routine activities cause a single row update (timestamp only), not a second update from summary refresh.
- 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:S
Approvability#
Verdict: Needs human review
This PR changes when the thread shell summary refresh occurs, gating a database read/write operation based on event type. While the optimization logic appears correct, changes that determine whether significant processing work happens warrant human review to verify the gating conditions are complete.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).t3dotgg(GitHub profile, opens in a new tab) 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 Plus
Run ID:
aa0c1725-906e-4497-beb0-7514139b989dYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share