Repository navigation
fix(opencode): keep an @skill attached across a resize or a model-only row during Tab (#1992) - #2185
Conversation
…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.
…up, so a later switch is still seen
|
No actionable comments were generated in the recent review.
|
| 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:
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: 
5
-
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
#1992requires correct attachment reporting during resize and narrow model-only redraws, input-record parity, and retained agent-switch protection. The supplied PR evidence reports changes inserver/opencode-skill-attach.tsthat compare agent names only when both are present, defer acceptance when needed, and refuse a persistent switch withsubmit_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#1992and 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.
Comment @coderabbitai help to get the list of available commands.
|
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 |
…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.
…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).
Change
Fixes the follow-ups from #1991's review in #1992. They affect sending an
@skillfrom Chat to an OpenCode v2 pane (server/opencode-skill-attach.ts).@effect gotyped against@effect gorecorded).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. Withserver/dialogs/opencode.test.tsandserver/opencode-native.test.ts: 101 pass, 0 fail.bun run check faston 2a45100: 7934 unit tests pass, 0 fail; typecheck and build ok.submit_changedand send no Enter. This last fix was not re-reviewed by Codex; the merge pass reviews it.