Skip to content

[accent-picker] Accent Picker+ — durable accent, palette slot editing, live drag, gamut fix - #223

Closed
Ehco wants to merge 9 commits into
NousResearch:mainfrom
Ehco:accent-picker-plus
Closed

Ehco wants to merge 9 commits into
NousResearch:mainfrom
Ehco:accent-picker-plus

Conversation

@Ehco

@Ehco Ehco commented Oct 28, 2026

Copy link
Copy Markdown

A reimagined build of the official accent-picker desktop plugin (original by @Teknium), keeping its OKLCH field, swatches and command structure, and turning the authoring-only picker into a full user-facing theme editor.

Changes and why

1. Full square chroma/lightness field

oklchToSrgb255 returns null outside sRGB, and the field painted those pixels transparent — for saturated hues a wedge of the panel vanished (screenshot-verified). Out-of-gamut pixels are now gamut-clipped per row against maxChroma(l, hue), keeping hue/lightness and always filling the square.

2. Durable accent — 'Save as theme'

The original treats the accent as scratch state by design, so every pick was lost on restart. Save as theme re-derives the palette with the SDK's retintTheme and installs it as a user theme — written through window.hermesDesktop.uiPreferences (the host bridge) because a bare localStorage.setItem on the shared hermes-desktop-user-themes-v1 key is clobbered by the ui-preferences sync's next adopt().

3. Colors tab — every palette slot

Background, sidebar, card, popover, border, input, etc. are editable with the same OKLCH field, targeting the palette paletteFor(seed, resolvedMode) actually paints. Edits apply live while dragging (throttled to ~8 fps).

4. Reset / Revert / Restore

Per-slot Reset to default and Revert edit, a Restore base theme button, and an Accent+: revert the last color edit palette command. Undo history capped at 25 entries.

Verification

Tested against the packaged desktop build by driving the UI over CDP: gamut-clipped field renders fully opaque; slot edits paint and persist (survives an app restart); reset/restore return to the base theme; no console errors.

src/ still holds the original TSX and will be synced in a follow-up — the tested artifact is desktop/plugin.js, which is what ships.

Credit for the original plugin and design: Teknium / Nous Research. MIT.

… live drag, gamut fix

A reimagined build of the official accent-picker by Teknium.

- Full square chroma/lightness field (out-of-gamut pixels were painted transparent)
- 'Save as theme': durable accent via retintTheme + the uiPreferences bridge (survives restarts)
- Colors tab: every palette slot editable with the same OKLCH field, live while dragging
- Per-slot Reset to default / Revert edit, Restore base theme, revert-last-edit command
- Slot edits target the paletteFor(seed, resolvedMode) palette (renderedMode flips caused stuck colors)

README documents the changes and credits the original.
@Ehco
Ehco requested a review from teknium1 as a code owner October 28, 2026 20:07
- Slots no longer snap back on release: requestTheme(sameName) is a no-op that resolves stale
  data, so installations now select a unique per-color name while the durable record stays
  under the stable name; boot re-registers it and restores the selection after a crash.
- Pointer capture on the element with React-driven down/move/up props; no window listeners
  to accumulate (the 'filling up with garbage' lag).
- Hue rail is a static true-hue rainbow; the square gradient follows the rail's hue.
- RGB/CMYK/HSV/HSL value readouts beside the hex field.

Verified: 15 rapid drags leave zero dangling drags; background drag repaints the whole
window (1.27M px diff); accent drag repaints app-wide; release holds the new color.
@Ehco

Ehco commented Oct 30, 2026

Copy link
Copy Markdown
Author

Fix update pushed (ea0cf9d0)

Addresses the follow-up issues reported on the first build:

  • Slots stuck on one color / snapping back after release. Root cause: live installs re-used the stable theme
    name as the selection target, and requestTheme(<already-active-name>) is a no-op that resolves stale data —
    so each slot snapped back to its old color on release. Live installs now select a unique per-color name;
    the durable record stays under the stable name and boot re-registers it (restoring the stable selection if a
    crash left a live-tick name in the store).
  • Drag lag / garbage accumulation. The earlier helper attached window listeners per pointer-down; a missed
    pointer-up (released outside the window) left them attached and every later drag multiplied pointermove. Drag
    now runs on element pointer capture with React-driven down/move/up props, so nothing keeps listening —
    verified across 15 rapid drags leaving zero dangling drags.
  • Google-style picker. Hue rail is a static true-hue rainbow; the square's gradient follows the hue the
    rail selects; drag commits are throttled (~8 fps) and flushed with the final value.
  • RGB/CMYK/HSV/HSL readouts beside the hex field.

Paint verified by pixel diffing the live window: a background drag repainted the full screen (1.27M px),
an accent drag repainted app-wide (1.27M px), and the released color held instead of snapping back.

- The Accent tab swaps the decorative eight-square strip for grouped,
  labelled accents from real UIs: VS Code, Visual Studio, JetBrains,
  GitHub, Linear; Claude, OpenAI, Google; Notion, Slack, Figma, Stripe;
  Firefox, Discord, Shopify, Spotify. Clicking one seeds the OKLCH
  field and paints it live instead of a bare square.
- New Presets tab mirrors Settings ▸ Appearance: every installed theme
  (built-ins plus imported/user themes) with a mode-aware accent dot and
  active marker, plus Auto/Light/Dark mode. Applying calls setTheme, so
  the preset persists per profile like a pick from the settings grid.

Verified live: seeding VS Code painted #007ACC (RGB 0,122,204); reset
  restored #ECD300; applying GitHub selected #4f9e5e (github-dark);
  restoring Custom returned the user theme. Popover rendered with no
  clipping across all four accent groups and all presets.
@Ehco

Ehco commented Oct 30, 2026

Copy link
Copy Markdown
Author

Curated UI accents + UI presets tab (57ffae7d)

  • Accent tab: the bare swatch squares are replaced by 16 documented UI accents grouped by source and labelled by product:
    Editors (VS Code #007ACC, Visual Studio #68217A, JetBrains #FE2857, GitHub #0969DA, Linear #5E6AD2);
    AI (Claude #D97757, OpenAI #10A37F, Google #4285F4);
    Productivity (Notion #337EA9, Slack #36C5F0, Figma #F24E1E, Stripe #635BFF);
    Web & social (Firefox #FF7139, Discord #5865F2, Shopify #96BF48, Spotify #1DB954).
    Clicking one seeds the OKLCH field and paints live.
  • Presets tab: mirrors Settings ▸ Appearance. Every installed theme (built-ins and imported/user themes)
    appears with a mode-aware accent dot and active marker, plus Auto/Light/Dark mode. Applying calls setTheme, so
    the preset persists per profile exactly like a settings grid pick.

Verified live: seeding VS Code painted #007ACC (RGB 0,122,204); reset restored #ECD300; applying GitHub
selected #4f9e5e and switched to github-dark; restoring Custom returned the user theme. The popover rendered
all four groups and every preset without clipping.

Ehco added 6 commits November 7, 2026 01:52
… theme JSON share, and a Glass tab for window transparency

- Surface squares in the first menu: one square per palette slot; hovering
  a square outlines every UI region that slot paints (single data-attr +
  injected stylesheet, no listeners); click opens the slot editor, which
  keeps the glow up for as long as it is open.
- Per-slot copy/paste: copy badge on every square, right-click copies,
  editor gains Copy/Paste hex buttons (paste accepts #rrggbb from the
  clipboard and commits through the same undo/throttle path).
- Share: copy the whole theme record as JSON and import one from the
  clipboard (menu buttons + two command-palette entries); imports are
  name-deduped and applied live via requestTheme().
- Glass tab: window transparency controls writing the app's own
  hermes.desktop.translucency.v2 book (mode glass/clear, intensity, fade,
  material, scope), throttled writes via the same bridge as the theme
  record, with an Apply - reload button since the renderer resolves
  translucency from storage only on window load.
- version 1.1.0
…'s original height

The surface grid + theme-JSON share row made the first menu ~200px taller.
Both now live behind a collapsed 'Surfaces' toggle row; when opened the
grid scrolls internally (max-h) instead of growing the popover.
…eaves

pointerleave never fires when the hovered row (or the whole popover)
unmounts under a still pointer, leaving data-apglow on <html> forever.
Clear the glow on grid exit, on unmount, and when the pointer reaches
the toggle row.
…anel one

The Surfaces squares section is gone from the first menu. Panel one now
glows what the accent paints while you hover/drag the field, rail or hex
input; the existing Colors slot rows glow the region they recolor on
hover. Theme-JSON share buttons moved into the Colors tab, and the glow
is dropped on list exit, tab switch and popover unmount.
… matching unconditionally

"html[data-apglow='k'] a, b { }" only scopes "a": every selector after the
first comma (buttons, sidebar, inputs, ...) matched with no attribute set,
so the whole app glowed permanently. Prefix each selector instead.
The app's one-painter glass clears the sidebar surface token and paints
<body> from --ui-bg-chrome on both columns, so a custom theme's sidebar
slot never showed under glass (sidebar read as main at the tint level).
When glass+sidebar scope is on, repaint the body gradient with the
sidebar slot in the glass column; var() references keep it live with the
tint slider and rail edge, and glass-off removes the inline paint.
@teknium1 teknium1 added the needs-decision Awaiting an owner policy or product decision label Nov 19, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks @Ehco. Remembering the chosen accent landed via #358 (in #446). We're not turning Accent Picker into a full theme editor: it's about 1,600 lines working outside the plugin SDK, which we'd have to maintain against every Desktop change. A theme editor would make a good standalone catalog plugin built on the SDK. Closing.

@teknium1 teknium1 closed this Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-decision Awaiting an owner policy or product decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants