Skip to content

refactor(tui): theme switching & loading reactivity#3

Open
nihil2501 wants to merge 1 commit intodevfrom
tui-theme-reactivity
Open

refactor(tui): theme switching & loading reactivity#3
nihil2501 wants to merge 1 commit intodevfrom
tui-theme-reactivity

Conversation

@nihil2501
Copy link
Owner

@nihil2501 nihil2501 commented Jan 24, 2026

Issues

Refactor

Remodels theme resolution reactivity with respect to this tuple:

  • The user's requested theme
  • The loading status of relevant async resources

This change also prepares for a feature: system-like custom themes

tui-theme

Fixes

  • Theme picker list now updates on reload
  • Warning toasts on errored
    • These toasts could easily be removed

Performance

The theme context now readies 10x faster in by-far the most common case: using one of the default themes. The speedup is achieved by not waiting on resources irrelevant to the requested theme before marking it as ready.
Timed using this patch that calls console.time inside createSimpleContext.

After = 3.558ms

...
[17:05:25] [LOG] '%s: %s' 'context:Theme' '3.558ms'
...

Before = 31.264ms

...
[17:04:19] [LOG] '%s: %s' 'context:Theme' '31.264ms'
...

Implementation

  • 2x createResources
    • Custom theme loading
    • System palette detection
  • These in turn are accessed in a createMemo returning this tuple:
    • The user's requested theme
    • The loading status of relevant async resources
  • 2x createEffects
    • One to update the requested theme when the config generation increments
    • Another to redo theme resolution when our memoized tuple changes

@nihil2501 nihil2501 force-pushed the tui-theme-reactivity branch 3 times, most recently from fcad986 to c975501 Compare January 29, 2026 06:00
@nihil2501 nihil2501 force-pushed the tui-theme-reactivity branch 4 times, most recently from f41140c to ee5703f Compare February 11, 2026 03:24
@nihil2501 nihil2501 force-pushed the tui-theme-reactivity branch 2 times, most recently from bb86c29 to 1606248 Compare February 17, 2026 01:25
@nihil2501 nihil2501 force-pushed the tui-theme-reactivity branch from 1606248 to 14712f5 Compare February 25, 2026 03:02
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