Repository customization: per-repo title and color in the sidebar#276
Merged
Repository customization: per-repo title and color in the sidebar#276
Conversation
- New `Customize Repository…` entry on each git repo's ellipsis menu
opens a sheet with title text field and color swatches (default,
six predefined tints, plus a custom rainbow swatch backed by the
system color picker). Saved values land in `sidebar.json` under
each section's optional `title` / `color` fields.
- `RepositoryColor` enum carries the predefined cases plus
`.custom("#RRGGBB")`; legacy `sidebar.json` files round-trip via
`decodeIfPresent` / `encodeIfPresent`.
- `preserveOrphanSections` now propagates `title` and `color` so
customization survives transient orphan reconciles (matching how
`.archived` / `.pinned` curation already survives).
- `.binding(\.customColor)` is gated on `state.color?.isCustom == true`
so a stray sRGB-quantization round-trip can't demote a predefined
pick to a `.custom("#FF3B30")` hex; tapping the rainbow swatch
fires an explicit `selectCustomColor` action that enters custom
mode.
- `requestCustomizeRepository` rejects non-git repos so a future
deeplink or palette entry can't write customization that the
folder row would never render.
- Tests cover the parent reducer save/cancel paths, the binding
promotion contract, and Section codable round-trips. Section /
parser tests live in their owning suites.
- Custom color selection works again. Reverted the binding-gate (`state.color?.isCustom == true`) and the `selectCustomColor` entry action that the previous round added — that combination blocked the very first ColorPicker drag from promoting to `.custom`. Trade-off: a deliberate drag in the panel demotes `.red` to its sRGB-quantized hex, which is correct intent capture. - System color panel no longer outlives the customization sheet. `RepositoryCustomizationView.onDisappear` calls `NSColorPanel.shared.orderOut(nil)`. Combined with the main Window's new `.restorationBehavior(.disabled)`, the panel can't be resurrected at next launch via state restoration. - Force-quit-with-panel-visible now lands on the main window. `mainWindow(from:)`'s fallback filters `NSPanel` instances so `makeKeyAndOrderFront` can't surface a restored color panel as the "main window". - Alt-tab no longer kills the in-progress color panel. `applicationDidBecomeActive` previously called `NSColorPanel.shared.orderOut(nil)` unconditionally, dismissing the user's panel mid-edit on every cmd-tab return. Removed alongside the launch-time orderOut now that `.restorationBehavior(.disabled)` handles resurrection at the source. - Explicit `Remove Repository` no longer leaves a customization tombstone. `.repositoriesRemoved` purges `state.sidebar.sections[id]` before reconcile fires, so re-adding the same path doesn't silently restore the old title / color. `preserveOrphanSections` still keeps customization across transient drops (filesystem flutter). - Dropped `RepositoryColor.hexString` (zero callers; the doc comment described a path that doesn't exist) and updated `displayName`'s docstring to reflect actual usage. - Added a `RepositoriesFeatureCustomizationTests` regression asserting that explicit removal purges the sidebar tombstone.
- Set `NSColorPanel.shared.isRestorable = false` in `applicationDidFinishLaunching` so AppKit stops persisting the panel's visibility across launches. Reverted the main `Window` scene's `.restorationBehavior(.disabled)` — the main window stays restorable, only the system color panel opts out. - Dropped the launch-time `NSColorPanel.shared.orderOut(nil)`; `isRestorable = false` alone handles forward sessions. - Added a regression test pinning the predefined→custom demote on user-driven ColorPicker drags so a future refactor can't silently re-add the binding gate that broke first-drag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sidebar.jsonunder each section's optionaltitle/colorfields. Legacy files round-trip cleanly viadecodeIfPresent/encodeIfPresent.Implementation notes
RepositoryColorenum: predefined cases plus.custom("#RRGGBB"), codable as a string.RepositoryCustomizationFeaturemirrors the canonicalWorktreeCreationPromptFeaturesheet pattern (BindableAction, delegate,.ifLetpresentation).preserveOrphanSectionscarries title/color through transient orphan reconciles so a filesystem-flutter reload doesn't strip the user's tint. Explicit Remove Repository still purges the section so re-adding the same path doesn't silently restore the old customization.requestCustomizeRepositoryrejects non-git repos so a future deeplink or palette entry can't write customization that the folder row would never render.NSColorPanel.shared.isRestorable = falseopts the system color panel out of macOS state restoration so a left-open panel can't outlive the app across launches;.onDisappearon the customize sheet hides it explicitly.mainWindow(from:)filtersNSPanelfrom its fallback so a transient panel can't be surfaced as the main window.Test plan
sidebar.jsonfiles without title/color load unchanged.make checkpasses;make testpasses (new suites:RepositoryColorTests,RepositoriesFeatureCustomizationTests, plus additions toSidebarStateTestsandRepositoryCustomizationFeatureTests).Closes #275