From 89373676e83cb0906f5e36c6ed6ad3fa19bb7d65 Mon Sep 17 00:00:00 2001 From: Vassiliy Yegorov Date: Sun, 14 Jun 2026 08:00:45 +0700 Subject: [PATCH] fix(app): incremental scrollback search Search only ran on Enter; typing merely reset the counter to 0/0, so a visible term showed no matches until the user pressed Enter. run() now takes an optional query override and onChange fires it on every keystroke for search-as-you-type, while Enter/Shift+Enter still navigate matches. Co-Authored-By: Claude Opus 4.8 (1M context) --- app/src/SearchBar.tsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/SearchBar.tsx b/app/src/SearchBar.tsx index eac81fa..1956a51 100644 --- a/app/src/SearchBar.tsx +++ b/app/src/SearchBar.tsx @@ -45,16 +45,17 @@ export function SearchBar({ }; }, [surfaceId]); - function run(forward: boolean) { + function run(forward: boolean, override?: string) { if (!surfaceId) return; const addon = getSearch(surfaceId); - if (!addon || !term) { + const query = override ?? term; + if (!addon || !query) { addon?.clearDecorations(); setCount({ index: -1, total: 0 }); return; } - if (forward) addon.findNext(term, SEARCH_OPTS); - else addon.findPrevious(term, SEARCH_OPTS); + if (forward) addon.findNext(query, SEARCH_OPTS); + else addon.findPrevious(query, SEARCH_OPTS); } return ( @@ -79,9 +80,14 @@ export function SearchBar({ ref={inputRef} value={term} onChange={(e) => { - setTerm(e.target.value); - setCount({ index: -1, total: 0 }); - if (surfaceId) getSearch(surfaceId)?.clearDecorations(); + const value = e.target.value; + setTerm(value); + if (!value) { + setCount({ index: -1, total: 0 }); + if (surfaceId) getSearch(surfaceId)?.clearDecorations(); + } else { + run(true, value); // search-as-you-type + } }} onKeyDown={(e) => { if (e.key === "Enter") {