Repository navigation
Open terminals on native Windows - #4660
Conversation
The terminal manager refused every open on Windows and only knew POSIX shells. - Pick the Windows shell: PowerShell 7 on PATH, then Windows PowerShell, then ComSpec. Pass a command in the shell's own syntax (`-Command`, `/c`, `-lc`). - Close a Windows pseudoconsole without a signal, which node-pty rejects there. - Make `bb terminal send --enter` send a carriage return, the byte a terminal sends for Enter; PowerShell treats a line feed as a continuation. Co-Authored-By: Claude Code <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d576f1f4cc
ℹ️ 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".
| } | ||
| switch (kind) { | ||
| case "powershell": | ||
| return ["-NoLogo", "-Command", args.start.command]; |
There was a problem hiding this comment.
Preserve native exit codes from PowerShell commands
When start.command ends with a native executable returning a code such as 7, launching it with -Command does not forward $LASTEXITCODE; PowerShell documents that the resulting status is normalized to 0 or 1 unless the command explicitly uses exit. The terminal therefore records and reports the wrong exit code on Windows, unlike the POSIX -lc path. Wrap the command so the shell explicitly exits with the native command's code while still preserving PowerShell cmdlet failures.
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d576f1f4cc
ℹ️ 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".
| case "cmd": | ||
| return ["/d", "/s", "/c", args.start.command]; |
There was a problem hiding this comment.
Avoid POSIX-quoting positional commands for Windows targets
When a Windows terminal is created through the positional CLI form, resolveTerminalStart still serializes every argument with POSIX single-quote escaping before this branch passes the text to PowerShell or cmd. For example, an argument containing a space becomes 'hello world'; cmd does not treat single quotes as quoting, so the child receives split arguments containing literal quote characters, and embedded single quotes produce invalid PowerShell syntax. Either preserve the command as native-shell text or quote it according to the selected target shell so the newly enabled Windows feature works through the full CLI surface.
AGENTS.md reference: AGENTS.md:L26-L26
Useful? React with 👍 / 👎.
| A terminal runs the machine's own shell: $SHELL (then zsh, bash, sh) on macOS | ||
| and Linux; on Windows, PowerShell 7 when `pwsh` is on PATH, otherwise Windows | ||
| PowerShell, otherwise cmd. Write --command in that shell's syntax. `send --enter` | ||
| presses Enter (a carriage return), which every one of those shells accepts. |
There was a problem hiding this comment.
Document the Windows terminal contract in the bb-cli skill
This adds user-visible shell selection and changes terminal send --enter, but only the in-CLI guide was updated; the required plugins/bb-guide/skills/bb-cli surface still omits the native-shell contract. Agents relying on that installed skill can therefore generate POSIX-only command syntax for Windows terminals. Update its terminal reference alongside this guide change.
AGENTS.md reference: AGENTS.md:L27-L27
Useful? React with 👍 / 👎.
- A PowerShell terminal command now exits with the command's own exit code; -Command alone collapses every failure to 1. - bb terminal create -- <args> sends the argument list as is. The daemon quotes it for the shell it selected (PowerShell, cmd, or a POSIX shell) instead of the CLI quoting for a POSIX shell. Adds an argv terminal start mode and bumps the host daemon protocol to 225. - Document the per-platform shell and the argument-list form in the bb-cli skill. Co-Authored-By: Claude Code <[email protected]>
Human comments
What was wrong
TerminalManager.openTerminalreturnedunsupported_platform: Native Windows terminals are not supportedfor every open on Windows, so the Terminals panel andbb terminal createdid nothing there. Behind that refusal the shell lookup only knew$SHELL,/bin/zsh,/bin/bash, and/bin/sh, commands were always passed as-lc, and closing a terminal calledpty.kill(signal), which node-pty rejects on Windows ("Signals not supported on windows"). Separately,bb terminal send --enterappended a line feed; PowerShell's line editor treats that as "continue on the next line", so the command was never submitted. Part of #1206.What changed
apps/host-daemon/src/terminals/terminal-shell.ts: the Windows shell is PowerShell 7 (pwsh.exe) when it is on PATH, otherwise Windows PowerShell under%SystemRoot%, otherwise%ComSpec%. Start arguments follow the shell:-NoLogo -Command <text>for PowerShell,/d /s /c <text>for cmd,-lc <text>for POSIX shells (including Git bash). The terminal title drops.exe.terminal-manager.ts: the Windows refusal and the now-unusedplatformoption are removed. On Windows the pty is closed withpty.kill()and no signal; macOS and Linux still signal the process group.bb terminal send --entersends a carriage return, which is what a terminal emulator sends for the Enter key. Cooked-mode POSIX shells receive it as a newline through the tty's CR-to-NL translation, and raw-mode line editors bind it to accept-line. The flag's help text now reads "Press Enter after the text".-Commandby itself reports 1 for every failure, so the daemon appends a check that exits with$LASTEXITCODEwhen the last native command failed and with 1 when a cmdlet failed.bb terminal create -- <args>sends the argument list unchanged in a newargvstart mode, and the daemon quotes it for the shell it selected: single quotes after the call operator for PowerShell, double quotes for cmd, single quotes for POSIX shells. Before, the CLI quoted for a POSIX shell whatever the target machine ran.bb guide terminalsand the bb-cli skill (plugins/bb-guide/skills/bb-cli/references/thread-operation.md) say which shell a terminal runs on each platform and that the argument-list form is quoted for it.Wire change: the terminal start field accepts
{ mode: "argv", argv }inpackages/host-daemon-contractandpackages/server-contract, andHOST_DAEMON_PROTOCOL_VERSIONgoes from 224 to 225.How you verified
bb terminal create --machine bb-win11 --cwd C:\src\plainrepo --command "git status; echo done-marker"exited 0 and printed the git status anddone-marker; an interactive terminal opened with titlepowershelland the promptPS C:\src\plainrepo>;bb terminal send <id> --text hostname --enterprintedbb-win11and returned to the prompt;bb terminal close <id>took the session's PowerShell process count from 1 to 0.--enterchange the same send left PowerShell at its>>continuation prompt withhostnameunsubmitted.--command "cmd /c exit 7"ended with exit code 7 and--command 'node -e "process.exit(3)"'with 3 (both were 1 before); a failing cmdlet (Get-Item <missing> -ErrorAction Stop) ended with 1 andWrite-Output okwith 0.bb terminal create -- node -e <script> "C:\bb-setup\argv out.json" "two words" "it's" "semi;colon" '$env:USERNAME' "a&b" "C:\Program Files\x"wrote exactly those six arguments to the file, and-- node -e "process.exit(9)"ended with 9.turbo run lint typecheck testfor@bb/host-daemon,@bb/cli,@bb/host-daemon-contract,@bb/server-contract,@bb/templates, and the bb-guide plugin passes, including the existing real-pty terminal test.terminal-shell.test.tscovers shell classification, start arguments and quoting per shell, the exit-code suffix, titles, and the Windows shell order; the CLI tests pin the carriage return and theargvstart mode.check-npm-version-guard.mjspasses without a plugin SDK bump.Not verified:
--enteragainst a full-screen terminal program on macOS or Linux; cmd as the fallback shell on a machine without PowerShell, including its argument quoting, which only the unit tests cover; PowerShell 7 (the VM has only Windows PowerShell 5.1).🤖 Generated with Claude Code