fix(opencode): fix file reference feature of VS Code extension#27679
Open
Noitidart wants to merge 1 commit into
Open
fix(opencode): fix file reference feature of VS Code extension#27679Noitidart wants to merge 1 commit into
Noitidart wants to merge 1 commit into
Conversation
The VS Code extension requires the terminal title to be "opencode" in order for the Cmd+Option+K file reference hotkey to prefill the prompt. VS Code names terminal tabs after the foreground process detected via the OS process table (kern_proc on macOS, /proc on Linux). It reads the actual binary filename — not process.title, argv[0], or ANSI escape sequences. The old bin/opencode was a Node.js wrapper that used child_process.spawn() to launch the compiled binary, keeping the node process alive as a signal forwarder. This created a three-deep process tree: zsh → node (wrapper) → opencode (compiled binary) VS Code sees "node" as the direct child of zsh and never recurses into grandchildren, so the terminal tab stays "zsh". The VS Code extension identifies opencode terminals by checking terminal.name === "opencode", which means Cmd+Option+K (file reference insertion) silently does nothing. The fix replaces the Node.js wrapper with a POSIX shell script that exec's directly into the compiled binary. On Unix, exec replaces the calling process with the target binary in-place, so the OS process table shows "opencode" as the direct child of zsh. The platform detection logic (AVX2, musl, architecture) moves to a separate bin/opencode-resolve Node.js script that outputs the binary path to stdout. A bin/opencode.cmd fallback is added for Windows. Fixes anomalyco#10993 Fixes anomalyco#27678
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #10993
Closes #27678
Type of change
What does this PR do?
The VS Code extension gates the Cmd+Option+K file reference hotkey on
terminal.name === "opencode". When opencode is launched manually in the integrated terminal (typingopencode), the tab stays named "zsh" so the hotkey does nothing.VS Code names terminal tabs after the foreground process by reading the actual binary filename from the OS process table. The old
bin/opencodewas a Node.js wrapper usingchild_process.spawn(), which createdzsh → node → opencode. VS Code sees "node" as the direct child and never recurses into grandchildren.This PR replaces the Node.js wrapper with a POSIX shell script that
execs directly into the compiled binary. On Unix,execreplaces the calling process in-place, so the tree becomeszsh → opencodeand VS Code correctly names the tab "opencode".The platform detection logic (AVX2, musl, architecture) moves to
bin/opencode-resolve(Node.js script that outputs the binary path to stdout). Abin/opencode.cmdfallback is added for Windows.How did you verify your code works?
bun run buildfrompackages/opencodeOPENCODE_BIN_PATHenv var → tab renamed to "opencode"bun turbo typecheck)Screenshots / recordings
N/A — no UI changes, this is a CLI bin wrapper change.
Checklist