Skip to content

The agent that grows with you

fix(desktop): keep gateway search shortcut local

David Dudok de Wite999df46fa20
diff --git a/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx b/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx
index 4ef8ab9ec89..7ae606241fb 100644
--- a/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx
+++ b/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx
@@ -3,6 +3,7 @@ import { atom } from 'nanostores'
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { DesktopConnectionsRegistry } from '@/global'
+import { $findInPage } from '@/store/find-in-page'
import { ConnectionSwitcher } from './connection-switcher'
@@ -104,6 +105,7 @@ afterEach(() => {
visible: true
})
$pendingConnectionId.set(null)
+ $findInPage.set({ active: false, query: '', matchOrdinal: 0, matchCount: 0 })
})
describe('ConnectionSwitcher', () => {
@@ -248,9 +250,11 @@ describe('ConnectionSwitcher', () => {
fireEvent.keyDown(search, { key: 'ArrowDown' })
expect(globalThis.document.activeElement).toBe(result)
+ $findInPage.set({ active: true, query: '', matchOrdinal: 0, matchCount: 0 })
result.focus()
fireEvent.keyDown(result, { key: 'f', metaKey: true })
expect(globalThis.document.activeElement).toBe(search)
+ expect($findInPage.get().active).toBe(false)
fireEvent.keyDown(search, { key: 'Escape' })
expect(screen.queryByPlaceholderText('Search gateways…')).toBeNull()
diff --git a/apps/desktop/src/app/chat/sidebar/connection-switcher.tsx b/apps/desktop/src/app/chat/sidebar/connection-switcher.tsx
index c0b4f861412..87c81f610dd 100644
--- a/apps/desktop/src/app/chat/sidebar/connection-switcher.tsx
+++ b/apps/desktop/src/app/chat/sidebar/connection-switcher.tsx
@@ -34,6 +34,7 @@ import {
refreshConnectionsRegistry,
selectConnection
} from '@/store/connections'
+import { closeFindBar } from '@/store/find-in-page'
import { notifyError } from '@/store/notifications'
export function ConnectionSwitcher({ onConnect }: { onConnect: () => void }) {
@@ -160,6 +161,10 @@ export function ConnectionSwitcher({ onConnect }: { onConnect: () => void }) {
if (searchable && (event.metaKey || event.ctrlKey) && event.key.toLocaleLowerCase() === 'f') {
event.preventDefault()
event.stopPropagation()
+ // The app-level keybind sees the chord at window capture before
+ // this portal and may open Find in page. This menu owns the chord
+ // while it is open, so close that surface before focusing here.
+ closeFindBar()
searchInputRef.current?.focus()
searchInputRef.current?.select()
}