Repository navigation
fix(status): a Claude turn at rest under a streaming background subagent is not working - #2072
Conversation
…ent is not working
Claude Code keeps its busy title spinner up while a background subagent
streams, after the session's own turn ended, and herdr reads that title as
working. The pane then read working in the sidebar, alerts, queue and chat
("Working…" and Stop under a finished answer) for as long as the subagent
worked, where background-wait.ts means to show it waiting (BG).
The subagent tracker now reads the session's own rest from its transcript:
from the turn's `turn_duration` entry until a next turn writes its request,
prompt or answer. While the turn rests and subagents or commands run, the
status hub takes herdr's `working` for a rest, in status events and in
snapshots, and herdr's word stands again once the session moves on.
Fixes devswha#2069
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HePebNzw6NLs2oJx3vmZ1f
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Track Claude resting state server/claude-subagents.ts, server/claude-subagents.test.ts |
Parent transcript scanning records turn endings and clears them when later activity appears. Subagent state and change notifications include resting; tests cover resting-state transitions. |
Apply resting state to pane status server/core/status.ts, server/core/status.test.ts, changelog.d/claude-background-subagent-rest.md |
Status snapshots and collector events adjust Claude pane status based on resting subagent work. Tests cover background wait and a new prompt returning the pane to working. The changelog describes the pane indicator change. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: devswha
Merge Risk: 
Minimal · previous review 3211f
-
The replay path preserves the status needed to restore a Claude pane to working when its transcript resumes. No actionable merge-blocking risk remains.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
The description explains the problem, implementation, affected behavior, issue reference, tests, and validation results. It uses headings different from the template, but it covers the required Change and Validation information.
Full details: Linked Issues check
-
Explanation
Issue
#2069requires Claude to enter rest when its main turn ends while subagents or commands continue, and to use herdr'sworkingstatus again when the next turn starts.server/claude-subagents.tstracks the parent transcript throughturn_duration, ignores sidechain entries, clears rest on the next prompt orapi-request, and exposesrestsOn.server/core/status.tsapplies the rest adjustment to status events and snapshots, then re-evaluates status when tracker state changes. The added tests verifydoneplus background wait, snapshot consistency, and restoration toworking.
Full details: Out of Scope Changes check
-
Explanation
The implementation changes in
server/claude-subagents.tsandserver/core/status.tsdirectly support issue#2069. The added tests cover the required transcript and status transitions. The changelog documents the same behavior. No unrelated change is demonstrated.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 8 functions across 4 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- 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.
Comment @coderabbitai help to get the list of available commands.
Co-authored-by: sisyphus-dev-ai <[email protected]>
|
Thanks for this fix. Status from the merge pass: Round 1 (both reviewers blocked 3211fda) found one HIGH and four MEDIUMs: stale rest overriding a fresh working turn, incomplete or oversized records certifying rest, a snapshot-first rest not announced, a delayed Claude callback finishing a Codex pane, and a collector replay overwriting raw working status. I fixed them on the branch in f5a97dd: rest evidence is scoped to a turn by a transcript byte boundary, skipped or incomplete records clear rest, the collector keeps herdr's raw status, and callbacks are guarded by the pane's current agent. Eight regression tests in Round 2 on f5a97dd still blocks. The merge pass reproduced these:
All three come down to one missing signal: a reliable turn start while herdr's raw status never leaves |
…'s working edge Under a background subagent's spinner herdr's raw status never leaves working, so a new prompt gave no working edge and the previous turn's rest stayed in force: queued input was offered while Claude was busy. A working event or send acknowledgement that came after its turn already ended put the rest boundary past that turn's own rest, and every chat send (also /model) published working with nothing to end it. The transcript now says where each turn began. A busy signal (any herdr working event, a snapshot or replay that moves the pane to working, or a chat send that is a prompt) reads it first: a turn begun after every turn seen at rest is that signal's own, late; otherwise its turn is not written yet, and only a rest written past the transcript's size then ends it. herdr and the chat are matched separately, signals heard before the transcript is first read are matched at that read, and the status stays herdr's word with the rest projected on it: a send no longer makes a pane working. Co-authored-by: Noobear <[email protected]>
… subagents under a half-written line Review of 329b519 found a busy signal could take the turn an earlier signal was still waiting for, or a terminal turn begun before a chat send, and reopen the queue; a rest read before its late signal, a server start under the spinner and Claude's local-command entries withheld a genuine rest for good. Round 1's widened "behind" also hid running subagents while the session's last line had no newline yet (claude-session contract). - Signals waiting for their turn take the first turns begun past them, in order, before a new signal is matched. - A chat send carries when its Enter was sent: its turn is the first begun (or the first message taken into a turn at work) since then. - herdr's working event after an idle one is the first turn begun since that idle; a snapshot's first sight of a pane is no turn start. - A signal whose turn is not written within 5 s began none and stops holding the pane working. - Local-command echoes, isMeta entries and progress lines begin no turn. - Rest needs every byte read and parsed; the subagent list keeps its own "behind". Co-authored-by: Noobear <[email protected]>
Codex's re-review of 872e5e0: excluding every isMeta user entry kept the previous rest while Claude answered a task notification Claude marks as its own, and offered queued input. Only a local command's caveat, echo and output begin no turn, and the command-echo pattern already covers the caveat. Co-authored-by: Noobear <[email protected]>
… back omo's re-review of 872e5e0: treating every command echo as no turn kept a skill or custom command from beginning one (and from moving promptAt) until Claude's first answer. The echo begins a turn as a prompt does; a local command's output, written right after its echo, takes back what the echo began, rest and prompt time included. Co-authored-by: Noobear <[email protected]>
Codex's second re-review of 688481b: Claude Code records a skill's or custom command's echo with neither origin nor a permission mode, so the echo began a turn but did not move promptAt, and the background wait counted the previous prompt's subagents as the skill's. An echo that is not marked as another's is the person's prompt. Co-authored-by: Noobear <[email protected]>
|
Thanks again @Noobear for finding #2069 and for this fix. The merge pass parked this PR after round 2 because it lacked a reliable signal for when a new Claude turn starts while the background spinner keeps herdr's raw status at What changedTurn starts come from Claude's transcript. The parent-transcript scan keeps a short list of recent turn starts: the byte position and timestamp of each prompt, or of the first entry after a rest. A rest only counts for the turn it was written in. Any later turn entry cancels it, including a record skipped for its size or a half-written last line. Busy signals are matched to a turn. A busy signal is herdr's
A signal whose turn never appears stops holding the pane after 5 s. Claude writes a turn's first entry as the turn begins, so such a signal started nothing. Examples are a repeated herdr Status and slash commands. herdr's raw status stays separate from the projected one. A chat send no longer reports Fix to the round-1 commit. Round 1 widened the subagent reader's Verification
Known limitsSome orderings carry no evidence to place a signal: a herdr A prompt typed into the terminal under a continuous spinner gives herdr no event. It shows as working once Claude writes the prompt to its transcript and Ovis reads it, which happens on every poll, every snapshot, and the queue's pre-Enter check. |
…s quoting command tags The merge pass's round 3 on 611096c reproduced three ways queued input was offered during a new Claude turn: - A herdr working event with nothing to place it took the latest turn no signal had told, even one that had already ended unseen between polls. Such an event now takes only the turn still going on; otherwise it waits for its own. - A signal whose turn was not written within 5 s gave up, and the old rest made the queue ready again. The pane is still shown at rest then, but its queue stays held until a rest is written past the signal or herdr says the pane does no work; the automatic send rechecks the hold. - A prompt quoting <local-command-stdout> was taken for a local command's output. Only Claude's own records (no origin, no permission mode; the caveat also isMeta) are. Co-authored-by: Noobear <[email protected]>
…/compact keep a rest Reviews of fa42b9e: - Codex (HIGH): a queue request that arrived while the pane was shown at rest but its queue held was sent at once; a hold request's status read handed the queue a ready status for a moment. Both now go by the hold. - omo round 3: a chat send's hold is released by the transcript only, not by herdr's idle word (Claude can write a prompt late behind a slow UserPromptSubmit hook). Bash-mode records (<bash-input>, <bash-stdout>, <bash-stderr>), a compaction's summary and /compact as typed begin no turn of their own: /compact reads working until its output, an idle compaction keeps the rest. Shapes taken from recorded transcripts of Claude Code 2.1.288-2.1.306. - A held queue let go of with the pane's rest unchanged (a whole turn between polls, or a snapshot reading herdr idle) is told to the queue; a chat bash-mode line (!ls) is not taken for a prompt; signals kept for a pane whose transcript is not found yet are bounded. Co-authored-by: Noobear <[email protected]>
…mode chat sends as prompts Codex's review of 56042a4 found two ways queued input was typed while a send still awaited its turn: - /compact's output restored the rest from before /compact even when a message was taken in (queued_command) or a skill ran in between. The rollback now belongs to one command: another command's echo starts its own, and a message taken in drops it. - A chat line starting with "!" was not taken for a prompt, but Claude Code 2.1.311 answers bash mode in a model turn. It is a prompt again; a bash-mode input record counts as the send's own entry, so versions that write no turn for it still release the queue. Co-authored-by: Noobear <[email protected]>
…and they name Codex's review of d260a0e: - A person's prompt quoting /compact's echo while /compact ran was taken for that echo, and the compaction's output restored the rest from before it. Echoes and raw slash lines count only without origin or a permission mode, as Claude Code writes them. - A raw /compact line's own arguments could name another command, and a name ran on past an escaped newline. The leading token of the typed line names it; the echo's name is read from where Claude puts it. - A chat bash-mode line whose records came after its 5 s hold kept the queue held for good where no model turn follows: the send's own late entry now releases it. The raw slash match is also anchored to the entry's own content, not a tool result that starts with "/" (omo LOW). Co-authored-by: Noobear <[email protected]>
… that none follows omo's review of d260a0e: Claude Code 2.1.311 answers bash mode in a model turn, which writes its request first. Comment and test title only. Co-authored-by: Noobear <[email protected]>
|
Merge-pass round 3 fixes for #2072, again on top of @Noobear's fix (credit to the author for #2069 and the original approach). The merge pass reproduced three MEDIUMs on 611096c, and the reviewers raised more along the way. All of them are fixed in fa42b9e..8acf023: Signals that a new turn began
Claude Code's own records (shapes taken from real transcripts of Claude Code 2.1.288–2.1.311)
Verification
Known limits
|
|
Thanks for this fix. Before merging, the merge pass reviewed it strictly (external PR) over four rounds with omo-native-code-reviewer and Codex, and reproduced each blocking finding. The fixes landed on this branch:
Behaviour beyond the original description: queued input is now also held at ingress and in the auto-send guard while a turn is open ( Both reviewers pass 8acf023 with LOW notes only. The merge pass's round-1/2 reproductions pass, and of round 3's, R3-C also fails on main. The required checks are green, and CodeRabbit did not review this head. The remaining LOW ordering limits go to a follow-up issue. |
## Release 0.4.20 The release PR, prepared by step 1 of [docs/development.md#releasing](https://github.com/devswha/ovis/blob/main/docs/development.md#releasing), initially on main `bd676637a16471e8744d62c7311026ddb43a39eb` (#2335, xterm 6), then merged with final-scope main `ef482f2e66b3344658fb548fa1110744a92929c9` (#2338) and test-only follow-up main `269e9ce19558b8d197959250075da56b25b9668f` (#2345): - **Version:** `version` is 0.4.20 in `package.json` and `herdr-plugin.toml`. - **Changelog:** `bun scripts/changelog-fold.ts 0.4.20` initially folded 122 fragments into the 2026-10-29 section of `CHANGELOG.md`, linked their PRs, and deleted the fragments. After merging main, the modified `letta-native-chat.md` from #2338 was folded by hand with its current wording and PR link. No other late fragment landed; `changelog.d` holds only `README.md`. Four additional entries for external PRs without their own fragments bring the section to 157 entries. - Added 22 `by @login` credits across all 19 outside-contributor PRs in the release range. Preserved the existing credit to @Yoonwoo-Ha for #1634. See the complete ancestry-based audit below. - **Release summaries:** en, ko, ja and zh each have 5 new, 5 improved and 5 fixed lines, matching 0.4.19's shape. They include the xterm 6 improvement: terminal frames no longer mix old and new output. Every English line is at most 80 characters. - **Remote bundle:** `REMOTE_BUNDLE_VERSION` rises from 38 to 39 because the bundle inputs changed since remote-v38. - **Telemetry:** the guard confirms no Worker deploy or deployed fingerprint update is needed. - **iOS upload note:** CURRENT_PROJECT_VERSION raised to 3 for App and OvisNotifications (last uploaded: 2, source: `docs/native-app.md:99`, commit `54fdadc1c65da5d50a6afef411e3ed8f23b6c255`). Both targets inherit project-level Debug and Release settings, and every `CURRENT_PROJECT_VERSION` entry is 3. `app/store/ios.md` now records the prepared build. This is the last documented upload, not a live App Store Connect query; check for later uploads before uploading. The marketing version remains 1.0. - The changelog explicitly distinguishes delivery: removing WebKit's form bar (#2109) requires the new iOS app build, while Korean composition (#2307) comes with the PC update and needs no new iOS build. The Korean-input summary says the same in all four languages, with no change to list counts. ## Validation - Final `dori heavy release-check -- bun run check fast`: passed, exit 0; workflow syntax, generated types/themes, typecheck, build and unit suite (8,591 pass, 0 fail, 34 platform skips in 549 files). This is the merged tree containing #2338, #2345, the contributor corrections and iOS build 3. - `bun test scripts/changelog-fold.test.ts server/release-notes.test.ts`: 33 pass, 0 fail. - `bun scripts/release-notes.ts 0.4.20`: passed, with all patch-note lists and the full changelog. - `bun scripts/release-guards.ts` and CI mode with `--base ef482f2`: passed on the final merged tree: "Release 0.4.20: remote bundle, telemetry Worker and release metadata are in order." - `bun scripts/release-guards.ts --release 0.4.20`: expected exit 1 only because "remote-v39 is not published." The merge pass publishes it after merging. ## Merge pass **Do not merge before the owner's OK.** - [ ] Merge only after the owner's OK and required checks pass. - [ ] After merging, push `remote-v39` on the merged commit and wait for the **Remote PC bundles** workflow to publish the manifest and all archives. - [ ] Then run **Release** on `main` with version `0.4.20`, without `v`. The Release workflow creates the app tag; do not push it by hand. - [ ] From this PR's merge until the Release run is done, merge nothing touching `server/`, `shared/`, `bun.lock` or `patches/`. - [ ] A changelog fragment merged after this PR must be moved into 0.4.20 by hand. This lane stops at the open PR. No tag, workflow dispatch, merge or telemetry deploy was performed. **Completed release follow-up:** merged main `ef482f2e` including #2338 (`fix/letta-no-live-box`), folded its revised fragment into 0.4.20, and retained the contributor-credit commit `184dc120` and iOS-build commit `0ffa3d45`. The Letta summary already describes conversation support without promising a live-terminal box, so it needs no change. Merged test-only #2345 from main `269e9ce1`: the two usage browser checks now wait for the earlier shared account-order save and start the sign-in check from a cleared order. No product behavior or late fragment was added; `changelog.d` still contains only `README.md`. The iOS delivery clarification and resolved review thread are retained. ## Complete external-contributor audit Checked every merged PR whose merge commit is in `git log v0.4.19..origin/main`: 133 PRs through final-scope main `ef482f2e`, or 134 including test-only #2345 on `269e9ce1`, with 19 PRs by 12 external non-bot authors. Both rescans found no additional external-author gaps; #2345 is by the maintainer. Added the four missing entries: #2271 and #2274 by @CharleoYang, #2290 by @DravenDou, and #2282 by @fivetaku. The tab-reopening summary now includes the history-page improvement in all four languages; list counts remain 5/5/5. Full external PR list checked: #1911 @jjsteffen; #2068 @YuuuXie; #2072 @Noobear; #2087 @JJLiebig; #2145 @mattmarcin; #2176 @jpcarranza94; #2231 @philipprass-prog; #2235 @vuongnmhvn; #2270, #2271, #2274 @CharleoYang; #2278 @jpcarranza94; #2282 @fivetaku; #2283, #2292, #2293 @YuuuXie; #2301 @jpcarranza94; #2321 @kilhyeonjun. Every PR has a linked `by @login` credit in 0.4.20. --------- Co-authored-by: sisyphus-dev-ai <[email protected]>
…ng (#3269) ## Change When a Claude turn ends while a `Workflow` run is still going in the background, Claude Code keeps its busy title up (the screen reads `Waiting for 1 dynamic workflow to finish`, with the prompt ready). herdr reads that title as `working`, so the pane shows a Stop button and counts as busy. `restingClaude` already corrects this for background subagents and commands (#2069, #2072), but only for what the transcript scan counts as running, and it did not count a `Workflow` run. A run writes no `backgroundTaskId` and keeps its agents under `subagents/workflows/`, so the count stayed 0 and herdr's `working` stood. A `Workflow` call answers at once with `toolUseResult` `{ status: "async_launched", taskType: "local_workflow", taskId, workflowName }`, and the run ends with the ordinary `<task-notification>` of that task id. This change takes that answer as a background command launch, titled with the workflow's name, so the existing rest and end paths apply. A `TaskStop` of the run ends it the same way. ## Validation - `bun test server/claude-subagents.test.ts server/core/status.test.ts scripts/changelog-fold.test.ts` with `HERDR_TEST_MODE=unit`: 201 pass, 0 fail, including a new test for the launch, the rest and the notice. - A real transcript slice from Claude Code 2.1.319, cut after a `Workflow` launch and before its notice: `claudeSubagentState` gives `running: 0` on v0.5.0 and `running: 1, resting: true` with this change, listing the run by name. - `bun run check fast` on macOS: generated files, typecheck and build pass. Its unit lane fails in 20 test files, and the same 20 files fail on unpatched v0.5.0 on this machine. - Not run: `check full`, and a browser check of the composer. The Stop button follows the pane status, which the status tests cover. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_015jTjTLoX5uyzKWX1o2SQ1p Co-authored-by: Claude Opus 5.5 <[email protected]>
…nd refuse a linked subagents folder (#3360) Fixes #3348. ## What In `server/claude-subagents.ts`: - **The last background task ending no longer brings back a stale `working`.** When the last background task ended (subagent, Bash command or Workflow) while herdr's last report was still `working`, the running count dropped to 0. `restsOn()` turned false, and herdr's old `working` came back even though the transcript said the turn was at rest. The pane now keeps the transcript's rest. That holds across a same-session re-lookup and clears on a reset. A newer herdr `working` event or a new turn still makes the pane work again. - **A linked folder is refused, and the listing is bounded.** The `<session>/subagents` reader followed a linked folder, so another session's records counted for this pane, and it read the whole directory before keeping 5,000 names. The listing now opens the folder through the same checked opening as the detail read (`openFolder`), refuses a linked `subagents` or `<session>` folder, lists nothing if a folder on the way is swapped, and stops at the cap. `subagentDetails()` (the chat cards' titles) goes through the same checked folder. ## Validation - Failing-first tests, each of which failed on main or on the first commit: - rest kept at the pane-status level, returned snapshot included, after the last task ends - rest kept after a same-session re-lookup - linked `subagents` and linked `<session>` folders, through both the listing and `subagentDetails()` - a folder swapped before and after its open - Guard tests: a herdr `working` event after the last task ends, with and without a poll first, and a next turn written late. Each one makes the pane work again. - **One existing #2072 test changed:** it expected `working` in exactly the case this issue calls a bug (the transcript at rest, herdr's only `working` before the child ended). It now expects rest. - `bun run check fast` passes on current main (e450d27). ## Review A Codex (gpt-6.1-terra, xhigh) adversarial review ran before this PR opened. - **Fixed in the second commit** (three MEDIUMs): - the rest flag was lost on a same-session re-lookup - a linked `<session>` folder was still followed - `subagentDetails()` skipped the folder check - **Left as is:** - LOW: the 5,000-entry window is taken before names are filtered, so in a huge folder an active agent past it can go uncounted. This predates the change. - After the listing, each agent's files are read by path, so a swap between the listing and those reads is not anchored. --------- Co-authored-by: sisyphus-dev-ai <[email protected]>
The reads delivery makes right before its writes answer for a self-resumed turn's hold alone, so a busy signal's hold (#2072) that comes up after the paste is found only where main found it: at the look before the Enter. No test failed without that check, and the differential run does not reach it (600 scripts with it removed gave the same as main). This one sends an Enter without it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Fixes #2069.
What
A Claude Code pane whose turn has ended read working while a background subagent it started kept streaming: Claude Code keeps its busy title spinner (
◐/◑) up for the subagent, and herdr'sosc_title_workingrule reads that title as working. The sidebar, alerts, pending queue and chat followed — the chat showed "Working…" and Stop under the finished answer for as long as the subagent worked.background-wait.tsalready has the right state for it (BG); it assumed herdr reads such a pane at rest.How
server/claude-subagents.ts: the parent-transcript scan tracks the session's own rest — from the turn'ssystem/turn_durationentry until a next turn writes anapi-request,userorassistantentry (sidechain lines ignored; only the rareturn_durationline is parsed).claudeSubagentStatereturnsresting(only when the transcript is read to its end), the tracker passes it throughonChange, andrestsOn(paneId)says the turn rests while subagents or commands run.server/core/status.ts:restingClaudetakes herdr'sworkingforidleon a Claude pane thatrestsOn, both for status events (onStatus, now a named function so the tracker can re-run it) and for snapshots (rawSnapshot, next tolaunchedAgents.settle). The tracker is polled first so the read is fresh. When the rest starts or ends with herdr still sayingworking(no new herdr event),claudeAgentsChangedre-runs the status path with herdr's last word, so the pane goes to done/BG when the turn ends and back to working when a next turn starts.The
onStatusbody only moved out of thestartStatusCollectorliteral (2-space dedent);git diff -wshows the real change.Tests
server/core/status.test.ts: herdr says working → the turn ends under a running subagent (no new herdr event) →done+ BG, alert stillworking; a snapshot read meanwhile agrees; a new prompt →workingagain. Fails without the fix.server/claude-subagents.test.ts:restingfromturn_duration, unchanged by between-turn entries (last-prompt), kept on a cold re-read, cleared by the nextapi-request.bun run typecheck,server/claude-subagents.test.ts,server/core/status.test.ts,server/background-wait.test.ts,scripts/conventions.test.tspass on macOS.bun run test:unit's 10 failing files there (sockets/processes under load) pass when run on their own, with and without this change.The transcript shapes (
turn_durationwithpendingBackgroundAgentCount,api-requestbefore the notification turn) are from the Claude Code 2.1.311 session recorded in #2069. Not yet exercised against a live herdr from a built Ovis.🤖 Generated with Claude Code
https://claude.ai/code/session_01HePebNzw6NLs2oJx3vmZ1f