Skip to content

fix(server): background compactions no longer flip threads to Working - #25122

Merged
juliusmarminge merged 2 commits into
mainfrom
t3code/idle-compaction-shell
Oct 25, 2026
Merged

juliusmarminge merged 2 commits into
mainfrom
t3code/idle-compaction-shell

Conversation

@juliusmarminge

Copy link
Copy Markdown
Member

Follow-up to #24334. When T3 Code compacts an idle Claude thread on its own, the thread flipped to "Working" in the sidebar, inbox and mobile list. When the compaction finished, the inbox moved the thread to the top as a "return" and the sidebar showed an unread "Completed" pill. The hidden /compact prompt also bumped the thread's sort time, and the run restarted the auto-settle clock.

Fix

The thread shell now skips T3 Code's own idle compaction runs, and their /compact prompts, unless the compaction fails. This covers the in-memory threadShellFromProjection and the SQL shell and settlement queries, which share one SQL predicate that mirrors idleCompactionOf. The shell is what lists, notifications and the relay read, so they all keep presenting the user's last turn without any client changes:

  • The sidebar, inbox and mobile list never show Working for the compaction and never move the thread.
  • No Done notification, and the relay (mobile Done alerts, Live Activity) stays quiet.
  • Auto-settle timing ignores the run.
  • A failed compaction still becomes the latest run, so it still surfaces and notifies.

This replaces the latestRunSilent shell flag from #24334 and its client-side checks in the notification coordinator and agentAwareness. Those clients now see no change at all instead of having to filter one.

The open thread is unaffected: web and mobile build their live state from the full projection, so the timeline still shows the live "Compacting before the cache expires…" divider. A /compact you type is an ordinary turn. When you send to an idle thread and the composer compacts first, the sidebar shows activity once your queued message's own turn starts.

Evidence

This was checked against a real Claude Haiku thread on a dev server. To avoid waiting an hour, the idle compaction was patched to fire 15 seconds after the turn, for recording only. The page sampled the sidebar row every 250 ms:

 1.8s  sidebar row: Working 0s   ← the user's own turn
 3.5s  sidebar row: Working 1s
 4.0s  sidebar row: now          ← turn done
18.5s  sidebar row: now   timeline: "Compacting before the cache expires…"
24.8s  sidebar row: now   timeline: "Context automatically compacted before cache expiry 36.3K → 8.18K tokens"

The row stayed in the same position (index 0, y=102) throughout, and no pill appeared.

Tests

  • ProjectionStore.test.ts, in both shell paths: a running idle compaction, from the server or from compacting on return, is not the latest, active or activity run, and its prompt is not the latest user message. A typed /compact and an ordinary prompt are. A failed idle compaction surfaces.

Not run: mobile in a simulator.

Claude Opus 5.5 via Claude Code in T3 Code.

🤖 Generated with Claude Code

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). 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