Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(desktop): add command palette and shortcuts settings

Josué7349a8186be0
diff --git a/desktop-app/src/__tests__/desktopCommands.test.ts b/desktop-app/src/__tests__/desktopCommands.test.ts
index 60b7e10d4..bee0d6285 100644
--- a/desktop-app/src/__tests__/desktopCommands.test.ts
+++ b/desktop-app/src/__tests__/desktopCommands.test.ts
@@ -5,6 +5,7 @@ import {
desktopBindingCollisionKey,
formatDesktopShortcut,
getDesktopCommand,
+ isDesktopCommandEligible,
matchDesktopCommand,
} from '../desktopCommands.js'
@@ -68,4 +69,14 @@ describe('Desktop command registry', () => {
expect(matchDesktopCommand(input({ key: '9' }), 'darwin', 'host')?.id).toBe('tabs.selectLast')
expect(DESKTOP_COMMANDS.some(command => command.id === 'tabs.select9')).toBe(false)
})
+
+ it('enables commands from the same registry context used by keyboard and palette actions', () => {
+ const context = { tabCount: 1, searchableContent: false, composerAvailable: false }
+ expect(isDesktopCommandEligible(getDesktopCommand('tabs.select1'), context)).toBe(true)
+ expect(isDesktopCommandEligible(getDesktopCommand('tabs.select2'), context)).toBe(false)
+ expect(isDesktopCommandEligible(getDesktopCommand('tabs.next'), context)).toBe(false)
+ expect(isDesktopCommandEligible(getDesktopCommand('search.current'), context)).toBe(false)
+ expect(isDesktopCommandEligible(getDesktopCommand('composer.focus'), context)).toBe(false)
+ expect(isDesktopCommandEligible(getDesktopCommand('search.open'), context)).toBe(true)
+ })
})
diff --git a/desktop-app/src/desktopCommands.ts b/desktop-app/src/desktopCommands.ts
index 0c649511b..f3fce2548 100644
--- a/desktop-app/src/desktopCommands.ts
+++ b/desktop-app/src/desktopCommands.ts
@@ -32,6 +32,46 @@ export type DesktopCommandDefinition = {
visibleInSettings: boolean
}
+export type DesktopCommandRuntimeContext = {
+ tabCount: number
+ searchableContent: boolean
+ composerAvailable: boolean
+}
+
+function tabSelectCommand<const Id extends `tabs.select${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}`>(
+ id: Id,
+ tabIndex: number
+) {
+ const number = tabIndex + 1
+ return {
+ id,
+ label: `Select tab ${number}`,
+ description: `Switch to chat tab ${number}.`,
+ group: 'Navigation' as const,
+ order: 30 + tabIndex,
+ defaultBinding: { key: String(number), mod: true as const },
+ sources: ['host', 'sandbox'] as const,
+ eligibility: 'tab-index' as const,
+ tabIndex,
+ editingPolicy: 'allow' as const,
+ modalPolicy: 'block' as const,
+ actionOwner: 'renderer' as const,
+ visibleInPalette: true,
+ visibleInSettings: true,
+ }
+}
+
+const TAB_SELECT_COMMANDS = [
+ tabSelectCommand('tabs.select1', 0),
+ tabSelectCommand('tabs.select2', 1),
+ tabSelectCommand('tabs.select3', 2),
+ tabSelectCommand('tabs.select4', 3),
+ tabSelectCommand('tabs.select5', 4),
+ tabSelectCommand('tabs.select6', 5),
+ tabSelectCommand('tabs.select7', 6),
+ tabSelectCommand('tabs.select8', 7),
+] as const
+
const definitions = [
{
id: 'chat.newTab',
@@ -63,22 +103,7 @@ const definitions = [
visibleInPalette: true,
visibleInSettings: true,
},
- ...Array.from({ length: 8 }, (_, index) => ({
- id: `tabs.select${index + 1}` as const,
- label: `Select tab ${index + 1}`,
- description: `Switch to chat tab ${index + 1}.`,
- group: 'Navigation' as const,
- order: 30 + index,
- defaultBinding: { key: String(index + 1), mod: true as const },
- sources: ['host', 'sandbox'] as const,
- eligibility: 'tab-index' as const,
- tabIndex: index,
- editingPolicy: 'allow' as const,
- modalPolicy: 'block' as const,
- actionOwner: 'renderer' as const,
- visibleInPalette: true,
- visibleInSettings: true,
- })),
+ ...TAB_SELECT_COMMANDS,
{
id: 'tabs.selectLast',
label: 'Select last tab',
@@ -226,6 +251,20 @@ export function getDesktopCommand(id: DesktopCommandId): DesktopCommandDefinitio
return command
}
+export function isDesktopCommandEligible(
+ command: DesktopCommandDefinition,
+ context: DesktopCommandRuntimeContext
+): boolean {
+ if (command.eligibility === 'always') return true
+ if (command.eligibility === 'tab-exists') return context.tabCount > 0
+ if (command.eligibility === 'multiple-tabs') return context.tabCount > 1
+ if (command.eligibility === 'tab-index') {
+ return command.tabIndex !== undefined && command.tabIndex < context.tabCount
+ }
+ if (command.eligibility === 'searchable-content') return context.searchableContent
+ return context.composerAvailable
+}
+
export function platformFromNode(platform: NodeJS.Platform): DesktopShortcutPlatform {
if (platform === 'darwin' || platform === 'win32') return platform
return 'linux'
diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsx
index aae483f76..3333287f0 100644
--- a/desktop-app/ui/src/App.tsx
+++ b/desktop-app/ui/src/App.tsx
@@ -13,6 +13,7 @@ import { AppHeader } from '@components/AppHeader'
import { BootSplash } from '@components/BootSplash'
import { ChatLocalSearch } from '@components/ChatLocalSearch'
import { ChatTabs } from '@components/ChatTabs'
+import { CommandPalette } from '@components/CommandPalette'
import { Button, ToastStack } from '@components/Common'
import { ConfirmDialog } from '@components/ConfirmDialog'
import { GfsImagePreview } from '@components/GfsImagePreview'
@@ -78,7 +79,12 @@ import { UnavailablePage } from '@pages/UnavailablePage'
import { WorkflowsPage } from '@pages/WorkflowsPage'
import type { PendingSandboxUiDeepLink, SandboxUiDeepLinkEnvelope } from '@/App.types'
import type { ActiveSandboxUiApp, NavItem, ThemeMode } from '@/uiTypes'
-import { type DesktopCommandId, getDesktopCommand } from '../../src/desktopCommands'
+import {
+ type DesktopCommandId,
+ getDesktopCommand,
+ isDesktopCommandEligible,
+ platformFromNavigator,
+} from '../../src/desktopCommands'
type PendingSandboxUiDeepLinkLaunch = {
linkId: number
@@ -257,6 +263,8 @@ export function App() {
const [globalSearchFocusRequestId, setGlobalSearchFocusRequestId] = React.useState(0)
const [chatLocalSearchOpen, setChatLocalSearchOpen] = React.useState(false)
const [sandboxLocalSearchRequestId, setSandboxLocalSearchRequestId] = React.useState(0)
+ const [commandPaletteOpen, setCommandPaletteOpen] = React.useState(false)
+ const [settingsShortcutsRequestId, setSettingsShortcutsRequestId] = React.useState(0)
const chatLocalSearchPreviousFocusRef = React.useRef<HTMLElement | null>(null)
const contentPanelRef = React.useRef<HTMLElement | null>(null)
const activeConversationOriginRef = React.useRef<SandboxUiConversationOrigin | null>(null)
@@ -1035,16 +1043,55 @@ export function App() {
setGlobalSearchFocusRequestId(0)
setChatLocalSearchOpen(false)
setSandboxLocalSearchRequestId(0)
+ setCommandPaletteOpen(false)
+ setSettingsShortcutsRequestId(0)
}, [vm.authenticatedPrincipalIdentity])
- React.useEffect(() => {
- if (!window.clerum.shortcuts) return undefined
- return window.clerum.shortcuts.onCommand((commandId: DesktopCommandId) => {
- if (!vm.isAuthenticated || document.querySelector('[role="dialog"][aria-modal="true"]')) {
+ const desktopCommandContext = React.useMemo(
+ () => ({
+ tabCount: chatViewTabs.tabs.length,
+ searchableContent:
+ (vm.navItem === DESKTOP_ROUTES.apps && Boolean(activeSandboxUiApp)) ||
+ (vm.navItem === DESKTOP_ROUTES.chat && Boolean(vm.activeChatId)),
+ composerAvailable:
+ vm.navItem === DESKTOP_ROUTES.chat &&
+ Boolean(activeChatViewTab(chatViewTabs).agentRef) &&
+ vm.hostRuntimeStatus?.degraded?.reason !== 'llm_key_missing',
+ }),
+ [activeSandboxUiApp, chatViewTabs, vm.activeChatId, vm.hostRuntimeStatus, vm.navItem]
+ )
+
+ const isCommandEligible = React.useCallback(
+ (commandId: DesktopCommandId) =>
+ isDesktopCommandEligible(getDesktopCommand(commandId), desktopCommandContext),
+ [desktopCommandContext]
+ )
+
+ const executeDesktopCommand = React.useCallback(
+ (commandId: DesktopCommandId, source: 'shortcut' | 'palette' = 'shortcut') => {
+ if (!vm.isAuthenticated) return
+ if (source === 'shortcut' && commandPaletteOpen) {
+ if (commandId === 'commands.open') setCommandPaletteOpen(false)
+ return
+ }
+ if (source === 'shortcut' && document.querySelector('[role="dialog"][aria-modal="true"]')) {
return
}
const command = getDesktopCommand(commandId)
const state = chatViewTabsRef.current
+ if (!isDesktopCommandEligible(command, desktopCommandContext)) return
+ if (commandId === 'commands.open') {
+ closeChatLocalSearch(false)
+ setCommandPaletteOpen(true)
+ return
+ }
+ if (commandId === 'settings.shortcuts') {
+ closeChatLocalSearch(false)
+ setCommandPaletteOpen(false)
+ vm.handleNavSelect(DESKTOP_ROUTES.settings)
+ setSettingsShortcutsRequestId(value => value + 1)
+ return
+ }
if (commandId === 'chat.newTab') {
closeChatLocalSearch(false)
handleNewChatViewTab()
@@ -1096,17 +1143,26 @@ export function App() {
setChatLocalSearchOpen(true)
}
}
- })
- }, [
- activeSandboxUiApp,
- closeChatLocalSearch,
- handleCloseChatViewTab,
- handleNewChatViewTab,
- revealChatViewTab,
- vm.activeChatId,
- vm.isAuthenticated,
- vm.navItem,
- ])
+ },
+ [
+ activeSandboxUiApp,
+ closeChatLocalSearch,
+ commandPaletteOpen,
+ desktopCommandContext,
+ handleCloseChatViewTab,
+ handleNewChatViewTab,
+ revealChatViewTab,
+ vm.activeChatId,
+ vm.handleNavSelect,
+ vm.isAuthenticated,
+ vm.navItem,
+ ]
+ )
+
+ React.useEffect(() => {
+ if (!window.clerum.shortcuts) return undefined
+ return window.clerum.shortcuts.onCommand(commandId => executeDesktopCommand(commandId))
+ }, [executeDesktopCommand])
const sandboxUiBoundsRefreshKey = `${sidebarCollapsed ? 'collapsed' : 'expanded'}:${
appNotificationDrawerOpen ? 'notification-drawer-open' : 'notification-drawer-closed'
@@ -1637,7 +1693,9 @@ export function App() {
boundsRefreshKey={sandboxUiBoundsRefreshKey}
conversationOrigin={sandboxUiConversationOrigin}
currentTeamId={vm.currentTeamId}
- headerShellOverlayOpen={headerShellOverlayOpen}
+ headerShellOverlayOpen={
+ headerShellOverlayOpen || commandPaletteOpen
+ }
sidebarShellOverlayOpen={sidebarSettingsMenuOpen}
toastShellOverlayOpen={vm.toasts.length > 0}
shortcutApp={activeSandboxUiApp}
@@ -1654,6 +1712,7 @@ export function App() {
)}
{vm.navItem === DESKTOP_ROUTES.settings && (
<SettingsPage
+ shortcutsFocusRequestId={settingsShortcutsRequestId}
notificationSettings={vm.notificationSettings}
desktopNotificationPermission={vm.desktopNotificationPermission}
themeMode={themeMode}
@@ -1679,6 +1738,14 @@ export function App() {
</section>
</section>
</main>
+ {commandPaletteOpen ? (
+ <CommandPalette
+ platform={platformFromNavigator(navigator.platform)}
+ isEligible={isCommandEligible}
+ onClose={() => setCommandPaletteOpen(false)}
+ onExecute={commandId => executeDesktopCommand(commandId, 'palette')}
+ />
+ ) : null}
{desktopUpdateRequiredDialog}
{environmentSetupConfirmationDialog}
{environmentSetupSuccessDialog}
diff --git a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
index 03ec0324e..f3a25cb66 100644
--- a/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
+++ b/desktop-app/ui/src/__tests__/App.deepLinks.test.tsx
@@ -22,8 +22,17 @@ const appHeaderHarness = vi.hoisted(() => ({
const chatLocalSearchHarness = vi.hoisted(() => ({ rendered: vi.fn() }))
+const commandPaletteHarness = vi.hoisted(() => ({
+ props: null as null | {
+ isEligible: (commandId: DesktopCommandId) => boolean
+ onClose: () => void
+ onExecute: (commandId: DesktopCommandId) => void
+ },
+}))
+
const sandboxUiPageHarness = vi.hoisted(() => ({
props: null as null | {
+ headerShellOverlayOpen?: boolean
shortcutOpenRequestId?: number
localSearchRequestId?: number
onEmbeddedAppOpening?: (app: {
@@ -60,6 +69,12 @@ vi.mock('@components/ChatLocalSearch', () => ({
return null
},
}))
+vi.mock('@components/CommandPalette', () => ({
+ CommandPalette: (props: NonNullable<typeof commandPaletteHarness.props>) => {
+ commandPaletteHarness.props = props
+ return <div role="dialog" aria-modal="true" aria-label="Command palette" />
+ },
+}))
vi.mock('@components/BootSplash', () => ({ BootSplash: () => null }))
vi.mock('@components/Common', () => ({ Button: () => null, ToastStack: () => null }))
vi.mock('@components/ConfirmDialog', () => ({
@@ -83,7 +98,15 @@ vi.mock('@pages/SandboxUiPage', () => ({
return null
},
}))
-vi.mock('@pages/SettingsPage', () => ({ SettingsPage: () => null }))
+const settingsPageHarness = vi.hoisted(() => ({
+ props: null as null | { shortcutsFocusRequestId?: number },
+}))
+vi.mock('@pages/SettingsPage', () => ({
+ SettingsPage: (props: NonNullable<typeof settingsPageHarness.props>) => {
+ settingsPageHarness.props = props
+ return null
+ },
+}))
vi.mock('@pages/TeamDetailsPage', () => ({ TeamDetailsPage: () => null }))
vi.mock('@pages/TeamsPage', () => ({ TeamsPage: () => null }))
vi.mock('@pages/UnavailablePage', () => ({ UnavailablePage: () => null }))
@@ -188,6 +211,8 @@ describe('App deep-link orchestration', () => {
confirmDialogHarness.props = null
appHeaderHarness.props = null
chatLocalSearchHarness.rendered.mockReset()
+ commandPaletteHarness.props = null
+ settingsPageHarness.props = null
sandboxUiPageHarness.props = null
acknowledgeDeepLink.mockResolvedValue(undefined)
listApps.mockResolvedValue({ apps: [] })
@@ -280,6 +305,40 @@ describe('App deep-link orchestration', () => {
expect(appHeaderHarness.props?.searchFocusRequestId).toBe(0)
})
+ it('opens the palette, executes eligible registry actions, and captures the sandbox view', () => {
+ currentController = makeController({
+ initialExperienceLoading: false,
+ navItem: DESKTOP_ROUTES.apps,
+ selectedAgent: 'alpha',
+ } as Partial<AppController>)
+ render(<App />)
+ act(() => {
+ sandboxUiPageHarness.props?.onEmbeddedAppOpening?.({
+ appRef: 'ns/app',
+ label: 'App',
+ defaultPath: '/',
+ })
+ emitCommand?.('commands.open')
+ })
+
+ expect(commandPaletteHarness.props).not.toBeNull()
+ expect(sandboxUiPageHarness.props?.headerShellOverlayOpen).toBe(true)
+ expect(commandPaletteHarness.props?.isEligible('search.current')).toBe(true)
+
+ act(() => commandPaletteHarness.props?.onExecute('search.open'))
+ expect(appHeaderHarness.props?.searchFocusRequestId).toBe(1)
+ })
+
+ it('opens Settings Shortcuts through the registered palette action', () => {
+ currentController = makeController({ initialExperienceLoading: false })
+ render(<App />)
+ act(() => emitCommand?.('commands.open'))
+ act(() => commandPaletteHarness.props?.onExecute('settings.shortcuts'))
+
+ expect(currentController.handleNavSelect).toHaveBeenCalledWith(DESKTOP_ROUTES.settings)
+ expect(settingsPageHarness.props?.shortcutsFocusRequestId).toBe(1)
+ })
+
afterEach(() => {
vi.useRealTimers()
})
diff --git a/desktop-app/ui/src/components/CommandPalette/CommandPalette.test.tsx b/desktop-app/ui/src/components/CommandPalette/CommandPalette.test.tsx
new file mode 100644
index 000000000..5bfaa12b2
--- /dev/null
+++ b/desktop-app/ui/src/components/CommandPalette/CommandPalette.test.tsx
@@ -0,0 +1,72 @@
+// @vitest-environment jsdom
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, fireEvent, render, screen } from '@testing-library/react'
+import { CommandPalette } from '.'
+
+afterEach(cleanup)
+
+describe('CommandPalette', () => {
+ it('filters commands only, navigates, executes eligible actions, and closes', () => {
+ const onExecute = vi.fn()
+ const onClose = vi.fn()
+ render(
+ <CommandPalette
+ platform="darwin"
+ isEligible={id => id !== 'search.current'}
+ onClose={onClose}
+ onExecute={onExecute}
+ />
+ )
+ const input = screen.getByRole('textbox', { name: 'Search commands' })
+ expect(document.activeElement).toBe(input)
+ expect(screen.getByText('New chat tab')).toBeTruthy()
+ expect(screen.queryByText('Search Results')).toBeNull()
+
+ fireEvent.change(input, { target: { value: 'current content' } })
+ const disabledCommand = screen.getByRole('option', { name: /Search current content/ })
+ expect(disabledCommand.hasAttribute('disabled')).toBe(true)
+ fireEvent.click(disabledCommand)
+ expect(onExecute).not.toHaveBeenCalled()
+
+ fireEvent.change(input, { target: { value: 'new chat' } })
+ fireEvent.keyDown(input, { key: 'Enter' })
+ expect(onExecute).toHaveBeenCalledWith('chat.newTab')
+ fireEvent.keyDown(input, { key: 'Escape' })
+ expect(onClose).toHaveBeenCalledOnce()
+ })
+
+ it('supports click, wrapping arrows, focus trap, and focus restoration', () => {
+ const previous = document.createElement('button')
+ document.body.append(previous)
+ previous.focus()
+ const onExecute = vi.fn()
+ const { unmount } = render(
+ <CommandPalette
+ platform="win32"
+ isEligible={() => true}
+ onClose={vi.fn()}
+ onExecute={onExecute}
+ />
+ )
+ const dialog = screen.getByRole('dialog', { name: 'Command palette' })
+ fireEvent.keyDown(dialog, { key: 'ArrowUp' })
+ fireEvent.keyDown(dialog, { key: 'Enter' })
+ expect(onExecute).toHaveBeenCalled()
+ expect(screen.getByText('Ctrl+K')).toBeTruthy()
+ fireEvent.click(screen.getByRole('option', { name: /Keyboard shortcuts/ }))
+ expect(onExecute).toHaveBeenLastCalledWith('settings.shortcuts')
+
+ const input = screen.getByRole('textbox', { name: 'Search commands' })
+ input.focus()
+ fireEvent.keyDown(input, { key: 'Tab', shiftKey: true })
+ expect(document.activeElement).not.toBe(input)
+ unmount()
+ return new Promise<void>(resolve =>
+ requestAnimationFrame(() => {
+ expect(document.activeElement).toBe(previous)
+ previous.remove()
+ resolve()
+ })
+ )
+ })
+})
diff --git a/desktop-app/ui/src/components/CommandPalette/index.tsx b/desktop-app/ui/src/components/CommandPalette/index.tsx
new file mode 100644
index 000000000..6fcdc7962
--- /dev/null
+++ b/desktop-app/ui/src/components/CommandPalette/index.tsx
@@ -0,0 +1,143 @@
+import { useEffect, useMemo, useRef, useState } from 'react'
+import { Button, TextInput } from '@components/Common'
+import {
+ DESKTOP_COMMANDS,
+ type DesktopCommandId,
+ formatDesktopShortcut,
+} from '../../../../src/desktopCommands'
+import type { CommandPaletteProps } from './types'
+
+export function CommandPalette({ platform, isEligible, onClose, onExecute }: CommandPaletteProps) {
+ const [query, setQuery] = useState('')
+ const [selectedId, setSelectedId] = useState<DesktopCommandId | null>(null)
+ const dialogRef = useRef<HTMLDivElement | null>(null)
+ const inputRef = useRef<HTMLInputElement | null>(null)
+ const previousFocusRef = useRef<HTMLElement | null>(null)
+ const commands = useMemo(() => {
+ const normalized = query.trim().toLocaleLowerCase()
+ return DESKTOP_COMMANDS.filter(command => command.visibleInPalette)
+ .filter(command =>
+ normalized
+ ? `${command.label} ${command.description} ${command.group}`
+ .toLocaleLowerCase()
+ .includes(normalized)
+ : true
+ )
+ .sort((left, right) => left.order - right.order)
+ }, [query])
+ const eligibleCommands = commands.filter(command => isEligible(command.id as DesktopCommandId))
+
+ useEffect(() => {
+ previousFocusRef.current = document.activeElement as HTMLElement | null
+ inputRef.current?.focus()
+ return () => {
+ const previous = previousFocusRef.current
+ requestAnimationFrame(() => {
+ if (previous?.isConnected) previous.focus()
+ })
+ }
+ }, [])
+
+ useEffect(() => {
+ if (selectedId && eligibleCommands.some(command => command.id === selectedId)) return
+ setSelectedId((eligibleCommands[0]?.id as DesktopCommandId | undefined) ?? null)
+ }, [eligibleCommands, selectedId])
+
+ const moveSelection = (delta: 1 | -1) => {
+ if (!eligibleCommands.length) return
+ const currentIndex = eligibleCommands.findIndex(command => command.id === selectedId)
+ const nextIndex =
+ currentIndex < 0
+ ? 0
+ : (currentIndex + delta + eligibleCommands.length) % eligibleCommands.length
+ setSelectedId(eligibleCommands[nextIndex]!.id as DesktopCommandId)
+ }
+
+ const execute = (commandId: DesktopCommandId) => {
+ if (!isEligible(commandId)) return
+ onExecute(commandId)
+ }
+
+ return (
+ <div className="command-palette-backdrop" role="presentation">
+ <div
+ ref={dialogRef}
+ aria-label="Command palette"
+ aria-modal="true"
+ className="command-palette"
+ onKeyDown={event => {
+ if (event.key === 'Escape') {
+ event.preventDefault()
+ onClose()
+ } else if (event.key === 'ArrowDown') {
+ event.preventDefault()
+ moveSelection(1)
+ } else if (event.key === 'ArrowUp') {
+ event.preventDefault()
+ moveSelection(-1)
+ } else if (event.key === 'Enter' && selectedId) {
+ event.preventDefault()
+ execute(selectedId)
+ } else if (event.key === 'Tab') {
+ const focusable = Array.from(
+ dialogRef.current?.querySelectorAll<HTMLElement>(
+ 'input:not([disabled]), button:not([disabled])'
+ ) ?? []
+ )
+ const first = focusable[0]
+ const last = focusable.at(-1)
+ if (event.shiftKey && document.activeElement === first && last) {
+ event.preventDefault()
+ last.focus()
+ } else if (!event.shiftKey && document.activeElement === last && first) {
+ event.preventDefault()
+ first.focus()
+ }
+ }
+ }}
+ role="dialog"
+ >
+ <div className="command-palette__header">
+ <TextInput
+ ref={inputRef}
+ aria-label="Search commands"
+ onChange={event => setQuery(event.currentTarget.value)}
+ placeholder="Type a command"
+ value={query}
+ />
+ </div>
+ <div className="command-palette__list" role="listbox" aria-label="Desktop commands">
+ {commands.length ? (
+ commands.map(command => {
+ const commandId = command.id as DesktopCommandId
+ const eligible = isEligible(commandId)
+ const selected = eligible && selectedId === commandId
+ return (
+ <Button
+ aria-selected={selected}
+ className={`command-palette__item${selected ? ' is-selected' : ''}`}
+ color="neutral"
+ disabled={!eligible}
+ key={command.id}
+ onClick={() => execute(commandId)}
+ role="option"
+ variant="ghost"
+ >
+ <span className="command-palette__item-copy">
+ <strong>{command.label}</strong>
+ <span>{command.description}</span>
+ </span>
+ {command.defaultBinding ? (
+ <kbd>{formatDesktopShortcut(command.defaultBinding, platform)}</kbd>
+ ) : null}
+ </Button>
+ )
+ })
+ ) : (
+ <p className="command-palette__empty">No matching commands.</p>
+ )}
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/desktop-app/ui/src/components/CommandPalette/types.ts b/desktop-app/ui/src/components/CommandPalette/types.ts
new file mode 100644
index 000000000..281e7b24d
--- /dev/null
+++ b/desktop-app/ui/src/components/CommandPalette/types.ts
@@ -0,0 +1,8 @@
+import type { DesktopCommandId, DesktopShortcutPlatform } from '../../../../src/desktopCommands'
+
+export type CommandPaletteProps = {
+ platform: DesktopShortcutPlatform
+ isEligible: (commandId: DesktopCommandId) => boolean
+ onClose: () => void
+ onExecute: (commandId: DesktopCommandId) => void
+}
diff --git a/desktop-app/ui/src/pages/SettingsPage.tsx b/desktop-app/ui/src/pages/SettingsPage.tsx
index fa8269a57..131206b72 100644
--- a/desktop-app/ui/src/pages/SettingsPage.tsx
+++ b/desktop-app/ui/src/pages/SettingsPage.tsx
@@ -24,6 +24,11 @@ import type {
ThemeMode,
Tone,
} from '@/uiTypes'
+import {
+ DESKTOP_COMMANDS,
+ formatDesktopShortcut,
+ platformFromNavigator,
+} from '../../../src/desktopCommands'
import type {
DependencyHealth,
DesktopAppInfo,
@@ -34,7 +39,14 @@ import type {
import type { SettingsPageProps } from './SettingsPage.types'
type NotificationPreferenceSection = 'inApp' | 'desktop'
-type SettingsTab = 'account' | 'appearance' | 'notifications' | 'plugins' | 'social' | 'information'
+type SettingsTab =
+ | 'account'
+ | 'appearance'
+ | 'notifications'
+ | 'plugins'
+ | 'shortcuts'
+ | 'social'
+ | 'information'
type EndpointDiagnostics = {
appInfo: DesktopAppInfo | null
@@ -279,6 +291,7 @@ function socialChannelLabel(medium: string): string {
}
export function SettingsPage({
+ shortcutsFocusRequestId = 0,
notificationSettings,
desktopNotificationPermission,
themeMode,
@@ -316,6 +329,14 @@ export function SettingsPage({
accounts: [],
})
const [socialChannelsLoading, setSocialChannelsLoading] = useState(true)
+ const shortcutPlatform = platformFromNavigator(navigator.platform)
+ const shortcutCommands = DESKTOP_COMMANDS.filter(
+ command => command.visibleInSettings && command.defaultBinding
+ ).sort((left, right) => left.order - right.order)
+
+ useEffect(() => {
+ if (shortcutsFocusRequestId > 0) setActiveSettingsTab('shortcuts')
+ }, [shortcutsFocusRequestId])
const runtimeConfigOptions = runtimeConfigState?.options || []
const activeRuntimeConfigId = runtimeConfigState?.activeOptionId ?? ''
@@ -550,6 +571,16 @@ export function SettingsPage({
Social channels
</TabButton>
) : null}
+ <TabButton
+ active={activeSettingsTab === 'shortcuts'}
+ className="page-tab"
+ id="settings-tab-shortcuts"
+ role="tab"
+ aria-controls="settings-panel-shortcuts"
+ onClick={() => setActiveSettingsTab('shortcuts')}
+ >
+ Shortcuts
+ </TabButton>
<TabButton
active={activeSettingsTab === 'information'}
className="page-tab"
@@ -563,6 +594,66 @@ export function SettingsPage({
</div>
<div className="page-layout settings-layout">
+ {activeSettingsTab === 'shortcuts' ? (
+ <section
+ className="settings-tab-panel"
+ id="settings-panel-shortcuts"
+ role="tabpanel"
+ aria-labelledby="settings-tab-shortcuts"
+ >
+ <section
+ className="page-card settings-card"
+ aria-labelledby="settings-shortcuts-heading"
+ >
+ <div className="page-card__header">
+ <div className="settings-card-title-row">
+ <span className="settings-card-title-icon" aria-hidden="true">
+ <IconSettings />
+ </span>
+ <div>
+ <h3 id="settings-shortcuts-heading">Keyboard shortcuts</h3>
+ <p className="muted">Desktop commands available from the keyboard.</p>
+ </div>
+ </div>
+ </div>
+ <div
+ aria-label="Keyboard shortcuts"
+ className="da-grid settings-shortcuts-grid"
+ role="table"
+ style={
+ {
+ '--da-grid-cols': 'minmax(12ch, 0.55fr) minmax(0, 1.45fr)',
+ } as React.CSSProperties
+ }
+ >
+ <div className="da-grid__head" role="row">
+ <span className="da-grid__col-header" role="columnheader">
+ Shortcut
+ </span>
+ <span className="da-grid__col-header" role="columnheader">
+ Action
+ </span>
+ </div>
+ <div className="da-grid__body" role="rowgroup">
+ {shortcutCommands.map(command => (
+ <div className="da-grid__row da-grid__row--compact" key={command.id} role="row">
+ <span className="da-grid__cell" role="cell">
+ <kbd>
+ {formatDesktopShortcut(command.defaultBinding!, shortcutPlatform)}
+ </kbd>
+ </span>
+ <span className="da-grid__cell settings-shortcuts-action" role="cell">
+ <strong>{command.label}</strong>
+ <span>{command.description}</span>
+ </span>
+ </div>
+ ))}
+ </div>
+ </div>
+ </section>
+ </section>
+ ) : null}
+
{activeSettingsTab === 'account' ? (
<section
className="settings-tab-panel"
diff --git a/desktop-app/ui/src/pages/SettingsPage.types.ts b/desktop-app/ui/src/pages/SettingsPage.types.ts
index f5556912d..8c2e95e5d 100644
--- a/desktop-app/ui/src/pages/SettingsPage.types.ts
+++ b/desktop-app/ui/src/pages/SettingsPage.types.ts
@@ -7,6 +7,7 @@ import type {
import type { UserNotificationPreferences } from '../../../src/types'
export type SettingsPageProps = {
+ shortcutsFocusRequestId?: number
notificationSettings: NotificationSettings
desktopNotificationPermission: DesktopNotificationPermission
themeMode: ThemeMode
diff --git a/desktop-app/ui/src/pages/__tests__/SettingsPage.test.tsx b/desktop-app/ui/src/pages/__tests__/SettingsPage.test.tsx
index 13886d8ff..138d6011e 100644
--- a/desktop-app/ui/src/pages/__tests__/SettingsPage.test.tsx
+++ b/desktop-app/ui/src/pages/__tests__/SettingsPage.test.tsx
@@ -2,6 +2,11 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { cleanup, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
+import {
+ DESKTOP_COMMANDS,
+ formatDesktopShortcut,
+ platformFromNavigator,
+} from '../../../../src/desktopCommands'
import { AuthContext } from '../../contexts/AuthContext'
import type { AuthContextValue } from '../../contexts/AuthContext'
import { SettingsPage } from '../SettingsPage'
@@ -174,4 +179,34 @@ describe('SettingsPage', () => {
.auth
expect(auth.getDesktopReleaseStatus).toHaveBeenCalledTimes(1)
})
+
+ it('renders the read-only Shortcuts tab from the authoritative registry', async () => {
+ const user = userEvent.setup()
+ renderSettingsPage()
+
+ await user.click(screen.getByRole('tab', { name: 'Shortcuts' }))
+
+ const visibleCommands = DESKTOP_COMMANDS.filter(
+ command => command.visibleInSettings && command.defaultBinding
+ )
+ expect(screen.getAllByRole('row')).toHaveLength(visibleCommands.length + 1)
+ const platform = platformFromNavigator(navigator.platform)
+ for (const command of visibleCommands) {
+ expect(screen.getByText(command.label)).toBeTruthy()
+ expect(
+ screen.getAllByText(formatDesktopShortcut(command.defaultBinding!, platform)).length
+ ).toBeGreaterThan(0)
+ }
+ expect(screen.queryByRole('button', { name: /save|reset/i })).toBeNull()
+ expect(screen.queryByRole('textbox')).toBeNull()
+ })
+
+ it('opens Shortcuts when requested by a registered command', () => {
+ render(
+ <AuthContext.Provider value={makeAuthValue()}>
+ <SettingsPage {...defaultSettingsProps} shortcutsFocusRequestId={1} />
+ </AuthContext.Provider>
+ )
+ expect(screen.getByRole('tabpanel', { name: 'Shortcuts' })).toBeTruthy()
+ })
})
diff --git a/desktop-app/ui/src/styles.css b/desktop-app/ui/src/styles.css
index 4460b3433..c4660d187 100644
--- a/desktop-app/ui/src/styles.css
+++ b/desktop-app/ui/src/styles.css
@@ -5783,6 +5783,113 @@ h3 {
background: rgba(var(--overlay-rgb), 0.42);
}
+.command-palette-backdrop {
+ position: fixed;
+ inset: 0;
+ z-index: 2300;
+ display: grid;
+ place-items: start center;
+ padding: min(18vh, calc(var(--space-5) + var(--space-5) + var(--space-5))) var(--space-4)
+ var(--space-4);
+ background: rgba(var(--overlay-rgb), 0.58);
+ backdrop-filter: blur(10px);
+}
+
+.command-palette {
+ width: min(680px, 100%);
+ max-height: min(640px, 72vh);
+ display: grid;
+ grid-template-rows: auto minmax(0, 1fr);
+ overflow: hidden;
+ border: 1px solid rgba(var(--accent-rgb), 0.34);
+ border-radius: var(--radius-xl);
+ background: var(--surface-strong);
+ box-shadow: var(--shadow-hard);
+}
+
+.command-palette__header {
+ padding: var(--space-3);
+ border-bottom: 1px solid rgba(var(--edge-rgb), 0.3);
+}
+
+.command-palette__header .ui-control {
+ width: 100%;
+}
+
+.command-palette__list {
+ display: grid;
+ align-content: start;
+ gap: var(--space-1);
+ min-height: 0;
+ padding: var(--space-2);
+ overflow-y: auto;
+}
+
+.command-palette__item.ui-button {
+ width: 100%;
+ min-height: 52px;
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto;
+ gap: var(--space-3);
+ padding: var(--space-2) var(--space-3);
+ text-align: left;
+}
+
+.command-palette__item.ui-button:hover:enabled,
+.command-palette__item.ui-button.is-selected {
+ transform: none;
+ filter: none;
+ background: rgba(var(--accent-rgb), 0.16);
+}
+
+.command-palette__item-copy,
+.settings-shortcuts-action {
+ min-width: 0;
+ display: grid;
+ gap: var(--space-0-5);
+}
+
+.command-palette__item-copy strong,
+.settings-shortcuts-action strong {
+ color: var(--text);
+ font-size: var(--font-size-sm);
+ line-height: var(--line-height-tight);
+}
+
+.command-palette__item-copy span,
+.settings-shortcuts-action span {
+ color: var(--text-muted);
+ font-size: var(--font-size-xs);
+ line-height: var(--line-height-normal);
+}
+
+.command-palette kbd,
+.settings-shortcuts-grid kbd {
+ display: inline-flex;
+ width: fit-content;
+ align-items: center;
+ min-height: var(--space-4);
+ padding: var(--space-0-5) var(--space-1-5);
+ border: 1px solid rgba(var(--edge-rgb), 0.44);
+ border-radius: var(--radius-sm);
+ background: var(--surface-soft);
+ color: var(--text-muted);
+ font-family: var(--font-family-mono);
+ font-size: var(--font-size-xs);
+ white-space: nowrap;
+}
+
+.command-palette__empty {
+ margin: 0;
+ padding: var(--space-5) var(--space-3);
+ color: var(--text-muted);
+ text-align: center;
+}
+
+.settings-shortcuts-grid {
+ max-width: 760px;
+}
+
.confirm-dialog {
width: min(360px, 100%);
border-radius: var(--radius-md);