Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(claude): show automatic compaction while it runs #15631

Mergedmaria-rcksmerged 10 commits intomain fromrefs/pull/15631/headmerged by juliusmarminge View on GitHub

maria-rckscommented

Claude’s automatic compaction appeared as generic work until it had already finished. The adapter now publishes a running compaction item and settles that same item, preserving its identity, start time, and token counts. Web and mobile recognize running compaction in the active run, alongside the existing manual /compact path. These client checks also recognize Codex’s existing running compaction items, so follow-ups queue during those automatic compactions too.

Contributor commits are preserved, with main merged and the adapter implementation rebuilt to share the running/boundary item construction. Thanks @maria-rcks for #15631.

Closes #10959.

Verification:

  • Three focused suites: 496 → 493 tests (server adapter 292 → 290, mobile activity 101 → 100, shared presentation 103 unchanged). Restoring main production produced six assertion failures; restoring the fix returned all 493 to passing.
  • Scoped lint and formatting pass, with one inherited unused-variable warning. Server, web, mobile, and client-runtime typechecks pass.
  • Independent full-PR reviews found stale running items after a compaction outcome status; reported outcomes now settle immediately, and late success boundaries enrich the same item. A second round found hook-skipped compaction could remain running; a bare idle status now stops it, while permission-only updates preserve it. Both independent third-round full-PR reviews returned no findings; the final round also reran all 493 targeted tests.
  • An isolated Linux web client exercised a real send through the production SDK, adapter, and orchestration using a mocked Claude CLI. It showed the running compaction and completed token-count divider, a failure label while the turn continued, a skipped compaction stopping before the turn finished, and manual /compact interrupted through Stop generation. This verifies integration with controlled provider frames; native Claude auto-compaction was not exercised. Status-to-boundary matching assumes sequential compaction cycles, as in the inspected installed CLI 2.1.303.
  • Native mobile verification is unavailable: the Device tool reports “Agent device access is turned off for this environment.” macOS, Windows, Electron desktop, iOS, and Android were not run.

Before (actual main production, same prompt, fixture, and viewport; composer region cropped): Before: automatic compaction appears as Thinking

After: After: automatic compaction appears while it runs

Before recording · After recording · Failure while the turn continues · Skipped compaction while the turn continues

Maintainer takeover: Codex gpt-6-astra tests and gpt-6.1-sol implementation, with independent Claude Opus 5.5 and Codex gpt-6-sol review through T3 Code.

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 9ddedd50-5548-4d67-853f-6a709dd1ec28
      📥 Commits

      Reviewing files that changed from the base of the PR and between 4ee6bfd50ef4a089440d5c3662db2298da9cc50e and 8c4d35b5aa96f7394078ade3bf1ccd29d775c138.

      📒 Files selected for processing (6)
      • apps/mobile/src/lib/threadActivity.test.ts
      • apps/mobile/src/state/use-thread-composer-state.ts
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
      • apps/web/src/components/ChatView.tsx
      • packages/client-runtime/src/work-log/presentation.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

      📝 Walkthrough

      Claude automatic compaction now emits a running work-log item and completes it at the compact boundary. If the turn ends first, the server emits a terminal item. Web and mobile views recognize running, failed, interrupted, and cancelled compaction states.

      Changes: Claude compaction status lifecycle

      Layer / File(s)Summary
      Emit and settle compaction items
      apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
      The adapter emits one running item for repeated compacting status frames. At the compact boundary, it completes that item with token counts. If the turn ends before the boundary, it emits a terminal item. Tests cover boundary completion and turn-ending outcomes.
      Recognize and present compaction states
      apps/web/src/components/ChatView.tsx, apps/mobile/src/state/use-thread-composer-state.ts, packages/client-runtime/src/work-log/presentation.ts, apps/mobile/src/lib/threadActivity.test.ts
      Web and mobile state checks recognize running compaction items and terminal statuses. Compaction labels distinguish failed and stopped outcomes. Mobile tests cover failed and cancelled labels.

      Priority: ⬇️ Low

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Sequence Diagram(s)

      sequenceDiagram
        participant ClaudeSDK
        participant ClaudeAdapterV2
        participant ChatView
        ClaudeSDK->>ClaudeAdapterV2: Send compacting status
        ClaudeAdapterV2->>ChatView: Emit running compaction item
        ClaudeSDK->>ClaudeAdapterV2: Send compact_boundary
        ClaudeAdapterV2->>ChatView: Emit completed item with token counts

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to 8c4d3

      The change is mergeable after normal checks; no concrete issue requiring a fix before merge was identified.

      Security architecture risk: 🔵 Low · up to 8c4d3

      The change adds progress reporting without an evidenced increase in access or privileges. Risk is low, with end-to-end behavior and recovery after abrupt termination still unverified.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • inferred — The evidenced new flow affects progress state and presentation for the owning conversation run. Provider-supplied identity is reused through the existing item allocator, while ownership comes from the active server context. No additional tenant, credential, tool, or infrastructure authority was identified in this flow.

      Trust Boundaries and Controls

      • observed — Frame processing rejects a query that no longer owns the live query context. Query-exit cleanup also checks ownership before finalizing the active turn. Web and mobile compaction indicators match items to the active run, limiting stale-query and unrelated-run propagation.
      Pre-merge checks: Passed 4 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 6 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      Passed Passed checks: 4 passed
      Check nameStatusExplanation
      Linked Issues checkPassed[#10959] ClaudeAdapterV2 emits one running compaction item for Claude’s compacting status and completes that same item at compact_boundary, preserving its start time and adding token counts. `Ch…
      Out of Scope Changes checkPassedAll reported changes support [#10959]. The adapter implementation and tests handle automatic compaction events and cleanup. Web, mobile, and shared presentation changes show the active state and prese…
      Title checkPassedThe title clearly identifies the primary change: showing automatic Claude compaction while it is running.
      Description checkPassedThe description explains the problem and implementation, links the related issue and prior discussion, documents focused verification and UI evidence, and states unverified environments and limitation…
      Full details: Linked Issues check

      Explanation

      [#10959] ClaudeAdapterV2 emits one running compaction item for Claude’s compacting status and completes that same item at compact_boundary, preserving its start time and adding token counts. ChatView and the mobile composer recognize a running item for the active run while retaining the manual /compact path. Adapter tests cover repeated status frames, boundary completion, terminal outcomes, idle frames, and the next turn. Client-side automatic compaction and native runtime checks remain unverified, but the code and automated tests address the issue’s coding requirements.

      Full details: Out of Scope Changes check

      Explanation

      All reported changes support [#10959]. The adapter implementation and tests handle automatic compaction events and cleanup. Web, mobile, and shared presentation changes show the active state and present terminal results. No unrelated changes are evident in the reviewed diff.

      Full details: Description check

      Explanation

      The description explains the problem and implementation, links the related issue and prior discussion, documents focused verification and UI evidence, and states unverified environments and limitations. Although it does not repeat the template headings, it provides the required information in a complete, relevant form.

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

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

      Approvability

      Verdict: Approved at 7c9883b

      Macroscope's review found this PR approvable — This is a focused lifecycle and presentation fix for existing automatic context compaction, with bounded server, web, mobile, and shared-runtime changes. Comprehensive tests cover completion, failure, interruption, retry, and turn termination without changing schemas, defaults, or deployment behavior.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge added labelsmacroscope-review

    5. juliusmarminge assignedjuliusmarminge

    6. Taking over this one for maintainer batch claude-08. I’ll merge current main, reduce the tests, rebuild the automatic-compaction lifecycle, and run independent reviews. The original author’s commits will be preserved.

    7. juliusmarminge merged thisfc21184

    8. juliusmarminge closed this

Sign in to join this conversation.