Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat: show compaction state and result instead of a generic Working #7714

Closedrobertnisipeanu(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/7714/headopened View on GitHub

When a provider compacts a thread, the timeline shows a bare "Working for N" with nothing saying compaction is running, how long it has been running, or whether it succeeded. This PR gives compaction its own visible state and result row, for every provider that has a compaction concept.

Stacked on #7591 — it includes that branch's commit, because the compaction states compose with its no-turn heartbeat guard. Once #7591 merges this PR reduces to the single feat: commit.

How it works

  • OrchestrationSession gains an optional statusDetail: "compacting". The status itself stays running, so lifecycle semantics (settling, turn tracking) are untouched, and older clients that don't know the field keep decoding sessions.
  • Ingestion raises the detail from a new compacting runtime session state — only on non-terminal sessions, so a late compacting signal cannot mask an errored or stopped one — and carries it across lifecycle events that keep the session busy without saying anything about compaction (a completed turn the compaction outlived, session/thread start notifications landing mid-work). The session also carries a compactingSince timestamp stamped by the write that raises the detail, so compaction timers count from the actual start on every client, including one that connects mid-compaction. A session that is only busy compacting does not wake a thread the user explicitly settled.
  • Completed context_compaction items map to the existing context-compaction activity kind — with an error tone and "Context compaction failed" summary for failures — so clients render one row shape regardless of which provider reported it.
  • New status_detail and compacting_since columns on projection_thread_sessions (migrations 042 and 043) persist the detail and its clock.

Per provider

ProviderStart signalEnd signalResult
Claudestatus:"compacting" (exempted from the no-turn heartbeat guard; the closing status lands on ready when no turn owns it, so the pair self-clears)closing status / compact_boundarytoken delta + duration from compact_metadata; compact_result:"failed"/compact_error becomes a failed context_compaction item
Codexnative contextCompaction item starteditem completed (lands on ready when the turn already closed, tracked per session)plain "Context compacted"; the deprecated thread/compacted notification is consumed silently so the two signals cannot double-report
OpenCodesession.time.compacting rising edgefalling edge / session.compactedplain "Context compacted"
Cursor, Grok——ACP has no compaction concept

UI

Web and mobile render "Compacting context for N" in place of the working row (elapsed timer, no synthetic progress bar — no provider emits real compaction progress), a "Compacting" sidebar/thread-list label, and a completion row enriched with the token delta and duration where the provider supplies them: Context compacted · 148k → 12k tokens · 45s. Failed compactions render with an error tone and the provider's error text.

Testing

Focused suites across the touched surfaces (adapters, ingestion, decider, projections, contracts, web logic, mobile logic): 560+ tests passing. New coverage: Claude compaction status pair + failed compaction item + compact_result closing a busy status, Codex item pair + post-turn completion + silenced deprecated notification, OpenCode edge transitions, ingestion statusDetail lifecycle (raise, carry across turn.completed and thread.started, stable compactingSince, terminal-session guard, clear), decider settle behavior, sidebar label, the failure-reason row detail, and the metadata-enriched row label on web and mobile.

Closes #7652

🤖 Generated with Claude Code — Claude Fable 5


Note

Medium Risk Touches session lifecycle, projections, and provider adapters so overlay/clock bugs could mislabel busy vs ready or mask terminal errors. Compaction is designed not to drive turn status, and coverage is extensive.

Overview When a provider compacts context, clients now show Compacting (with elapsed time) instead of a generic Working row, plus a first-class result row (token delta/duration when the provider reports them, error tone + reason on failure).

Sessions gain optional statusDetail: "compacting" and compactingSince. Compaction overlays the turn lifecycle rather than driving it: a /compact can stay compacting after the turn settles to ready, late compacting signals never mask error/stopped, and compacting-only sessions do not unsettle a user-settled thread. The overlay is persisted on projection_thread_sessions (migrations 042/043).

Claude, Codex, and OpenCode emit a new runtime compacting state and map completion/failure into context-compaction activities. Web and mobile timelines keep compaction rows out of turn folds so they do not inflate “Worked for” duration.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7d489919c5b48b1811d820db22232bf85811bc07. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Show compaction state and result instead of generic 'Working' across adapters and UI

  • Adds compacting to RuntimeSessionState and optional statusDetail/compactingSince fields to OrchestrationSession in orchestration.ts and providerRuntime.ts
  • Claude, Codex, and OpenCode adapters track compaction across messages and emit session.state.changed:compacting transitions; failed compactions surface as context_compaction items with error detail
  • Server ingestion treats compaction as a non-lifecycle overlay (statusDetail='compacting' with stable compactingSince) that survives turn completion but is dropped on terminal sessions; DB migrations 042/043 add status_detail and compacting_since columns to projection_thread_sessions
  • Web and mobile UI render a CompactionTimelineRow with token/duration metadata, show a pulsing 'Compacting' pill in the sidebar and thread list, and exclude compaction entries from turn folds and duration calculations
  • Risk: decider.ts decideOrchestrationCommand no longer emits unsettled for thread.session.set with statusDetail='compacting'; review the isSessionActivity check in decider.ts if other statusDetail values are added later. setThreadSessionErrorOnTurnStartFailure in ProviderCommandReactor.ts no longer carries transient fields from prior sessions.
Macroscope summarized 7d48991.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: fe63a5b6-4214-42fb-8e56-eeb54987bb49

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Skipped

      Macroscope did not run approvability analysis for this PR. Macroscope could not determine whether this PR modifies its approvability configuration, so the PR was not approved automatically. A PR that may change the rules that govern approval is never approved automatically.

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/07930eea4b9ab1d6ed207f89836083237ec7a285/apps/mobile/src/features/threads/ThreadFeed.tsx#L1995

      When compaction runs with an empty feed and no active turn, the “No conversation yet” placeholder renders over the Compacting context row, hiding the compaction state. The placeholder condition only checks props.activeWorkStartedAt; also exclude props.compactingSince so the working row remains visible.

      ✅ Resolved in 8a29926bb469054134252dc6c4a5c0d9093667aa

    5. Real, fixed in 8a29926. The placeholder condition now also excludes an in-flight compaction, so the "Compacting context" row is never covered on an empty feed.

    6. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    7. One consistency finding on the web sidebar's compacting label. The rest of the web changes (timeline compaction row, working row copy, pill resolver, ChatView plumbing) look consistent with the existing row/fold treatment.

      Posted via Macroscope — UI Consistency
    8. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/ddf8548709feb327f392cc41484b97cfb253a5fd/apps/web/src/components/Sidebar.tsx#L1479

      Compacting still displays elapsed time from resolveWorkingStartedAt(thread), so a compaction that begins during a long-running turn shows the turn's age (for example, Compacting 20m) instead of time since compaction began. Use the compaction session timestamp, such as thread.session?.updatedAt, when statusDetail === "compacting".

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/web/src/components/Sidebar.tsx around line 1479:
      
      `Compacting` still displays elapsed time from `resolveWorkingStartedAt(thread)`, so a compaction that begins during a long-running turn shows the turn's age (for example, `Compacting 20m`) instead of time since compaction began. Use the compaction session timestamp, such as `thread.session?.updatedAt`, when `statusDetail === "compacting"`.
    9. Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f637b859e286c8101ab6c15ce08e4d5e16c0d548. Configure [here](https://www.cursor.com/dashboard/bugbot).
    10. Fixed in 0e13058e5: the Compacting duration ticks from the session's compactingSince (a new persisted field stamped when the detail is raised), not from the turn-start clock.

    11. Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    12. One finding in the changed web sidebar row: the new compaction elapsed timer is not gated on the row actually showing the "Compacting" label, so it can attach a duration to labels that never carry one.

      Posted via Macroscope — UI Consistency
    13. Superseded by https://github.com/pingdotgg/t3code/pull/9293, which landed the compaction timeline state/result UI this PR targeted (and closes the linked feature https://github.com/pingdotgg/t3code/issues/7652).

    14. juliusmarminge closed this

Sign in to join this conversation.