Skip to content

fix(automation): Address colors by palette slot - #161

Merged
epilande merged 5 commits into
mainfrom
fix/color-by-slot
Nov 24, 2026
Merged

epilande merged 5 commits into
mainfrom
fix/color-by-slot

Conversation

@epilande

@epilande epilande commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Prep for #155. The annotate://color link and the Shortcuts Set Color action now address a color by its palette slot, so an editable palette can change what a slot holds without breaking saved links and shortcuts. Neither has shipped yet, so there is no compatibility to keep.

Summary

  • Links: annotate://color/<slot> takes 1 to 9. Anything else (red, 0, 10, 01, +1) is rejected as an unknown value, like any other bad link. Percent-encoded links (color/%34, color/4%2F) are rejected too, for every command: no link needs encoding, and a decoded %2F passed for a separator, so color/4%2F ran as color/4/.
  • Shortcuts: Set Color takes a slot number from 1 to 9. A number outside that range, such as one from a variable, fails with "Choose a color slot from 1 to 9." and leaves the color alone. The action's description lists the slots. The link parser and the action share one slot lookup.
  • Slot numbers: a slot is the color's position in the palette (1 is red, 9 is black). Binding a color to another key doesn't change its slot, so the color picker's numbers can differ from the slots.
  • Color keys: the stored color shortcuts are keyed by slot (shortcut.color4 instead of shortcut.colorGreen). They aren't in v1.8.0, so nothing is migrated. Color keys set in a development build go back to unassigned.
  • README: the action, link, and value list describe slots and how they differ from the picker's numbers.

Testing

  • swift test: 1317 tests, 4 skipped, 0 failures. SwiftLint: 0 violations.
  • Xcode Debug build: the extracted Set Color metadata has one integer parameter with bounds 1 and 9, and the description with the slot list. Xcode only accepts literal bounds (PaletteColor.allCases.count fails the build), so a test fails if the palette stops having 9 colors.
  • The new tests for percent-encoding, stored keys, and the description each fail with their change reverted.
  • Not run: Set Color inside the Shortcuts app, which needs a build signed with an Apple Development certificate.

Live verification: passed on b6324d3. How: links opened in the verify-annotate debug copy, one pen stroke after each. color/1, color/4, and color/7 drew red, green, and magenta; after color/green and color/10 the stroke stayed magenta. Not rerun for the follow-up commits, which change nothing drawn on screen. Evidence for that commit: recording and end-state screenshot attached below.

Summary by CodeRabbit

  • Changes

    • Color selection in Shortcuts and URL links uses palette slots 1–9 instead of color names. Slots remain tied to the palette order, regardless of shortcut key bindings.
    • Invalid, out-of-range, or malformed slots are rejected. Percent-encoded URL paths are not decoded, so encoded separators are not treated as path separators.
  • Documentation

    • Updated the README with the palette slot order and guidance for selecting colors in Shortcuts and URL links.
annotate-color-slots.mp4

Strokes after color/1, 4, 7, green, 10: red, green, then magenta

annotate://color/<slot> and the Set Color action take a palette slot from
1 to 9 instead of a color name, so an editable palette can change what a
slot holds without breaking saved links and shortcuts.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Color command paths and the Set Color shortcut action now identify colors by palette slot, numbered 1–9. Invalid slots are rejected. URL parsing preserves percent-encoding, and tests and README documentation reflect the slot-based format.

Changes: Palette Slot Color References

Layer / File(s) Summary
Palette mapping and command paths
Annotate/Constants.swift, Annotate/AnnotateCommand.swift, AnnotateTests/AnnotateCommandTests.swift
PaletteColor now exposes a 1-based slot mapping. Color paths use decimal slot values, and parsing rejects noncanonical or out-of-range values. Tests cover slot mapping and path validation.
Set Color intent
Annotate/AnnotateIntents.swift, AnnotateTests/AnnotateCommandTests.swift
SetColorIntent accepts a slot and throws unknownColorSlot when the slot is invalid. The PaletteColor AppEnum display representation was removed. Tests cover slot mapping and invalid-slot behavior.
URL, shortcut storage, and documentation
Annotate/URLCommands.swift, Annotate/ShortcutManager.swift, AnnotateTests/URLCommandTests.swift, AnnotateTests/SettingsStoreTests.swift, README.md
URL parsing preserves percent-encoding. Shortcut color keys use slot numbers. URL tests use numeric color paths, and the README describes numbered slots for Shortcuts and URL color links.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related issues

  • epilande/Annotate#155 — This change switches color links and the Set Color action to palette slots. It does not add the editable palette or the naming and display plan described in the issue.

Possibly related PRs

  • epilande/Annotate#136 — This PR changes the color-link format parsed by the URL handling introduced in PR #136.
  • epilande/Annotate#135 — This PR changes the Set Color parameter contract and command behavior introduced in PR #135.

Suggested reviewers: geoffgeoffgeoff3

Merge Risk: Minimal · up to 1c363

Colors are now addressed by palette slot 1 to 9 in links and the Set Color action, and invalid slots are rejected. No merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: color addressing in annotate links and the Shortcuts action moves from color names to palette slots. The fix(automation) prefix matches the scope. The changeset covers…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: color addressing in annotate links and the Shortcuts action moves from color names to palette slots. The fix(automation) prefix matches the scope. The changeset covers the path format, intents, palette slot lookup, shortcut key raw values, README, and tests, all of which relate to slot-based addressing.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eae29204-861a-4f90-b414-31f0e77bda15
Commits

Reviewing files that changed from the base of the PR and between b6324d3 and 1c3639b.

Files selected for processing: 9

  • Annotate/AnnotateCommand.swift
  • Annotate/AnnotateIntents.swift
  • Annotate/Constants.swift
  • Annotate/ShortcutManager.swift
  • Annotate/URLCommands.swift
  • AnnotateTests/AnnotateCommandTests.swift
  • AnnotateTests/SettingsStoreTests.swift
  • AnnotateTests/URLCommandTests.swift
  • README.md
Files skipped from review as they are similar to previous changes: 2

  • Annotate/AnnotateIntents.swift
  • Annotate/Constants.swift

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@epilande

Copy link
Copy Markdown
Owner Author

Live verification

Head: 1c3639b
Build: signed Apple Development build on macOS 27 (Mac mini)

  • URL scheme color links address palette slots; percent-encoded links are rejected (clip in the PR description)
  • Shortcuts "Set Color" info lists slots 1 red through 9 black
  • Slot parameter metadata is bounded 1–9
  • Slots 1, 4, 9 set red, green, black; toolbar and saved prefs agree
  • Out-of-range slot 0 is rejected: Shortcuts re-prompts for the value and the color is unchanged

Not tested: the number pad and non-US keyboard layouts.

@epilande
epilande merged commit b1976f2 into main Nov 24, 2026
2 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.

1 participant