Skip to content

feat(tui): theme switcher with preview#264

Merged
adamdotdevin merged 2 commits intoanomalyco:devfrom
xHeaven:theme-switcher
Jun 20, 2025
Merged

feat(tui): theme switcher with preview#264
adamdotdevin merged 2 commits intoanomalyco:devfrom
xHeaven:theme-switcher

Conversation

@xHeaven
Copy link
Copy Markdown
Contributor

@xHeaven xHeaven commented Jun 20, 2025

Previously, to see a theme in action, you had to do this:

  1. /themes
  2. Select a new theme
  3. Save with Enter
  4. Decide whether you like it or not
  5. If you like it, profit, if you don't, go back to step 1

After this PR, the new behavior is this:

  1. /themes
  2. Preview the available themes via the up and down arrow keys
  3. Press Enter if you like a theme to save it or Esc to discard the selection and close the modal

Copilot AI review requested due to automatic review settings June 20, 2025 17:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces live theme previews in the TUI theme selector and ensures modal close commands are propagated for cleanup or animations.

  • Propagate modal.Close() commands in appModel.Update to enable proper modal teardown.
  • Implement live theme preview on list navigation and restore the original theme if the dialog is closed without applying.
  • Track and restore the original theme state in the theme dialog.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/tui/internal/tui/tui.go Return modal.Close() command on ESC and CloseModalMsg cases
packages/tui/internal/components/dialog/theme.go Add originalTheme/themeApplied, preview on navigation, and restore on close
Comments suppressed due to low confidence (2)

packages/tui/internal/components/dialog/theme.go:84

  • Live preview and restore behavior aren't currently covered by tests. Add unit tests to verify theme preview on navigation and theme restoration when cancelling.
	_, prevIdx := t.list.GetSelectedItem()

packages/tui/internal/components/dialog/theme.go:90

  • [nitpick] Calling theme.SetTheme on every selection change may cause UI flicker or slowdowns. Consider debouncing updates or applying them only after a brief pause in navigation.
	if item, newIdx := t.list.GetSelectedItem(); newIdx >= 0 && newIdx != prevIdx {

Comment thread packages/tui/internal/tui/tui.go
Comment thread packages/tui/internal/components/dialog/theme.go
Comment thread packages/tui/internal/components/dialog/theme.go
@xHeaven
Copy link
Copy Markdown
Contributor Author

xHeaven commented Jun 20, 2025

^ Sorry for the AI brainfart above, I accidentally left it enabled. 👀

@adamdotdevin adamdotdevin merged commit eee396f into anomalyco:dev Jun 20, 2025
@adamdotdevin
Copy link
Copy Markdown
Member

nice! thanks!

@xHeaven xHeaven deleted the theme-switcher branch June 20, 2025 21:11
achembarpu pushed a commit to achembarpu/opencode that referenced this pull request Aug 4, 2025
andreipromarketing-dev pushed a commit to andreipromarketing-dev/opencode that referenced this pull request Apr 7, 2026
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.

3 participants