fix(supervision): opencode-aware composer-idle detection + exclude supervisor pane from stale scan#49
Open
e-jung wants to merge 1 commit into
Open
Conversation
…pervisor pane from stale scan
Two bugs that together completely broke autonomous (permanent-afk) supervision
when firstmate runs on opencode (the captain's harness):
Bug 1 — pane_input_pending() false-positives on opencode's idle composer.
opencode renders a bordered input widget on the cursor line, so a clean idle
prompt is NOT blank: the cursor line is '<indent>┃ Ask anything... "<sugg>"'
(┃ = U+2503 box-drawing border; 'Ask anything...' is the fixed empty-composer
placeholder). The old COMPOSER_IDLE_RE never matched it, so every injection was
deferred forever ('inject deferred: pending input'). Broaden the regex to
recognize opencode's idle composer (box-drawing border + placeholder, or
border-only chrome). Typed text ('┃ hello') matches neither, so the pending-
input guard still holds. A typed line resembling the placeholder but without
the literal '...' still classifies as pending.
Bug 2 — stale-wedge detector flagged the supervisor's own idle pane.
The supervisor pane (the opencode window running firstmate) is legitimately
idle between events while the captain is away; stale detection must apply ONLY
to crewmate panes (fm-* windows). Add is_crewmate_window() and guard
classify_stale + stale_marker_record so a non-crewmate window never records a
stale marker that housekeeping would age into a false wedge.
Verified against opencode 1.17.x's real idle rendering (live pane_input_pending
+ full inject path). New tests/fm-daemon-opencode.test.sh pins both fixes; all
existing daemon/supervision suites (fm-wake-queue, fm-afk-inject-e2e,
fm-teardown, fm-daemon-opencode) stay green. shellcheck clean.
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.
What
Two fixes for
bin/fm-supervise-daemon.shthat together broke autonomous (permanent-afk) supervision when firstmate runs on opencode.Bug 1 —
pane_input_pending()false-positives on opencode's idle composeropencode renders a bordered input widget (box-drawing
┃+ an "Ask anything…" placeholder) on the cursor line at a clean idle prompt. The composer-idle check read that as a non-empty line, returned "pending" forever, and the daemon deferred every injection indefinitely — so nothing was delivered while the user was away.Fix: broadened the shared
COMPOSER_IDLE_RE_DEFAULTto recognize opencode's border-only line and the "Ask anything…" placeholder as idle. Existing patterns for claude/codex/pi (bare\$ > ❯ % #prompts,esc (to )?interrupt,Working…) are unchanged.Bug 2 — stale scan flagged the supervisor's own idle pane
While the user is away, the supervisor pane is legitimately idle; the stale detector flagged it as
stale persisted (possible wedge)every cycle, flooding the escalation buffer. Fixed by excluding the supervisor pane from stale-wedge detection (only crewmate panes are candidates).Verification (honest)
tests/fm-daemon-opencode.test.sh(byte-level fixtures from a real opencode 1.17.x pane) + all existing daemon suites green;shellcheckclean.Why share upstream
Even if this doesn't merge, documenting the opencode idle-composer edge case + the additive fix may help anyone running firstmate's afk daemon on opencode. We hit it in production (permanent-afk deployment) and wanted to contribute the fix back.
AI disclosure: Human-reviewed.