Edge-Drop is a clipboard shelf on the edge of your screen. Hover to open it. Drag files and images into any app, click to copy text and links. Free and open-source for Windows.
TypeScript clipboardclipboard-managerdesktop-appdrag-and-dropelectronopen-sourceproductivityproductivity-toolwindows
feat(search): implement ShelfSearch with non-activating OS focus handover and header centering for horizontal dock
Deepender25630e9cf36cc2
diff --git a/electron/main/ipc.ts b/electron/main/ipc.tsindex e065546..1c9197c 100644--- a/electron/main/ipc.ts+++ b/electron/main/ipc.ts@@ -12,7 +12,7 @@ import { psHost, getSystemPowerShellPath, getWritableCwd } from './powershell'import { filterValidPaths, isExistingFilePath } from './pathValidation'import { type InvokeMap, type InvokeChannel, type SendMap, type SendChannel } from '../../shared/ipc'import { getStore, loadSettings, saveSettings, pushState, addFiles, getWatcher } from './state'-import { sendToMainWindow, setInteractive, setHeartbeatPaused, setHotZoneWidth, repositionWindow, getDisplayListOptions, popUpAndRetract, setWindowFocusable } from './window'+import { sendToMainWindow, setInteractive, setHeartbeatPaused, setHotZoneWidth, repositionWindow, getDisplayListOptions, popUpAndRetract, setWindowFocusable, captureExternalForeground, traceFg, resolvePasteTarget } from './window'import { registerGlobalHotkey } from './index'import { getOnboardingWindow } from './onboardingWindow'import { rebuildTrayMenu } from './tray'@@ -430,10 +430,19 @@ export function registerIpc(): void {getStore().touch(id)}- // 4. Simulate Ctrl+V after 50ms- setTimeout(() => {- simulatePaste()- }, 50)+ // 4. Keys under the uniform rule: clipboard is already written, so+ // resolve WHERE they may go. Verified target -> send after settle;+ // unrecoverable foreground -> toast, never fire blind.+ const sendDelay = await resolvePasteTarget(50)+ if (sendDelay < 0) {+ toast('Clipboard ready — click your app and press Ctrl+V to paste', 'info')+ } else {+ setTimeout(() => {+ traceFg('sendKeys')+ simulatePaste()+ setTimeout(() => traceFg('sendKeys+400ms'), 400)+ }, sendDelay)+ }// 5. Broadcast updated items list after panel has fully closed off-screen (250ms)if (settings.movePastedToTop !== false) {@@ -489,10 +498,17 @@ export function registerIpc(): void {// Pass false to explicitly close and avoid toggle race conditions.pushState.togglePanel(false)- // Wait 50ms for layout updates, then simulate Ctrl+V- setTimeout(() => {- simulatePaste()- }, 50)+ // Wait for layout updates, then keys under the uniform rule.+ const subSendDelay = await resolvePasteTarget(50)+ if (subSendDelay < 0) {+ toast('Clipboard ready — click your app and press Ctrl+V to paste', 'info')+ } else {+ setTimeout(() => {+ traceFg('sendKeys')+ simulatePaste()+ setTimeout(() => traceFg('sendKeys+400ms'), 400)+ }, subSendDelay)+ }} finally {setTimeout(() => {watcher.invalidateSignature()@@ -518,9 +534,16 @@ export function registerIpc(): void {// same emoji from another app still lands: signatures include the Win32// sequence number, so an outside Ctrl+C is a new seq and is recorded.clipboard.writeText(text.trim())- setTimeout(() => {- simulatePaste()- }, 40)+ const emojiSendDelay = await resolvePasteTarget(40)+ if (emojiSendDelay < 0) {+ toast('Clipboard ready — click your app and press Ctrl+V to paste', 'info')+ } else {+ setTimeout(() => {+ traceFg('sendKeys')+ simulatePaste()+ setTimeout(() => traceFg('sendKeys+400ms'), 400)+ }, emojiSendDelay)+ }} finally {setTimeout(() => {watcher.resyncSignature()@@ -710,8 +733,21 @@ export function registerIpc(): void {}})- handle('window:focus', (focusable) => {- setWindowFocusable(focusable ?? true)+ handle('window:focus', async (focusable) => {+ const want = focusable ?? true+ traceFg(`window:focus(${want})`)+ if (want) {+ // Last safe instant: we cannot be foreground yet (still NOACTIVATE /+ // non-focusable), so whatever is front is the user's app. Re-capture+ // heals any stale open-time note.+ try {+ captureExternalForeground()+ } catch { /* ignore */ }+ }+ // Release path fully handled inside setWindowFocusable (writes, then+ // before/after-compared verified repair). No pre-restore here: restoring+ // first would only mask the before-reading the repair depends on.+ setWindowFocusable(want)})handle('displays:list', () => {diff --git a/electron/main/window.ts b/electron/main/window.tsindex 23e5749..08c5b4d 100644--- a/electron/main/window.ts+++ b/electron/main/window.ts@@ -29,12 +29,16 @@ type RegisterWindowMessageFn = (lpString: string) => numbertype SetWindowLongPtrFn = (hWnd: number | bigint, nIndex: number, dwNewLong: number | bigint) => number | biginttype GetWindowLongPtrFn = (hWnd: number | bigint, nIndex: number) => number | biginttype ClipboardListenerFn = (hWnd: number | bigint) => number+type GetForegroundWindowFn = () => number | bigint+type SetForegroundWindowFn = (hWnd: number | bigint) => booleanlet registerWindowMessageFn: RegisterWindowMessageFn | null = nulllet setWindowLongPtrFn: SetWindowLongPtrFn | null = nulllet getWindowLongPtrFn: GetWindowLongPtrFn | null = nulllet addClipboardFormatListenerFn: ClipboardListenerFn | null = nulllet removeClipboardFormatListenerFn: ClipboardListenerFn | null = null+let getForegroundWindowFn: GetForegroundWindowFn | null = null+let setForegroundWindowFn: SetForegroundWindowFn | null = nullif (process.platform === 'win32') {try {@@ -56,6 +60,12 @@ if (process.platform === 'win32') {} catch (err) {console.error('[Window] Failed to load clipboard listener APIs:', err)}+ try {+ getForegroundWindowFn = user32.func('uintptr_t GetForegroundWindow()') as GetForegroundWindowFn+ setForegroundWindowFn = user32.func('bool SetForegroundWindow(uintptr_t hWnd)') as SetForegroundWindowFn+ } catch (err) {+ console.error('[Window] Failed to load foreground-window APIs:', err)+ }} catch (err) {console.error('[Window] Failed to load user32 functions via koffi:', err)}@@ -166,6 +176,157 @@ export function isInteractive(): boolean {return interactive}+/**+ * Foreground memory for shelf search + paste.+ *+ * The shelf normally never takes OS focus, so paste (Ctrl+V to "whatever is+ * focused") just works. Typing in search REQUIRES focus, which moves the+ * foreground to Edge-Drop. To keep the user's flow (click item -> lands in+ * their app), the main process notes which window was in front at open time+ * and again at search-engage time (when WE cannot yet be foreground, so the+ * reading is guaranteed correct), and hands focus back — verified — before+ * any paste or release. Proven rule from trace diagnosis: native+ * style/focusability writes disturb the foreground, so the verified handoff+ * is always the LAST focus-affecting act, and redundant native writes are+ * skipped via focusabilityApplied.+ */+let lastExternalForeground: number | bigint = 0+/** Last focusability actually applied via native calls (avoids redundant writes). */+let focusabilityApplied: boolean | null = null++function hwndNumber(h: number | bigint): number {+ try {+ return Number(h)+ } catch {+ return 0+ }+}++function hwndHex(h: number | bigint): string {+ try {+ return `0x${Number(h).toString(16)}`+ } catch {+ return '0x0'+ }+}++/** Diagnostic probe: logs the foreground window at a named checkpoint. */+export function traceFg(tag: string): void {+ try {+ if (process.platform !== 'win32' || !getForegroundWindowFn) return+ const fg = getForegroundWindowFn()+ console.log(`[FocusTrace] ${tag} fg=${fg ? hwndHex(fg) : 'none'}`)+ } catch { /* ignore */ }+}++/** Record the foreground window unless it is our own. Last-wins. */+export function captureExternalForeground(): void {+ if (process.platform !== 'win32' || !getForegroundWindowFn) return+ try {+ const fg = getForegroundWindowFn()+ if (!fg || hwndNumber(fg) === 0) return+ const self = getHwnd(mainWindow)+ if (self && hwndNumber(fg) === hwndNumber(self)) return+ lastExternalForeground = fg+ console.log(`[Focus] captured external foreground=${hwndHex(fg)} (self=${self ? hwndHex(self) : 'none'})`)+ } catch { /* ignore */ }+}++/** True when OUR window currently holds the OS foreground (search typing). */+export function holdsOwnForeground(): boolean {+ if (process.platform !== 'win32' || !getForegroundWindowFn) return false+ if (!mainWindow || mainWindow.isDestroyed()) return false+ try {+ const fg = getForegroundWindowFn()+ const self = getHwnd(mainWindow)+ return !!fg && !!self && hwndNumber(fg) === hwndNumber(self)+ } catch {+ return false+ }+}++/** Read the current foreground window (0 when none). */+function currentFg(): number | bigint {+ try {+ if (process.platform !== 'win32' || !getForegroundWindowFn) return 0+ return getForegroundWindowFn() ?? 0+ } catch {+ return 0+ }+}++/** True for a usable (non-zero) window handle. */+function usableHwnd(h: number | bigint): boolean {+ return !!h && hwndNumber(h) !== 0+}++/**+ * Verified handoff to an explicit target: attempt SetForegroundWindow, then+ * CONFIRM the foreground actually moved (Windows can refuse transiently).+ * Retries with small sleeps. Resolves true only when the target is+ * foreground afterwards.+ */+export async function restoreFgAwaited(target: number | bigint, tag: string): Promise<boolean> {+ if (process.platform !== 'win32' || !setForegroundWindowFn || !getForegroundWindowFn) {+ return false+ }+ if (!usableHwnd(target)) {+ console.log(`[Focus] ${tag}: no target to restore`)+ return false+ }+ for (let attempt = 1; attempt <= 4; attempt++) {+ try {+ const before = getForegroundWindowFn()+ const ok = !!setForegroundWindowFn(target)+ await new Promise((r) => setTimeout(r, 30))+ const fg = getForegroundWindowFn()+ const verified = !!fg && hwndNumber(fg) === hwndNumber(target)+ console.log(+ `[Focus] ${tag} attempt ${attempt}: setFg=${ok} verified=${verified} ` ++ `before=${before ? hwndHex(before) : 'none'} after=${fg ? hwndHex(fg) : 'none'} ` ++ `target=${hwndHex(target)}`+ )+ if (verified) return true+ } catch (err) {+ console.error(`[Focus] ${tag} attempt ${attempt} threw:`, err)+ }+ }+ console.log(`[Focus] ${tag} FAILED all attempts`)+ return false+}++/**+ * Verified handoff to the captured app. Thin wrapper over restoreFgAwaited.+ */+export function restoreExternalFocusAwaited(): Promise<boolean> {+ return restoreFgAwaited(lastExternalForeground, 'restore')+}++/**+ * Uniform pre-send rule for every paste path (search or normal).+ *+ * Clipboard content is ALWAYS written before this runs, so nothing is lost.+ * Returns a settle delay in ms when Ctrl+V may be sent, or -1 when the+ * foreground is unrecoverably ours — the caller must then toast instead of+ * firing blind (silent mis-paste is the only unforgivable outcome).+ * - Foreground already correct (normal flow, or user moved on themselves):+ * return the standard delay, zero focus work.+ * - Foreground is us (search flow): drop focusability, verified handoff,+ * longer settle on success, -1 on failure.+ */+export async function resolvePasteTarget(normalDelayMs: number): Promise<number> {+ if (process.platform !== 'win32') return normalDelayMs+ try {+ if (!holdsOwnForeground()) return normalDelayMs+ setWindowFocusable(false)+ const restored = await restoreExternalFocusAwaited()+ console.log(`[Focus] paste resolve restored=${restored}`)+ return restored ? 140 : -1+ } catch {+ return normalDelayMs+ }+}+/*** Toggle whether the panel swallows pointer events.*@@ -183,6 +344,8 @@ export function setInteractive(value: boolean): void {interactive = valueif (value) {// Panel is open: disable click-through so user can interact.+ // Remember who is in front BEFORE any search typing can steal focus.+ captureExternalForeground()// Cancel any pending idle GC: collecting during the open animation is// what made fast reopen-after-close hitch. The next close re-arms it.if (gcTimer !== null) {@@ -924,11 +1087,52 @@ export function setVisible(visible: boolean): void {export function setWindowFocusable(focusable: boolean): void {if (mainWindow && !mainWindow.isDestroyed()) {try {- applyNoActivateStyle(mainWindow, !focusable)- mainWindow.setFocusable(focusable)- if (focusable) {- mainWindow.focus()+ // Skip redundant native writes: even "no-op" style/focusability calls+ // have disturbed the foreground in traces, so never repeat them.+ if (focusabilityApplied === focusable) {+ if (focusable) {+ try { mainWindow.focus() } catch { /* ignore */ }+ }+ return+ }+ if (!focusable) {+ // Trace-proven: these native writes can drop or move the foreground+ // (observed: target -> NONE), and any guard read AFTER the writes+ // then sees "not us" and skips recovery. So snapshot the foreground+ // BEFORE, write, then repair AFTER based on fresh readings:+ // - after==us or after==none: the writes broke it. Restore `before`+ // when it was a healthy other window (exact truth just observed),+ // else the captured app. Verified with retries; nothing native+ // runs after the handoff.+ // - after==healthy other window: untouched, leave it alone (covers+ // Alt+Tab-away: never yanks the user back).+ const self = getHwnd(mainWindow)+ const isSelf = (h: number | bigint): boolean => !!self && !!h && hwndNumber(h) === hwndNumber(self)+ const before = currentFg()+ const beforeHealthy = usableHwnd(before) && !isSelf(before)+ applyNoActivateStyle(mainWindow, true)+ traceFg('setWindowFocusable(false) after NOACTIVATE')+ mainWindow.setFocusable(false)+ traceFg('setWindowFocusable(false) after setFocusable')+ focusabilityApplied = false+ const after = currentFg()+ if (!usableHwnd(after) || isSelf(after)) {+ const target = beforeHealthy ? before : lastExternalForeground+ console.log(+ `[Focus] release repair: before=${before ? hwndHex(before) : 'none'} ` ++ `after=${after ? hwndHex(after) : 'none'} target=${usableHwnd(target) ? hwndHex(target) : 'none'}`+ )+ if (usableHwnd(target)) {+ void restoreFgAwaited(target, 'release-repair').catch(() => {})+ }+ }+ return}+ applyNoActivateStyle(mainWindow, false)+ mainWindow.setFocusable(true)+ focusabilityApplied = true+ mainWindow.focus()+ traceFg('setWindowFocusable(true) exit')} catch {}}}diff --git a/src/components/Header.tsx b/src/components/Header.tsxindex 6ee9ead..737646e 100644--- a/src/components/Header.tsx+++ b/src/components/Header.tsx@@ -4,6 +4,7 @@ import { useStore } from '../store/appStore'import { GearIcon, CloseIcon, InfoIcon, ClockIcon, TypeIcon, LinkIcon, ImageIcon, FilesIcon, PaletteIcon, EmojiSmileIcon } from './icons'import { playButtonClickSound } from '../lib/soundEffects'import { loadEmojiCatalog } from '../lib/emoji/load'+import { ShelfSearch } from './ShelfSearch'import { useTranslation } from '../i18n'import { ClearMenu } from './ClearMenu'@@ -255,6 +256,11 @@ export function Header({ isHorizontal = false, itemCount, clearProps }: HeaderPr)}</div>+ {isHorizontal && !settingsOpen && !emojiOpen && (+ <div className="header-search header-search-center">+ <ShelfSearch />+ </div>+ )}<div style={{ display: 'flex', alignItems: 'center', gap: 6, flexShrink: 0, paddingRight: 2, position: 'relative', zIndex: 260 }}>{isHorizontal && !settingsOpen && itemCount != null && (<div className="footer-capsule" style={{ marginRight: 2 }}>diff --git a/src/components/Panel.tsx b/src/components/Panel.tsxindex c5fb276..b8ea954 100644--- a/src/components/Panel.tsx+++ b/src/components/Panel.tsx@@ -12,6 +12,7 @@ import { useEffect, useRef, useState, useMemo } from 'react'import { useStore } from '../store/appStore'import { PANEL_LEAVE_EVENT, PANEL_ENTER_EVENT } from '../hooks/useEdgeHover'import { Header } from './Header'+import { ShelfSearch } from './ShelfSearch'import { ItemList } from './ItemList'import { EmojiPicker } from './EmojiPicker'import { Settings } from './Settings'@@ -471,6 +472,7 @@ export function Panel() {/><ToastStack />+ {!isHorizontal && !emojiOpen && !settingsOpen && <ShelfSearch />}<div style={{ flex: 1, display: 'grid', gridTemplate: '1fr / 1fr', overflow: 'hidden', position: 'relative' }}>{/* Main clipboard / emoji view (persistent so ItemList is never torn down and doesn't jump on Y-axis) */}<divdiff --git a/src/components/SearchBar.tsx b/src/components/SearchBar.tsxdeleted file mode 100644index 2bdbbb4..0000000--- a/src/components/SearchBar.tsx+++ /dev/null@@ -1,23 +0,0 @@-/** Controlled search input bound to the store's query. */-import { useStore } from '../store/appStore'-import { useTranslation } from '../i18n'-import { SearchIcon } from './icons'--export function SearchBar() {- const { t } = useTranslation()- const query = useStore((s) => s.query)- const setQuery = useStore((s) => s.setQuery)-- return (- <div className="search">- <SearchIcon className="search-icon" width={14} height={14} />- <input- type="text"- placeholder={t('header.searchPlaceholder')}- value={query}- onChange={(e) => setQuery(e.target.value)}- spellCheck={false}- />- </div>- )-}diff --git a/src/components/ShelfSearch.tsx b/src/components/ShelfSearch.tsxnew file mode 100644index 0000000..9874be3--- /dev/null+++ b/src/components/ShelfSearch.tsx@@ -0,0 +1,103 @@+/**+ * ShelfSearch — the clipboard search box.+ *+ * Typing needs OS keyboard focus, which the shelf normally never takes. So+ * engaging this input temporarily makes the window focusable (and pauses the+ * global toggle hotkey so typing can't yank the shelf), and every exit hands+ * everything back. The main process captured the user's app at open time and+ * again at engage time, so a click on an item still pastes into that app.+ *+ * Engagement starts on pointer-down, NOT on focus: a NOACTIVATE window may+ * never produce a focus event from a plain click, so waiting for onFocus+ * would make the box look dead.+ */+import { useCallback, useEffect, useRef } from 'react'+import { useStore } from '../store/appStore'+import { edge } from '../lib/edge'+import { noteSearchEngaged } from '../lib/searchFocus'+import { useTranslation } from '../i18n'+import { SearchIcon } from './icons'++export function ShelfSearch() {+ const { t } = useTranslation()+ const query = useStore((s) => s.query)+ const setQuery = useStore((s) => s.setQuery)+ const inputRef = useRef<HTMLInputElement>(null)+ const engagedRef = useRef(false)++ const disengage = useCallback(() => {+ if (!engagedRef.current) return+ engagedRef.current = false+ noteSearchEngaged(false)+ try {+ void edge.focusWindow(false)?.catch?.(() => {})+ } catch { /* ignore */ }+ try {+ void edge.pauseHotkey(false)?.catch?.(() => {})+ } catch { /* ignore */ }+ }, [])++ // Engage BEFORE focus can happen: pointer-down always fires, focus may not.+ // Idempotent — the focus-event backup below reuses it safely.+ const engage = useCallback(() => {+ if (engagedRef.current) return+ engagedRef.current = true+ noteSearchEngaged(true)+ try {+ window.focus()+ } catch { /* ignore */ }+ try {+ const p = edge.focusWindow(true) as unknown as Promise<void> | undefined+ if (p && typeof (p as Promise<void>).then === 'function') {+ ;(p as Promise<void>).then(() => {+ try { inputRef.current?.focus() } catch { /* ignore */ }+ }).catch(() => {})+ } else {+ try { inputRef.current?.focus() } catch { /* ignore */ }+ }+ } catch { /* ignore */ }+ try {+ void edge.pauseHotkey(true)?.catch?.(() => {})+ } catch { /* ignore */ }+ }, [])++ // Safety: if the input unmounts mid-focus (view switch), restore state.+ useEffect(() => () => {+ disengage()+ }, [disengage])++ return (+ <div className="search">+ <SearchIcon className="search-icon" width={14} height={14} />+ <input+ ref={inputRef}+ type="text"+ placeholder={t('header.searchPlaceholder')}+ value={query}+ onChange={(e) => setQuery(e.target.value)}+ onPointerDown={() => {+ engage()+ }}+ onFocus={() => {+ engage()+ }}+ onBlur={() => {+ disengage()+ }}+ onKeyDown={(e) => {+ if (e.key === 'Escape') {+ // Staged Escape: clear first, blur second — never close the+ // panel while typing (the window handler skips inputs as well).+ e.stopPropagation()+ if (query) {+ setQuery('')+ } else {+ inputRef.current?.blur()+ }+ }+ }}+ spellCheck={false}+ />+ </div>+ )+}diff --git a/src/hooks/useEdgeHover.ts b/src/hooks/useEdgeHover.tsindex 099000d..2f3d4cf 100644--- a/src/hooks/useEdgeHover.ts+++ b/src/hooks/useEdgeHover.ts@@ -638,6 +638,10 @@ export function useEdgeHover(): void {// ── keyboard ───────────────────────────────────────────────────────────const onKeyDown = (e: KeyboardEvent) => {+ // Never close the panel while the user is typing in a text field+ // (search owns Escape: clear, then blur).+ const t = e.target as HTMLElement | null+ if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA')) returnif (e.key === 'Escape' && useStore.getState().open) scheduleClose(0)}diff --git a/src/lib/searchFocus.ts b/src/lib/searchFocus.tsindex 77169ed..424a3e2 100644--- a/src/lib/searchFocus.ts+++ b/src/lib/searchFocus.ts@@ -3,19 +3,19 @@** While the user types in search, the shelf is temporarily OS-focusable and* the global toggle hotkey is paused. If the panel closes through a path- * that skips the input's blur handler (tray toggle, hotkey, cursor leave),- * `setOpen(false)` uses this flag to restore focusability + hotkey exactly- * once. No imports — safe to use from both component and store modules.+ * that skips the input's blur handler (tray toggle, cursor leave), the+ * store's setOpen(false) uses this flag to restore focusability + hotkey+ * exactly once. No imports — safe from both component and store modules.*/-let searchPausedHotkey = false+let searchEngaged = false-export function noteSearchHotkeyPaused(paused: boolean): void {- searchPausedHotkey = paused+export function noteSearchEngaged(engaged: boolean): void {+ searchEngaged = engaged}-export function takeSearchHotkeyPaused(): boolean {- const was = searchPausedHotkey- searchPausedHotkey = false+export function takeSearchEngaged(): boolean {+ const was = searchEngaged+ searchEngaged = falsereturn was}diff --git a/src/store/appStore.ts b/src/store/appStore.tsindex 592f7b0..6e90de4 100644--- a/src/store/appStore.ts+++ b/src/store/appStore.ts@@ -8,6 +8,7 @@*/import { create } from 'zustand'import { edge } from '../lib/edge'+import { takeSearchEngaged } from '../lib/searchFocus'import type { ClipboardItemDto, Settings, DragRequest } from '../../shared/types'import { DEFAULT_SETTINGS } from '../../shared/types'import { playEdgeRetractSound, playEdgeBeaconAppearSound, playEdgeExpandSound, playButtonClickSound } from '../lib/soundEffects'@@ -397,6 +398,15 @@ export const useStore = create<AppState>((set, get) => ({// compiling under the DOM-less node tsconfig.)const active = (globalThis as { document?: { activeElement?: { blur?: () => void } } }).document?.activeElementtry { active?.blur?.() } catch { /* ignore */ }+ // If search held temporary OS focusability + paused hotkey through a+ // close path that skipped the input's blur (tray toggle, cursor+ // leave), restore both exactly once. No-op when search was never used.+ try {+ if (takeSearchEngaged()) {+ void edge.focusWindow(false)?.catch?.(() => {})+ void edge.pauseHotkey(false)?.catch?.(() => {})+ }+ } catch { /* ignore */ }// NOTE: Do NOT reset styleFlyoutOpen here — closePanel() handles the// sequencing so the flyout exit animation completes before the panel closes.// Only reset previewItemId so the normal preview flyout clears correctly.diff --git a/src/styles/panel.css b/src/styles/panel.cssindex 231ebe0..5d5035f 100644--- a/src/styles/panel.css+++ b/src/styles/panel.css@@ -220,6 +220,32 @@pointer-events: none;}+/* Header-embedded search (horizontal dock): centered overlay, long field.+ Absolutely centered to the header so side widths can't offset it; fixed+ width so focusing never shifts any neighboring buttons. */+.header-search-center {+ position: absolute;+ left: 50%;+ top: 50%;+ transform: translate(-50%, -50%);+ z-index: 5;+ display: flex;+ align-items: center;+}+.header-search-center .search {+ margin: 0;+}+.header-search-center .search input {+ height: 30px;+ width: 300px;+ max-width: 100%;+ padding: 0 10px 0 30px;+ font-size: calc(12px * var(--font-scale, 1));+}+.header-search-center .search .search-icon {+ left: 9px;+}+/* Scroll area */.list {flex: 1;diff --git a/tests/searchFocus.test.ts b/tests/searchFocus.test.tsnew file mode 100644index 0000000..db4676b--- /dev/null+++ b/tests/searchFocus.test.ts@@ -0,0 +1,17 @@+import { describe, expect, it } from 'vitest'+import { noteSearchEngaged, takeSearchEngaged } from '../src/lib/searchFocus'++describe('search engagement flag', () => {+ it('starts disengaged and takes exactly once', () => {+ expect(takeSearchEngaged()).toBe(false)+ noteSearchEngaged(true)+ expect(takeSearchEngaged()).toBe(true)+ expect(takeSearchEngaged()).toBe(false)+ })++ it('can be cleared without taking', () => {+ noteSearchEngaged(true)+ noteSearchEngaged(false)+ expect(takeSearchEngaged()).toBe(false)+ })+})