[codex] fix(vscode): run commands in remote terminals#12063
[codex] fix(vscode): run commands in remote terminals#12063yzlu0917 wants to merge 6 commits intocontinuedev:mainfrom
Conversation
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="extensions/vscode/src/util/runCommandInTerminal.ts">
<violation number="1" location="extensions/vscode/src/util/runCommandInTerminal.ts:64">
P2: Remote terminal creation is race-prone and can resolve to an unrelated concurrently opened terminal, causing commands to run in the wrong terminal session.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0fe8c9c462
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (resolveIfNewTerminalExists()) { | ||
| return; |
There was a problem hiding this comment.
Remove pre-open scan for "new" remote terminals
The early resolveIfNewTerminalExists() check can select an unrelated terminal that was opened by the user/another extension after existingTerminals is captured but before workbench.action.terminal.new is executed. In that race, this function returns immediately, skips creating its own terminal, and then sends the command to the wrong terminal, which makes /cmd and startup helpers non-deterministic in busy remote workspaces.
Useful? React with 👍 / 👎.
0fe8c9c to
e36d9ec
Compare
|
Does anyone have a workaround for this while we wait for the PR to be merged? I tried hooking up an external MCP terminal server (@dillip285/mcp-terminal) and wrapping the command in SSH inside the config.yaml to force it to run on the remote machine but it completely failed 😭 If anyone has a reliable way to get terminal commands actually executing on the remote host in the meantime, I'd appreciate it! |
Summary
VsCodeIde.runCommand()through a dedicated terminal helperworkbench.action.terminal.newwhen the workspace is remote, so SSH/devcontainer/codespaces commands start on the correct machineWhy
VsCodeIde.runCommand()currently has two remote-terminal bugs:sendText(command, false)types the command but never executes itcreateTerminal()from the UI-side extension host creates a local terminal instead of a remote oneThat breaks
/cmd, Ollama/Lemonade startup helpers, and any terminal-tool fallback path in remote workspaces.Validation
npm test -- src/util/runCommandInTerminal.vitest.tsinextensions/vscodegit diff --checknpm run tsc:checkinextensions/vscodeand only hit existing repo issues unrelated to this patch:../../core/llm/llms/OpenRouter.ts: missingOPENROUTER_HEADERSexportsrc/extension.ts: missing./.buildTimestampdeclarationCloses #10542
Summary by cubic
Fixes command execution in VS Code terminals across remote workspaces and restores
/cmd, Ollama/Lemonade helpers, and terminal-tool fallbacks. Adds default OpenRouter metadata headers in the coreOpenRouterclient.Bug Fixes
VsCodeIde.runCommand()throughrunCommandInTerminal; in remote workspaces create terminals viaworkbench.action.terminal.new, wait until the new terminal is active, and ignore unrelated terminals (5s timeout).Dependencies
OPENROUTER_HEADERSfrom@continuedev/openai-adaptersand apply them in coreOpenRouter(addsHTTP-Referer,X-OpenRouter-Title, andX-OpenRouter-Categories).Written for commit abd96ca. Summary will update on new commits.