Repository navigation
fix(bin): submit the Herdr doorbell into a vim-mode Claude composer - #14
Merged
Merged
Conversation
Claude's optional vim editor mode gives its composer a command mode whose keystrokes are editor commands, and Escape - Claude's own interrupt key - is what leaves text entry. A doorbell typed into a composer left there is eaten from the front: `: Firstma` becomes the space, find-backwards, replace, till and append commands, so only `te instruction waiting: ...` is inserted. The Herdr payload proof correctly refuses that fragment, and the steer was reported as a doorbell that did not reach the pane while no instruction was ever delivered. The adapter now recovers a refusal the mode caused, exactly once. After the refused fragment is cleared back to the proven-empty state the send started from, it checks the harness's text-entry indicator: an eaten payload usually ends on an insert command and has already restored text entry itself, so nothing is typed, and only an absent indicator makes the adapter type the text-entry key - which counts only when the indicator appears while the composer still reads empty. The payload is then typed and proven a second time before Enter, so the whole doorbell is submitted rather than its remainder. A payload still refused after that is reported send-failed with the composer empty. The steering ring no longer counts an unaccountable delivery as rung. A backend verdict of `unknown` means it could confirm neither the submission nor that its own half-typed text is gone, and a composer still holding that fragment answers every later ring with the pending skip, so both `unknown` and `send-failed` now report a failed ring and the watcher's re-ring is expected rather than a surprise. `pending` keeps its meaning: the composer provably holds the complete doorbell, which the next ring submits. The indicator, the text-entry key, and how the indicator is recognized move to bin/fm-composer-lib.sh, the composer owner, because delivery and lifecycle control now both read them; bin/fm-control.sh keeps its own restore and sources that owner directly. Two things this is NOT. It is not the composer-reader defect in kunchenguid#5558: the reader identified the idle pane and the fragment correctly, and refusing that fragment was the right call. And it is not a consequence of the restart-control change in #10 - the tail capture width that change replaced refuses the identical fragment, measured live against the same pane. Verified live in an isolated Herdr lab on herdr 0.9.1 with Claude Code 2.1.282, editorMode pinned per pane: the doorbell is submitted to a composer taking text, to one an Escape left in command mode, and to one with no modal editor.
…only indicator read
max-metaplanet
added a commit
that referenced
this pull request
Oct 6, 2026
Carried from fork commit de888f6 (#14). bin/backends/herdr.sh keeps this commit's type-prove-recover loop, which the conflict's shared tail already belongs to, but reads the composer through upstream's full visible viewport rather than this commit's 200-row tail. Upstream's read is the stronger one and its own regression covers the case this commit's width was chosen for, so the recovery loop now sits on top of it. bin/fm-send.sh keeps upstream's `$ring_retry`, which reports whether the retry ring was actually recorded instead of asserting that the watcher will re-ring, and keeps this commit's wording for the unconfirmed case, because an unconfirmed submission now counts as a failed ring too. docs/herdr-backend.md takes this commit's description, which is what the merged code does: a clear that cannot be verified reports `unaccounted`, and a cleared refusal gets exactly one modal recovery. docs/verification/runtime-backends.md keeps both records, which measure different findings. This commit's record claimed the 200-row proof read was not involved; since the read is now the full viewport, that clause states the proof width is not involved and points at the viewport section rather than naming a width this branch no longer uses.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
On the herdr backend, the fm-send doorbell line reaches an idle Claude Code worker's input box but is never submitted, so the worker never learns an instruction is waiting. Observed twice in 20 minutes on live workers, and a third time since: fm-send printed "doorbell did not reach ", and the pane showed the input box holding ": Firstmate instruction waiting: list ..." unsent, in vim INSERT mode. Pressing Enter by hand made the worker handle the waiting message. Every affected pane had Claude Code editorMode set to vim. The line in the input box starts with ": ", so check whether a leading character is being eaten, or whether the line is typed while the input box is in vim command mode. This appeared after today's merge of the restart-control change (PR #10, which restores normal typing after an interrupt on vim-mode workers), so check whether that change is involved. Compare with upstream issue kunchenguid#5558 ("composer reader fails on an idle Claude Code pane, so text delivery, relaunch, and exit are all refused"), which describes the input-box reader failing to recognise an idle Claude Code screen. Fix it so a doorbell is submitted and verified, and a failed delivery is re-rung rather than left sitting in the input box.
What Changed
bin/backends/herdr.shnow clears it and tries to recover exactly once. The usual cause is vim command mode eating the start of the payload:: Firstmagets read as editor commands. The newfm_backend_herdr_modal_entry_ensurechecks for-- INSERT --in the composer footer. If it is missing, it typesi, and counts the fix only if the indicator then shows and the composer is still empty. After that it retypes the payload and checks it again. If the composer can't be verified empty after a refusal, the send now reports a newunaccountedverdict, notunknown.bin/fm-task-inbox-lib.shnow counts bothsend-failedandunaccountedas a failed doorbell ring, so the watcher rings again instead of leaving a half-typed line in the input box.unknown, which covers "Enter was pressed but not confirmed", still counts as rung. Thefm-send.shand remote secondmate notices now say "did not reach, or could not be confirmed there".bin/fm-control-lib.shintobin/fm-composer-lib.shasfm_composer_modal_entry_signal,fm_composer_modal_entry_keyandfm_composer_modal_entry_shown. Lifecycle control and Herdr text delivery now share them. The matcher reads-- INSERT --only in the rows below the composer, so a transcript that quotes it doesn't count. Docs cover the new behaviour, anddocs/verification/runtime-backends.mdrecords the live Herdr 0.9.1 / Claude Code 2.1.282 check. Unit and live e2e tests were extended.🤖 Generated with Claude Code
Risk Assessment
✅ Low: Both fixes from the previous round are narrow and correct.
unaccountedis emitted only on the herdr paths where Enter was never pressed. Every caller that switches on the verdict sends it to the same branchunknownused to reach: fm-send's refusal default, fm-control's non-send-failed path, kimi/rovo spawn, and the daemon's non-empty check. The only change is that the ring returns 2 for it. The INSERT matcher now reads only the rows below the bottom-most composer envelope that a prompt glyph proves (the pi-pair scan keeps the last pair). A false negative there fails safe: the typed probe key is cleared and the result is send-failed. The one stale doc sentence is the only issue found.Testing
The repo's live Herdr e2e guard (all 5 cases) and an ad-hoc live driver were run against real Claude Code in throwaway fm-lab-* sessions created with bin/fm-herdr-lab.sh; each lab was torn down afterwards and the default session was never touched. The driver showed the bug on the base commit: in command mode the ring returned 2 and nothing was submitted. On HEAD the full ': Firstmate instruction waiting…' line was submitted in plain command mode. It was also submitted when the transcript contained a decoy '-- INSERT --' line, and Claude started a turn both times. Pane captures are saved as evidence. The targeted unit suites for the rung/failed-ring contract, secondmate drain, footer matcher, herdr backend, and control all passed. The only exception was one fm-wake-queue concurrent-lock test, which failed once and then passed on two re-runs; it is an unrelated timing flake. This is a terminal UI with no visual rendering, so text pane captures stand in for screenshots.
Evidence: Live e2e guard transcript (real Claude 2.1.282 / herdr 0.9.1)
Source: Live e2e guard transcript (real Claude 2.1.282 / herdr 0.9.1)
Evidence: Base commit reproduction: vim command mode, ring rc=2, doorbell never submitted
Source: Base commit reproduction: vim command mode, ring rc=2, doorbell never submitted
Evidence: HEAD: vim command mode, ring rc=0, doorbell submitted and Claude working
Source: HEAD: vim command mode, ring rc=0, doorbell submitted and Claude working
Evidence: HEAD adversarial: '-- INSERT --' in transcript above command-mode composer, doorbell still recovered and submitted
Source: HEAD adversarial: '-- INSERT --' in transcript above command-mode composer, doorbell still recovered and submitted
Evidence: Live driver script used for the base/HEAD/adversarial runs
Source: Live driver script used for the base/HEAD/adversarial runs
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-task-inbox-lib.sh:332- The ring now returns 2 forunknownon every backend, not only for the Herdr fragment case this change fixes.unknownis also the verdict when Enter was already pressed but the backend could not confirm the submit. Two examples: tmuxfm_tmux_submit_enter_corereturnsunknownwhen a harness like pi has an unclassifiable composer and its busy flip is not seen within the 2×0.4s budget, and Herdr returnsunknownwhenwait_for_workinganswers unknown. The main watcher ladder records the ring whatever the return code, so for it only the wording changes. Butsecondmate_ring_to_drain(bin/fm-watch.sh:822/924) treats any non-zero return as a failed ring. It skips writing the ring marker and falls straight through to the 'check: secondmate wake-loop stalled' captain alert. Before this change, the likely-delivered drain steer was counted and the watcher waited another interval. Scenario: a secondmate whose submit readsunknownafter a successful Enter now raises a stall alert right away instead of being given time to drain. The intent only requires Herdr doorbells to be submitted, verified and re-rung; the watcher re-rings on its own timer either way. Decide whetherunknownshould stay a success for the ring, or whethersecondmate_ring_to_drainshould keep treating it as rung (for example, by mapping only rc 2 caused by send-failed to failure).bin/fm-composer-lib.sh:1796-fm_composer_modal_entry_showngreps the whole visible viewport for-- INSERT --, not just the composer footer. The doorbell recovery infm_backend_herdr_modal_entry_ensurereturns 'already taking text' as soon as that string appears anywhere on screen. A worker's transcript can easily show it: for example, a firstmate worker that just read or edited fm-composer-lib.sh or these docs, or any turn that talks about vim. If the composer is really in command mode at that moment, the recovery types noi, the retyped doorbell is eaten again, and the ring ends as send-failed. That is the original failure this change was meant to fix. Limit the match to the footer rows below the composer, using the shared composer geometry, so that transcript text cannot count as proof of text-entry mode. The fm-control lifecycle restore uses the same shared matcher and would benefit too.🔧 Fix applied.
1 info still open:
docs/herdr-backend.md:239- The fix round renamed the herdr pre-Enter verdict tounaccounted. It covers a refused payload, or the text-entry probe character, that could not be verified as cleared. This line still says 'If the composer cannot be verified empty again, the submit reportsunknowninstead'. Readers and operators who seeverdict=unaccountedin fm-send's 'text not submitted' error will not find it documented, and the doc now contradicts herdr.sh:3408/3414. Fix: update the sentence tounaccounted, and say that Enter was never pressed and that the ring reports it as failed.tests/fm-wake-queue.test.sh- The 'concurrent append/drain subprocess' case in tests/fm-wake-queue.test.sh failed once ('queue lock could not be acquired safely') and then passed on two re-runs. This change leaves bin/fm-wake* and bin/fm-watch.sh untouched, so it is a timing flake unrelated to this change.FM_HERDR_SUBMIT_CONFIRM_LIVE=1 bash tests/fm-herdr-submit-confirm-live-e2e.test.sh(real Claude in an fm-lab-* session: 2 existing submit-confirm cases + 3 new doorbell cases)drive-vim-doorbell.sh <base-8c1679a-tree> command: reproduced the bug on the base commit in a real vim-mode Claude after Escapedrive-vim-doorbell.sh <HEAD worktree> command: same setup on HEAD, real fm_task_inbox_ringdrive-vim-doorbell.sh <HEAD worktree> transcript: adversarial run where Claude's reply prints-- INSERT --in the transcript, then Escape, then ringbash tests/fm-task-inbox.test.sh(failed-ring vs unconfirmed-Enter-counts-as-rung, re-ring ladder)bash tests/fm-wake-queue.test.sh(secondmate drain counts an unknown submit as rung; run 3x)bash tests/fm-composer-lib.test.sh(footer-only INSERT matcher)bash tests/fm-backend-herdr.test.shbash tests/fm-control.test.sh✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.