Skip to content

The agent that grows with you

Merge pull request #86847 from NousResearch/salvage/72959-titlebar-tool-count

Tekniume0c73bfece3b
diff --cc apps/desktop/src/components/find-bar.test.tsx
index fcc107eb66d,02448cac78d..4c5f549da1e
--- a/apps/desktop/src/components/find-bar.test.tsx
+++ b/apps/desktop/src/components/find-bar.test.tsx
@@@ -609,61 -617,67 +617,124 @@@ describe('FindBar', () =>
await waitFor(() => expect(screen.queryByRole('search')).toBeNull())
expect(bridge.stopFindInPage).not.toHaveBeenCalled()
})
+
+ it('does not render on overlay routes (settings, command center, …)', () => {
+ // Match isOverlayView: agents, command-center, cron, profiles, settings,
+ // starmap, webhooks. Test with the most commonly hit one.
+ openFindBar()
+ renderFindBar('/settings')
+
+ expect(screen.queryByRole('search')).toBeNull()
+ // The store still has active=true but the component guard suppresses
+ // rendering — a harmless state ghost that the next pathname-change
+ // cleanup will drain via closeFindBar.
+ expect($findInPage.get().active).toBe(true)
+ })
+ })
+
+ // ── Keybind gate: view.findInPage on overlay routes ─────────────────────────
+ // The component guard above proves hidden RENDERING; this proves the keybind
+ // itself never OPENS the bar on an overlay route. Mounted against the real
+ // useKeybinds listener + combo index so a regression in either the handler
+ // wiring or the route classification fails the test.
+
+ function KeybindHarness({ deps }: { deps: KeybindRuntimeDeps }) {
+ useKeybinds(deps)
+
+ return null
+ }
+
+ describe('view.findInPage keybind gate', () => {
+ function renderKeybinds(pathname: string) {
+ const deps: KeybindRuntimeDeps = {
+ toggleCommandCenter: vi.fn(),
+ startFreshSession: vi.fn(),
+ openNewSessionTab: vi.fn(),
+ toggleSelectedPin: vi.fn(),
+ archiveSelectedSession: vi.fn()
+ }
+
+ render(
+ <MemoryRouter initialEntries={[pathname]}>
+ <I18nProvider configClient={null} initialLocale="en">
+ <KeybindHarness deps={deps} />
+ </I18nProvider>
+ </MemoryRouter>
+ )
+
+ return deps
+ }
+
+ it('does not open the find bar for mod+f while an overlay route is showing', () => {
+ renderKeybinds('/settings')
+
+ fireEvent.keyDown(window, { key: 'f', metaKey: true })
+
+ expect($findInPage.get().active).toBe(false)
+ })
+
+ it('opens the find bar for mod+f on a normal chat route', () => {
+ renderKeybinds('/session/a')
+
+ fireEvent.keyDown(window, { key: 'f', metaKey: true })
+
+ expect($findInPage.get().active).toBe(true)
+ })
})
+
+// ── Files-pane-aware positioning ────────────────────────────────────────────
+
+describe('FindBar files pane positioning', () => {
+ function mountAside(width = 240) {
+ // eslint-disable-next-line no-restricted-globals -- the component queries the live document for the aside
+ const aside = document.createElement('aside')
+ aside.setAttribute('aria-label', 'Right sidebar')
+ // jsdom has no layout — stub the rect the component measures.
+ aside.getBoundingClientRect = () =>
+ ({ left: window.innerWidth - width, width } as DOMRect)
+ // eslint-disable-next-line no-restricted-globals -- must land in the real DOM the component measures
+ document.body.appendChild(aside)
+
+ return aside
+ }
+
+ afterEach(() => {
+ // eslint-disable-next-line no-restricted-globals -- cleanup of the real DOM the component measures
+ for (const aside of document.querySelectorAll('aside[aria-label="Right sidebar"]')) {
+ aside.remove()
+ }
+ })
+
+ it('keeps the default right-4 position when the pane is closed', async () => {
+ openFindBar()
+ renderFindBar()
+
+ const bar = await screen.findByRole('search')
+ expect(bar.style.right).toBe('')
+ })
+
+ it('parks the bar left of the pane when it is open', async () => {
+ mountAside(240)
+ openFindBar()
+ renderFindBar()
+
+ const bar = await screen.findByRole('search')
+ await waitFor(() => expect(bar.style.right).toBe('calc(240px + 0.75rem)'))
+ })
+
+ it('re-measures when the pane opens or closes while the bar is up', async () => {
+ openFindBar()
+ renderFindBar()
+
+ const bar = await screen.findByRole('search')
+ expect(bar.style.right).toBe('')
+
+ // Pane opens mid-session: the MutationObserver path must re-measure.
+ const aside = mountAside(300)
+ await waitFor(() => expect(bar.style.right).toBe('calc(300px + 0.75rem)'))
+
+ // Pane closes again: the bar falls back to the default position.
+ aside.remove()
+ await waitFor(() => expect(bar.style.right).toBe(''))
+ })
+})