Skip to content

fix(chat): send at once to an idle Claude that only awaits background agents - #2271

Merged
devswha merged 2 commits into
devswha:mainfrom
CharleoYang:fix/immediate-send-idle-claude
Oct 28, 2026
Merged

devswha merged 2 commits into
devswha:mainfrom
CharleoYang:fix/immediate-send-idle-claude

Conversation

@CharleoYang

Copy link
Copy Markdown
Contributor

Problem

A Claude main agent that has ended its turn keeps its composer holding the message while a subagent it started is still running: herdr reports the pane as working, so the composer queues instead of sending, and the message waits for a subagent that is only reading.

Root cause

herdr's Claude manifest treats two things as work: the braille spinner in the window title (osc_title_working, 1100) and Waiting for N background agents to finish (background_agents_working, 965) — both rank above the idle prompt box (live_prompt_box, 950). So a pane whose main turn is over but whose subagent is alive is reported working, and composerDelivery() (src/lib/compose.ts:273) answers queue for it.

建议修法(为什么是这个修法)

Let the screen decide, for Claude only, because the screen is the only thing that distinguishes "the main turn ended, a subagent still runs" from "the main turn is still running":

  • claudeMainAtRest(row, lines) — true when the input row is ready (lib/inputRow.ts) and no visible line carries a live turn's own markers: esc to interrupt|cancel (a turn in progress or a form asking for esc), or a turn line ending in an ellipsis with its duration (✳ Doing the thing… (1m 3s)).
  • composerDelivery keeps its rule for every other agent; Claude's is asked only when the input row is at rest, and a running turn's own line still vetoes the fast path.
  • PaneTerminal supplies it to useComposerSends as inputAtRest, which turns settled === "queue" into immediate only when that reads true.

Rejected: changing herdr's manifest priority (the spinner and the background-agents sentence are right for the terminal view, and a subagent can be working while the main agent waits); trusting the idle input row alone (a turn that started can have its row drawn before its first tool call).

Change

  • src/lib/compose.ts: claudeMainAtRest.
  • src/lib/compose.test.ts: the shapes that must stay working (a turn line with its duration, esc to interrupt), the background-agents sentence with an at-rest row (sends), a non-ready row (queues).
  • src/lib/useComposerSends.ts: an optional inputAtRest dep; queue becomes immediate only when it reads true.
  • src/components/PaneTerminal.tsx: supplies inputAtRest from Claude's own screen.

Evidence

  • bun test src/lib/compose.test.ts src/lib/useComposerSends → 70 pass, 0 fail.
  • bun test src shared → 2666 pass, 0 fail (248 files) on this branch.
  • bun run typecheck → 0 errors; bun run build → built.
  • The negative controls are in the test: a live turn's line (ellipsis + duration) and esc to interrupt both keep the send queued, so the fast path is not "always immediate".

变更历史(逐轮)

轮 改了什么(文件) 实测证据
1 原提交(compose.ts / compose.test.ts / useComposerSends.ts / PaneTerminal.tsx) 70 pass;2666 pass
2 落在 upstream main 上:无冲突,未改动 typecheck 0;build 通过

Review 历史(逐轮)

轮 结论 findings(file:line) 代价
— 尚未有独立 review — —

Review status

Independent review pending. Not merged.

Not covered

  • Only Claude: every other agent keeps composerDelivery's rule.
  • The turn-line pattern is a screen heuristic; a localised CLI that redraws its turn line differently falls back to queue, which is the old behaviour (no send is lost, it just waits).

… agents

herdr's claude manifest reports working for a main agent that ended its turn
while a subagent it started still runs: osc_title_working (1100) and
background_agents_working (965) both outrank live_prompt_box (950), so the
composer held the message and the reader had to press Send now.

The screen decides instead: when the input row is at rest (lib/inputRow.ts
ready) and no line of the turn says how to interrupt it, the message goes out
at once, whatever the pane's status. A live turn keeps esc to interrupt or its
own spinner line, and a blocked form keeps esc to cancel, so both still queue.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental 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
  • Source mode: Auto
  • Repository: devswha/ovis
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 792dbb9
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ce7a040b-b11f-4b8e-b153-f85caa358a3f

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
📝 Summary

Summary by CodeRabbit

  • Improvements
    • Messages queued for Claude are now sent immediately when its terminal indicates it is ready for input. Messages remain queued while Claude is actively working or a draft is present.
  • Tests
    • Added coverage for ready states, active turns, drafts, and cases where no visible prompt marker is present.

The composer now checks Claude’s visible terminal state when deciding whether to send a queued message immediately. A new predicate identifies a ready main turn without visible activity, and PaneTerminal supplies the predicate’s inputs.

Changes: Claude Composer Delivery

Layer / File(s) Summary
Claude rest-state predicate
src/lib/compose.ts, src/lib/compose.test.ts
claudeMainAtRest checks for a ready input row and visible turn activity in recent nonblank lines. Tests cover running subagents, activity markers, non-ready rows, and rows without a visible prompt marker.
Composer delivery and terminal wiring
src/lib/useComposerSends.ts, src/components/PaneTerminal.tsx
useComposerSends converts queued delivery to immediate when the optional inputAtRest callback returns true. PaneTerminal provides the callback using Claude’s active screen and input row.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • devswha/ovis#2072: Detects when Claude’s main turn has ended while background subagents continue, a condition related to this PR’s terminal rest-state check.

Suggested reviewers: devswha

Merge Risk: Minimal · previous review 44171

No messaging disruption is established for the documented Claude screen shapes. The change is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.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 clearly identifies the main change: immediate sending for an idle Claude pane waiting on background agents.
Description check Passed The description explains the problem, root cause, implementation, scope, limitations, and validation results. It includes a Change section and provides Validation-equivalent evidence, although the tem…
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.
Full details: Description check

Explanation

The description explains the problem, root cause, implementation, scope, limitations, and validation results. It includes a Change section and provides Validation-equivalent evidence, although the template heading is named Evidence.

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 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 2 functions across 4 files.

Resolution

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

Finishing Touches: 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • 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

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments: 1
src/lib/compose.ts-291-291: 1

291-291: Major · Functional Correctness · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Keep single-unit live turns queued.

If a ready row shows ✻ Forming… (3s) without a separate interruption hint, this regex misses the live-turn line: it requires a space or · after s, but the line has ). claudeMainAtRest then returns true, and useComposerSends changes a working Claude’s delivery from queue to immediate. Accept ) as a duration boundary and test this screen shape. (raw.githubusercontent.com)


Review info
Run configuration
  • Source mode: Auto
  • Repository: devswha/ovis
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 792dbb9
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0f401265-0bc6-4543-aefd-5532086ec741
Commits

Reviewing files that changed from the base of the PR and between 792dbb9 and 441717b.

Files selected for processing: 4
  • src/components/PaneTerminal.tsx
  • src/lib/compose.test.ts
  • src/lib/compose.ts
  • src/lib/useComposerSends.ts

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

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Merging 83437d9 (external, @CharleoYang). Codex was at capacity, so an omo reviewer and an independent second reviewer reviewed it strictly. A Claude whose main turn has ended keeps the pane 'working' while a background agent runs, so the composer used to queue the message; this sends it at once in that state. The first reviews reproduced a HIGH: the check read physical screen rows, so a running turn's activity line that wrapped in a narrow pane read as idle and the message was sent at once even with automatic sending of queued messages off; the last-12-rows window and '(3s)' durations also let a running turn through. The merge pass fixed it on the branch in 83437d9: the override now needs a 'Waiting for N background agents' line and no running-turn marker anywhere above the input box, read on logical (wrapped rows joined) lines; a clipped screen fails closed; the idle footer is no longer taken for a spinner. 14 delivery tests through the send hook fail on 441717b and pass now. Re-review at this head: 26 of 26 real-xterm probes through useComposerSends pass with auto-send on and off (wrapped running line, spinner above 13 background-agent rows, '(3s)', compaction, permission dialog and no waiting line all hold or queue; idle with the waiting line, wrapped or not, sends at once), and other agents are unchanged. Not filed: an old spinner-like line still visible in the transcript can keep the override off, which only means the message waits as before. Thank you, @CharleoYang, for finding this and for the clear root-cause write-up.

@devswha
devswha merged commit 4cc61dc into devswha:main Oct 28, 2026
12 checks passed
@devswha devswha mentioned this pull request Oct 29, 2026
5 tasks
devswha added a commit that referenced this pull request Oct 29, 2026
## 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]>
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.

2 participants