Skip to content

Commit b1787af

Browse files
Address Copilot review feedback
- Fix pika://set/... URL parsing: pass arg1 (hex) not arg2 (nil) to handleSet - Skip pushUndo() in recordHistory() when history is empty to avoid restoring an empty snapshot on first undo - Guard against empty history in swap() to prevent index-out-of-range crash - Remove stale isActivePair reference from ColorPair comment (active tracking is now by id, not hex equality) - Fix history toggle hidden shortcut: ⌘Y → plain H to match storyboard/docs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent dba78b8 commit b1787af

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

Pika/Services/ColorPair.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ struct ColorPair: Codable, Identifiable, Equatable {
1111
var backgroundColor: NSColor { Self.colorFromHex(backgroundHex) }
1212

1313
// Reconstructs the color in Defaults[.colorSpace] — the same space toHexString()
14-
// reads from. This makes set() a no-op (colorSpace → colorSpace), so the stored
15-
// hex round-trips exactly and isActivePair comparison always holds.
14+
// reads from. This makes set() a no-op (colorSpace → colorSpace) so the stored
15+
// hex round-trips exactly.
1616
private static func colorFromHex(_ hex: String) -> NSColor {
1717
let fallback = NSColor.black.usingColorSpace(Defaults[.colorSpace]) ?? .black
1818
let h = hex.replacingOccurrences(of: "#", with: "")

Pika/Services/Eyedroppers.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Eyedroppers: ObservableObject {
3939
return
4040
}
4141

42-
pushUndo()
42+
if !history.isEmpty { pushUndo() }
4343
let pair = ColorPair(id: UUID(), foregroundHex: fgHex, backgroundHex: bgHex, date: Date())
4444
var updated = [pair] + history
4545
if updated.count > ColorPair.maxHistory {
@@ -56,6 +56,7 @@ class Eyedroppers: ObservableObject {
5656
background.color = temp
5757

5858
var history = Defaults[.colorHistory]
59+
guard !history.isEmpty else { return }
5960
let index = activeIndex
6061
let entry = history[index]
6162
history[index] = ColorPair(

Pika/Services/URLSchemeHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class URLSchemeHandler: NSObject {
2828
case "pick": handlePick(task: task)
2929
case "system": handleSystem(task: task)
3030
case "copy": handleCopy(task: task)
31-
case "set": handleSet(task: task, hex: arg2)
31+
case "set": handleSet(task: task, hex: arg1)
3232
case "history": handleHistory(task: task)
3333
case "window": handleWindow(task: task, arg1: arg1, arg2: arg2)
3434
case "appearance": handleAppearance(task: task)

Pika/Views/NavigationMenu.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct NavigationMenu: View {
7070
historyDrawerVisible.toggle()
7171
}
7272
})
73-
.keyboardShortcut("y", modifiers: .command)
73+
.keyboardShortcut("h", modifiers: [])
7474
}
7575
.opacity(0)
7676
.frame(width: 0, height: 0)

0 commit comments

Comments
 (0)