Skip to content

feat(server): update Chat mode sub-thread labels at fixed user-message counts - #260

Merged
orbitingflea merged 1 commit into
mainfrom
feat/subthread-summary-cadence
Nov 22, 2026
Merged

orbitingflea merged 1 commit into
mainfrom
feat/subthread-summary-cadence

Conversation

@orbitingflea

@orbitingflea orbitingflea commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

This change limits how often Chat mode sub-thread labels update.

改了什么行为

Behaviour change: yes, users in Chat mode see sub-thread summary labels update at fixed user-message counts instead of every message.

Before, every reply, answer, and rewrite updated the label. Now it runs at reply 1, then user messages 3, 6, 10, and every 10 after. A user first message counts as 1, so replies 1 and 2 update it. Under an agent message, replies 1, 3, 6, 10, and every 10 after do. An agent answer that opens a sub-thread under a user message makes its first label. Other answers and rewrites start no run beyond a due one. Failed calls keep the old label and retry on the next user reply. Restarts skip done counts.

Why

Each update costs a model call. Running at these counts avoids a call per message.

Checks

  • 29 SQLite service tests use a fake title model for both sub-thread kinds, latest 6 messages, an opening agent answer, skipped answers and rewrites, ordered runs, retries, Chat filtering, steers, rollback or edit drops, repeats, restarts, and cleanup. 23 of 29 fail before this change.
  • vp run check:changed passed for format, lint, knip, typecheck, and tests.
  • On a read-only copy of the largest real thread, 4,364 user messages, the count query takes about 60 ms on a read-only connection.
  • Not run in a live client. Each message needs a paid call, and the UI does not change.

How to undo

Revert the commit. The two new tables stay unused, and labels return to every message.

Details

How it works:

  • On each user reply in a sub-thread, the server counts the sub-thread's user messages up to that reply in timeline order, as Chat shows them. Only messages that the user typed in a client count. Messages from rolled-back turns, undelivered queued replies, and the empty message from a Resume click do not count. The count reads the thread's stored timeline on a read-only connection.
  • The server stores, per sub-thread, the timeline position of the last user reply that the label covers. It computes the count up to that position the same way, so a rollback lowers the count on its own and a restart needs no extra state.
  • The server also stores replies whose model call did not save a label. If the server handles that same reply again, such as after a restart, it skips the model call and waits for the next new reply. These records live in two new SQLite tables created at startup with no migration.
  • A summary starts only when the count passes 1, 3, 6, 10, or a later multiple of 10 since the covered reply. When a late agent answer opens a sub-thread under the user's own message, that sub-thread has no label yet, so the answer makes its first label and the user's message counts as user message 1. Otherwise, agent answers and rewrites start no run beyond a due one.
  • The server handles one sub-thread's replies one at a time, in order, so each due count runs with its own messages. It saves the label and the covered position in one transaction, only if the reply still shows with the same text. If a rollback or an edit changed that reply during the model call, the server drops the result and leaves the reply due.
  • Callers, the client, the data sent to clients, and the prompt format do not change. Only apps/server/src/fork/subThreads/SubThreads.ts, its test file, and apps/server/src/fork/shownHistory/ShownHistory.ts change. ShownHistory.ts now exports its typed-user-message SQL so both files share one rule.

Accepted limits:

  • A sub-thread that already has a label from before this change gets one fresh label at its next user reply, then follows the exact counts.
  • A forked thread counts only the replies made in the fork.
  • While a covered reply is back in the queue, or if a queued reply is sent as a steer after a newer reply got a label, one label can be written twice.
  • If an answer is rewritten while its sub-thread ends with a user reply, the server treats it like handling that reply again and never adds a run beyond the due one.
  • An attachment-only reply counts toward the message count, while the prompt still carries only text because the prompt format does not change.
  • The top-level thread title, all UI, and Normal mode do not change.

Surfaces not changed:

  • Mobile has no Chat mode replies.
  • Providers do not change.
  • No locale text changes.

…, then every 10

The sub-thread label ran the text-generation model on every message. It now runs only when a
user reply brings the sub-thread's user-message count to 1, 3, 6, 10 or a later multiple of 10
since the reply the label covers, and once when an agent answer opens a sub-thread that has no
label yet. The count follows the typed user messages that Chat shows, in timeline order
(rolled-back turns, undelivered queued replies, server-made and empty Resume messages do not
count). One table keeps the covered position per sub-thread and one keeps the replies whose run
did not store a label, so a second wrap of one starts no run. Wraps of one sub-thread run one at
a time; the label and the covered position are stored in one transaction that rechecks the
reply still shows with the same text. ShownHistory exports its typed-message SQL so both use one
rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L labels Nov 22, 2026
@github-actions

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 82a8646 · PR result: 6679dc3 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@orbitingflea
orbitingflea merged commit 48c03fb into main Nov 22, 2026
27 checks passed
@orbitingflea
orbitingflea deleted the feat/subthread-summary-cadence branch November 22, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted 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