From 43c90adbc09933d43e1603796e2d933c5858d7a5 Mon Sep 17 00:00:00 2001 From: Kacper Date: Thu, 11 Dec 2025 02:07:15 +0100 Subject: [PATCH] fix: implement copilot suggestions --- app/electron/services/codex-config-manager.js | 1 + app/electron/services/mcp-server-stdio.js | 1 + app/src/components/ui/keyboard-map.tsx | 3 +-- .../keyboard-shortcuts-section.tsx | 1 - app/src/components/views/setup-view.tsx | 24 +++++++++++++------ app/src/hooks/use-window-state.ts | 1 + app/src/store/app-store.ts | 21 ++++++++++------ 7 files changed, 35 insertions(+), 17 deletions(-) diff --git a/app/electron/services/codex-config-manager.js b/app/electron/services/codex-config-manager.js index 9ee0f175..ed324917 100644 --- a/app/electron/services/codex-config-manager.js +++ b/app/electron/services/codex-config-manager.js @@ -350,3 +350,4 @@ class CodexConfigManager { module.exports = new CodexConfigManager(); + diff --git a/app/electron/services/mcp-server-stdio.js b/app/electron/services/mcp-server-stdio.js index f29dbca4..44cdd6b4 100644 --- a/app/electron/services/mcp-server-stdio.js +++ b/app/electron/services/mcp-server-stdio.js @@ -346,3 +346,4 @@ console.error('[McpServerStdio] Starting MCP server for automaker-tools'); console.error(`[McpServerStdio] Project path: ${projectPath}`); console.error(`[McpServerStdio] IPC channel: ${ipcChannel}`); + diff --git a/app/src/components/ui/keyboard-map.tsx b/app/src/components/ui/keyboard-map.tsx index 86051949..76f71d3a 100644 --- a/app/src/components/ui/keyboard-map.tsx +++ b/app/src/components/ui/keyboard-map.tsx @@ -181,7 +181,6 @@ export function KeyboardMap({ onKeySelect, selectedKey, className }: KeyboardMap const isModified = shortcuts.some( (s) => keyboardShortcuts[s] !== DEFAULT_KEYBOARD_SHORTCUTS[s] ); - const hasModifierShortcuts = shortcutInfos.some(s => s.hasModifiers); // Get category for coloring (use first shortcut's category if multiple) const category = shortcuts.length > 0 ? SHORTCUT_CATEGORIES[shortcuts[0]] : null; @@ -193,7 +192,7 @@ export function KeyboardMap({ onKeySelect, selectedKey, className }: KeyboardMap onClick={() => onKeySelect?.(keyDef.key)} className={cn( "relative flex flex-col items-center justify-center rounded-lg border transition-all", - "h-12 min-w-[2.75rem] py-1", + "h-12 min-w-11 py-1", keyDef.width > 1 && `w-[${keyDef.width * 2.75}rem]`, // Base styles !isBound && "bg-sidebar-accent/10 border-sidebar-border hover:bg-sidebar-accent/20", diff --git a/app/src/components/views/settings-view/keyboard-shortcuts/keyboard-shortcuts-section.tsx b/app/src/components/views/settings-view/keyboard-shortcuts/keyboard-shortcuts-section.tsx index 2baf9320..a1fa5e34 100644 --- a/app/src/components/views/settings-view/keyboard-shortcuts/keyboard-shortcuts-section.tsx +++ b/app/src/components/views/settings-view/keyboard-shortcuts/keyboard-shortcuts-section.tsx @@ -1,5 +1,4 @@ import { Button } from "@/components/ui/button"; -import { Label } from "@/components/ui/label"; import { Settings2, Keyboard } from "lucide-react"; interface KeyboardShortcutsSectionProps { diff --git a/app/src/components/views/setup-view.tsx b/app/src/components/views/setup-view.tsx index bcad97f4..cac5e1f1 100644 --- a/app/src/components/views/setup-view.tsx +++ b/app/src/components/views/setup-view.tsx @@ -780,6 +780,22 @@ function CodexSetupStep({ const [apiKey, setApiKey] = useState(""); const [isSavingKey, setIsSavingKey] = useState(false); + // Normalize CLI auth method strings to our store-friendly values + const mapAuthMethod = (method?: string): CodexAuthStatus["method"] => { + switch (method) { + case "cli_verified": + return "cli_verified"; + case "cli_tokens": + return "cli_tokens"; + case "auth_file": + return "api_key"; + case "env_var": + return "env"; + default: + return "none"; + } + }; + const checkStatus = useCallback(async () => { console.log("[Codex Setup] Starting status check..."); setIsChecking(true); @@ -805,13 +821,7 @@ function CodexSetupStep({ setCodexCliStatus(cliStatus); if (result.auth) { - const method = result.auth.method === "cli_verified" || result.auth.method === "cli_tokens" - ? (result.auth.method === "cli_verified" ? "cli_verified" : "cli_tokens") - : result.auth.method === "auth_file" - ? "api_key" - : result.auth.method === "env_var" - ? "env" - : "none"; + const method = mapAuthMethod(result.auth.method); const authStatus: CodexAuthStatus = { authenticated: result.auth.authenticated, diff --git a/app/src/hooks/use-window-state.ts b/app/src/hooks/use-window-state.ts index 3647b892..a54bafd7 100644 --- a/app/src/hooks/use-window-state.ts +++ b/app/src/hooks/use-window-state.ts @@ -53,3 +53,4 @@ export function useWindowState(): WindowState { } + diff --git a/app/src/store/app-store.ts b/app/src/store/app-store.ts index acaf0bc5..21d88563 100644 --- a/app/src/store/app-store.ts +++ b/app/src/store/app-store.ts @@ -50,6 +50,7 @@ export function parseShortcut(shortcut: string): ShortcutKey { const parts = shortcut.split("+").map(p => p.trim()); const result: ShortcutKey = { key: parts[parts.length - 1] }; + // Normalize common OS-specific modifiers (Cmd/Ctrl/Win/Super symbols) into cmdCtrl for (let i = 0; i < parts.length - 1; i++) { const modifier = parts[i].toLowerCase(); if (modifier === "shift") result.shift = true; @@ -65,13 +66,19 @@ export function formatShortcut(shortcut: string, forDisplay = false): string { const parsed = parseShortcut(shortcut); const parts: string[] = []; - // Improved OS detection - let platform: 'darwin' | 'win32' | 'linux' = 'linux'; - if (typeof navigator !== 'undefined') { - const p = navigator.platform.toLowerCase(); - if (p.includes('mac')) platform = 'darwin'; - else if (p.includes('win')) platform = 'win32'; - } + // Prefer User-Agent Client Hints when available; fall back to legacy + const platform: 'darwin' | 'win32' | 'linux' = (() => { + if (typeof navigator === 'undefined') return 'linux'; + + const uaPlatform = (navigator as Navigator & { userAgentData?: { platform?: string } }) + .userAgentData?.platform?.toLowerCase?.(); + const legacyPlatform = navigator.platform?.toLowerCase?.(); + const platformString = uaPlatform || legacyPlatform || ''; + + if (platformString.includes('mac')) return 'darwin'; + if (platformString.includes('win')) return 'win32'; + return 'linux'; + })(); // Primary modifier - OS-specific if (parsed.cmdCtrl) {