Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): r3-l1 render Shift modifier as text
Josuéd3730c204952
diff --git a/desktop-app/src/__tests__/desktopCommands.test.ts b/desktop-app/src/__tests__/desktopCommands.test.tsindex 0c7eaae78..69c041fa2 100644--- a/desktop-app/src/__tests__/desktopCommands.test.ts+++ b/desktop-app/src/__tests__/desktopCommands.test.ts@@ -6,7 +6,6 @@ import {DESKTOP_COMMANDS,type DesktopShortcutInput,desktopBindingCollisionKey,- formatDesktopShortcut,getDesktopCommand,isDesktopCommandEligible,matchDesktopCommand,@@ -68,10 +67,7 @@ describe('Desktop command registry', () => {}})- it('formats and matches Command on macOS and Ctrl on Windows', () => {- const binding = getDesktopCommand('search.current').defaultBinding!- expect(formatDesktopShortcut(binding, 'darwin')).toBe('⌘⇧F')- expect(formatDesktopShortcut(binding, 'win32')).toBe('Ctrl+Shift+F')+ it('matches Command on macOS and Ctrl on Windows', () => {expect(matchDesktopCommand(input({ shift: true }), 'darwin', 'host')?.id).toBe('search.current')expect(matchDesktopCommand(input({ meta: false, control: true, shift: true }), 'win32', 'sandbox')@@ -80,9 +76,6 @@ describe('Desktop command registry', () => {})it('binds only Open Settings in the approved core palette action set', () => {- const settings = getDesktopCommand('settings.open')- expect(formatDesktopShortcut(settings.defaultBinding!, 'darwin')).toBe('⌘,')- expect(formatDesktopShortcut(settings.defaultBinding!, 'win32')).toBe('Ctrl+,')expect(matchDesktopCommand(input({ key: ',' }), 'darwin', 'sandbox')?.id).toBe('settings.open')for (const id of ['auth.logout',@@ -111,12 +104,6 @@ describe('Desktop command registry', () => {})it('uses Control for tab cycling on macOS to avoid the reserved Command+Tab app switcher', () => {- const next = getDesktopCommand('tabs.next').defaultBinding!- const previous = getDesktopCommand('tabs.previous').defaultBinding!- expect(formatDesktopShortcut(next, 'darwin')).toBe('⌃Tab')- expect(formatDesktopShortcut(previous, 'darwin')).toBe('⌃⇧Tab')- expect(formatDesktopShortcut(next, 'win32')).toBe('Ctrl+Tab')- expect(formatDesktopShortcut(previous, 'win32')).toBe('Ctrl+Shift+Tab')expect(matchDesktopCommand(input({ key: 'Tab', meta: false, control: true }), 'darwin', 'host')?.id).toBe('tabs.next')diff --git a/desktop-app/src/desktopCommands.ts b/desktop-app/src/desktopCommands.tsindex 5ea73f47b..4e2293d5f 100644--- a/desktop-app/src/desktopCommands.ts+++ b/desktop-app/src/desktopCommands.ts@@ -554,9 +554,9 @@ export function formatDesktopShortcut(): string {const key = binding.key === 'Tab' ? 'Tab' : binding.key.toUpperCase()if (platform === 'darwin' && binding.modifier === 'mod') {- return `⌘${binding.shift ? '⇧' : ''}${key}`+ return binding.shift ? `⌘ Shift ${key}` : `⌘${key}`}- if (platform === 'darwin') return `⌃${binding.shift ? '⇧' : ''}${key}`+ if (platform === 'darwin') return binding.shift ? `⌃ Shift ${key}` : `⌃${key}`return `Ctrl+${binding.shift ? 'Shift+' : ''}${key}`}diff --git a/desktop-app/ui/src/__tests__/desktopShortcutLabels.test.tsx b/desktop-app/ui/src/__tests__/desktopShortcutLabels.test.tsxnew file mode 100644index 000000000..374684dcf--- /dev/null+++ b/desktop-app/ui/src/__tests__/desktopShortcutLabels.test.tsx@@ -0,0 +1,116 @@+// @vitest-environment jsdom+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { cleanup, render, screen } from '@testing-library/react'+import {+ type SemanticShortcutBinding,+ bindingMatchesInput,+ formatDesktopShortcut,+} from '../../../src/desktopCommands'+import { CommandPalette } from '../components/CommandPalette'+import { SettingsPage } from '../pages/SettingsPage'++vi.mock('@contexts/AuthContext', () => ({+ useAuthContext: () => ({+ email: '[email protected]',+ me: { email: '[email protected]', name: 'User' },+ runtimeConfigState: {+ configured: false,+ isLocalhost: false,+ selectorVisible: false,+ activeOptionId: null,+ envKey: 'test',+ storagePath: '/test',+ options: [],+ },+ }),+}))++beforeEach(() => {+ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ socialChannels: {+ getSummary: vi.fn(async () => ({ accounts: [], targets: [] })),+ },+ },+ })+})++afterEach(() => {+ cleanup()+ delete (window as { clerum?: unknown }).clerum+})++const modShiftF: SemanticShortcutBinding = { key: 'f', modifier: 'mod', shift: true }++describe('Desktop shortcut labels', () => {+ it('renders Shift text from the authoritative formatter without changing matching', () => {+ expect(formatDesktopShortcut(modShiftF, 'darwin')).toBe('⌘ Shift F')+ expect(formatDesktopShortcut(modShiftF, 'win32')).toBe('Ctrl+Shift+F')+ expect(formatDesktopShortcut({ key: 'Tab', modifier: 'control', shift: true }, 'darwin')).toBe(+ '⌃ Shift Tab'+ )+ expect(formatDesktopShortcut({ key: 'f', modifier: 'mod' }, 'darwin')).toBe('⌘F')+ expect(formatDesktopShortcut({ key: 'f', modifier: 'mod' }, 'win32')).toBe('Ctrl+F')+ expect(formatDesktopShortcut({ key: ',', modifier: 'mod' }, 'darwin')).toBe('⌘,')+ expect(formatDesktopShortcut({ key: ',', modifier: 'mod' }, 'win32')).toBe('Ctrl+,')+ expect(formatDesktopShortcut({ key: 'Tab', modifier: 'control' }, 'darwin')).toBe('⌃Tab')+ expect(formatDesktopShortcut({ key: 'Tab', modifier: 'control' }, 'win32')).toBe('Ctrl+Tab')++ expect(+ bindingMatchesInput(+ modShiftF,+ {+ alt: false,+ control: false,+ isComposing: false,+ key: 'f',+ meta: true,+ shift: true,+ type: 'keyDown',+ },+ 'darwin'+ )+ ).toBe(true)+ })++ it('renders textual Shift in the command palette', () => {+ render(+ <CommandPalette+ platform="darwin"+ isEligible={() => true}+ onClose={vi.fn()}+ onExecute={vi.fn()}+ />+ )+ expect(screen.getAllByText('⌘ Shift F').length).toBeGreaterThan(0)+ expect(screen.queryByText(/⇧/)).toBeNull()+ })++ it('renders textual Shift in Settings shortcuts', () => {+ Object.defineProperty(window.navigator, 'platform', { configurable: true, value: 'MacIntel' })+ render(+ <SettingsPage+ channelNotificationPreferences={{+ channelFallbackEnabled: false,+ preferredMedium: null,+ verifiedMedia: [],+ }}+ channelNotificationPreferencesLoading={false}+ channelNotificationPreferencesSaving={false}+ desktopNotificationPermission="default"+ notificationSettings={{ desktop: 'when_app_unfocused', inApp: 'always', soundVolume: 50 }}+ onNotificationSoundVolumeChange={vi.fn()}+ onNotify={vi.fn()}+ onPlayNotificationSoundPreview={vi.fn()}+ onSaveChannelNotificationPreferences={vi.fn(async () => undefined)}+ onSaveNotificationSettings={vi.fn(async () => 'default')}+ onThemeModeChange={vi.fn()}+ shortcutsFocusRequestId={1}+ themeMode="dark"+ />+ )+ expect(screen.getAllByText('⌘ Shift F').length).toBeGreaterThan(0)+ expect(screen.queryByText(/⇧/)).toBeNull()+ })+})