Bug Description
When freebuff CLI (v0.0.149) exits unexpectedly or crashes on Windows PowerShell, it fails to execute terminal cleanup reset sequences (TERMINAL_RESET_SEQUENCES). This results in two primary issues:
- Terminal State Pollution (
[I Error): Focus Reporting mode (\x1b[?1004h) remains enabled in the terminal host. Upon refocusing the PowerShell window, the terminal automatically emits \x1b[I into stdin, leaving [I in the input prompt and triggering PowerShell parser errors:
Missing ] at end of attribute or type literal.
- Stdout Buffer Leak: Raw indexer/file content strings (e.g., array string pools from scanned
.js / .css files) leak into the main scrollback buffer instead of being isolated within the alternate screen buffer (\x1b[?1049h).
Environment
- App Version:
freebuff v0.0.149 (npm wrapper v0.0.146)
- OS: Windows 10 / 11
- Shell: PowerShell (Windows Terminal / ConHost)
Steps to Reproduce
- Open Windows PowerShell in a workspace containing JavaScript / CSS files.
- Run the
freebuff command.
- Terminate or trigger an unhandled exit / indexing operation.
- Observe raw source code chunks printed onto the main terminal scrollback buffer.
- Click or refocus the PowerShell window.
- Observe
[I inserted into the prompt, causing:
PS C:\...> [I
At line:1 char:3
+ [I
+ ~
Missing ] at end of attribute or type literal.
Root Cause Analysis
cli/src/utils/terminal-reset-sequences.ts defines TERMINAL_RESET_SEQUENCES containing \x1b[?1004l (Disable focus reporting) and \x1b[?1049l (Exit alternate screen buffer).
- On Windows PowerShell, when the underlying process exits or receives an unhandled exception in
launcher.js or terminal-protocol-controller.ts, the exit handler is either bypassed or fails to flush TERMINAL_RESET_SEQUENCES to stdout/stderr before process termination.
Expected Behavior
The exit and error handlers in launcher.js and terminal-protocol-controller.ts should guarantee that TERMINAL_RESET_SEQUENCES (\x1b[?1004l\x1b[?1049l\x1b[?25h) are reliably flushed to standard output before exiting on Windows.
Bug Description
When
freebuffCLI (v0.0.149) exits unexpectedly or crashes on Windows PowerShell, it fails to execute terminal cleanup reset sequences (TERMINAL_RESET_SEQUENCES). This results in two primary issues:[IError): Focus Reporting mode (\x1b[?1004h) remains enabled in the terminal host. Upon refocusing the PowerShell window, the terminal automatically emits\x1b[Iintostdin, leaving[Iin the input prompt and triggering PowerShell parser errors:Missing ] at end of attribute or type literal..js/.cssfiles) leak into the main scrollback buffer instead of being isolated within the alternate screen buffer (\x1b[?1049h).Environment
freebuffv0.0.149 (npm wrapper v0.0.146)Steps to Reproduce
freebuffcommand.[Iinserted into the prompt, causing:Root Cause Analysis
cli/src/utils/terminal-reset-sequences.tsdefinesTERMINAL_RESET_SEQUENCEScontaining\x1b[?1004l(Disable focus reporting) and\x1b[?1049l(Exit alternate screen buffer).launcher.jsorterminal-protocol-controller.ts, the exit handler is either bypassed or fails to flushTERMINAL_RESET_SEQUENCEStostdout/stderrbefore process termination.Expected Behavior
The exit and error handlers in
launcher.jsandterminal-protocol-controller.tsshould guarantee thatTERMINAL_RESET_SEQUENCES(\x1b[?1004l\x1b[?1049l\x1b[?25h) are reliably flushed to standard output before exiting on Windows.