Repository navigation
Conversation
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
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.
Fixes #1743.
Summary
Running
freebuff --versionorfreebuff --help(andNO_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_COLORis 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()returnsfalsewhenNO_COLORis set or whenprocess.argvcontains--version/-v/--help/-h.cli/src/index.tsx—oscQuerySupportedis gated the same way, sodetectTerminalTheme()is not called for those invocations.cli/src/types/env.ts,cli/src/utils/env.ts— addNO_COLORtoCliEnvandgetCliEnv().Testing
bun test cli/src/utils/__tests__/terminal-color-detection.test.ts→ 70 pass, 0 fail.terminalSupportsOSCreturnsfalsefor--versionandNO_COLOR=1,trueotherwise.Scope
Touches only
cli/and CLI env/types; no backend, billing, deployment, or secret-management paths. Single focused fix.