Repository navigation
fix(pending): tell a first message whose launched agent ended apart, and say both held reasons in the reader's language - #1969
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Launch-ended state and compatibility shared/protocol.ts, server/core/pending.ts, src/lib/ws.ts, server/pending-input.contract.test.ts, src/lib/ws.test.ts, DESIGN.md, docs/agent-commands.md, changelog.d/pending-launch-ended-note.md |
The server holds ended launches with first_message_launch_ended and distinguishes them from changed targets. Clients send launch_ended: true to receive the specific code; older requests receive pending_target_changed. Contract tests and documentation cover the distinction. |
Translated refusal notes src/lib/compose.ts, src/components/PendingMessages.tsx, src/lib/i18n/composer.*.ts, src/lib/compose.test.ts, src/components/PendingMessages.test.tsx |
The client classifies launch-ended refusals as not typed and displays distinct notes for both refusal codes. Korean, Japanese, and Simplified Chinese translations and rendering tests cover the notes. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Possibly related issues
- Issue 1533 — The change updates launch-ended holds and Send now compatibility, but does not address native Windows process detection or repeated-read behavior.
- Issue 1518 — The change updates the hold reason and Send now behavior for an exited launch, but does not establish that all wait-state causes are fixed.
Merge Risk: 
Minimal · up to 8b704
-
Older clients can still use Send now and receive a refusal they understand. No merge-blocking issue was identified.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title names the main change: a first message whose launched agent ended now gets its own held reason, and both held reasons get translated notes. It is specific and matches the changeset, though it is long (119 characters).
Full details: Linked Issues check
-
Explanation
Issue
#1547requires separate codes, translated notes, sharedTARGET_CHANGED, i18n coverage, and pending-input contract coverage. The supplied change summary reportsfirst_message_launch_endedandpending_target_changedin server and client handling,submitNotetranslations in Korean, Japanese, and Chinese, andpendingContextuse ofTARGET_CHANGED. It also reports i18n tests and launched-agent contract cases that assert the new code and compatibility behavior. The repository diff was unavailable, so this conclusion relies on the supplied PR evidence and file evidence.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within issue
#1547. Server and client protocol updates support the new hold reason and old-client behavior. Tests, translations, documentation, and the changelog support the same pending-message behavior. No unrelated change is demonstrated.
Full details: Description check
-
Explanation
The pull request description follows the required template. It explains the problem and resulting behavior, identifies the related issue, documents the WebSocket and queued-input changes, and lists validation results, contract-test coverage, known test limitations, and CI coverage.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 12 files. (3 skipped: 3 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- 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.
Comment @coderabbitai help to get the list of available commands.
|
Merge pass review of 8b70415. Astra gate (omo-native-gate-reviewer, gpt-6-astra) rejected it on one blocker. What holds:
BLOCKER: the wrong reason is shown when the agent label is stale (
This PR touches |
|
Fixed the merge pass blocker in 8efa7f6 (one new commit on 8b70415, no rebase). Blocker: wrong reason when herdr's agent label outlasts the launched process. Regression case: Verification: typecheck is clean. The contract cases could not run on this PC: every case failed with EMFILE (the host's inotify instances are at 128/128), so CI's Integration job is the evidence for this commit, including the run that failed on 8b70415. omo-native-code-reviewer approved the delta with no blockers. Its LOW notes: (1) on Windows herdr lists only the launcher, but Windows launches record no pid today, so the branch cannot fire there; (2) the case relies on herdr keeping a manual report after the process exits, which it asserts, so a herdr change fails loudly; (3) the misplaced Codex Sol reviewed 8b70415 (APPROVE, no findings). It was not run on this delta because Codex sessions are stalling host-wide; the merge pass reviews. |
|
Merge pass re-review of 8efa7f6 (Astra gate). The original SC3 case is fixed, but the fix broke replacement detection. Fixed:
BLOCKER: an agent exec'd at the shell's PID is read as launch-ended (
This PR touches |
|
Fixed the second blocker in 063fd3d (one new commit on 8efa7f6). Blocker: an agent exec'd at the shell's pid read as launch-ended. A launch-bound first message now keeps the process name of its launched agent ( Covered without herdr timing:
Each earlier commit fails its own case:
Removed: the contract case added in 8efa7f6 ("says first_message_launch_ended while herdr still names its launched agent..."). It relied on herdr keeping its manual name after the process exited. In an isolated run, herdr had already dropped the name by the control assertion, so the case passed or failed by timing. The scripted unit cases cover what it was meant to cover. Verification on this PC:
Reviews: omo-native-code-reviewer approved the exec fix, with the MEDIUM above (now fixed) and these LOWs:
Codex was not run on this delta because Codex sessions are stalling host-wide. The merge pass reviews. |
|
Merge pass re-review of 063fd3d (Astra gate). The exec-at-shell-PID blocker is fixed. Two findings remain. Fixed: the replacement assertion at BLOCKER 1: if the agent exits before the first drain, the stale-label bug comes back (
BLOCKER 2: the moved regression lost coverage (
This PR touches |
|
Both findings are fixed in 726b73d (one new commit on 063fd3d). BLOCKER 1: the agent exits before the first drain. BLOCKER 2: the moved regression's coverage. The unit case in
Each scenario checks:
Mutation checks (the same unit file, against each
Verification on this PC:
The remaining contract case ( |
726b73d to
eece2f0
Compare
…and say both held reasons in the reader's language A first message held because the agent started for it has ended now carries its own code, first_message_launch_ended, instead of sharing pending_target_changed with a pane whose terminal or agent session changed. Both codes get a note of their own in Korean, Japanese and Chinese, so a held row no longer shows the bridge's English reason. pendingContext throws the shared TARGET_CHANGED constant. Send now answers the new code only to a client whose pending-action frame says launch_ended; an older client, which would take an unknown code as maybe typed, is answered pending_target_changed, while the card keeps the new reason. Fixes #1547
…th the shell back in front The launched process can exit while herdr still names its agent in the pane. The first message was then held as pending_target_changed, and since a message held for that reason is not read again, the wrong reason stayed. launchGone now also counts the launch as ended when herdr names the launched kind but the pane's own shell is the process in front; any other process under that name is still another agent. A contract case kills the launched agent while herdr's manual report still names it, checks the shell is back in front, and expects the first held reason to be first_message_launch_ended, kept after herdr lets go.
…shell coming back An exec keeps the pid, so an agent exec'd in place of the pane's shell was read as the shell back in front and its first message held as the launch having ended, not as a replacement. A launch-bound first message now keeps the process name of its launched agent, read while that process runs in front under the launched kind, whether its pid was bound at queueing or learned at an event. The process at the shell's pid counts as the shell only under another name; without a known name the reason stays pending_target_changed. The stale-name reads are covered in server/core/pending.test.ts, where the process read is scripted: learned at an event or bound at queueing and ended with the shell back under herdr's name (first_message_launch_ended), and an agent of the kind exec'd at the shell's pid (pending_target_changed). The contract case that relied on herdr keeping its name after the process exited is removed: herdr drops it at its own pace, so that case could pass or fail by timing.
… a held first message's reason end to end A first message bound at its queueing kept its launched agent's name only from a later event's read, so an agent that left before the first drain was read with no name, and the shell back in front under herdr's stale name held the message as pending_target_changed for good. queueFirstMessage now learns from its own read as an event would. The unit cases in server/core/pending.test.ts script each process read in turn: learned at an event, or bound at queueing and gone at the next read, with the shell back under herdr's name, and an agent of the kind exec'd at the shell's pid. Each checks the first reason it is held with, that the reason stays once herdr lets go of an ended agent's name, that Send now answers that reason (and pending_target_changed to a frame without launch_ended), and that nothing reaches herdr's text, key or screen calls, the pty, or submitText.
… however many reads it makes The case where a launch's agent leaves before any event scripted exactly one process read for the queueing. An identity read that reads the foreground again before it answers (#1986) then saw the agent gone at its queueing and the case failed, though nothing it checks changed. The agent now leaves from the second session snapshot on, which every identity read starts with, so the queueing's reads see it and every later read, whichever drain makes it, finds it gone.
|
Head moved: rebased onto main after #1986 merged (1f8bb08), with one test-only commit (95588f8). Why: #1986 and this PR both change Fix (test only): the agent now leaves from the second session snapshot on. Every identity read starts with that snapshot, so the queueing's reads see the agent and every later read, whichever drain makes it, finds it gone. That holds however many process reads an identity read makes. Checked locally:
One push, so one CI run. |
eece2f0 to
95588f8
Compare
|
Merge pass review report. Overall: PASSED. This PR changes queued input (pending first messages) and the WS contract ( What holds:
Findings, and how each was resolved:
Checks: 5 core tests, 4 selected contracts and all 3 production probes pass. Locally, PendingMessages, compose and ws pass 147/147,
|
…he first agent ends (#2222) Found by the main-integration lane: Integration failed on main run 40644839354 (30cd84f) and on #2176's run 40643516119. ## Cause (test flake, not a product regression) `a create request's first message > is bound to the agent process it was queued under: a replacement of the same kind ...` started SESSION2 from the shell (`recorder SESSION1; exec recorder SESSION2`). Between SIGKILL of SESSION1 and the `exec`, bash alone is in front. A pane event in that gap makes `launchGone` (shell back in front, `server/core/pending.ts`) hold the message as `first_message_launch_ended`. That is the documented behaviour from #1969: the launched agent did end, and no agent was in front. The test expected `pending_target_changed`, so it failed whenever a read landed in the gap. **Reproduced:** keeping the shell busy for a moment before the `exec` (a builtin loop, so the shell itself stays in front) fails the old test 3 of 3, with exactly CI's `Received: "first_message_launch_ended"`. A `sleep 1` there does not reproduce it, because `sleep` is another process and reads as a changed target. ## Change - The npm-style launcher fixture now also handles SIGUSR1: it starts SESSION2, and ends SESSION1 once SESSION2 has spawned, so an agent is in front throughout. Its exit-driven path (used by the #1545 test) is unchanged. - The test uses that launcher and waits until herdr no longer lists SESSION1 before it reports idle. ## Proof - **Mutation:** with `samePendingIdentity` ignoring process pid and birth, the new test fails 2 of 2 (the message is typed into SESSION2). - **Stress:** the first-message block plus the two replacement tests (21 tests) passed 10 of 10 on CI's Node 22 and herdr 0.9.3, through `dori heavy` on a loaded host. - **Local checks:** `bun run check fast` ok. Test-only: no app code changes. Splits from the same lane: #2223 and #2224. ## Reviews - **omo-native-code-reviewer**, round 1 on the combined change: BLOCK with two HIGHs, both fixed. One was a loop shape that `scripts/conventions.test.ts` counts as a fixed sleep; the other was the OpenCode helper not waiting for its own Ctrl-L. Round 2 on these heads: APPROVE, no findings above LOW. - Test-only, so no Codex review (notes/pr-policy.md: the test-only gate is omo alone).
Fixes #1547.
Change
A pane's first message is held for one of two reasons that shared the code
pending_target_changed: the pane's terminal or agent session changed, or the agent started for that message came up and ended before the message went (#1532). The client could not tell them apart.pending_target_changedwas also missing fromsubmitNote, soPendingMessagesshowed the bridge's English reason (Not sent: {message}) in Korean, Japanese and Chinese.server/core/pending.ts: the launch-ended hold (LAUNCH_GONE) gets its own code,first_message_launch_ended.bindLaunchednow returns"ended"when the launched agent came up and left. The drain then holds the message with that reason and drains the pane once more. Send now answers that reason and re-holds with it.launchBoundInstops re-reading a message held for either reason.pendingContextthrows the sharedTARGET_CHANGEDconstant instead of repeating its text.pending-actionframe therefore gains an optionallaunch_ended: true, which this client always sends (src/lib/ws.ts). A frame without it getspending_target_changedfor this case, which an older client takes as nothing typed. The held row every connection sees keeps the new reason. A new client against an older bridge just seespending_target_changed, as before.src/lib/compose.ts: both codes are insubmitNotTypedand get their own note insubmitNote.src/components/PendingMessages.tsxroutes both codes tosubmitNote.src/lib/i18n/composer.{ko,ja,zh}.ts: the two notes, next tofirst_message_unattended's.docs/agent-commands.md: the first-message paragraph names both codes and the frame flag.DESIGN.md: the first-message paragraph names the new hold reason.changelog.d/pending-launch-ended-note.md.This changes the WebSocket contract (a new held reason and an optional
pending-actionfield) and touches queued input. Per AGENTS.md it needs a real review.A launch also counts as ended while herdr still names its agent for a moment after the process exits, when the pane's shell itself is back in front (8efa7f6). An agent exec'd at the shell's pid keeps the shell's pid, so the process there counts as the shell only under a name other than the launched agent's, which the message keeps from the process read while that agent runs in front, from its queueing on (063fd3d, 726b73d). Without a known name, the reason stays
pending_target_changed.Known limits: a launched process named like the shell (an
shwrapper under anshshell) falls back topending_target_changed. A drain that lands in the instant between a killed agent's exit and anexecof another holds the message as launch-ended, which is what it is at that moment. In every case the message is held and never typed; only the note differs.Design precedent
None applies. This gives an existing held-message note its own wording, the way
first_message_unattendedalready has one. No new UI.Validation
server/pending-input.contract.test.ts, the launched-agent cases: a launched agent that came up and quit is held withfirst_message_launch_ended, and Send now answers with it. A frame withoutlaunch_endedgetspending_target_changedwhile the row keeps the new reason. Another agent coming up in the terminal still holds the message withpending_target_changed. These cases were not re-run locally after the rebase: this PC is at its inotify instance limit, so watcher-backed contract tests fail with EMFILE here, and the herdr-backed check run was refused admission (a check slot port was held). CI's Integration job runs them.src/lib/compose.test.ts,src/components/PendingMessages.test.tsx(ko, ja and zh rows for both codes, no English server text),src/lib/ws.test.ts(the frame carrieslaunch_ended), andsrc/lib/i18n.test.ts. A mutation check: dropping the two codes fromPendingMessages.tsxfails the new row test.omo-native-code-reviewerapproved with no HIGH finding. Codex (gpt-6.1-sol, xhigh) found no HIGH finding. Both raised the old-client skew, which thelaunch_endedflag fixes, and one test assertion that could not fail, which was replaced. Codex's LOW about identity-read races is the known limit above.omo-native-code-reviewerapproved again with no CRITICAL, HIGH or MEDIUM finding. Its LOWs:DESIGN.mddid not name the new reason (fixed here); the drain's"ended"branch is reached only when two quick pane reads disagree and has no test (correct as written);launch_endedis sent on every pending action, discards included (harmless); a comment abovetargetChangedon main belongs tolaunchGone(not in this diff). Codex (gpt-6.1-sol, xhigh) approved the rebased commit with no HIGH, MEDIUM or LOW finding; it also checked that a held message stays held in both version-skew directions and that the extra drain runs once.server/core/pending.test.ts(each process read scripted in turn): a launched agent learned at an event, or bound at queueing and gone at the next read, then ended with the shell back under herdr's name for it, is first held withfirst_message_launch_endedand keeps it once herdr lets go. An agent of its kind exec'd at the shell's pid is held withpending_target_changed. Send now answers that reason, andpending_target_changedto a frame withoutlaunch_ended. Nothing reaches herdr's text, key or screen calls, the pty, orsubmitText. Each earlier commit of this PR fails its own case. On 726b73d,-t 'first message'inserver/pending-input.contract.test.tspasses 19/0 on this PC.bun run typecheckpasses, andsrc/lib/compose.test.ts,src/components/PendingMessages.test.tsx,src/lib/ws.test.ts,src/lib/i18n.test.ts,src/conventions.test.tsandscripts/changelog-fold.test.tspass (189 tests, 0 failures).bun run check fastcould not run its herdr-backed steps here for the same host reasons (inotify limit, check-slot admission), none of them in files this diff touches; per the lead it counts as passed locally, and GitHub CI runs the full suite.