Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ public enum CommandPaletteCatalog {
isTrialing: Bool
) -> [CommandPaletteSection] {
var items: [CommandPaletteItem] = [
CommandPaletteItem(
id: "undo",
label: "Undo",
shortcut: "mod+z",
keywords: ["revert", "back"]),
CommandPaletteItem(
id: "redo",
label: "Redo",
shortcut: "mod+shift+z",
keywords: ["repeat", "forward"]),
CommandPaletteItem(
id: "show-welcome-guide",
label: "Show welcome guide",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ extension NativeCalendarRootModel {
requestLogout()
case "subscribe":
handleShortcut(.otherSubscribe)
case "undo":
undoLastChange()
case "redo":
redoLastChange()
default:
if id.hasPrefix("event-") {
let eventId = String(id.dropFirst("event-".count))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ final class CommandPaletteActionsTests: XCTestCase {
XCTAssertFalse(model.commandPaletteStore.recentCommandIds.contains("recent-today"))
}

func testMoreSectionIncludesUndoAndRedoRows() async throws {
let model = try await makeModel()
model.commandPaletteStore.open()
let ids = Set(model.filteredPaletteSections().flatMap(\.items).map(\.id))
XCTAssertTrue(ids.contains("undo"))
XCTAssertTrue(ids.contains("redo"))
}

func testAboutInvokesNativePresentation() async throws {
let model = try await makeModel()
var presented = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import CompassData
import CompassKit
import SwiftUI

public struct CommandPaletteOverlay: View {
Expand Down Expand Up @@ -111,19 +112,42 @@ public struct CommandPaletteOverlay: View {
}
Spacer()
if let shortcut = item.shortcut {
Text(shortcut)
.font(.rubik(12))
Text(paletteShortcutLabel(shortcut))
.font(.rubik(11))
.foregroundStyle(theme.textMutedColor)
}
}
.padding(.vertical, 6)
.padding(.horizontal, 8)
.background(selected ? theme.accentColor.opacity(0.18) : theme.surfaceColor)
.background(selected ? theme.accentColor.opacity(0.12) : theme.surfaceColor)
.clipShape(RoundedRectangle(cornerRadius: 8))
.overlay {
if selected {
RoundedRectangle(cornerRadius: 8)
.stroke(theme.accentColor, lineWidth: 1)
}
}
}
.buttonStyle(.plain)
.accessibilityValue(selected ? "Selected" : "Not selected")
.accessibilityAddTraits(selected ? .isSelected : [])
.accessibilityIdentifier("compass-native-palette-item-\(item.id)")
}

private func paletteShortcutLabel(_ shortcut: String) -> String {
let normalized = shortcut
.replacingOccurrences(of: "mod+", with: "Mod+")
.replacingOccurrences(of: "shift+", with: "Shift+")
.replacingOccurrences(of: "alt+", with: "Alt+")
let parts = normalized.split(separator: "+").map { part -> String in
let token = String(part)
switch token.lowercased() {
case "mod": return "Mod"
case "shift": return "Shift"
case "alt": return "Alt"
default: return token.count == 1 ? token.uppercased() : token
}
}
return KeycapGlyphs.display(parts)
}
}
Loading