Skip to content

fix(opencode): keep an @skill attached across a resize or a model-only row during Tab (#1992) - #2185

Merged
devswha merged 2 commits into
mainfrom
fix/opencode-skill-resize-attach
Oct 28, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/opencode-skill-resize-attach

Conversation

@devswha

@devswha devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Change

Fixes the follow-ups from #1991's review in #1992. They affect sending an @skill from Chat to an OpenCode v2 pane (server/opencode-skill-attach.ts).

  • A resize during Tab, or a narrow redraw that drops the agent label, no longer reports an attached skill as missed. The check after Tab compared the agent named before Tab with the one named after it, and a narrow model-only status row names no agent. Agents are now compared only when both rows name one.
  • Input and record stay equal in that case: when the input is drawn in the padding's colour, the skill is now confirmed, so Tab's space is recorded once and never typed again (no more @effect go typed against @effect go recorded).
  • An agent switch is still refused. Another agent named after Tab stays a switch until a read names the original agent again. A model-only read cannot clear it, and at the 1 s deadline the send is refused with submit_changed. When the agent before Tab is known, a model-only read is accepted only on the deadline read, so a switch that shows after it is still caught. A wide-to-narrow resize therefore waits up to 1 s per skill.

Known limits (unchanged on main): if the pane is narrow before Tab, no agent name is on screen to compare against, so a switch cannot be seen. The send goes on as before, and the skill now reads as attached when its styling shows. A wide-to-narrow acceptance rests on the deadline read: if that one read cannot be parsed, the skill is reported missed, as it always was on main, and input and record still match.

Dropped from the issue's direction: treating an ambiguous separator as its own case. A skill that is not confirmed makes the send terminal-only (skillsNotAttached), and its watch is dropped before the recorded text is read (server/opencode-native.ts, commit), so a record change there would never run.

Fixes #1992

Verification

  • server/opencode-skill-attach.test.ts: 69 pass. Seven new cases. Six fail on main: both resize directions, the narrow redraw with the padding-coloured input, a switch hidden by a model-only read until the deadline, a switch named back before a model-only redraw, and a switch that shows only after a first model-only read. The seventh, a switch that settles on the other agent, passes on main too; it guards against this change. With server/dialogs/opencode.test.ts and server/opencode-native.test.ts: 101 pass, 0 fail.
  • bun run check fast on 2a45100: 7934 unit tests pass, 0 fail; typecheck and build ok.
  • Reviews:
    • Codex (gpt-6.1-sol, fast, xhigh), round 1: HIGH. A model-only read after a read naming another agent was accepted, so the rest and Enter went to the switched agent on both the immediate and the queued path. Fixed with the switch latch.
    • Codex, final round: HIGH. A model-only first read was accepted before a later switch could show. Fixed: when the pre-Tab agent is known, a model-only read is accepted only on the deadline read. Both of Codex's mocked send-path reproducers (composer and pending) now refuse with submit_changed and send no Enter. This last fix was not re-reviewed by Codex; the merge pass reviews it.
    • omo-native-code-reviewer: round 1 blocked on an unreachable record path, which was removed. Round 2 on the final head: APPROVE. Its three LOW notes are the known limits above and the up-to-1 s wait.

…y row during Tab (#1992)

The check after Tab compared the agent label read before Tab with the one
after it, so a narrow model-only status row (a resize during Tab, or a narrow
redraw) made an attached skill read as missed. Agents are now compared only
when both rows name one. An agent named after Tab that differs from the one
before stays a switch until a read names the original agent again: a
model-only read cannot clear it, and at the deadline it is refused.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8299220 and 2a45100.

Files selected for processing: 3
  • changelog.d/opencode-skill-resize-attach.md
  • server/opencode-skill-attach.test.ts
  • server/opencode-skill-attach.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • OpenCode skills sent from Chat are now correctly recognized as attached when the terminal is resized during acceptance or when a narrow terminal omits the agent name from its status row.
    • Improved handling of agent changes during skill acceptance, including cases where the agent changes temporarily and then returns to the original.
    • Fixed input handling on narrow terminal redraws where input and padding use the same color.

The change updates OpenCode @skill attachment checks for terminal resizes and model-only status rows. It tracks named agent changes after Tab and adds tests for acceptance, rejection, and input-record parity.

Changes: OpenCode skill attachment

Layer / File(s) Summary
Attachment acceptance and agent tracking
server/opencode-skill-attach.ts
Acceptance no longer requires both screens to name the same agent when one screen omits the name. After Tab, a named agent change is tracked, cleared if the original agent returns, and reported as submit_changed if it remains at the deadline.
Redraw regression coverage
server/opencode-skill-attach.test.ts, changelog.d/opencode-skill-resize-attach.md
Tests cover both resize directions, model-only redraws, persistent and transient agent changes, and input-record parity. The changelog describes the resize and narrow-status-row cases.

Priority: Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • devswha/ovis#1991: Introduced the post-Tab attachment and agent-switch checks that this change updates.
Merge Risk: Minimal · up to 2a451

The change is ready to merge after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main fix: preserving an @skill attachment across terminal resize and model-only status rows during Tab.
Description check Passed The description explains the problem, resulting behavior, known limits, implementation scope, and detailed validation results. It uses “## Verification” instead of the template’s “## Validation,” but …
Linked Issues check Passed Issue #1992 requires correct attachment reporting during resize and narrow model-only redraws, input-record parity, and retained agent-switch protection. The supplied PR evidence reports changes in `s…
Out of Scope Changes check Passed The reported changes are limited to server/opencode-skill-attach.ts, its focused tests, and a changelog entry. These changes directly support Issue #1992 and its regression coverage. No unrelated im…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Description check

Explanation

The description explains the problem, resulting behavior, known limits, implementation scope, and detailed validation results. It uses “## Verification” instead of the template’s “## Validation,” but it provides the required validation information.

Full details: Linked Issues check

Explanation

Issue #1992 requires correct attachment reporting during resize and narrow model-only redraws, input-record parity, and retained agent-switch protection. The supplied PR evidence reports changes in server/opencode-skill-attach.ts that compare agent names only when both are present, defer acceptance when needed, and refuse a persistent switch with submit_changed. The reported tests cover both resize directions, model-only redraws, input-record parity, and switch scenarios. The dropped ambiguous-separator direction is not a mandatory coding requirement, and the described terminal-only path remains safe.

Full details: Out of Scope Changes check

Explanation

The reported changes are limited to server/opencode-skill-attach.ts, its focused tests, and a changelog entry. These changes directly support Issue #1992 and its regression coverage. No unrelated implementation or test changes are identified in the supplied PR evidence.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Merging 2a45100: omo-native-code-reviewer and Codex both pass this head. The new resize and model-only cases fail on main, and the change also closes a hole on main where a mid-Tab agent switch could take the Enter. The required checks are green; Native Windows install first failed in scripts/windows-plugin.test.ts and passed on rerun, and CodeRabbit did not review this head. A pre-existing MEDIUM (Tab's space typed twice after a blank redraw, also on main) and the LOW notes go to a follow-up issue.

@devswha
devswha merged commit 505008e into main Oct 28, 2026
33 of 35 checks passed
@devswha
devswha deleted the fix/opencode-skill-resize-attach branch October 28, 2026 05:28
devswha added a commit that referenced this pull request Oct 28, 2026
…arent number pulls in nothing (#2202)

## Change

**What was wrong.** On Windows CI, "starts after its launcher exits,
stops its owned tree and restarts on Windows" sometimes failed at "wait
up to ten seconds for the Windows-owned process tree to disappear"
(#2185, run 40635841024; #2193, run 40638822136). `stop` itself had
succeeded: it exited 0, and `run("stop")` asserts that. The test then
waited for its own list of "owned" processes, and that list was wrong.
It held 128 and 123 pids, starting with boot-time system pids. It also
held the test runner's own pid (8248 and 2228). The earlier test in the
same file prints that number in "stopped Ovis (pid N)", because it
records `process.pid`. The runner started before the server, so it can
never be part of the server's tree, and it never exits.

The test built that list with a plain parent walk (unchanged since
#330). Windows keeps a dead parent's number on its children and gives
that number to new processes. When a process in the server's tree got a
number that long-lived processes still named as their parent, the walk
pulled them in, and everything below them.

**Is #2166 the cause?** No. #2166 (the plugin lifecycle lock) does not
change what `stop` waits for, and `stop` returned 0 in both failures.
Its Windows wait already uses `descendantProcesses` (`scripts/plugin.ts`
`stopInTurn`), the reuse-aware walk that skips a process older than its
parent. The test's walk had this hole since #330. Whether it shows up
depends on which numbers the runner hands out. Two hits half an hour
apart, right after #2166 merged, look like timing on the hosted runners
rather than something #2166 did, but that is not proven.

**Fix (test only).** The test builds the owned tree with
`descendantProcesses`, the walk `stop` uses. After the 10 s deadline, it
also drops a member whose number now belongs to a process with a
different start time. A member with a missing start time, or a failed
table read, stays on the list, so the check still fails closed. No
product code changes.

## Validation

- **The mechanism on a real PC (home-window, Windows 11), from a scratch
script that is not committed:** in a table of 418 processes, one stale
parent number (1200) took the plain walk to 293 processes, including the
bun process running the check. The reuse-aware walk reached 289 and left
it out.
- **home-window loops** (fresh clone under `%TEMP%`, throwaway profile,
app data and temp folders, `HERDR_TEST_MODE=unit`, removed afterwards
with no bun or herdr process left): the fixed test passed 30 of 30 runs.
The unfixed test also passed 10 of 10 there. The failure needs a
server-tree process to land on one of the few stale parent numbers, so
it did not happen on this PC in 10 tries. The failures above and the
walk comparison are the evidence for the cause, not a local
reproduction.
- `bun run check fast`: green at the head commit (7968 unit tests pass,
0 fail).
- The Native Windows install job on this PR: see the reruns below.

## Reviews

- **omo-native-code-reviewer:** APPROVE, no CRITICAL, HIGH or MEDIUM. It
confirmed from the CI logs that the runner's pid is `process.pid` from
the earlier test, and that the order of the list matches a walk from
boot-time system processes down to the runner. It found no way for the
new check to pass while an owned process still runs. LOW notes: the test
and `stop` now share one walk (it keeps its own unit test in
`server/shell-agent.test.ts`); a backwards clock step between a parent's
and a child's start; a reused number costing an extra table read within
the 90 s timeout.
- **Codex (gpt-6.1-sol, fast, xhigh):** PASS, no CRITICAL, HIGH or
MEDIUM. One LOW: if an owned number is reused and the final table read
then fails, the test still fails, which is fail-closed.

CodeRabbit: test-only change, so no review requested.
devswha added a commit that referenced this pull request Oct 28, 2026
…omplete (#2223)

Found by the main-integration lane: Integration failed on main run
40643422650 (7dc187a).

## Cause (test flake from #1991's test order, not a regression from
#2185 or #2200)

`refuses a confirmed Tab agent switch during immediate delivery without
Enter` runs right after `delivers a queued message completely when Tab
leaves the skill unconfirmed`, and that test leaves @effect's
autocomplete row selected (the recorded screen whose status row names no
agent). The stand-in redraws only when it is typed to. If herdr has not
yet drawn the screen that the next send's own `@effect` produces,
`typeWithSkills` (`server/opencode-skill-attach.ts`) reads the old box.
The agent before Tab is then unknown, and the Build to Plan switch
cannot be seen, so the send succeeds. The queue case then fails on the
outcome the immediate case left behind.

**Reproduced:** delaying the stand-in's `@effect` redraw by 400 ms fails
both cases 3 of 3, with CI's `ok: true` and the recorded outcome.

## Change

- The stand-in draws the recorded closed-autocomplete screen on Ctrl-L.
- `closedPrompt()` sends Ctrl-L, then waits until the stand-in has
logged it and herdr shows no selected @effect row. Both Tab-switch cases
call it before they note what was typed.

## Proof

- **With the fix:** the same 400 ms delay passes 4 of 4, and 3 of 3
again after review.
- **Stress:** `server/opencode.contract.test.ts` (24 tests) passed 10 of
10 on CI's Node 22 and herdr 0.9.3. That includes #2200's `closes the
shared stream when its last verified pane ends or stops being OpenCode`.
Its failure in run 40639664878 was #2200's pre-merge head, which still
had the stop-then-create test that the merged version replaced.
- **Local checks:** `bun run check fast` ok.

Test-only. Splits: #2222 and #2224.

## Reviews

- **omo-native-code-reviewer**, round 1 on the combined change: BLOCK
with two HIGHs, both fixed. One was a loop shape that
`scripts/conventions.test.ts` counts as a fixed sleep; the other was the
OpenCode helper not waiting for its own Ctrl-L. Round 2 on these heads:
APPROVE, no findings above LOW.
- Test-only, so no Codex review (notes/pr-policy.md: the test-only gate
is omo alone).
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.

OpenCode @skill: resize or a narrow redraw during Tab misreports the attachment (#1991 review follow-ups)

1 participant