Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

fix(opencode): backport small upstream fixes - #403

Merged
brentyates-swx merged 20 commits into
swxtchfrom
fm/oc-small-backports-388
Nov 4, 2026
Merged

brentyates-swx merged 20 commits into
swxtchfrom
fm/oc-small-backports-388

Conversation

@brentyates-swx

@brentyates-swx brentyates-swx commented Nov 4, 2026 •

Copy link
Copy Markdown

Closes swxtchio/swx-opencode#388

Scope

Backport anomalyco#54936, anomalyco#51538, anomalyco#45383, and anomalyco#54207 as four separate full-SHA git cherry-pick -x commits. The fork's existing V1/V2 owners are preserved; the upstream-only .changeset/rename-undo.md is omitted because CHANGESET.md is this fork's release ledger.

Donor application and lineage

The refreshed ship base was 1b2e93436a988773e485cc49a924ea9274b6e7f0, equal to origin/swxtch. Each standalone scratch trial at that base applied cleanly and nonempty; each branch donor commit below retains the full source trailer.

  • fix(opencode): answer a failed TUI worker request instead of hanging anomalyco/opencode#54936 source bbad8f350f977272faf9d5d9fe652b412a153876: trial changed packages/opencode/src/util/rpc.ts; branch donor commit ae720339651804213f1610553d43d083a4d98f80; trailer (cherry picked from commit bbad8f350f977272faf9d5d9fe652b412a153876).
  • fix(opencode): catch completed MCP browser launcher failures anomalyco/opencode#51538 source b471c2b4495747353af768fbf2e0790c9d820ce2: trial changed packages/opencode/src/mcp/browser.ts and packages/opencode/test/mcp/browser.test.ts; branch donor commit 73eb517cbccd495850e89ce583cb70a0db018075; trailer (cherry picked from commit b471c2b4495747353af768fbf2e0790c9d820ce2).
  • fix(core): preserve renamed files when undoing changes anomalyco/opencode#45383 source d68031bc0d92e7c1bfb7a4ad1e7fa234b1cac756: trial changed .changeset/rename-undo.md, packages/core/src/git.ts, packages/core/test/git.test.ts, and packages/core/test/session-revert.test.ts; branch donor commit 4f77f76fed27869ccd1b8a969f2a0b345fc1031b; trailer (cherry picked from commit d68031bc0d92e7c1bfb7a4ad1e7fa234b1cac756). The upstream changeset note is removed in a compatibility commit; production behavior is complete and SessionV2 test plumbing is adapted.
  • fix(core): accept interleaved Copilot reasoning_opaque values anomalyco/opencode#54207 source b2a3926e87e35fc7f6308521c4418067cddd5d0e: trial changed packages/core/src/github-copilot/chat/convert-to-openai-compatible-chat-messages.ts, packages/core/src/github-copilot/chat/openai-compatible-chat-language-model.ts, packages/core/test/github-copilot/convert-to-copilot-messages.test.ts, and packages/core/test/github-copilot/copilot-chat-model.test.ts; branch donor commit bbed4c571f581965bc4e9168fb76a3abda5593f8; trailer (cherry picked from commit b2a3926e87e35fc7f6308521c4418067cddd5d0e).

upstream/dev was pinned at 156bb610108c3da91c6963056f439e2acc1614f0; the branch/upstream merge-base remained 696f41bc8e7586657375d53390925fc54c25d34c before and after the donor sequence. The V1 RPC donor is not an ancestor of that upstream/dev pin (git merge-base --is-ancestor returned 1). No upstream merge parent or “Upstream syncs” entry was added.

Focused behavioral evidence

Initial focused test results were collected on 2026-11-04 at behavior/test head 62112d0575531b9c3c8e3f01e50be2f3a9dc1661 with Bun 1.4.2. Commands were run from the named package directory. For each changed behavior, the listed regression passed with the donor behavior restored and failed after that behavior was removed or reverted.

RPC — cwd packages/opencode

  • bun test test/util/rpc.test.ts --test-name-pattern 'settles only the failed synchronous request' — green: 1 pass, 2 filtered, 0 fail. Removing the listen error reply made the in-test timeout report missing synchronous RPC result; removing client-side rejection made the failed result resolve instead of reject. The successful concurrent request and its event were asserted.
  • bun test test/util/rpc.test.ts --test-name-pattern 'rejects a pending call when its worker handler rejects asynchronously' — green: 1 pass, 2 filtered, 0 fail. Removing the listen rejection handler failed within the test with missing asynchronous RPC result.
  • bun test test/util/rpc.test.ts --test-name-pattern 'uses nested cause text when the worker error message is empty' — green: 1 pass, 2 filtered, 0 fail. Removing cause traversal returned Error instead of nested cause failure.

Browser — cwd packages/opencode

  • bun test test/mcp/browser.test.ts --test-name-pattern 'reports a browser launcher that exited before openUrl returned' — green: 1 pass, 2 filtered, 0 fail. Removing the completed-child exitCode observation returned no error instead of Browser open failed with exit code 23.
  • bun test test/mcp/browser.test.ts --test-name-pattern 'accepts a browser launcher that exited successfully before openUrl returned' — green: 1 pass, 2 filtered, 0 fail.
  • bun test test/mcp/browser.test.ts --test-name-pattern 'reports a browser launcher that exits after openUrl returns' — green: 1 pass, 2 filtered, 0 fail; the fixture acknowledges the child-ready line, actual production listener registration, child exit release and close event.

Rename undo — cwd packages/core

  • bun test test/git.test.ts --test-name-pattern 'lists both sides of a rename as separate file changes' — green: 1 pass, 4 filtered, 0 fail. Removing --no-renames omitted old name.txt from the production Git.tree.files result.
  • bun test test/session-revert.test.ts --test-name-pattern 'undoes a projected file rename and clears it without losing later edits' — green: 1 pass, 0 fail, 9 assertions. Removing --no-renames made the actual SessionV2 stage leave both paths absent; the regression failed because the original path was not restored. The green path also verifies returned added/deleted statuses, contents, clear, and the unrelated later edit.

Copilot interleaved reasoning — cwd packages/core

  • bun test test/github-copilot/copilot-chat-model.test.ts --test-name-pattern 'should accept successive interleaved reasoning_opaque values' — green: 1 pass, 13 filtered, 0 fail. Restoring the old second-value error produced InvalidResponseDataError.
  • bun test test/github-copilot/copilot-chat-model.test.ts --test-name-pattern 'should emit and replay interleaved reasoning in segment order' — green: 1 pass, 13 filtered, 0 fail. Keeping only the first stream opaque failed the second-segment metadata assertion; overwriting reasoning text failed the test-built replayPrompt() bridge's converter-result concatenation assertion.
  • bun test test/github-copilot/copilot-chat-model.test.ts --test-name-pattern 'should replay the latest interleaved reasoning_opaque value' — green: 1 pass, 13 filtered, 0 fail. Keeping only the first opaque failed latest finish/replay selection coverage.
  • bun test test/github-copilot/convert-to-copilot-messages.test.ts --test-name-pattern 'should replay interleaved reasoning as concatenated text with the latest reasoning_opaque' — green: 1 pass, 18 filtered, 0 fail. This direct converter regression uses a hand-built assistant prompt; the actual adapter stream parts reach the converter through the test-built replayPrompt() bridge in copilot-chat-model.test.ts.

Round 1 fix batch 1

The delayed-launcher case was updated in test commit 53699b8bf69fb5a704ee754fbbbbac1eff372c88. The child registers its stdin handler before it emits ready; the openUrl seam awaits that line before returning. The newListener notification is followed by a microtask check of listenerCount("exit"), then the fixture releases the child; the child emits released before exiting, and the test waits for close. Five-second within bounds only guard missing acknowledgments; cleanup releases any still-live child over stdin, awaits close, and closes the readline interface. The production 500 ms window was not changed and there are no sleeps. With the production exit-reporting handler replaced by a no-op, all three acknowledgments complete and the test fails because it receives unexpected-result rather than the expected browser error. After restoring the handler, the focused case passed in six simultaneous invocations (6/6) under test-process CPU contention.

The Copilot ledger entry now says what the test actually proves: replayPrompt() is a test-built stream-parts-to-assistant-prompt bridge. It exercises the converter on real adapter-emitted values, but does not claim coverage of production history-to-prompt conversion. CHANGESET.md no longer calls this “producer-to-replay.”

bun typecheck passed from packages/opencode. The round-1 changeset check reported ok: #403 is recorded.

- Keep all four assigned fixes as separate full-SHA cherry-pick -x commits.
- Adapt producer-driven regressions at the fork RPC, browser launcher, V2 undo, and Copilot stream/replay boundaries.
- Prove each changed behavior with focused red/green runs, then record provenance and compatibility in CHANGESET.md.

Claude-Session: unknown
@brentyates-swx

Copy link
Copy Markdown
Author

Session ID: unknown
Working repo: /home/byates/fm-worktrees/fm-llmrouter/oc-small-backports-388/swx-opencode

Nowaker and others added 16 commits November 4, 2026 03:10
@brentyates-swx
brentyates-swx marked this pull request as ready for review November 4, 2026 06:15
@brentyates-swx
brentyates-swx merged commit 4cd4eb7 into swxtch Nov 4, 2026
2 of 4 checks passed
@brentyates-swx
brentyates-swx deleted the fm/oc-small-backports-388 branch November 4, 2026 06:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backport four small upstream fixes: TUI RPC error result, MCP browser exit, undo rename source, Copilot reasoning

4 participants