Skip to content

fix(composer): treat OpenCode's right-aligned cwd:branch rail as furniture, not typed text - #5030

Closed
konih wants to merge 8 commits into
kunchenguid:mainfrom
konih:fm/fm-opencode-composer-cwd
Closed

konih wants to merge 8 commits into
kunchenguid:mainfrom
konih:fm/fm-opencode-composer-cwd

Conversation

@konih

@konih konih commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Since OpenCode 1.18.0 (upstream anomalyco/opencode#36457) the idle left-bar composer draws the pane's working directory and git branch right-aligned inside the composer rows above the Build · <model> footer, wrapped over up to three fragments with the tail continuing onto the footer row. The shared composer classifier in bin/fm-composer-lib.sh read those fragments as unsent typed text, so every idle OpenCode 1.18.x tmux worker answered pending. That skipped the steering doorbell in fm-send, the watcher's re-ring ladder, and the typed /exit in fm-control.sh exit|relaunch: idle workers could not be steered or stopped without typing into the pane by hand. This change teaches the left-bar classifier to recognise that rail structurally and skip it, so an idle pane reads empty again while every ambiguous shape still defers.

Changes

Classifier (bin/fm-composer-lib.sh)

  • New _fm_composer_leftbar_cwd_start finds the rail inside a left-bar region and returns its top row, or nothing. Recognition is structural and position-gated, never a match on a specific path:
    • the region's last row must match the existing footer regex;
    • walking upward from the footer, each row must be a bar row holding one whitespace-free token whose gap after the bar exceeds half the region's width (widest trimmed row across the region, so a short token cannot pass a gate measured against its own row);
    • the topmost token must itself start with ~/. The prefix is checked on that fragment's own bytes, so a typed lone ~ above a rail starting with / cannot be assembled into a false ~/.
  • _fm_composer_classify_leftbar and fm_composer_extract_selected_content skip the recognised rows, so idle panes read empty and extraction no longer returns rail fragments as user content.
  • A lone / is deliberately not accepted as a rail start: it is the first keystroke of a slash command and must never read empty. A worker whose cwd is outside $HOME renders a /... rail and therefore keeps the old conservative pending.
  • The recognition works on the ANSI-stripped row, so it is independent of FM_COMPOSER_GHOST_LUMA_MAX. The rail is drawn in RGB 128 grey, exactly on the ghost-luma ceiling, which is why ghost stripping never removed it.

Tests and fixtures

  • Two live tmux captures from idle 1.18.31 workers (272x70, real #{cursor_y}) under tests/fixtures/opencode-1.18.31-cwd/: a long cwd:branch wrapping over three rows, and a short one occupying a single row directly above the footer (the rail is bottom-aligned, leaving blank bar rows above it).
  • test_matrix_opencode_leftbar_cwd_furniture in tests/fm-composer-lib.test.sh pins: empty on both fixtures with the cursor inside the rail and on the cropped cursorless profiles; pending for left-edge typed prose, a left-edge typed path, a lone /, a lone ~ above an outside-$HOME rail, a space-prefixed short ~/a, a right-aligned non-path token, and a bare branch fragment with no path start; extraction scoped to the typed row only; and the one accepted residual described under Notes.

Docs

  • docs/verification/runtime-backends.md: dated 2026-09-18 entry with the live before/after read (pending then empty) on real fleet panes, the RGB 128 finding, and the upstream version history.
  • Harness reference for OpenCode and docs/tmux-backend.md: describe the rail as furniture present since 1.18.0 and note the cursorless deferral below.

Testing

  • bash tests/fm-composer-lib.test.sh: 36 pass, including the new matrix test. Against the pre-fix library the new test fails with expected empty, got 'pending', so it is a real regression test.
  • bash tests/fm-composer-ghost.test.sh: 33 pass.
  • Live OpenCode 1.18.31 driven in a pty (272x70, isolated HOME, worktree whose path wraps the rail) and its rendered composer fed to the real classifier: idle long rail empty (pre-fix pending); short rail empty; typed left-edge prose, lone /, lone ~, space-prefixed ~/a, and an outside-$HOME idle rail all pending. Extraction on the idle pane returns nothing instead of the fragments.
  • fm_tmux_composer_state run read-only against three real idle fleet panes on tmux: pending before the fix, empty after.

Not verified:

  • The full steering path (fm-send doorbell and fm-control.sh exit) end to end against a live 1.18.x pane. Only the classifier verdict those commands consume was checked.
  • Herdr and Zellij. Their cursorless full-pane reads of an idle 1.18.x pane still answer unknown, because the status rail below the composer floor is contiguous non-blank content the cursorless selector refuses to outrank. This change does not repair that; it is a separate follow-up.
  • Why the older 1.18.30 capture in test_matrix_opencode_leftbar_signals shows the placeholder hint but no rail. The test comment offers two possible reasons; neither has been confirmed against the upstream source.

Notes

  • Accepted residual, pinned by test. A composer whose only content is a single whitespace-free ~/... token typed so far right that it starts beyond the region's midpoint reads empty. Every other misfire path defers to pending or unknown. Tightening this further is a deliberate classifier change, not drift.
  • Workers outside $HOME remain unsteerable on OpenCode 1.18.x, since their rail starts with / and keeps the conservative pending. Every evidenced fleet pane renders ~/...; widening to absolute paths would need a stronger position proof.
  • Narrow panes. If the pane is narrow enough that the rail starts in the left half of the row, the position gate refuses it and the pane defers as before.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ docs/tmux-backend.md:75 - This sentence, added by this branch, still attributes the cwd:branch furniture to OpenCode 1.18.31 specifically ("OpenCode 1.18.31 also draws its working directory and branch..."), which is the version framing the captain's decision (1) requires replaced with "present since 1.18.0 (observed live on 1.18.31)". Every other file the decision enumerated (bin/fm-composer-lib.sh, the harness-adapters OpenCode reference, docs/verification/runtime-backends.md, the 1.18.30 test comment) was corrected, but this sibling doc line keeps the old story. Mechanical factual correction: say the furniture is present since OpenCode 1.18.x and was observed live on 1.18.31.
  • ℹ️ bin/fm-composer-lib.sh:1262 - Known, authorized residual, noted rather than flagged for action: the region-width gate (indent*2 &gt; width, width = max trimmed plain row over first..last) still recognizes a lone whitespace-free ~/... token typed far enough right as cwd furniture, so that composer reads empty. Traced concretely: the test's 200-space row has indent 200 and is itself the widest row (width 210), so 400 > 210 passes and fm_composer_classify_screen returns empty. The captain's own prescribed algorithm (width = max trimmed plain row length over the region) necessarily yields this, and the branch pins it explicitly with a comment calling it the accepted residual, so this is intentional containment rather than an unaddressed defect. Every other misfire path (left-edge typed text, path-shaped left-edge text, lone ~, lone /, non-path right-aligned tokens, outside-$HOME rails) was verified to defer to pending/unknown.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 8 of 11 scenarios driven live against the product
Scenario Result Live Evidence
An idle OpenCode 1.18.31 worker whose cwd:branch wraps into the composer rows is read empty by the real classifier (steering doorbell no longer skipped) ✅ pass live live-opencode-cwd-classification.log (verdict fix: empty on the live idle capture); live-opencode-idle-cwd-composer.html
The same live idle pane read by the pre-fix classifier is pending (the reported bug reproduced end-to-end) ✅ pass live live-opencode-cwd-classification.log (verdict base: pending)
Typed left-edge text in a live OpenCode composer still reads pending (never treated as empty/injectable) ✅ pass live live-opencode-cwd-classification.log (typed left-edge prose: fix pending)
A lone / typed as the first keystroke of a slash command never reads empty on a live OpenCode pane ✅ pass live live-opencode-cwd-classification.log (lone slash: fix pending)
A typed lone ~ above a rail whose top fragment starts with / (outside-$HOME cwd) does not assemble a false ~/ and stays pending ✅ pass live live-opencode-cwd-classification.log (outside-$HOME idle: pending; typed lone tilde above it: pending)
A short cwd:branch that fits entirely on the footer row still reads empty (no false pending for short paths) ✅ pass live live-opencode-cwd-classification.log (short idle: empty)
An idle worker whose cwd lies outside $HOME keeps the documented conservative pending (accepted trade-off, never empty) ✅ pass live live-opencode-cwd-classification.log (outside-$HOME idle: pending)
Extraction on the live idle pane excludes the cwd:branch furniture (returns empty instead of the rail fragments) ✅ pass live live-opencode-cwd-classification.log (idle fix: [] vs base: furniture fragments)
The committed regression test fails on the pre-fix library and passes after the fix ⏸️ untested no The prior payload recorded live=false: this scenario is a shell regression test run against bin/fm-composer-lib.sh, not the running product, so it cannot support a pass. To establish it live, drive th…
End-to-end steering doorbell (fm-send) rings against a live tmux OpenCode 1.18.31 worker through fm_tmux_composer_state ⏸️ untested no tmux is not installed on this host (command -v tmux empty) and no herdr binary is present, so the tmux capture-pane/cursor adapter and the fm-send doorbell could not be driven against a live pane. T…
The PR body carries the corrected 1.18.0 framing, the three real checks, corrected fixture paths, and the Herdr/Zellij compatibility note ⏸️ untested no The PR body is a delivery artifact owned by the push/PR phase, which this test phase must not execute; it is not a runtime surface. The outer executor owns applying intent items 2-5 to the PR.
  • opencode --version -> 1.18.31 (installed at ~/.no-mistakes/bin/opencode)
  • Drove the real OpenCode 1.18.31 TUI in a non-zero pty (272x70 via TIOCSWINSZ) under an isolated HOME and a git worktree whose path wraps the cwd:branch rail; captured the rendered grid and per-cell truecolor
  • Ran the real fm_composer_classify_screen with tmux caps (styled=1 cursor=1 identity=1) and cursor row 64 against the live idle capture: fix empty, base pending
  • Adversarial live typed cases against the same live rail: left-edge prose pending; lone / pending; lone ~ pending; space-prefixed ~/a pending
  • Live idle worker whose cwd is outside $HOME (rail starts with /): fix pending (documented conservative trade-off), typed lone ~ above it pending
  • Live short cwd:branch that fits entirely on the footer row (tmux palette): empty
  • Ran fm_composer_extract_selected_content on the live idle capture (cursorless): fix [], base returns the furniture fragments
  • bash tests/fm-composer-lib.test.sh (after fix) -> all pass
  • bash tests/fm-composer-lib.test.sh against the pre-fix library -> not ok - opencode 1.18.31 idle cwd:branch furniture on tmux: expected empty, got &#39;pending&#39;
  • bash tests/fm-composer-ghost.test.sh -> all pass
  • bash tests/fm-composer-matrix-live-e2e.test.sh -> skipped (opt-in; needs tmux, which is not installed)
  • Read the corrected version framing in bin/fm-composer-lib.sh, .agents/skills/harness-adapters/references/harness/opencode.md, docs/tmux-backend.md, docs/verification/runtime-backends.md; confirmed no absent on 1.18.4 / from 1.18.31 / &gt;= 1.18 / footer-tail-concat-knob remnants
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…niture

OpenCode 1.18.31 draws the worker pane's working directory and branch
right-aligned inside the left-bar composer rows above the Build footer,
wrapped over up to three rail-width fragments whose final fragment
continues onto the footer row's right end. The fragments are RGB 128
grey with luminance exactly on the ghost-luma ceiling, so they survive
ghost stripping, and the left-bar classifier read them as unsent typed
text: every idle 1.18.31 pane answered pending, which skipped the
steering doorbell, the watcher's re-ring ladder, and /exit typing.

_fm_composer_leftbar_cwd_start recognises the run structurally and
position-gated: contiguous single-token rows immediately above the
footer row whose gap after the bar exceeds half the row, whose
fragments plus the footer row's gap-separated right-hand tail
concatenate to a path, optionally followed by :<branch>. A path-shaped
string typed at the composer's left edge is still typed text, so a
wrong call can only defer, never inject. Extraction shares the same
rule so extracted composer content stays user-scoped.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is waiting on the author.

HEAD 4f90ada46b7b877e5d93cb207d6281275166ba8a (konih/firstmate). MERGEABLE/UNSTABLE vs main a09090d13ef24ce3cf71d171ade119896d6db301. Workflow-zero (no .github/workflows/*). Author not blocked.

Attestation: MISSING — PR body has no no-mistakes-pipeline-attestation / bound head SHA. Require no-mistakes body-compliance: opened run 35507952851 SUCCESS; edited run 35512556987 FAILURE (expected until the body is rebound). CI run 35507952860 queued after fork approval.

Contract-class: restore — inspected tip vs main on bin/fm-composer-lib.sh + fixtures/tests/docs. The existing left-bar idle path already promised proven empty so doorbell / re-ring / /exit can run; OpenCode 1.18.31's new right-aligned cwd:branch rail was misread as typed text (pending), which broke that specified default. This teaches the classifier to treat that furniture as furniture (position-gated, fail-closed toward pending/unknown), with live fixtures. Not a new default-on surface.

VISION (per rule):

  1. One captain, one interface — aligns: restores steerability of idle OpenCode workers; no new captain-facing surface.
  2. Authority explicit — aligns: recognition only skips proven furniture; wrong calls defer, never inject / never assume empty.
  3. Scripts own mechanics — aligns: deterministic classifier + fixtures; no agent judgment in the path.
  4. Restart is a non-event — aligns: unblocks durable send/watch/control paths that were skipping on false pending.
  5. Delegation with a spine — aligns: workers stay reachable through existing contracts; no new task shape.
  6. Fleet outlives any vendor — aligns: named, version-pinned OpenCode surface read with verification debt recorded in docs/fixtures (1.18.31); 1.18.4 fixtures stay green.
  7. Scope — aligns: command-layer composer safety / harness adapter, not workshop.

Closing align/resist: deepens peace of mind by restoring fleet steering on a vendor TUI change; resists injecting on ambiguity.

First-time fork CI: after full diff review I approved workflow runs 35512556987 (Require no-mistakes), 35507952851 (Require no-mistakes), 35507952860 (CI) for this HEAD. No security risk in the diff.

Security FYI (not a captain gate): widening what reads empty is always injection-adjacent; this tip keeps fail-closed (position + ~/ top-fragment gate; lone / stays pending). Tip-only.

Waiting on you: git push no-mistakes (or equivalent) so the PR body attestation binds exactly to HEAD 4f90ada46b7b877e5d93cb207d6281275166ba8a, then green CI + green Require no-mistakes on that tip. Not a captain hold. Do not merge yet.

Review round on the independent PR review: the position gate now measures
the gap against the region's width (the widest trimmed plain row across
first..last), so a short space-prefixed home path typed into an otherwise
empty composer no longer reads empty; the right-half lone-token residual
is pinned explicitly. The cwd:branch furniture is documented as present
since OpenCode 1.18.0 (upstream anomalyco/opencode#36457, merged
2026-07-11), not a 1.18.31 layout change. The 1.18.30 capture comment
notes it omits the directory footer, and a cropped-composer extraction
assertion scopes user content to the typed row above the rail.
@konih konih changed the title fix(composer): treat OpenCode 1.18.31 right-aligned cwd:branch rail as composer furniture fix(composer): treat OpenCode 1.18.x right-aligned cwd:branch footer as furniture Sep 20, 2026
@konih konih changed the title fix(composer): treat OpenCode 1.18.x right-aligned cwd:branch footer as furniture fix(composer): treat OpenCode's right-aligned cwd:branch rail as furniture, not typed text Sep 20, 2026
kunchenguid pushed a commit that referenced this pull request Oct 14, 2026
…re, including absolute paths (#7307)

* fix(composer): treat OpenCode >= 1.18 right-aligned cwd:branch as furniture

OpenCode 1.18.31 draws the worker pane's working directory and branch
right-aligned inside the left-bar composer rows above the Build footer,
wrapped over up to three rail-width fragments whose final fragment
continues onto the footer row's right end. The fragments are RGB 128
grey with luminance exactly on the ghost-luma ceiling, so they survive
ghost stripping, and the left-bar classifier read them as unsent typed
text: every idle 1.18.31 pane answered pending, which skipped the
steering doorbell, the watcher's re-ring ladder, and /exit typing.

_fm_composer_leftbar_cwd_start recognises the run structurally and
position-gated: contiguous single-token rows immediately above the
footer row whose gap after the bar exceeds half the row, whose
fragments plus the footer row's gap-separated right-hand tail
concatenate to a path, optionally followed by :<branch>. A path-shaped
string typed at the composer's left edge is still typed text, so a
wrong call can only defer, never inject. Extraction shares the same
rule so extracted composer content stays user-scoped.

* no-mistakes(review): drop dead footer-tail concat, add live short-cwd fixture

* no-mistakes(review): accept only ~/ cwd rail; lone slash stays pending

* no-mistakes(review): require footer row for leftbar cwd furniture walk

* no-mistakes(review): Require topmost cwd fragment to carry ~/ prefix

* no-mistakes(document): Correct cwd furniture recognition doc to topmost-fragment check

* fix(composer): gate cwd rail on region width; correct version story

Review round on the independent PR review: the position gate now measures
the gap against the region's width (the widest trimmed plain row across
first..last), so a short space-prefixed home path typed into an otherwise
empty composer no longer reads empty; the right-half lone-token residual
is pinned explicitly. The cwd:branch furniture is documented as present
since OpenCode 1.18.0 (upstream anomalyco/opencode#36457, merged
2026-07-11), not a 1.18.31 layout change. The 1.18.30 capture comment
notes it omits the directory footer, and a cropped-composer extraction
assertion scopes user content to the typed row above the rail.

* no-mistakes(document): correct OpenCode cwd-furniture version framing and doc typos

* fix(composer): accept an absolute cwd rail outside $HOME as OpenCode furniture

Refs #4632, builds on #5030.

* no-mistakes(review): Harden live abs-cwd check waits and qualify rail comment

* no-mistakes(review): Fix composer-lib relative path in OpenCode harness doc

* no-mistakes(test): Relax live check's DONE wait for wide OpenCode panes

* no-mistakes(document): Separate absolute-cwd verification output block from following prose

---------

Co-authored-by: Konrad Heimel <[email protected]>
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @konih. Your cwd:branch rail fix has landed as part of #7307 (squash 08f0a069). @KostadinP carried all eight of your commits forward and added the absolute-path case, so your work is in main. I'm closing this one because its changes are now fully included there. Really appreciate you taking the time on this.

valerius21 added a commit to valerius21/firstmate that referenced this pull request Oct 15, 2026