Skip to content

Add a preference controlling whether selecting a colour closes the palette - #75

Merged
charlesangus merged 3 commits into
mainfrom
agent/issue-70
Aug 31, 2026
Merged

charlesangus merged 3 commits into
mainfrom
agent/issue-70

Conversation

@charlesangus

Copy link
Copy Markdown
Owner

Closes #70

What

Adds close_palette_on_select to the plugin preferences, exposed in Anchor
Preferences...
as Selecting a color closes the color palette (next to the
Custom Colors swatches).

It defaults to True, i.e. today's behaviour: picking a colour accepts and
closes the palette. With it off, picking only highlights the colour and the
palette stays open until the user confirms with Enter / OK (or discards
with Esc) — handy when comparing a few colours, or when naming and colouring
an anchor in one dialog.

How

  • prefs.py — new persisted boolean, validated and defaulted like the other
    keys, so old prefs files and corrupt values keep the current behaviour.
  • colors.pyColorPaletteDialog gains a close_on_select=True argument
    rather than importing prefs itself, matching how custom_colors is already
    injected by the caller. All three selection paths — swatch click, hint-mode
    address (Tab then e.g. a1), and the Custom Color... picker — now
    funnel through a single _select_color() so the flag applies consistently;
    previously each one called accept() on its own. Resolving a hint address
    also leaves hint mode, so the selection highlight is visible when the dialog
    stays open.
  • anchor.py — passes close_on_select=prefs.close_palette_on_select at all
    three places it opens the palette.

Tests

pytest tests/ — 502 passing, 16 new: prefs round-trip/default/corrupt-value
handling, both branches of the flag for swatch clicks and custom colours, and
structural checks that the hint-mode handlers and every anchor.py call site go
through the shared gate.

Docs

docs/user-guide.md updated (Colours section + Preferences list) and
docs/anchors-user-guide.pdf regenerated with make pdf. Screenshots were not
regenerated: the colour palette is visually unchanged and the Preferences dialog
is not one of the captured GUI scenarios in scenarios/gui.json.

Persisted boolean, defaulting to True so the existing behaviour (picking a
colour accepts and closes the palette) is unchanged for everyone who never
touches the setting.  Non-bool and missing values fall back to the default,
matching how the other prefs keys are validated.
ColorPaletteDialog gains a close_on_select argument (default True), injected
by anchor.py from prefs.close_palette_on_select — the dialog stays
prefs-agnostic, exactly as it already is for custom_colors.

All three selection paths (swatch click, hint-mode address, and the
Custom Color... picker) now funnel through _select_color(), so the flag
applies consistently: with it off the colour is only highlighted and the user
confirms with Enter or OK.  Resolving a hint address also leaves hint mode so
the selection highlight is visible once the dialog stays open.

PrefsDialog exposes the setting as a checkbox next to the Custom Colors
swatches.
Adds the new checkbox to the Preferences list and explains the behaviour in
the Colours section, and regenerates the committed PDF with 'make pdf'.

No screenshots needed regenerating: the colour palette itself is visually
unchanged, and the Preferences dialog is not among the captured GUI
scenarios.
Copilot AI lite review requested due to automatic review settings August 26, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped, preserves the existing default, is consistently plumbed through call sites/UI, and is covered by targeted tests plus updated user documentation.

Pull request overview

Adds a new user preference that controls whether selecting a colour in the ColorPaletteDialog immediately accepts/closes the dialog, while preserving the current default behavior.

Changes:

  • Introduces persisted prefs.close_palette_on_select (default True) with type validation on load and persistence on save.
  • Refactors ColorPaletteDialog selection handling to route all selection paths through a single _select_color() gate controlled by close_on_select.
  • Wires the preference through the Preferences UI and all anchor.py call sites that open the palette; extends tests and updates the user guide.
File summaries
File Description
prefs.py Adds close_palette_on_select preference with validated load and persisted save.
colors.py Adds close_on_select arg, centralizes selection in _select_color(), leaves hint mode before selection when needed, and exposes the preference via PrefsDialog.
anchor.py Passes close_on_select=prefs.close_palette_on_select to all ColorPaletteDialog constructions.
tests/test_prefs.py Adds round-trip/default/corrupt/missing-key coverage for the new pref.
tests/test_anchor_color_system.py Adds harness + behavioral/source-level checks ensuring the close-on-select gate is consistently applied.
docs/user-guide.md Documents the new preference and updated expected palette behavior.
Review details
  • Files reviewed: 6/7 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@charlesangus
charlesangus merged commit 8e095cc into main Aug 31, 2026
1 check passed
@charlesangus
charlesangus deleted the agent/issue-70 branch August 31, 2026 03:05
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.

Add a preference to control whether selecting a colour accepts and closes the popup or not

2 participants