Repository navigation
fix(windows): console output after the chat, PATH install, CRLF diffs - #18
Merged
Merged
Conversation
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 ␍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
The classic console starts with virtual terminal processing off; bubbletea turns it on only while a program runs and restores the mode it found.
Executenow 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: justWindowsApps), so$parts + $dirconcatenated them:Both entries break:
docsgpt-cliis not found in new windows, and neither are the Store apps' commands (winget). Running the installer again glued it on a second time. Now$partsis 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 (ordocsgpt-cli install) always repairs them.docs/install.mdsays 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 filesAn edit of a CRLF file showed
1 - hello world ␍. Diff preview lines drop their trailing\rwhen both sides use CRLF; a change of line endings still shows it.Also tested on Windows (no change needed)
install.ps1(latest andDOCSGPT_CLI_VERSION=v1.9.1),update,update --rollback,updateagainaskon a TTY (rendering, a run_command approval), piped and redirected!cmdwith a failing exit code, Esc/Ctrl+C stopping a running command (the whole process tree is killed), a server error, saved sessions and-cTesting
gofmt -l .,go build ./...,go vet ./...(alsoGOOS=windows),go test ./...TestDiffPreviewcovers the CRLF case