Fixes #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 --check passed
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
eventCanChangeThreadShellSummary in ProjectionPipeline.ts to gate calls to refreshThreadShellSummary. 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 shell updatedAt timestamp instead of triggering a full summary refresh.
- Behavioral Change: previously every
thread.message-sent and thread.activity-appended event caused a summary rescan; now only a subset does.
Macroscope summarized 77b586e.
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.
Reviewed by Cursor Bugbot for commit 77b586e. Bugbot is set up for automated code reviews on this repo. Configure here.