fix(tui): improve color contrast for light-background terminals#38636
fix(tui): improve color contrast for light-background terminals#38636ademczuk wants to merge 1 commit intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 87b592176c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Greptile SummaryThis PR introduces light-terminal support to the TUI theme layer by adding palette auto-detection ( Key observations:
Confidence Score: 4/5
Last reviewed commit: 87b5921 |
00b2364 to
a7bccee
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 880c9e9dbf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b758228463
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba9a0f994f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@ademczuk screenshot before or after or im closing this PR as i have no way of verifying without a build |
vincentkoc
left a comment
There was a problem hiding this comment.
need verification of changes
CI StatusThe 3 failing checks are pre-existing type errors on
This PR only touches
|
f3f68fc to
3303076
Compare
Aisle Security Finding — AddressedFixed in a35aa35. The
This addresses CWE-400 (uncontrolled resource consumption) by bounding both input size and output range before any computation. |
Rendered using the exact hex values from
Every color shown corresponds 1:1 to the palette objects in the diff. The |
|
Pushed Summary of changes across all commits:
Verification steps: # Run tests
pnpm vitest run src/tui/theme/theme.test.ts
# Manual - force light mode
OPENCLAW_THEME=light openclaw gateway status
# Manual - auto-detect from terminal
COLORFGBG=0;15 openclaw gateway statusAll 10 bot comments from chatgpt-codex-connector and greptile addressed across 5 rounds. CI green (secrets failure is expected for fork PRs). |
|
@vincentkoc these CI checks could do with some intent engineering, as this should be a slamdunk of a PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 011a70c859
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@vincentkoc - verification of the changes: What changed (commit Before: Verification:
No other files changed. Only 8 lines modified in pnpm vitest run src/tui/theme/theme.test.ts # 19 tests pass
pnpm tsgo # zero errorsCI: all test jobs green. |
898ddc2 to
5e1b6dc
Compare
|
Pushed a rebased update to What changed:
Verification:
The branch is rebased onto current |
|
@vincentkoc - thanks for the rewrite, the contrast-ratio detection is a much better approach than the fixed threshold. I've added the missing changelog entry (a5f3808). All CI was green on 5e1b6dc and the branch is rebased on current main. Since you authored the core rewrite commit ( |
…nclaw#38636) Detect light terminal backgrounds via COLORFGBG and apply a WCAG AA-compliant light palette. Adds OPENCLAW_THEME=light|dark env var override for terminals without auto-detection. Uses proper sRGB linearisation and WCAG 2.1 contrast ratios to pick whichever text palette (dark or light) has higher contrast against the detected background colour. Co-authored-by: ademczuk <[email protected]>
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
10 similar comments
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
|
Closing this PR because it looks dirty (too many unrelated or unexpected changes). This usually happens when a branch picks up unrelated commits or a merge went sideways. Please recreate the PR from a clean branch. |
…nclaw#38636) Detect light terminal backgrounds via COLORFGBG and apply a WCAG AA-compliant light palette. Adds OPENCLAW_THEME=light|dark env var override for terminals without auto-detection. Uses proper sRGB linearisation and WCAG 2.1 contrast ratios to pick whichever text palette (dark or light) has higher contrast against the detected background colour. Co-authored-by: ademczuk <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac1d843386
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Superseded by #40339 - same branch, CHANGELOG conflict resolved, clean diff against main (6 files). This PR was auto-closed after the branch was force-pushed and couldn't be reopened. |
|
Too many files changed for review. ( |
* fix(tui): improve colour contrast for light-background terminals (#38636) Detect light terminal backgrounds via COLORFGBG and apply a WCAG AA-compliant light palette. Adds OPENCLAW_THEME=light|dark env var override for terminals without auto-detection. Uses proper sRGB linearisation and WCAG 2.1 contrast ratios to pick whichever text palette (dark or light) has higher contrast against the detected background colour. Co-authored-by: ademczuk <[email protected]> * Update CHANGELOG.md --------- Co-authored-by: ademczuk <[email protected]> Co-authored-by: ademczuk <[email protected]>
…claw#40345) * fix(tui): improve colour contrast for light-background terminals (openclaw#38636) Detect light terminal backgrounds via COLORFGBG and apply a WCAG AA-compliant light palette. Adds OPENCLAW_THEME=light|dark env var override for terminals without auto-detection. Uses proper sRGB linearisation and WCAG 2.1 contrast ratios to pick whichever text palette (dark or light) has higher contrast against the detected background colour. Co-authored-by: ademczuk <[email protected]> * Update CHANGELOG.md --------- Co-authored-by: ademczuk <[email protected]> Co-authored-by: ademczuk <[email protected]>
…claw#40345) * fix(tui): improve colour contrast for light-background terminals (openclaw#38636) Detect light terminal backgrounds via COLORFGBG and apply a WCAG AA-compliant light palette. Adds OPENCLAW_THEME=light|dark env var override for terminals without auto-detection. Uses proper sRGB linearisation and WCAG 2.1 contrast ratios to pick whichever text palette (dark or light) has higher contrast against the detected background colour. Co-authored-by: ademczuk <[email protected]> * Update CHANGELOG.md --------- Co-authored-by: ademczuk <[email protected]> Co-authored-by: ademczuk <[email protected]>
上游更新摘要(abb8f6310 → bda63c3,164 commits): ### 新功能 - ACP: 新增 resumeSessionId 支持 ACP session 恢复(openclaw#41847) - CLI: 新增 openclaw backup create/verify 本地状态归档命令(openclaw#40163) - Talk: 新增 talk.silenceTimeoutMs 配置项,可自定义静默超时(openclaw#39607) - ACP Provenance: 新增 ACP 入站溯源元数据和回执注入(openclaw#40473) - Brave 搜索: 新增 llm-context 模式,返回 AI 精炼摘要(openclaw#33383) - browser.relayBindHost: Chrome relay 可绑定非 loopback 地址(WSL2 支持)(openclaw#39364) - node-pending-work: 新增 node.pending.pull/ack RPC 接口 - Telegram: 新增 exec-approvals 处理器,支持 Telegram 内命令执行审批 - Mattermost: 新增 target-resolution,修复 markdown 保留和 DM media 上传 - MS Teams: 修复 Bot Framework General channel 对话 ID 兼容性(openclaw#41838) - secrets/runtime-web-tools: 全新 web runtime secrets 工具模块 - cron: 新增 store-migration,isolated-agent 直送核心通道,delivery failure notify - TUI: 自动检测浅色终端主题(COLORFGBG),支持 OPENCLAW_THEME 覆盖(openclaw#38636) ### 修复 - macOS: launchd 重启前重启已禁用服务,修复 openclaw update 卡死问题 - Telegram DM: 按 agent 去重入站 DM,防止同一条消息触发重复回复(openclaw#40519) - Matrix DM: 修复 m.direct homeserver 检测,保留房间绑定优先级(openclaw#19736) - 飞书: 清理插件发现缓存,修复 onboarding 安装后重复弹窗(openclaw#39642) - config/runtime snapshots: 修复 config 写入后 secret 快照丢失问题(openclaw#37313) - browser/CDP: 修复 ws:// CDP URL 反向代理和 wildcard 地址重写 - agents/failover: 识别 Bedrock tokens per day 限额为 rate limit ### 版本 - ACPX 0.1.16 - iOS/macOS 版本号更新 - Android: 精简后台权限 构建验证:待执行
…claw#40345) * fix(tui): improve colour contrast for light-background terminals (openclaw#38636) Detect light terminal backgrounds via COLORFGBG and apply a WCAG AA-compliant light palette. Adds OPENCLAW_THEME=light|dark env var override for terminals without auto-detection. Uses proper sRGB linearisation and WCAG 2.1 contrast ratios to pick whichever text palette (dark or light) has higher contrast against the detected background colour. Co-authored-by: ademczuk <[email protected]> * Update CHANGELOG.md --------- Co-authored-by: ademczuk <[email protected]> Co-authored-by: ademczuk <[email protected]>
…claw#40345) * fix(tui): improve colour contrast for light-background terminals (openclaw#38636) Detect light terminal backgrounds via COLORFGBG and apply a WCAG AA-compliant light palette. Adds OPENCLAW_THEME=light|dark env var override for terminals without auto-detection. Uses proper sRGB linearisation and WCAG 2.1 contrast ratios to pick whichever text palette (dark or light) has higher contrast against the detected background colour. Co-authored-by: ademczuk <[email protected]> * Update CHANGELOG.md --------- Co-authored-by: ademczuk <[email protected]> Co-authored-by: ademczuk <[email protected]>
…claw#40345) * fix(tui): improve colour contrast for light-background terminals (openclaw#38636) Detect light terminal backgrounds via COLORFGBG and apply a WCAG AA-compliant light palette. Adds OPENCLAW_THEME=light|dark env var override for terminals without auto-detection. Uses proper sRGB linearisation and WCAG 2.1 contrast ratios to pick whichever text palette (dark or light) has higher contrast against the detected background colour. Co-authored-by: ademczuk <[email protected]> * Update CHANGELOG.md --------- Co-authored-by: ademczuk <[email protected]> Co-authored-by: ademczuk <[email protected]>
|
Branch got contaminated with upstream commits during rebase - ended up with a 3k file diff that's obviously unreviewable. Closing to cut down on review queue noise. The original colour contrast fix was a 2-file change, but it's not worth salvaging at this point given upstream terminal rendering has changed since. |
…claw#40345) * fix(tui): improve colour contrast for light-background terminals (openclaw#38636) Detect light terminal backgrounds via COLORFGBG and apply a WCAG AA-compliant light palette. Adds OPENCLAW_THEME=light|dark env var override for terminals without auto-detection. Uses proper sRGB linearisation and WCAG 2.1 contrast ratios to pick whichever text palette (dark or light) has higher contrast against the detected background colour. Co-authored-by: ademczuk <[email protected]> * Update CHANGELOG.md --------- Co-authored-by: ademczuk <[email protected]> Co-authored-by: ademczuk <[email protected]>
…claw#40345) * fix(tui): improve colour contrast for light-background terminals (openclaw#38636) Detect light terminal backgrounds via COLORFGBG and apply a WCAG AA-compliant light palette. Adds OPENCLAW_THEME=light|dark env var override for terminals without auto-detection. Uses proper sRGB linearisation and WCAG 2.1 contrast ratios to pick whichever text palette (dark or light) has higher contrast against the detected background colour. Co-authored-by: ademczuk <[email protected]> * Update CHANGELOG.md --------- Co-authored-by: ademczuk <[email protected]> Co-authored-by: ademczuk <[email protected]>

Summary
This PR enhances the color contrast for syntax highlighting in light-background terminals. It introduces a new parameter to the
createSyntaxThemefunction to support light themes, ensuring better visibility and adherence to accessibility standards. [HIGH_CONFIDENCE]Type: fix [HIGH_CONFIDENCE]
Key Changes
Testing
Verify the changes by running the application in both light and dark terminal backgrounds. Check that the syntax highlighting colors are appropriate for each mode and that the light mode is correctly detected based on the environment variables.
Original Description
Summary
Problem: TUI colours are hardcoded for dark terminals. Users with light-theme terminals (iTerm2 Solarized Light, Windows Terminal Light, VS Code Light) get invisible or near-invisible text, with contrast ratios as low as 1.2:1 against white backgrounds (WCAG AA requires 4.5:1).
Why it matters: All light-theme terminal users have degraded readability. Affects text, syntax highlighting, status indicators, and tool output.
What changed: Added light/dark palette detection + WCAG AA-compliant light palette + light syntax theme. 3 files, 167 lines, all in
src/tui/theme/.What did NOT change: Dark theme is identical.
lightModedefaults tofalse, selecting the unchanged dark palette. No consumer code changes. No behavioural changes.Visual Verification
Three panels rendered with exact hex values from
darkPaletteandlightPalette:Change Type
Scope
Linked Issue/PR
User-visible / Behavior Changes
Users with light-background terminals will see properly contrasted text when
OPENCLAW_THEME=lightis set orCOLORFGBGenv var indicates a light background. Dark terminal users see zero change.How It Works
Detection (
src/tui/theme/theme.ts)Files Changed
| File | Lines | What |
|------|-------|------|
|
src/tui/theme/theme.ts| +48 |isLightBackground()detection, light palette, palette selection ||
src/tui/theme/syntax-theme.ts| +50 |lightparameter, VS Code Light+ inspired syntax colours ||
src/tui/theme/theme.test.ts| +73 | 7 tests: detection logic, env var precedence, identity behaviour |Key Design Decisions
All TUI colour goes through the centralised theme - palette swap propagates automatically to all 7 theme exports (
theme,markdownTheme,selectListTheme, etc.)OPENCLAW_THEMEoverridesCOLORFGBG- explicit user intent wins over auto-detectionCOLORFGBGthreshold >= 7 - standard ANSI convention (used by vim, tmux); conservative to avoid false positivesModule-level evaluation - same pattern as
src/terminal/theme.ts(NO_COLOR/FORCE_COLOR)Security Impact
Handles user input or env vars
Reads
OPENCLAW_THEMEandCOLORFGBG, both display-only env vars with no security implications. No validation bypass, no auth changes, no file system access.Evidence
Unit/integration test added or updated
7 new tests covering: default dark, explicit light/dark, COLORFGBG auto-detect, COLORFGBG dark threshold, override precedence, assistantText identity in both modes
All 180 TUI tests pass
Human Verification
Verified scenarios: Tests cover detection logic exhaustively. Visual verification requires manual terminal switching.
Edge cases checked: COLORFGBG with multiple semicolons (uses last value), missing env vars, mixed case OPENCLAW_THEME
What was NOT verified: Visual appearance on every terminal emulator beyond Windows 11. Colours are WCAG AA-calculated; screenshot verification above confirms contrast on white background.
Compatibility / Migration
Backward compatible: yes. Dark theme unchanged, light requires explicit opt-in or COLORFGBG
Config changes: new optional
OPENCLAW_THEMEenv var (light/dark)Migration needed: none
Failure Recovery
Revert:
git revert <sha>, single commit, clean revertFiles to restore:
src/tui/theme/theme.ts,src/tui/theme/syntax-theme.tsBad symptoms: Wrong colours on specific terminal (set
OPENCLAW_THEME=darkas workaround)Risks and Mitigations
| Risk | Mitigation |
|------|-----------|
| COLORFGBG false positive (detects light on dark terminal) |
OPENCLAW_THEME=darkexplicit override available || Light palette colour not contrasted enough on specific terminal | All colours WCAG AA-calculated (>=4.5:1 on white);
OPENCLAW_THEMEoverride as escape hatch || Pre-existing feishu TS2353 errors in CI | Not introduced by this PR. Same 4 errors exist on
main|Regression Risk Assessment
Active regressions: 0 open regression issues in TUI area
Recent bugfixes in same files: 0 bugfix PRs in last 48h touching
src/tui/theme/Competing PRs: None
Overall risk: Low. Pure visual change, zero behavioural impact, dark theme unchanged