Skip to content

fix(ui): avoid mixed theme preview frames#458

Merged
benvinegar merged 1 commit into
mainfrom
fix/theme-preview-flash
Jun 20, 2026
Merged

fix(ui): avoid mixed theme preview frames#458
benvinegar merged 1 commit into
mainfrom
fix/theme-preview-flash

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • keep theme selector open/selected/preview state in one atomic state object
  • derive the rendered preview theme without committing it until Enter
  • avoid transient mixed-color frames when previewing, accepting, or cancelling theme selection

Verification

  • bun test src/ui/AppHost.interactions.test.tsx --test-name-pattern 'theme'\n- bun run typecheck\n\nThis PR description was generated by Pi using OpenAI GPT-5

@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes transient mixed-color frames in the theme selector by consolidating three separate state variables (themeSelectorOpen, themeSelectorIndex, and themeSelectorOriginRef) into a single atomic ThemeSelectorState object and introducing a previewThemeId overlay on top of the committed themeId.

  • Atomic state consolidation: Replaces three independent state pieces with one ThemeSelectorState object (open, selectedIndex, previewThemeId), ensuring open/index/preview transitions always land in the same render frame.
  • Non-mutating preview: Theme previews now write to previewThemeId instead of directly mutating themeId; effectiveThemeId = previewThemeId ?? themeId drives rendering, so cancelling is a single null-assignment with no intermediate frame showing the wrong theme.
  • Simplified cancel path: The themeSelectorOriginRef tracking the origin theme is removed — Escape simply sets previewThemeId: null in one update, atomically reverting all previewed colors.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to theme-selector state management and is well covered by the existing interaction test suite.

The refactor correctly uses functional updaters for all concurrent-safe paths (move, pick, close), batches selectTheme with setThemeSelectorState in acceptThemeSelector so no intermediate frame can show a mismatched theme, and removes the themeSelectorOriginRef without leaving any dangling restore path. The escape/revert, accept, and reopen-on-committed-theme flows are all exercised by the existing tests in AppHost.interactions.test.tsx.

No files require special attention.

Important Files Changed

Filename Overview
src/ui/App.tsx Core refactor of theme selector state: three separate pieces (open bool, index, origin ref) merged into one atomic ThemeSelectorState object with a previewThemeId overlay; logic is consistent across open/move/pick/accept/close paths with correct functional updater usage.
.changeset/theme-preview-flash.md Adds a patch-level changeset entry describing the fix for mixed-color frame flashes during theme preview/acceptance.

Reviews (1): Last reviewed commit: "fix(ui): avoid mixed theme preview frame..." | Re-trigger Greptile

@benvinegar benvinegar force-pushed the fix/theme-preview-flash branch from b9bc21c to e855db4 Compare June 20, 2026 20:09
@benvinegar benvinegar merged commit ae57101 into main Jun 20, 2026
8 checks passed
@benvinegar benvinegar deleted the fix/theme-preview-flash branch June 20, 2026 20:58
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.

1 participant