Skip to content

feat(openui-cloud): model selector UI revamp + persist selection across refresh - #832

Merged
i-subham23 merged 4 commits into
mainfrom
fix/model_selector
Jul 24, 2026
Merged

feat(openui-cloud): model selector UI revamp + persist selection across refresh#832
i-subham23 merged 4 commits into
mainfrom
fix/model_selector

Conversation

@i-subham23

@i-subham23 i-subham23 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Reworks the openui-cloud model selector and makes the selected model survive a page refresh. All changes live in the CLI template (packages/openui-cli/src/templates/openui-cloud) — the only surface with a model switcher.

Model selector UI

Reworked the selector to match the composition-console design and converted it fully to Tailwind (removed all .openui-cloud-model-switcher* rules from globals.css).

  • Scrollable dropdown (max-height + overflow) — the original ask.
  • Provider logos + per-provider grouping (Anthropic / OpenAI / Google).
  • Recommended chip on Claude Sonnet 5 and a separate Free section with a Usage-policy link.
  • Trigger shows the provider logo + model name + Recommended/Free badge.

Persist model across refresh

The selected model is now stored in localStorage (openui-cloud:selected-model) and restored on load, so it no longer resets to the default.

  • Read via useSyncExternalStore — hydration-safe (SSR → default, client → stored) and synced across tabs, with no setState-in-effect.
  • Stale/removed model ids are ignored (falls back to default).
  • Fixes the refresh flash: since the server can't read localStorage, the trigger briefly showed the default model. It now shows a neutral skeleton until the stored value loads, then the real model — no wrong-model flash.
  • The chat LLM is constructed with the persisted model, so the first request already uses the saved selection.

Changes

  • openui-cloud/src/components/model-switcher.tsx — Tailwind rewrite, provider logos, grouping, skeleton flash fix
  • openui-cloud/src/components/cloud-chat.tsx — localStorage persistence store
  • openui-cloud/src/app/globals.css — removed the old model-switcher CSS
  • openui-cloud/public/logos/* — provider marks (anthropic/openai/google × dark/light)

Testing

  • tsc --noEmit and eslint clean.
  • Verified live: select model → refresh → selection persists; server HTML no longer contains the default model name (skeleton instead); dropdown scrolls; Recommended/Free render correctly.
  • Independently verified against a dev stack (template run standalone): persistence + skeleton-no-flash on reload, cross-tab sync via the storage event, stale-id fallback, dropdown scroll/grouping/badges — all pass.

@i-subham23
i-subham23 requested a review from ankit-thesys July 23, 2026 09:39
…switcher component

Introduced new SVG logos for Anthropic (dark and light), Google (dark and light), and OpenAI (dark and light). Updated the ModelSwitcher component to utilize these logos, enhancing the visual representation of model providers. Removed outdated styles from globals.css to streamline the codebase.
…Chat component

Enhanced the CloudChat component to persist the selected model in localStorage, ensuring it remains consistent across page refreshes and tabs. Utilized useSyncExternalStore for hydration-safe state management, preventing UI flashes during initial render. Updated the ModelSwitcher component to handle model selection changes and display a neutral skeleton while loading the persisted model.
@ankit-thesys ankit-thesys changed the title feat(openui-cloud): model selector UI revamp + persist selection across refresh (TH-2373, TH-2365) feat(openui-cloud): model selector UI revamp + persist selection across refresh Jul 24, 2026
ankit-thesys and others added 2 commits July 24, 2026 15:38
…dular files

- Deleted the original ModelSwitcher implementation and replaced it with a modular structure.
- Introduced new files: ModelRow, ModelBadge, ProviderLogo, TriggerContent, and utils for better organization and maintainability.
- Enhanced the ModelSwitcher to utilize these components, improving readability and separation of concerns.
- Implemented a neutral skeleton loading state for improved user experience during hydration.
@i-subham23
i-subham23 merged commit 101830b into main Jul 24, 2026
23 of 25 checks passed
@i-subham23
i-subham23 deleted the fix/model_selector branch July 24, 2026 11:34
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