Skip to content

Show when Claude is compacting before a reply starts - #37409

Merged
brennanb2025 merged 9 commits into
mainfrom
brennanb2025/claude-precompact-activity
Nov 2, 2026
Merged

brennanb2025 merged 9 commits into
mainfrom
brennanb2025/claude-precompact-activity

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​414 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​414
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​47 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​29

Problem. When Claude automatically compacts a long conversation right as you send a message, a Claude chat showed a generic "Working…" for the whole compaction (often 5-15 seconds) instead of "Compacting the conversation". Claude reports compaction before it echoes your message back, and Orca only opened a turn (which is what shows activity like "Compacting") once that echo arrived, so the compaction status was dropped.

What changes for users. During that wait the chat now says "Compacting the conversation", then continues into Claude's reply in the same turn. Stopping during the wait leaves one Interrupted turn. Explicit /compact, compaction in the middle of a reply, and ordinary sends look the same as before.

Tracked in STA-9923.

How it works. Claude tells Orca when it has started working on a particular message. When a compaction status arrives for a message Claude has started, Orca opens that message's turn right away, through the same path it already uses when Claude produces output before echoing a message (for example /goal), and shows the compaction status on it. When Claude's echo of that same message arrives, Orca keeps the turn it already opened instead of replacing it. The status clears when compaction ends. No saved fields, wire messages or client code change; the turn record is written a few seconds earlier, in a shape current and older clients already read.

Main: "Working…" during a 6 s auto-compaction This PR: "Compacting the conversation"
main branch

Stop during the compaction leaves one Interrupted turn:

stop

Differences from the common pattern (it owns a turn from the moment input is handed to the agent):

  • Intended: a pending send does not become a running turn at handoff. Pre-echo compaction opens its turn after Claude reports that message as started, and its correlated echo adopts the same turn. Earlier replies and background work can arrive after handoff, so handoff alone must not assign that work to an unanswered message (the common pattern's own tests show a queued prompt receiving a background task's reply when no start report or echo exists). Without a start report and with no turn already open, Orca keeps "Working…" through pre-echo compaction; an echo or later output follows the existing turn-opening rules.
  • Intended: an immediate follow-up can reach Claude once compaction opens the turn, before the opening message's echo. Explicitly queued messages keep their queue behavior. Elapsed time keeps its existing origin.
  • Temporary: a reminted echo for a different follow-up can still split the ongoing turn under the existing echo rule (also on main); the opening message's own reminted echo is adopted. Tracked in STA-13477.
  • Temporary: a compaction status with no open turn and no started message (for example Claude compacting on its own) opens no turn. Tracked in STA-13478.

Verification. A real Claude 2.1.316 chat in an isolated test copy with auto-compaction forced: main showed "Working…" through real 5-6 s compactions; this PR showed "Compacting the conversation", one turn per message, one Interrupted turn when stopped mid-compaction with no doubled delivery note, a follow-up sent during compaction delivered without loss, the sidebar showing Working, and /compact and ordinary sends unchanged. Host tests replay the real frame order (compaction before the echo, zero-length compaction, Stop in both forms, a follow-up folding into the turn, a background task waking Claude while a follow-up waits, and the receipt-less case staying on "Working…").

@brennanb2025
brennanb2025 marked this pull request as ready for review November 2, 2026 08:56
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 63832c10-e946-46bd-ab2e-5494f987f8ab
Commits

Reviewing files that changed from the base of the PR and between bcc7dd5 and 124216f.

Files selected for processing: 6
  • src/main/claude/claude-message-journaling.ts
  • src/main/claude/claude-open-turn.ts
  • src/main/claude/claude-turn-activity.ts
  • src/main/claude/structured/journal/claude-structured-journal-translation.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-claude-background-wake-owner.test.ts
  • src/main/native-chat/agent-session-wire/structured-agent-session-claude-precompact.test.ts

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

Walkthrough

Claude message journaling now checks the client message ID when deciding whether to open a send-echo turn. The journal translator uses a shared publisher for message and provider-frame activity. New tests cover pre-echo compaction, cancellation, follow-up sends, and background-wake ownership.

Merge Risk: Minimal · up to 12421

The change is intended to show compaction before Claude replies. No merge-blocking defect was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title matches the main change. It states that the UI shows "Compacting the conversation" before a reply starts. It is specific, short, and clear. It does not need to describe the turn-opening mech…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is mostly complete. It explains the problem, user-visible behavior, implementation, scope, testing, visual proof, known limitations, and compatibility impact. It does not follow every …
Full details: Title check

Explanation

The title matches the main change. It states that the UI shows "Compacting the conversation" before a reply starts. It is specific, short, and clear. It does not need to describe the turn-opening mechanism.

Full details: Description check

Explanation

The description is mostly complete. It explains the problem, user-visible behavior, implementation, scope, testing, visual proof, known limitations, and compatibility impact. It does not follow every template heading and lacks an explicit Fixes # issue link, risk level, AI disclosure, and completed checklist items, but these omissions do not make the description incomplete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 6 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A Claude chat now shows "Compacting the conversation" (and any other root
activity) as soon as Claude starts working on a message, including on CLIs
that send no command-lifecycle receipts. The send's turn is opened when
Orca hands the input to Claude, the echo confirms delivery into that same
turn, a follow-up handed over while it runs joins it, the previous cycle's
late idle or result no longer closes the new turn, and an input Claude
proves it never ran retracts its unworked turn instead of ending it.

Tracked in STA-9923.
…eally its own

A Claude turn opened when Orca hands a message over now tracks every
message handed over while it runs and which provider cycle each one ran
in. A turn Claude started and then cancelled ends on its own idle; a
refused message only removes itself, keeping the turn for any message that
joined it; a follow-up's echo with a new uuid stays in the turn it joined;
a finished turn's unechoed message never owns later work; an earlier
cycle's result no longer completes a newly handed-over turn; and
withdrawing an unrun message no longer announces the previous reply again.

Tracked in STA-9923.
A follow-up whose own result arrives after the turn it joined ended can
no longer anchor the next message's turn: every endpoint Claude reports
for an input (its named result, a terminal receipt, a refusal, or the end
of the run it ran in) now retires it in one step, wherever it is waiting.
Inputs are looked up by the ids Claude names them with instead of
scanning every message a long turn has folded in, so a turn with many
follow-ups stays cheap.

Tracked in STA-9923.
… started-send boundary

Precompaction: the previous turn's completed/idle tail, 14 s and zero-length
compaction, the receipt-less Working expectation, a follow-up released during
compaction with exact and reminted opener echoes across an intervening init,
both Stop forms with the published turn id, and started -> compacting ->
cancelled -> idle without an echo.

Background wake: captured CLI wake frames stay provider-owned whether the
follow-up was handed over before the first result (with or without a queued
receipt) or after the first turn ended; the follow-up's own echo opens its
turn. A follow-up settled by its own named result cannot own the next send.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review loop status: done

Problem. When Claude auto-compacted a conversation right as a message was sent, the chat showed "Working…" for the whole compaction (5-15 s) instead of "Compacting the conversation", because Claude reports compaction before echoing the message and Orca opened turns only from the echo.

User-facing change. The chat now shows "Compacting the conversation" during that wait and continues into the reply in the same turn; Stop in the wait leaves one Interrupted turn. /compact, mid-reply compaction and ordinary sends are unchanged.

How the review went. Round 1 (three reviewers) found no defect in the original design but questioned one difference from the common pattern (owning the turn from handoff rather than from Claude's start report). A design panel adopted handoff ownership; three repair rounds each surfaced new defects of the same kinds (a turn stuck on Working after a send that never ran; a waiting follow-up taking over an unrelated background-task reply; stale results closing the wrong turn). A fourth panel, with new evidence that the common pattern itself misattributes background work when there is no start report, unanimously returned to the original design. The handoff-ownership commits are reverted, so the shipped code is byte-identical to the original design that passed real QA, plus stronger tests from those rounds.

Fixed / kept: turn opened from Claude's start report when compaction precedes the echo; same-message echo adopts the turn; tests now cover Stop in both forms with the real delivery projection, zero-length compaction, follow-up folding, background-task wake while a follow-up waits, and the receipt-less case staying on "Working…".

Deferred (for Brennan):

  • Claude CLIs that don't report message starts keep "Working…" during pre-echo compaction (intended; see PR body).
  • A reminted echo for a different follow-up can split a turn — also on main. Tracked in STA-13477.
  • Compaction with no pending message (Claude compacting on its own) shows nothing until output. Tracked in STA-13478.
  • Synthetic only: started → compacting → cancelled with no result and no idle would leave the turn Working; no captured Claude CLI produces that order (every cancel after a start is preceded by a result and followed by idle).
  • A combined crash-in-the-gap → reopen → transcript catch-up test is not written; existing recovery tests pass.

Verified. Real Claude 2.1.316 in an isolated test copy on the M4Air (QA'd head 43aafa6, main baseline 81ec82b): main "Working…" through 5-6 s auto-compactions; branch "Compacting the conversation", one turn per send, Stop in the gap → one Interrupted turn with no doubled delivery note, follow-up during compaction delivered, sidebar Working during the gap, /compact and ordinary sends unchanged. Commits since the QA'd head: 211a0b7, 43df8fc, bcc7dd5 (handoff ownership) and their reverts 6b9007f, aaface4, aa7209c net to zero shipped change (git diff 43aafa64c0b 124216fced4 touches only two test files), plus test commit 124216f. CI green on 124216f. Final reference comparison done.

For Brennan's review

Main This PR
main branch

Stop during compaction: stop

Where judgment matters:

@brennanb2025
brennanb2025 merged commit 348b3be into main Nov 2, 2026
53 of 54 checks passed
mreinhofferxd-pixel pushed a commit to mreinhofferxd-pixel/orca that referenced this pull request Nov 5, 2026
Resolve conflicts with stablyai#37409, stablyai#37546, stablyai#37724 and stablyai#38082. Main's
publishClaudeTurnActivity now owns turn activity, so the transient
publications class keeps only prompt suggestions (ClaudePromptSuggestions).
Count suggestion publications separately in the status-feed test: Claude's
first turn clears any suggestion the host retained from a previous launch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant