Skip to content

cli: display.Mode always resolves to the mode actually rendered - #14103

Merged
glours merged 1 commit into
mainfrom
epic-14074-display-mode
Aug 20, 2026
Merged

cli: display.Mode always resolves to the mode actually rendered#14103
glours merged 1 commit into
mainfrom
epic-14074-display-mode

Conversation

@ndeloof

@ndeloof ndeloof commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

display.Mode stayed "auto" on the most common path (auto progress mode), so readers such as up's NavigationMenu gate acted on an unresolved value — and that gate compared against the literal "plain" instead of the constant. applyDisplayMode could also write a mode the renderer selection then contradicted (--ansi always + redirected stderr rendered Plain while Mode said tty).

selectEventProcessor is now the single resolution point: every branch assigns the mode matching the renderer it returns, so after command setup the global never holds ModeAuto. applyDisplayMode loses its redundant writes and its misleading name (applyAnsiMode); the contract is documented on the Mode variable and pinned by the existing TestSelectEventProcessor_* tables, which now assert the resolved mode per branch.

Deliberate behavior change: with stderr redirected (auto → plain rendering), the interactive navigation menu is no longer offered; it used to slip through because Mode still read "auto".

Part of #14074 (section E).

🤖 Generated with Claude Code

The display.Mode package global was left as "auto" on the most common
path (auto mode with an interactive or redirected terminal), so readers
like `up`'s NavigationMenu gate saw an unresolved value; that gate also
compared against the string literal "plain" instead of the constant.
applyDisplayMode wrote a mode that selectEventProcessor could then
contradict (--ansi always with a redirected stderr rendered Plain while
Mode said tty).

selectEventProcessor becomes the single resolution point: every branch
assigns the mode matching the renderer it returns, so after command
setup the global never holds ModeAuto. applyDisplayMode loses its
redundant writes and its misleading name (now applyAnsiMode); the
contract is documented on the Mode variable, and the existing
selectEventProcessor tests now pin the resolved mode for every branch.

Side effect, deliberate: with stderr redirected (auto -> plain
rendering) the navigation menu is no longer offered; it used to slip
through because Mode still read "auto".

Part of #14074 (section E).

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@glours
glours merged commit cccb9f1 into main Aug 20, 2026
92 of 93 checks passed
@glours
glours deleted the epic-14074-display-mode branch August 20, 2026 13:10
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.

2 participants