Skip to content

Fix OSC 11 background color query leaking after --version/--help - #1798

Open
YrFnS wants to merge 1 commit into
CodebuffAI:mainfrom
YrFnS:fix/osc-11-leak-on-version-help
Open

YrFnS wants to merge 1 commit into
CodebuffAI:mainfrom
YrFnS:fix/osc-11-leak-on-version-help

Conversation

@YrFnS

@YrFnS YrFnS commented Dec 4, 2026

Copy link
Copy Markdown

Fixes #1743.

Summary

Running freebuff --version or freebuff --help (and NO_COLOR=1 freebuff --version) left the terminal's OSC 11 background-color reply (e.g. 11;rgb:2c2c/3737/4646) sitting in the shell's input buffer.

The cause: OSC 10/11 terminal theme detection started before CLI flags were parsed. For early-exit commands, Commander printed the version/help and the process exited before the terminal's reply could be read, so the reply was never consumed and leaked into the next shell prompt.

This change skips the OSC query entirely for those invocations (and when NO_COLOR is set), falling back to the existing synchronous env/fallback theme evidence. No query is written to the TTY and stdin is not switched to raw mode, so there is nothing left for the shell to read.

Changes

  • cli/src/utils/terminal-color-detection.ts — terminalSupportsOSC() returns false when NO_COLOR is set or when process.argv contains --version/-v/--help/-h.
  • cli/src/index.tsx — oscQuerySupported is gated the same way, so detectTerminalTheme() is not called for those invocations.
  • cli/src/types/env.ts, cli/src/utils/env.ts — add NO_COLOR to CliEnv and getCliEnv().

Testing

  • bun test cli/src/utils/__tests__/terminal-color-detection.test.ts → 70 pass, 0 fail.
  • Verified terminalSupportsOSC returns false for --version and NO_COLOR=1, true otherwise.
  • Typecheck of the touched files introduced no new errors.
  • Not reproduced end-to-end in a real terminal, so the leak itself is unverified here.

Scope

Touches only cli/ and CLI env/types; no backend, billing, deployment, or secret-management paths. Single focused fix.

Skip the terminal OSC color query for non-interactive early-exit
invocations (--version/-v/--help/-h) and when NO_COLOR is set, so the
terminal's reply is never left in the shell input buffer.

This branch has not been deployed

No deployments
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.

[CLI] OSC 11 background color query leaks into terminal prompt after freebuff --version (v0.2.38)

1 participant