The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): focusing a window no longer throws, so deep links arrive (#130056)
Siddharth Balyan30673a43b9ab
diff --git a/apps/desktop/electron/window-focus-policy.test.ts b/apps/desktop/electron/window-focus-policy.test.tsindex 12e537d9dbf..e2860299f52 100644--- a/apps/desktop/electron/window-focus-policy.test.ts+++ b/apps/desktop/electron/window-focus-policy.test.ts@@ -32,3 +32,17 @@ test('an already-focused window never pumps the OS foreground path', () => {// runs SetForegroundWindow on Windows, dismissing another app's dialog.assert.equal(shouldFocusToTakeKeyboard({ isFocused: () => true }), false)})++test('the policy calls isFocused as a method, the way BrowserWindow needs it', () => {+ // BrowserWindow.isFocused reads its native handle from `this`; destructuring+ // it threw "Object has been destroyed" and dropped every deep link.+ class NativeLikeWindow {+ private readonly focused = false++ isFocused(): boolean {+ return this.focused+ }+ }++ assert.equal(shouldFocusToTakeKeyboard(new NativeLikeWindow()), true)+})diff --git a/apps/desktop/electron/window-focus-policy.ts b/apps/desktop/electron/window-focus-policy.tsindex d1d2ff487dd..893354d4b15 100644--- a/apps/desktop/electron/window-focus-policy.ts+++ b/apps/desktop/electron/window-focus-policy.ts@@ -40,6 +40,8 @@ export function revealAction(windowVisible: boolean): 'showInactive' | 'none' {* doesn't already have it. A `.focus()` call on an already-focused window* is a foreground pump on Windows and a no-op everywhere else — skip it.*/-export function shouldFocusToTakeKeyboard({ isFocused }: FocusPolicyWindow): boolean {- return !isFocused()+export function shouldFocusToTakeKeyboard(win: FocusPolicyWindow): boolean {+ // Call it as a method: BrowserWindow.isFocused reads its native handle from+ // `this`, and a detached call throws "Object has been destroyed".+ return !win.isFocused()}