Commit graph

39 commits

Author SHA1 Message Date
shanevcantwell
c79e6489a7
fix: restrict terminal childProcess.spawn to local-only environments (#10538)
fix: restrict childProcess.spawn to local-only environments

childProcess.spawn executes on the extension host machine. With
extensionKind: ["ui", "workspace"], the extension host almost always
runs locally. For any remote workspace (SSH, WSL, Dev Container,
Codespaces, tunnel), spawning locally either runs commands on the wrong
machine or fails with ENOENT when the local shell doesn't exist in the
extension host context.

Replace ENABLED_FOR_REMOTES (which listed all remote types) with
LOCAL_ONLY (just "" and "local"). All remote types now fall through to
ide.runCommand() which delegates to VS Code's integrated terminal and
executes in the correct remote environment.

The isWindowsHostWithRemote guard is removed as it is now redundant —
the platform-agnostic check handles all cases.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 20:33:04 -07:00
Keita A.
5d19470aa9
fix: add default timeout for terminal command tool execution (#10550)
* fix: add default timeout for terminal command tool execution

Terminal commands with waitForCompletion=true had no timeout, risking
indefinite hangs. Adds a 2-minute default timeout with graceful
SIGTERM -> 5s grace period -> SIGKILL escalation. Both streaming
and non-streaming code paths are covered. The SIGKILL timer is
properly cleared if the process exits during the grace period.

* fix: correct process running check and clear SIGKILL timer

Replace `childProc.killed` with `exitCode === null && signalCode === null`
for accurate process-state detection, and clear sigkillTimeoutId in error
handlers to prevent delayed kills after rejection.

Applied to both streaming and non-streaming paths.

---------

Co-authored-by: amabito <192487536+amabito@users.noreply.github.com>
Co-authored-by: amabito <amabito@local>
2026-03-24 11:04:28 -07:00
shanevcantwell
b7c2b4f074 fix: generalize Windows remote detection for terminal commands
Broadens the Windows-with-remote check from WSL-only to all non-local
remotes (Dev Container, SSH, Codespaces, etc.) so that terminal commands
fall back to ide.runCommand() instead of trying to spawn powershell.exe.

Fixes #10007

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 08:01:35 -07:00
shanevcantwell
c565bdc464 fix: use ide.runCommand when Windows host connects to WSL
When the VS Code extension runs on Windows but connects to WSL,
direct shell spawning fails because process.platform is "win32"
but commands should execute in the Linux WSL environment.

This caused: spawn powershell.exe ENOENT

The fix detects this scenario and falls back to ide.runCommand(),
letting VS Code handle the remote terminal execution properly.

Fixes #9661

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 10:55:16 -07:00
shanevcantwell
8e5a7c2152 refactor: generalize remote URI handling and remove CLAUDE.md
- Remove WSL-specific check in favor of generic URI handling
- Support all vscode-remote:// URI schemes (WSL, SSH, dev-container)
- Prefer file:// URIs when available, fall back to remote URIs
- Add tests for various remote URI formats
- Remove CLAUDE.md per reviewer feedback (use AGENTS.md convention)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 19:08:33 -07:00
shanevcantwell
074a6c74ba fix: decode URI-encoded pathname for WSL workspace paths
Paths with spaces or special characters (e.g., /home/user/my%20project)
need decodeURIComponent() to match actual filesystem paths.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 05:14:40 -07:00
shanevcantwell
eab2ac1e04 fix: properly resolve WSL2 workspace paths in runTerminalCommand
Parse vscode-remote://wsl+distro/path URIs to extract the actual
workspace path instead of falling back to Windows HOME directory.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 05:10:13 -07:00
shanevcantwell
788e25338a fix: wrap fileURLToPath in try-catch for WSL2 compatibility
The fileURLToPath function can throw "The URL must be of scheme file"
in some WSL2/remote environments with malformed URIs. Wrap in try-catch
to fall through to HOME directory fallback.

Fixes #8091

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 02:57:06 -07:00
Dallin Romney
814cc205fb fix: unify cwd and add missing case 2025-11-27 02:29:13 -08:00
Dallin Romney
4837ef1352 fix: only set cwd to file URI if file uri found 2025-11-24 13:49:29 -08:00
Dallin Romney
7c369e0ac9 fix: only set cwd to file URI if found 2025-11-24 13:49:10 -08:00
Patrick Erichsen
77a8db7f63 use specific ConitnueError for tool calls 2025-10-14 14:55:00 -07:00
chezsmithy
58cb7815ca feat: Add ability to stop foreground terminal commands 2025-09-09 10:12:59 -07:00
chezsmithy
6e0775b0ce fix: 🐛 Fix rebase issues 2025-08-08 00:07:55 -07:00
chezsmithy
c78db09037 fix: 🎨 Prettier fixes 2025-08-08 00:05:22 -07:00
chezsmithy
e7d82a6290 fix: 🐛 Fix terminal use without a workspace 2025-08-07 23:56:31 -07:00
Shawn Smith
1ef2c0da01
fix: 🐛 Use login shell and powershell (#6850)
* fix: 🐛 Use a login shell so IntelliJ gets PATH etc, also switch to powershell on windows

* fix: 🐛 Fix foreground spawning

* fix: 🎨 Prettier
2025-07-29 13:03:58 -07:00
Dallin Romney
1ee5c54151 feat: more thorough tool arg checking utils with tests 2025-07-21 15:31:52 +02:00
Dallin Romney
6af35548c8 fix: throw error if tool call args are missing 2025-07-20 14:13:15 +02:00
QiuYang Shen
a000397160 avoid garbled Chinese when call runTerminalCommandTool in windows 2025-07-13 19:00:52 +08:00
chezsmithy
e83290bd3a feat: ✨ Give the terminal color and ansi escape rendering 2025-06-05 01:13:26 -07:00
chezsmithy
2d3bdbe256 refactor: ♻️ Updates to code to remove negative cases first (linting) 2025-06-04 22:23:39 -07:00
Patrick Erichsen
67ab058211 fix: linting error 2025-06-04 17:29:11 -07:00
Tomasz Stefaniak
d51e5e159a
Merge pull request #5813 from chezsmithy/feat-terminals-on-more-hosts
feat: 🧱 Enable terminals for additional vscode Remote Host Types
2025-06-04 14:54:54 -07:00
Nate
184be8f092 npx prettier --check "core/**/*.{js,jsx,ts,tsx,json,css,md}" --ignore-p
ath .gitignore --ignore-path .prettierignore --write
2025-05-25 18:34:39 -07:00
Shawn Smith
1500281bb5 feat: 🧱 Enable terminals for additional vscode Remote Host Types 2025-05-23 06:35:53 +00:00
chezsmithy
c1a4284b68 more cleanup. 2025-04-18 07:53:19 -07:00
chezsmithy
e41f9cdffd removed square brackets and simplified 2025-04-18 07:53:19 -07:00
chezsmithy
3e436448ab minor cleanup for background processes and prompt 2025-04-18 07:53:18 -07:00
chezsmithy
a8c3fb5e19 Resolve additional comments 2025-04-18 07:53:18 -07:00
chezsmithy
0d49547a36 Inital cleanup based on comments 2025-04-18 07:53:18 -07:00
chezsmithy
324d76f4a8 De-dup protocols 2025-04-18 07:53:18 -07:00
chezsmithy
dba00ccd79 merged in the ultimate terminal changes 2025-04-18 07:53:16 -07:00
Nate
a6817d3986 first pass at terminal tool output ui 2025-04-18 07:53:15 -07:00
chezsmithy
e740278ce5 fix-stdout-terminal 2025-03-04 20:03:32 -08:00
Dallin Romney
25329bbd77 path -> uri continued 2024-12-11 19:15:32 -08:00
Dallin Romney
7dcec281a7 remove uses of 'require' 2024-12-09 13:17:26 -08:00
Nate
5d4e6e9494 read file tool 2024-11-29 08:38:26 -08:00
Nate
025dc0840d fix type errors 2024-11-22 22:08:58 -08:00