Skip to content

feat(colors): share the custom HEX history across every picker - #502

Merged
kirillDevPro merged 2 commits into
mainfrom
kirillDevPro/hex
Sep 11, 2026
Merged

feat(colors): share the custom HEX history across every picker#502
kirillDevPro merged 2 commits into
mainfrom
kirillDevPro/hex

Conversation

@kirillDevPro

Copy link
Copy Markdown
Collaborator

Closes #488.

What & why

A colour typed into a picker's HEX field was remembered only by the Badges settings tab, which
kept its own reuse list inside the portable badges.json. Every other picker — core colour,
strategy colour fields, order lines, chart figures, labels, the arbitrage editor, News tags —
made the user retype the same shade from its code each time. That is what the tester was actually
asking for: the palette is already identical everywhere, but only badges remembers.

The history now lives in its own cfg/custom_colors.json, owned by moon-core, and every picker
seeds from and writes to one app-global entity. Most-recent-first, de-duped, capped at 20 to match
MoonUI's own MAX_CUSTOM_COLORS, above which a seeded list is silently trimmed anyway.

Notes for review:

  • Not an AppConfig field, on purpose. Remembering a colour is immediate app-local state, so
    Cancel in Settings cannot roll it back and Save is not required to keep it. That is also why it
    is a standalone file rather than a key in settings.toml, which goes through the draft/preview
    machinery.
  • badges.json keeps its list and is imported once, the first time the new file is absent, so
    a downgrade still finds it. BadgesConfig::custom_colors therefore survives as migration-only
    data; parse_share still preserves it across a paste, for the same reason it always did.
  • A corrupt badges.json imports as empty rather than failing — the new file is never created
    on the error path, so a hard error would have left the history unpersisted on every later launch
    too. BadgesConfig::load already tolerates that same corruption.
  • The fan-out never rebuilds editor state. The badges tab's old sibling-fan-out existed
    precisely to avoid tearing down every row's MoonInputState, including the hex field being
    edited; the shared subscription only pushes swatches.
  • The second commit bumps MoonUI to pick up fix(color_picker): reveal scrollable palettes MoonUI#65, the other half of the issue:
    the swatch grid now shows that it scrolls.

How to verify

cargo test -p moon-core — 1919 passing. cargo fmt --all -- --check and
cargo check -p moon-core -p moon-ui-gpui --locked clean.

Checked in a live debug build against real cores: typing a HEX in the Connections tab's core-colour
picker writes cfg/custom_colors.json, and the same colour then leads the grid in the Lines tab's
order-line picker, which has its own unrelated value. The scrollbar is visible on open without
interaction.

Not verified: migration of a non-empty legacy list (the test profile's was empty) and the
corrupt-config path — both are named in the branch notes as unproven, with the mutations that would
catch a regression.

https://claude.ai/code/session_017mwXJTSXLJdEMfjXSvWpS4

A colour typed into a picker's HEX field was remembered only by the
Badges settings tab, which kept its own reuse list inside the portable
badges.json. Every other picker -- core colour, strategy colour fields,
order lines, chart figures, labels, the arbitrage editor, News tags --
made the user retype the same shade from its code each time, so a
personal colour scheme drifted apart across the surfaces it exists to
tie together.

The history now lives in its own cfg/custom_colors.json, owned by
moon-core, and every picker seeds from and writes to one app-global
entity. It stays most-recent-first, de-duped, and capped at 20 to match
MoonUI's own MAX_CUSTOM_COLORS, above which a seeded list is silently
trimmed.

It is deliberately not an AppConfig field: remembering a colour is
immediate app-local state, so pressing Cancel in Settings cannot roll it
back and pressing Save is not required to keep it.

An existing badges.json list is imported once, the first time the new
file is absent, and is left in place afterwards so a downgrade still
finds it. BadgesConfig::custom_colors therefore survives as
migration-only data rather than a live reuse list. A corrupt badges.json
imports as empty rather than failing, because the new file is never
created on the error path and a hard error would leave the history
unpersisted on every later launch too.

Claude-Session: https://claude.ai/code/session_017mwXJTSXLJdEMfjXSvWpS4
Picks up Moonbot-Tech/MoonUI#65, which gives MoonColorPicker's swatch
grid a visible scrollbar. The terminal hands that picker 65 swatches
plus up to 20 remembered custom colours -- 17 rows against a budget of
about five -- so without it the palette looked like only the rows that
happened to fit.

Only the MoonUI packages move; the MoonProtoBeta pin is unchanged.

Claude-Session: https://claude.ai/code/session_017mwXJTSXLJdEMfjXSvWpS4
@kirillDevPro
kirillDevPro merged commit e6e6612 into main Sep 11, 2026
6 checks passed
@kirillDevPro
kirillDevPro deleted the kirillDevPro/hex branch September 11, 2026 15:25
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.

Свои цвета (HEX) запоминаются только в бейджах, а палитра скроллится незаметно

1 participant