Skip to content

Preview palettes on hover in Settings → Appearance - #3108

Merged
SawyerHood merged 4 commits into
get-bb:mainfrom
vznh:bb/preview-palette-on-hover-thr_bxcm75yz9u
Sep 8, 2026
Merged

SawyerHood merged 4 commits into
get-bb:mainfrom
vznh:bb/preview-palette-on-hover-thr_bxcm75yz9u

Conversation

@vznh

@vznh vznh commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

Choosing a color palette in different editors (take Zed) allows you to preview when scrolling through them on Command Palette - wanted to bring similar functionality here.

If I had to choose, I would also do a transition-colors but deemed that unnecessary.

What was wrong

Choosing a palette in Settings → Appearance required users to choose the selection in order to preview it. Takes a lot of time to review themes and a bit harder to choose from there.

What changed

  • Hovering or arrow-keying over a palette item now applies that theme to the current window as an ephemeral preview. Leaving the item, closing the menu, or leaving Settings restores the committed theme. Selecting an item keeps the preview in place until the saved appearance lands, so there is no flash back to the old palette.
  • apps/app/src/lib/themes/index.ts and lib/code-theme.ts gain a preview layer over the committed palette CSS and code theme. Previews never touch the localStorage pre-paint cache, and a committed apply always supersedes a preview.
  • New useAppThemePreview hook resolves themes through react-query (systemTheme query key, 60s stale time) and prefetches every listed palette when the menu opens so the first hover applies from cache. Resolved themes are invalidated with system config, including realtime config-changed.
  • New route GET /api/v1/settings/themes/:id resolves a built-in, custom, or plugin theme without activating it (400 for a malformed id, 404 for a missing custom theme). The server shares the validation with PUT /settings/appearance. No host-daemon wire change, so HOST_DAEMON_PROTOCOL_VERSION is unchanged.
  • SDK: sdk.theme.resolve({ themeId }). CLI: bb theme show [id] [--css] resolves a theme by id without activating it. Updated the CLI guide (bb-guide-customization.md) and the bb-cli skill reference (theme-commands.md).
  • Bumped @get-bb/plugin-sdk to 0.4.48 with scripts/bump-plugin-sdk.mjs because the bundled ThemeArea type changed and 0.4.47 is already on npm.

How you verified

Hand-tested.

Screen.Recording.2026-09-04.at.11.32.58.PM.mov

Additionally:

  • New tests: apps/app/src/lib/themes/preview.test.ts (preview does not persist, commit supersedes preview), apps/app/src/hooks/useAppThemePreview.test.tsx (stale resolutions ignored, cache reuse, prefetch, unmount clears), apps/app/src/views/SettingsView.palette-preview.test.tsx (focus/blur/Escape/select flows, prefetch on open), packages/sdk/test/sdk.test.ts (theme.resolve transport), and tests/integration/fake/smoke/theme-resolve.test.ts (built-in, custom, 404, 400, active theme untouched).
  • pnpm exec turbo run typecheck lint across the repo passed.
  • pnpm exec turbo run test --filter=@bb/app --filter=@bb/cli --filter=@bb/sdk --filter=@bb/server-contract passed (483 app files, 54 CLI files, 6 SDK files, 7 contract files).
  • node packages/plugin-sdk/scripts/check-npm-version-guard.mjs passed for 0.4.48.
  • oxfmt --check on every changed file and git diff --check passed.

Fixes: no linked issue.

AGENT GENERATED

## What was wrong

Choosing a palette in Settings → Appearance was a blind commit: the dropdown listed names only, so seeing what Nord or a custom theme looked like meant activating it, which persisted the selection server-side and repainted every window. Custom and plugin palette CSS is only ever sent as the active appearance, so the client had no way to look at a theme it had not activated.

## What changed

- Hovering or arrow-keying over a palette item now applies that theme to the current window as an ephemeral preview. Leaving the item, closing the menu, or leaving Settings restores the committed theme. Selecting an item keeps the preview in place until the saved appearance lands, so there is no flash back to the old palette.
- `apps/app/src/lib/themes/index.ts` and `lib/code-theme.ts` gain a preview layer over the committed palette CSS and code theme. Previews never touch the localStorage pre-paint cache, and a committed apply always supersedes a preview.
- New `useAppThemePreview` hook resolves themes through react-query (`systemTheme` query key, 60s stale time) and prefetches every listed palette when the menu opens so the first hover applies from cache. Resolved themes are invalidated with system config, including realtime `config-changed`.
- New route `GET /api/v1/settings/themes/:id` resolves a built-in, custom, or plugin theme without activating it (400 for a malformed id, 404 for a missing custom theme). The server shares the validation with `PUT /settings/appearance`. No host-daemon wire change, so `HOST_DAEMON_PROTOCOL_VERSION` is unchanged.
- SDK: `sdk.theme.resolve({ themeId })`. CLI: `bb theme show [id] [--css]` resolves a theme by id without activating it. Updated the CLI guide (`bb-guide-customization.md`) and the bb-cli skill reference (`theme-commands.md`).
- Bumped `@get-bb/plugin-sdk` to 0.4.48 with `scripts/bump-plugin-sdk.mjs` because the bundled `ThemeArea` type changed and 0.4.47 is already on npm.

## How you verified

- New tests: `apps/app/src/lib/themes/preview.test.ts` (preview does not persist, commit supersedes preview), `apps/app/src/hooks/useAppThemePreview.test.tsx` (stale resolutions ignored, cache reuse, prefetch, unmount clears), `apps/app/src/views/SettingsView.palette-preview.test.tsx` (focus/blur/Escape/select flows, prefetch on open), `packages/sdk/test/sdk.test.ts` (`theme.resolve` transport), and `tests/integration/fake/smoke/theme-resolve.test.ts` (built-in, custom, 404, 400, active theme untouched).
- `pnpm exec turbo run typecheck lint` across the repo passed.
- `pnpm exec turbo run test --filter=@bb/app --filter=@bb/cli --filter=@bb/sdk --filter=@bb/server-contract` passed (483 app files, 54 CLI files, 6 SDK files, 7 contract files).
- `node packages/plugin-sdk/scripts/check-npm-version-guard.mjs` passed for 0.4.48.
- `oxfmt --check` on every changed file and `git diff --check` passed.

Fixes: no linked issue.
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Thanks @vznh for the PR. This repo needs approval before a PR. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ) and explain what you want to open a PR for and why. A maintainer then adds you to the allow list. This PR now closes on its own. Reopen it or open a new one after approval.

@github-actions github-actions Bot closed this Sep 5, 2026
@SawyerHood

Copy link
Copy Markdown
Collaborator

/approve @vznh

@SawyerHood SawyerHood reopened this Sep 5, 2026
@vznh

vznh commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor Author

happy to merge / make any adjustments! @SawyerHood

@SawyerHood
SawyerHood merged commit 30ac8be into get-bb:main Sep 8, 2026
14 checks passed
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