Skip to content

fix: correct adaptive TUI theme luminance calculation#23917

Open
Klassikcat wants to merge 1 commit intoanomalyco:devfrom
Klassikcat:fix/tui-adaptive-theme-luminance
Open

fix: correct adaptive TUI theme luminance calculation#23917
Klassikcat wants to merge 1 commit intoanomalyco:devfrom
Klassikcat:fix/tui-adaptive-theme-luminance

Conversation

@Klassikcat
Copy link
Copy Markdown

@Klassikcat Klassikcat commented Apr 23, 2026

Issue for this PR

Closes #23810

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  • remove the extra / 255 from TUI adaptive theme luminance calculation in packages/opencode/src/cli/cmd/tui/util/terminal.ts
  • make terminal background detection use the repo's normalized RGBA channel values correctly so light terminals resolve to the light theme
  • keep the existing dark fallback behavior when no terminal background is available

How did you verify your code works?

  • Local build: build in local Ubuntu machine and kitty/warp terminal.

Screenshots / recordings

Before

Screenshot_22-Apr_17-11-56_8258 Screenshot_22-Apr_17-14-35_19176

After

Screenshot_22-Apr_17-13-05_8484 Screenshot_22-Apr_17-14-50_5588

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@Klassikcat Klassikcat force-pushed the fix/tui-adaptive-theme-luminance branch from d7b8f6f to 6cdf29b Compare April 24, 2026 11:36
@Klassikcat
Copy link
Copy Markdown
Author

Klassikcat commented Apr 24, 2026

@adamdotdevin force-pushed this branch to track the latest dev, since dev itself was force-pushed. Also tested, and can confirm it also works in 1.14.22.

@Klassikcat
Copy link
Copy Markdown
Author

@adamdotdevin Brightness detection was moved into OpenTUI in 1.14.24. opencode pins OpenTUI 0.1.99, which only supports CSI ?997 — this breaks on terminals that don't support the sequence (kitty 0.32.2, apt/noble ghostty, etc.).

I'll close the PR and issue after updates opencode's OpenTUI dep to >=0.1.100

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.

Adaptive theme always falls back to dark mode due to incorrect luminance calculation in terminal.ts

1 participant