Skip to content

fix(supervision): opencode-aware composer-idle detection + exclude supervisor pane from stale scan - #49

Closed
e-jung wants to merge 1 commit into
kunchenguid:mainfrom
e-jung:fm-daemon-opencode-fix-r7
Closed

e-jung wants to merge 1 commit into
kunchenguid:mainfrom
e-jung:fm-daemon-opencode-fix-r7

Conversation

@e-jung

@e-jung e-jung commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

Two fixes for bin/fm-supervise-daemon.sh that together broke autonomous (permanent-afk) supervision when firstmate runs on opencode.

Bug 1 — pane_input_pending() false-positives on opencode's idle composer

opencode 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_DEFAULT to 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)

  • Live-verified on opencode (our harness): idle pane no longer false-defers; injection lands on walk-away.
  • claude/codex/pi: covered by the preserved shared-regex patterns + existing fake-tmux unit tests, but not live-retested — we only run opencode. The change is purely additive (no existing pattern narrowed/removed), and the new patterns match only a line that is solely a box-drawing border or the opencode placeholder, so a real typed line on another harness won't false-match.
  • New tests/fm-daemon-opencode.test.sh (byte-level fixtures from a real opencode 1.17.x pane) + all existing daemon suites green; shellcheck clean.

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.

Note: the PR must be raised via no-mistakes check fails due to the fork-routing gap (#293, being fixed separately). The 3 real checks (behavior tests / lint / invariants) pass.

…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.
@kunchenguid

Copy link
Copy Markdown
Owner

thanks for this. quick note on process - i require PRs to come through no-mistakes, which is why the "PR must be raised via no-mistakes" check is red here (this was opened directly).

the reason i ask for it: no-mistakes runs review, tests, lint, and docs on your branch before the PR is opened, so contributions arrive already validated. that keeps the quality bar high and keeps me from having to hand-review every change - i maintain this solo, so it's the only way i keep up.

can you re-raise it through no-mistakes? running the pipeline on your branch opens/updates the PR through the gate and turns that check green. the change looks useful, it just needs to come through that path. ping me if the setup gives you trouble.

@e-jung e-jung closed this Jul 17, 2026
pranaypratyush added a commit to pranaypratyush/firstmate that referenced this pull request Aug 24, 2026
* fix(afk): wait for Herdr launch pane readiness

* no-mistakes(review): Hardened Herdr launch regression coverage and rollback assertions

* no-mistakes(document): Document Herdr away-launch readiness boundary
fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 2, 2026
kunchenguid#49)

* Fix recursive steal-lock acquisition that nested .steal.steal paths.

Stale steal mutex reclaim now uses flat identity-backed reclaim instead of
recursing into another steal lock, so watcher arm no longer crashes on
abandoned steal state.

Co-authored-by: Cursor <[email protected]>

* no-mistakes(review): Gate stale-lock removal on re-verified identity; drop dead param

* no-mistakes(test): Gate TypeScript Pi tests; run node stdin as ESM

* no-mistakes(document): Document reserved .steal lock suffix and TS-runtime test skips

---------

Co-authored-by: Cursor <[email protected]>
@mklgrw

mklgrw commented Nov 3, 2026

Copy link
Copy Markdown

Price changed 2026-11-02 in https://github.com/mklgrw/smb-demand-pages/pull/54. Don't pool sign-ups across that date.

Tier Old price New price Files changed
Software $149/mo (≤100 doors / 20 listings) unchanged —
Managed $590/mo (≤300 doors / 60 listings) $5/door/mo ($400 min); $40/STR listing/mo ($300 min) src/sites/pmfin/config.ts

No article in src/content/pmfin quoted Propfina's $590; nothing there changed.

fritznoff pushed a commit to fritznoff/starship that referenced this pull request Nov 18, 2026
…starship command (kunchenguid#49)

* feat(bin): open the owner's whole desk in Herdr with one starship command

bin/fm-desk.py starts Herdr or attaches to the running session, fills in
only what config/desk-layout names that is missing (workspace, first mate,
bridge strip, Factory pane, factory and plain tabs), restarts plugin panes
and factory pages that Herdr brings back as plain shells after a restart,
and opens Terminal views until enough Herdr clients show the session, each
with its own profile and font size. A second run changes nothing. It can
also set Herdr's sidebar to start collapsed, read a running desk back as a
layout, open the desk at login through a LaunchAgent, and link itself as
`starship` on PATH.

* no-mistakes(review): Find factory tabs by record; drop desk login and plan

* no-mistakes(review): Add optional main tab label to the desk layout

* no-mistakes(test): Require an empty shell prompt before typing into panes

* fix(bin): give restored shells time to reach their prompt before the desk leaves them alone

Just after a restart every restored pane starts its shell at once, so none
shows a prompt when the desk first looks, and the tightened prompt check
left the bridge, the Factory pane and every factory page dead. The desk now
waits up to FM_DESK_WAIT for such shells to reach their prompt; one that
never does, or one holding typed-ahead input, is still left alone.

* fix(bin): open the desk's views only after restored shells have reached their prompt

A view attached while the desk could still start something in a pane would
let input typed through it race the desk's own command.

* no-mistakes(review): Scope desk wait, restore worker copies, drop toggles, guard install

* no-mistakes(test): Raise restored-shell desk test wait budget to stop flake

* no-mistakes(test): Wait for restored shells running startup commands before opening views
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.

3 participants