Skip to content

fix(windows): console output after the chat, PATH install, CRLF diffs - #18

Merged
dartpain merged 5 commits into
mainfrom
fix/windows-console
Oct 16, 2026
Merged

dartpain merged 5 commits into
mainfrom
fix/windows-console

Conversation

@dartpain

@dartpain dartpain commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Found by testing on a Windows Server 2022 VM: the classic console (cmd.exe and Windows PowerShell 5.1 in conhost, driven through a harness that types into a real console and reads its screen buffer), over ssh (ConPTY), and the PowerShell installer.

1. Raw escape codes after the chat (classic console)

The chat itself renders fine, but everything printed after its screen closes came out raw: the transcript printed on exit, the title restore and the tab status clear, e.g.

←[23;0t←]21337;status=;indicator=;status-color=←[38;2;167;152;215m …

The classic console starts with virtual terminal processing off; bubbletea turns it on only while a program runs and restores the mode it found. Execute now turns it on for stdout and stderr once (ui.EnableVT, a no-op elsewhere), so every bubbletea program restores it on. It is left on at exit: shells set the modes they need, and turning it off could pull it from under another docsgpt-cli on the same console (docsgpt-cli … | docsgpt-cli …). Over ssh/ConPTY and with redirected output nothing changes (redirected handles are not consoles and are skipped).

2. The installer breaks a one-entry user PATH (since v1.2.0)

addToWindowsPATH's PowerShell: $parts = $path -split ';' | Where-Object … yields a string when the user PATH has one entry (the default on a fresh Windows: just WindowsApps), so $parts + $dir concatenated them:

Path  REG_SZ  C:\Users\dgadmin\AppData\Local\Microsoft\WindowsAppsC:\Users\dgadmin\bin

Both entries break: docsgpt-cli is not found in new windows, and neither are the Store apps' commands (winget). Running the installer again glued it on a second time. Now $parts is an array, and entries an older installer glued the directory onto are split again. The update runs even when the window's PATH already has the directory (install.ps1 adds it there), writing only on change, so re-running the installer (or docsgpt-cli install) always repairs them. docs/install.md says so.

Checked on the VM, also with the directory already on the window's PATH: broken (glued once or twice) → …\WindowsApps;C:\Users\dgadmin\bin; one entry → appended with ;; no user PATH → just the directory; already present → unchanged; trailing ; → no empty entry.

3. ␍ in diff previews of CRLF files

An edit of a CRLF file showed 1 - hello world ␍. Diff preview lines drop their trailing \r when both sides use CRLF; a change of line endings still shows it.

Also tested on Windows (no change needed)

  • install.ps1 (latest and DOCSGPT_CLI_VERSION=v1.9.1), update, update --rollback, update again
  • ask on a TTY (rendering, a run_command approval), piped and redirected
  • chat in the classic console and over ssh: answers, tables, run_command / edit_file / write_file / read_file approvals, !cmd with a failing exit code, Esc/Ctrl+C stopping a running command (the whole process tree is killed), a server error, saved sessions and -c
  • tab status over ssh: ConPTY passes OSC 21337 through

Testing

  • gofmt -l ., go build ./..., go vet ./... (also GOOS=windows), go test ./...
  • TestDiffPreview covers the CRLF case
  • the scenarios above on the VM with this branch's build

The classic console (cmd.exe or Windows PowerShell in conhost) starts
with virtual terminal processing off. bubbletea turns it on only while a
program runs and then restores the mode it found, so everything printed
after the chat's screen closed (the transcript, the title restore, the
tab status clear) came out as raw escape codes. Execute now turns it on
for stdout and stderr once and restores the console's mode on exit.
A pipeline yielding a single PATH entry gives PowerShell a string, not an
array, so adding the install directory glued it onto that entry without a
';' (…\WindowsAppsC:\Users\you\bin), breaking both. The parts are now an
array, and entries an older installer glued the directory onto are split
again, so running the installer repairs them.
- install: run the user PATH update even when this window's PATH has the
  directory (install.ps1 adds it, or the user did), so running the
  installer again always repairs a glued entry; it writes only on change
- leave escape processing on at exit: turning it off could pull it from
  under another docsgpt-cli on the same console (a | b), and shells set
  the modes they need
- diffs keep ␍ when the line endings change (CRLF on one side only)
- the PATH script stops at an error, so a failed write is no longer
  reported as changed
- a failure to check the user PATH does not fail the install when the
  directory already runs by name
- neutral wording for a PATH update that only tidied it
- a new CRLF file's diff shows no ␍
@dartpain
dartpain merged commit 76a5045 into main Oct 16, 2026
1 check passed
@dartpain
dartpain deleted the fix/windows-console branch October 16, 2026 14:13
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