Repository navigation
feat(bin): detect Claude permission prompts on worker and main panes - #7612
johntran-mudflap wants to merge 13 commits into
Conversation
A Claude permission prompt, including the one a PreToolUse hook's ask decision opens, now matches fm_composer_permission_prompt by its bottom structure and is named as a blocking dialog with the prompted command's first line. Its selected '1. Yes' row read as a composer holding text, so a typed submit would have pressed the Enter that approves the call; the delivery guards now refuse it.
A worker parked on a Claude permission prompt is still inside its turn, so it read busy and was only reported after FM_BUSY_TURN_MAX_SECS. The watcher now raises one check wake, naming the task and the prompted command's first line, once the same prompt has stayed on the pane for FM_PERMISSION_PROMPT_SECS (default 90), and teardown prunes a task's pending prompt wakes. Nothing answers the prompt.
The config/wedge-alarm channel layer moves unchanged from the away-mode daemon into bin/fm-wedge-alarm-lib.sh so another alarm can use the same channels. Callers name their alarm through WEDGE_ALARM_TITLE, which the osascript banner now receives as an argv item.
A tracked Claude PermissionRequest hook records a prompt in the lock-owning primary session and starts one delayed check. After FM_MAIN_PROMPT_ALARM_SECS (default 300) it alerts once through the config/wedge-alarm channels when the session transcript has not moved and the main pane, when readable, still shows the prompt. The hook prints no decision, so the prompt is never answered. An opt-in live guard proves both prompt signals against the installed Claude Code.
Record the measured prompt shapes and hook behavior on Claude Code 2.1.306 and 2.1.153, the two new settings, the shared alarm channels, the new state records, and how a supervisor handles a worker parked on a permission prompt without approving it.
…entries The tracked PermissionRequest registration carries the same Grok guard as the other Claude-only entries, so the inventory of tracked hooks now stubs its script and expects eight guarded entries.
…on screen The watcher reads every worker pane on every poll, so the matcher now returns before forking unless the screen holds its question text.
…; fix moved comments
|
Speaking as Kun's firstmate: thanks @johntran-mudflap. This is a careful piece of work, and the live labs on real Claude Code 2.1.306 are exactly the kind of evidence that helps. This is my first triage look. I read the whole diff of head CI: this head's first-time-contributor runs were waiting for approval. I approved them (CI contract-class: new-default (my own read): without any configuration, every Claude worker pane gets a new wake class after Overlap worth knowing: #7480 (@Azd325) also wakes the first mate on Claude worker permission prompts. It does that through a VISION, rule by rule: One captain aligns (a stalled prompt surfaces instead of silently blocking). Authority aligns (it detects and alerts only, never answers, and the delivery guard stops a typed steer approving a call). Scripts/judgment aligns. Restart aligns (durable per-window records and a prunable keyed wake). Delegation aligns (live 7/8 plus unit suites). On vendor, it aligns with a note: the worker-pane wake reads Claude's rendered prompt even though Claude exposes a Where this stands: waiting on CI, with nothing required from you. If CI and the no-mistakes check come back green, this goes to Kun to decide whether to merge or leave it, since it changes default behavior. I won't merge it on my own. |
Resolves the operational-home-layout runtime-marker list as the union of both sides: the wedge-cap markers from main and the permission-prompt markers from this branch.
|
Speaking as Kun's firstmate: thanks for bringing this up to date with main, @johntran-mudflap. I looked at the new head CI: on this head, serial 2 was cancelled at the 30-minute limit, which is a known flake. Serial 4 failed one case, contract-class: new-default, same as before: with no configuration, worker panes get the new permission-prompt wake and the main Claude session gets the new Where this stands: waiting on the CI re-run, and you don't need to do anything. If it comes back green, this goes to Kun to decide whether to merge it or leave it. I won't merge it on my own. |
Resolves the operational-home-layout runtime-marker list again as the union of both sides: main's current wording and markers plus this branch's permission-prompt markers.
|
Merged the latest main to clear the conflict. On the previous run, the two red jobs looked unrelated to this change: "Behavior portable serial 2" hit the 30-minute timeout, and "serial 4" failed fm-watch-wedge-cap.test.sh once; that test passes 12/12 on both this branch and main, including under heavy parallel load. Could a maintainer approve the new workflow run? |
|
Speaking as Kun's firstmate: thanks @johntran-mudflap for merging main and for checking the two red jobs. I agree: the serial 2 timeout and the one-off I read the new head The new head's fork runs (CI Contract-class (my read, unchanged): new-default. VISION: unchanged. Status: waiting on CI, not on you. Once it's green, this goes to Kun as a merge-or-leave decision, not an auto-merge. |
What Changed
fm_composer_blocking_dialoginbin/fm-composer-lib.shnow recognizes Claude tool-permission prompts through the newfm_composer_permission_promptmatcher. The matcher handles the 2.1.306 and 2.1.153 layouts and reports the prompted command as the prompt's subject.bin/fm-watch.shraises a singlecheck: permission prompt pendingwake when the same prompt stays on an ordinary task's pane forFM_PERMISSION_PROMPT_SECS(default 90), whatever the pane's busy state. It never answers the prompt.fm_wake_queue_prune_tasknow also removes a task'spermission-prompt-<task>-<epoch>wakes.bin/fm-main-prompt-alarm.shruns as a tracked ClaudePermissionRequesthook (.claude/settings.json, skipped under Grok). It acts only for the lock-owning primary session of a primary checkout. It writes a record of the prompt and starts a delayed check. AfterFM_MAIN_PROMPT_ALARM_SECS(default 300) the check alerts once, but only if the record, session lock and transcript are all unchanged and the main pane, when it can be read, still shows the prompt. A newer prompt's record is never deleted by an older check.bin/fm-supervise-daemon.shinto the new sharedbin/fm-wedge-alarm-lib.sh, which both alarms use. Docs and skills cover the new detection and its settings. Tests were added for the composer matcher, watcher triage, the main-session alarm and wake-queue pruning, plus an opt-in live e2e test (tests/fm-permission-prompt-live-e2e.test.sh).🤖 Generated with Claude Code
Risk Assessment
✅ Low: The fix round changes one line: it removes the
rm -fof the shared prompt record, so a delayed check can no longer delete a newer prompt's record, and each check still alerts at most once because it is keyed to its own token. The test's wait condition was relaxed to match, and the rest of the diff, reviewed in round 1, still holds.Testing
I ran the opt-in live e2e guard against real Claude Code 2.1.308. I then drove a real Claude worker in a lab home onto a hook-ask permission prompt and pointed fm-send, the typed-submit path, and fm-watch at it. Finally I drove fm-main-prompt-alarm.sh's check through the superseded-prompt race and the transcript-changed case, and ran the four targeted test files. Everything passed. The prompt was never approved and was cancelled with Escape. Evidence is pane captures and transcripts; this change has no graphical surface, so there are no screenshots. All lab homes and tmux servers were torn down, and the worktree is clean.
Evidence: Live e2e guard on Claude Code 2.1.308
Source: Live e2e guard on Claude Code 2.1.308
Evidence: Live worker scenarios transcript (steer refusal + watcher wake)
Source: Live worker scenarios transcript (steer refusal + watcher wake)
fm-send: error: blocked on a prompt: Claude permission prompt: echo fm-live-ask-marker && echo second-line stale: fmlab:worker (blocked-on-prompt: Claude permission prompt: echo fm-live-ask-marker && echo second-line) check: permission prompt pending: task=w1 window=fmlab:worker waiting=7s - Claude permission prompt: echo fm-live-ask-marker && echo second-lineEvidence: Real worker pane on the permission prompt
Source: Real worker pane on the permission prompt
Evidence: Worker pane after the refused steer (prompt still open)
Source: Worker pane after the refused steer (prompt still open)
Evidence: Main-prompt alarm race and persistence transcript
Source: Main-prompt alarm race and persistence transcript
Evidence: Lab scripts used (run.sh, race.sh, persist.sh)
Source: Lab scripts used (run.sh, race.sh, persist.sh)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-main-prompt-alarm.sh:142- check() reads the record's token and then runsrm -f "$RECORD"without checking again that the record is still its own. Suppose prompt B's hook replaces the record in the short gap after prompt A's check has matched its token (A was answered long ago, and its delayed check fires just as a new prompt opens). A's check then deletes B's record. B's check later finds no matching token and exits silently, so a prompt that is really waiting never alerts. The window is a few milliseconds, so this is rare. Fix: re-read the token right before the remove, or drop thermand let the token comparison alone decide which check is current.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
FM_PERMISSION_PROMPT_LIVE_E2E=1 bash tests/fm-permission-prompt-live-e2e.test.sh(real Claude Code 2.1.308, isolated tmux and FM_HOME)Live lab script run.sh: real Claude worker parked on a hook-ask prompt;FM_HOME=$LAB bin/fm-send.sh fmlab:worker 'please continue'andfm_backend_send_text_submit tmux fmlab:worker ..., then a pane captureLive lab script run.sh:bin/fm-watch.shagainst the lab home with FM_PERMISSION_PROMPT_SECS=6, its wakes drained and acked throughbin/fm-wake-drain.shbetween runsrace.sh:bin/fm-main-prompt-alarm.sh check tokAsleeping while a newer prompt record (tokB) replaces it, thencheck tokB, then a transcript-changed check (tokC)persist.sh: after a check whose token matches, the prompt record still exists (HEAD commit removed the rm)bash tests/fm-main-prompt-alarm.test.sh,tests/fm-composer-lib.test.sh,tests/fm-tmux-submit-busy.test.sh,tests/fm-wake-queue.test.sh(targeted; no failures)✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.