Commit 881e8c3
committed
Replace the fragile SHELL_ALLOWLIST in shell.ts with delegation to
vscode.env.shell (stable since VS Code 1.37), which internally resolves
terminal.integrated.defaultProfile.platform - including PowerShell version
deduction, WSL detection, and per-platform system fallback.
Connect the Zoo Code terminal profile override to both execution paths:
the VS Code integrated terminal (shellPath/shellArgs in createTerminal)
and the execa inline fallback (shell resolution + profile env + WSL args).
Shell Detection (shell.ts + Terminal.ts)
- getShell(): profile override -> vscode.env.shell -> os.userInfo().shell
-> COMSPEC/SHELL -> platform default; WSL paths canonicalized to
WSL_EXE_PATH regardless of casing or slash direction
- isActiveShellPowerShell(): replace source-string heuristic with actual
PATH lookup (pwsh.exe / pwsh), fixing false positives on macOS/Linux
where PowerShell is the VS Code default but pwsh is not installed
- Shell identity methods: isCmdExe, isPowerShell, isFish,
isActiveShellCmdExe, isActiveShellPowerShell, isActiveShellFish
WSL Inline Execution (ExecaTerminalProcess.ts)
- Two-tier WSL detection: tier 1 - getShell() authoritative; tier 2 -
getConfiguredWslProfileArgs() trusted-scope VS Code config for distro
- 3-tier path conversion: drive-letter -> /mnt/drive/ ->
WSL UNC \\wsl$\Distro\ -> wsl.exe wslpath fallback
- Respect profile override shellArgs before falling back to VS Code
default WSL args, preventing distro mismatch when Zoo Code overrides
the active WSL profile
- Propagate profile env (sanitized, blocking ZDOTDIR/LD_PRELOAD/etc.)
to the WSL execa invocation
- Direct wsl.exe spawn (execa file + args array) to avoid cmd.exe
nested-quoting; --cd omitted with warning when wslpath fails
Terminal Process Error Recovery (TerminalProcess.ts + ExecaTerminalProcess.ts)
- SIGTERM instead of SIGKILL for process.kill on Windows compatibility
- Real exit code captured from execa subprocess; abort path preserves
signal info instead of reporting exitCode:0
- Bounded Ctrl+C retry loop for processes that trap SIGINT (#266)
- Guard against overlapping abort retry loops via aborting flag
- completionTimeout safety net for lost shell_execution_complete
(VS Code bug 237208); timeout cleared in finally to prevent
unhandled Promise rejection
- TextDecoder with stream:true + final flush to avoid U+FFFD on
multi-byte UTF-8 split across chunk boundaries
- WeakRef deref guarded in all event handlers against GC'd terminals
- C-marker search regression: restore commandOutputStarted boolean
so OSC 633;C arriving after the first chunk is detected
- isHot cleared on stream timeout to prevent task loop stall
- Multiline scripts wrapped for single shell execution:
PowerShell .{ }, fish begin/end, POSIX { }
Profile Override (Terminal.ts + BaseTerminal.ts)
- getConfiguredProfiles() / getConfiguredDefaultProfileName(): read only
defaultValue + globalValue, workspace settings intentionally excluded
- getConfiguredWslProfileArgs(): detect WSL by source field or name
pattern; normalize args (string -> [string])
- getProfileShell(): resolve profile to shellPath/shellArgs/env;
sanitize env (block ZDOTDIR, LD_PRELOAD, DYLD_INSERT_LIBRARIES,
BASH_ENV, etc.; only string/null values)
- Skip ZDOTDIR injection when profile override is active (VS Code's
injector handles it; two ZDOTDIRs fight per issue 96295)
Execute Command Tool (ExecuteCommandTool.ts + Task.ts)
- canRetryShellIntegrationError(): type guard for commandSubmitted:false
(shell startup race -> safe to retry via execa); commandSubmitted:true
(already submitted -> warn, do not retry)
- Show shell_integration_warning when falling back to execa
- cmd.exe fast-path: force execa provider (cmd.exe cannot emit
OSC 633;C per VS Code issue 164646)
- Reset hasAskedForCommandOutput on ask error for future retries
- 5s safety-net timeout for onCompleted promise
- Add abort guard to ask() pWaitFor to prevent deadlock on cancel
- Add abort/abandoned guard to userMessageContentReady pWaitFor
Tests (6 test files)
- shell.spec.ts: vscode.env.shell passthrough, WSL canonicalization
(case + slashes), fallback chain, profile override
- TerminalProfile.spec.ts: profile resolution, shell identity methods,
WSL args, ZDOTDIR guard, createTerminal integration, isFish
- TerminalProcess.spec.ts: C-marker regression, abort retry loop,
multiline wrapping, hot timer, commandSubmitted branches
- ExecaTerminalProcess.spec.ts: WSL args merging, path conversion,
profile env, abort behavior
- Terminal.spec.ts: profile-based constructor, reuseKey
- terminal-profile.test.ts (E2E): profile override lifecycle, transient
shell_integration_warning acceptance
Fixes #321 and all 14 code-review defects from PR #333
1 parent 8893d0b commit 881e8c3
12 files changed
Lines changed: 1017 additions & 170 deletions
File tree
- apps/vscode-e2e/src/suite/tools
- src
- core
- task
- tools
- integrations/terminal
- __tests__
- utils
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
159 | 164 | | |
160 | 165 | | |
161 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1300 | 1300 | | |
1301 | 1301 | | |
1302 | 1302 | | |
1303 | | - | |
| 1303 | + | |
1304 | 1304 | | |
1305 | 1305 | | |
1306 | 1306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
145 | 149 | | |
146 | 150 | | |
147 | 151 | | |
| |||
356 | 360 | | |
357 | 361 | | |
358 | 362 | | |
359 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
360 | 367 | | |
361 | 368 | | |
362 | 369 | | |
| |||
493 | 500 | | |
494 | 501 | | |
495 | 502 | | |
496 | | - | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
497 | 507 | | |
498 | 508 | | |
499 | 509 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
38 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | | - | |
| 46 | + | |
| 47 | + | |
41 | 48 | | |
42 | 49 | | |
43 | 50 | | |
| |||
62 | 69 | | |
63 | 70 | | |
64 | 71 | | |
65 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
66 | 77 | | |
67 | 78 | | |
68 | 79 | | |
| |||
85 | 96 | | |
86 | 97 | | |
87 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
88 | 105 | | |
89 | 106 | | |
90 | 107 | | |
91 | 108 | | |
92 | 109 | | |
93 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
94 | 122 | | |
95 | | - | |
| 123 | + | |
96 | 124 | | |
97 | | - | |
| 125 | + | |
98 | 126 | | |
99 | 127 | | |
100 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
101 | 134 | | |
102 | 135 | | |
| 136 | + | |
| 137 | + | |
103 | 138 | | |
104 | 139 | | |
105 | 140 | | |
106 | 141 | | |
107 | 142 | | |
108 | 143 | | |
| 144 | + | |
109 | 145 | | |
110 | 146 | | |
111 | 147 | | |
| |||
118 | 154 | | |
119 | 155 | | |
120 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
121 | 161 | | |
122 | 162 | | |
123 | 163 | | |
| |||
147 | 187 | | |
148 | 188 | | |
149 | 189 | | |
150 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
151 | 196 | | |
152 | 197 | | |
153 | | - | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
154 | 207 | | |
155 | 208 | | |
156 | 209 | | |
| |||
182 | 235 | | |
183 | 236 | | |
184 | 237 | | |
185 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
186 | 243 | | |
187 | 244 | | |
188 | 245 | | |
| |||
201 | 258 | | |
202 | 259 | | |
203 | 260 | | |
204 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
205 | 300 | | |
206 | 301 | | |
207 | 302 | | |
208 | | - | |
| 303 | + | |
209 | 304 | | |
210 | 305 | | |
211 | 306 | | |
| |||
216 | 311 | | |
217 | 312 | | |
218 | 313 | | |
219 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
220 | 321 | | |
221 | 322 | | |
222 | 323 | | |
| |||
249 | 350 | | |
250 | 351 | | |
251 | 352 | | |
252 | | - | |
| 353 | + | |
253 | 354 | | |
254 | 355 | | |
255 | 356 | | |
| |||
274 | 375 | | |
275 | 376 | | |
276 | 377 | | |
277 | | - | |
| 378 | + | |
278 | 379 | | |
279 | 380 | | |
280 | | - | |
| 381 | + | |
281 | 382 | | |
282 | 383 | | |
283 | 384 | | |
| |||
0 commit comments