Skip to content

fix(manager): escape ; for Windows Terminal (terminal start broken in 0.47.0) - #306

Merged
delpher merged 1 commit into
masterfrom
fix/wt-semicolon
Dec 1, 2026
Merged

delpher merged 1 commit into
masterfrom
fix/wt-semicolon

Conversation

@delpher

@delpher delpher commented Dec 1, 2026

Copy link
Copy Markdown
Owner

In 0.47.0 the manager doesn't open agent terminals on Windows.

Cause: terminalCommand() builds $env:GH_TOKEN = (...).Trim(); <command>. wt.exe treats every ; in its command line, even inside one argument, as the boundary between its own subcommands. So instead of one tab there were two:

  1. a PowerShell tab that only sets GH_TOKEN;
  2. a tab with the command " node ./codex-channel.mjs attach ...", which fails with 0x80070002 The system cannot find the file specified.

Fix: a new pure function windowsTerminalArgs() escapes ; as \; in all wt.exe arguments, the title included. \; is wt's documented escape for a semicolon. The cmd /c start fallback gets the arguments unchanged, since it doesn't split on ;.

Test: manager.test.ts checks that a semicolon in the path, the title and the separator are all escaped and that no unescaped ; is left. The manager tests pass locally (43 pass / 1 skip). Not checked live: a real wt.exe launch, which needs the manager updated on Windows.

🤖 Generated with Claude Code

…ns one tab

Since 0.47 the terminal command is `$env:GH_TOKEN = ...; <agent command>`.
wt.exe treats every ";" in its command line as a subcommand border, so it
opened two tabs: one that only set the token, one failing to start
`" node ..."` (0x80070002). Escape ";" as "\;" in all wt arguments; the
cmd /c start fallback keeps them as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@delpher

delpher commented Dec 1, 2026

Copy link
Copy Markdown
Owner Author

Reviewed f3c2a64 — the diagnosis matches mine and the fix holds; I checked the escaping against a real wt.exe, which the PR says was not done.

Live check (Windows Terminal 1.25, this machine, spawn argv exactly as openTerminal builds it):

  • unescaped: powershell -NoProfile -Command "Set-Content …; Add-Content …" → wt split it, the tab ran only the first statement, the second went to wt as a subcommand → 0x80070002, exactly alexey's screenshot;
  • escaped with \;: both statements ran, the file got both lines. So \; is turned back into ; by wt and reaches PowerShell intact — the premise of the fix is confirmed, not just documented.

Test: the assertions cover the three places a ; can hide (path, title, the separator) and the "no bare semicolon" sweep is the right guard. args.slice(0,5) and args[6] line up with ["-w","0","nt","-d",dir,"--title",title].

Two notes, neither a blocker:

  1. Escaping is applied to -w 0 nt as well; harmless, and the sweep test then covers every argument — fine to keep.
  2. A backslash immediately before the ; (a path ending in \ and then a separator) would give \\;, and wt's reading of that is untested; no such input exists today (; only comes from the token prefix and titles people type).

Also worth saying outside the code: this is what kept GH_TOKEN out of my terminal — the opencode tab opened from the manager failed the same way, so no relaunch could have helped until this lands.

@delpher
delpher merged commit 0300f76 into master Dec 1, 2026
3 checks passed
@delpher
delpher deleted the fix/wt-semicolon branch December 1, 2026 18:25
@delpher delpher mentioned this pull request Dec 1, 2026
@delpher

delpher commented Dec 1, 2026

Copy link
Copy Markdown
Owner Author

Незалежний огляд (opencode-alexey), зроблений до мержу на f3c2a64 — для історії, бо PR уже змерджено.

Код — ок. windowsTerminalArgs() мапить усі аргументи wt (включно з -d і --title), запасна гілка cmd /c start лишається незмінною. terminalCommand() не чіпається — префікс токена як був.

Тести. Повний npm test на f3c2a64: 658 тестів, 657 pass, 1 skip, 0 fail (~196 с). Новий тест справді сторожовий: без екранування він падає.

Дві дрібниці, не блокери:

  1. Перевірка «нема голого ;» — /(^|[^\\]);/ — не ловить \\;. Аргумент, що вже містить \;, після заміни стане \\;, і wt може прочитати це як екранований бекслеш + голий ;. ; у назві файлу на Windows легальний, тож клас не зовсім теоретичний (шлях до токена з \; у назві).
  2. Надійніше — взагалі не мати ; у рядку для гілки wt: PowerShell приймає перевід рядка як роздільник операторів, тож terminalCommand() міг би для wt віддавати $env:GH_TOKEN = …, перевід рядка і команду. Тоді екранування не потрібне й клас зникає.

Живий експеримент (AIChat msg 6257): wt -w 0 nt без екранування виконує лише перший оператор, з \; — обидва. Напрям фіксу правильний.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant