From 6d368604a15c26572c0789687db7dd3b12f9e65d Mon Sep 17 00:00:00 2001 From: Grimmer Kang Date: Tue, 7 Apr 2026 20:28:45 +0800 Subject: [PATCH 1/2] fix: Cmd+Ctrl+R focuses window when covered by another app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Normal App mode, if the CodeV window was visible but covered by another app (unfocused), pressing Cmd+Ctrl+R would hide it instead of bringing it to the front. Required two presses to reach top-most. Now the three states are: - Hidden/minimized → show + focus - Visible but unfocused → app.focus({ steal: true }) + focus - Visible AND focused → hide Menu bar mode is unaffected: onBlur auto-hides the window, so the visible-but-unfocused state can't occur there. The new app.focus call is also gated to normal mode as a safeguard. Co-Authored-By: Claude Opus 4.6 (1M context) --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/main.ts | 18 +++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8395276..cbc5cc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.0.72 + +- Fix: `Cmd+Ctrl+R` brings window to front when covered by another app + - Previously: visible-but-unfocused first press hid the window + - Now: visible+unfocused → focus to top; visible+focused → hide + ## 1.0.71 - Fix: use `setActivationPolicy` instead of `app.dock.hide/show` for proper Dock behavior diff --git a/package.json b/package.json index 285f32f..038014a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "CodeV", "productName": "CodeV", - "version": "1.0.71", + "version": "1.0.72", "description": "Quick switcher for VS Code, Cursor, and Claude Code sessions", "repository": { "type": "git", diff --git a/src/main.ts b/src/main.ts index c6f91b2..8f03de6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1327,10 +1327,22 @@ const trayToggleEvtHandler = async () => { const window = getSwitcherWindow(); if (window && window.isVisible() && !window.isMinimized()) { - if (isDebug) { - console.log('Switcher window visible, hiding it'); + if (window.isFocused()) { + if (isDebug) { + console.log('Switcher window visible and focused, hiding it'); + } + hideSwitcherWindow(); + } else { + // Visible but covered by another app — bring to top instead of hiding + if (isDebug) { + console.log('Switcher window visible but unfocused, bringing to front'); + } + if (appMode === 'normal') { + app.focus({ steal: true }); + } + window.show(); + window.focus(); } - hideSwitcherWindow(); } else if (window) { if (isDebug) { console.log('Switcher window exists but hidden, showing it'); From 5933a0ae3560fce7d9cba6edda3c6c6bf294bc62 Mon Sep 17 00:00:00 2001 From: Grimmer Kang Date: Tue, 7 Apr 2026 20:33:21 +0800 Subject: [PATCH 2/2] fix: extend focus-when-covered fix to tray click + Cmd+Ctrl+T Apply the same three-state logic to: - Tray left-click (trayToggleEvtHandler default branch) - Cmd+Ctrl+T Terminal callback For Cmd+Ctrl+T, the visible-but-unfocused branch also sends 'switch-to-terminal' so the user lands on the Terminal tab after the window comes to front (matches the user intent of "I want to use the terminal"). Also adds the missing !window.isMinimized() check to both callbacks for consistency with quickSwitcherCallback. Co-Authored-By: Claude Opus 4.6 (1M context) --- CHANGELOG.md | 6 ++++-- src/main.ts | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbc5cc6..74a86c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,11 @@ ## 1.0.72 -- Fix: `Cmd+Ctrl+R` brings window to front when covered by another app +- Fix: window-toggle actions bring window to front when covered by another app (Normal mode) + - `Cmd+Ctrl+R` (Quick Switcher), `Cmd+Ctrl+T` (Terminal), and tray left-click - Previously: visible-but-unfocused first press hid the window - - Now: visible+unfocused → focus to top; visible+focused → hide + - Now: visible+unfocused → focus to top; visible+focused → hide (or toggle Terminal tab) + - Menu bar mode unaffected (`onBlur` auto-hide makes the state unreachable) ## 1.0.71 diff --git a/src/main.ts b/src/main.ts index 8f03de6..f18a8e5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1002,12 +1002,24 @@ const trayToggleEvtHandler = async () => { showSwitcherWindow(); } else { const window = getSwitcherWindow(); - - if (window && window.isVisible()) { - if (isDebug) { - console.log('is visible, to hide'); + + if (window && window.isVisible() && !window.isMinimized()) { + if (window.isFocused()) { + if (isDebug) { + console.log('is visible and focused, to hide'); + } + hideSwitcherWindow(); + } else { + // Visible but covered by another app — bring to front instead of hiding + if (isDebug) { + console.log('is visible but unfocused, bringing to front'); + } + if (appMode === 'normal') { + app.focus({ steal: true }); + } + window.show(); + window.focus(); } - hideSwitcherWindow(); } else if (window) { if (isDebug) { console.log('is not visible, to show'); @@ -1638,9 +1650,19 @@ const trayToggleEvtHandler = async () => { switcherWindow = createSwitcherWindow(); } const window = getSwitcherWindow(); - if (window && window.isVisible()) { - // If already showing Terminal tab, hide; otherwise switch to Terminal - window.webContents.send('check-terminal-and-hide'); + if (window && window.isVisible() && !window.isMinimized()) { + if (window.isFocused()) { + // If already showing Terminal tab, hide; otherwise switch to Terminal + window.webContents.send('check-terminal-and-hide'); + } else { + // Visible but covered — bring to front and switch to Terminal tab + if (appMode === 'normal') { + app.focus({ steal: true }); + } + window.show(); + window.focus(); + window.webContents.send('switch-to-terminal'); + } } else if (window) { window.webContents.send('switch-to-terminal'); showSwitcherWindow();