Skip to content

fix(tui): re-query terminal palette on focus for system theme refresh - #42685

Open
ar1vit0r wants to merge 1 commit into
anomalyco:devfrom
ar1vit0r:fix/theme-focus-refresh
Open

fix(tui): re-query terminal palette on focus for system theme refresh#42685
ar1vit0r wants to merge 1 commit into
anomalyco:devfrom
ar1vit0r:fix/theme-focus-refresh

Conversation

@ar1vit0r

@ar1vit0rar1vit0r commented Aug 15, 2026

Copy link
Copy Markdown

Issue for this PR

Closes#42635

Type of change

  • Bug fix

What does this PR do?

The system theme only refreshed on ?997 escape sequences or SIGUSR2, which never arrive inside terminal multiplexers like herdr. Added a focus event listener that re-queries the terminal palette when the system theme is active, so the theme stays current when the host terminal changes color scheme.

How did you verify your code works?

Code review -- the renderer already emits focus events (used in attention.ts), and refreshSystemTheme() handles concurrent calls safely.

Checklist

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

@github-actionsgithub-actionsBot added the needs:compliance This means the issue will auto-close after 2 hours. label Aug 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search results, I found one potentially related PR:

PR #37537 - fix(tui): preserve system palette colors
#37537

This PR is related to system theme palette handling in the TUI, which is the same general area as the current PR. However, it appears to be addressing a different aspect (preserving colors vs. refreshing on focus).

The other results (PR #5657 about transparent background) are less directly related.

No other open PRs appear to be addressing the specific issue of re-querying the terminal palette on focus to refresh the system theme, particularly in the context of terminal multiplexers like herdr.

@github-actionsgithub-actionsBot removed the needs:compliance This means the issue will auto-close after 2 hours. label Aug 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference; please use your judgment.

Scope: one-liner TUI fix: re-query the terminal background/foreground palette on window focus when theme is system, so the theme follows host terminal scheme changes (e.g., under multiplexers like herdr) without restart.

  • Correctly scoped: guarded by store.lock and active === "system", so explicit themes never get clobbered and locked setups stay put.
  • Handler lifecycle is right — registered alongside the existing THEME_MODE listener and removed in onCleanup.
  • No debounce on focus events; each focus triggers a palette query. At human focus-switch rates this is fine, but if refreshSystemTheme writes OSC sequences it may be worth coalescing rapid focus/blur pairs (blur→query can race with refocus). Existing timeout bookkeeping (themeRefreshTimeouts) suggests some of this is already handled.
  • No test added; given it's an event-wiring change against the renderer singleton that's understandable, but a unit test asserting refreshSystemTheme fires on the focus event would be cheap insurance.

Sign up for freeto 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.

TUI system theme never refreshes terminal palette without a ?997 report (stale inside herdr)

2 participants

@ar1vit0r@Enough1122