Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(search): advance on-screen highlight on prev/next; a11y + clarity polish

enesfedfe429e59f
diff --git a/src/renderer/components/FindBar.tsx b/src/renderer/components/FindBar.tsx
index b9c1094f4..f51259e0a 100644
--- a/src/renderer/components/FindBar.tsx
+++ b/src/renderer/components/FindBar.tsx
@@ -55,13 +55,33 @@ export function FindBar({
}}
/>
<span className="term-node__find-count">{matchCount ? `${matchIndex} / ${matchCount}` : '0 / 0'}</span>
- <button className="term-node__find-btn" title="Previous (Shift+Enter)" onClick={onPrev} disabled={!matchCount}>
+ <button
+ type="button"
+ className="term-node__find-btn"
+ title="Previous (Shift+Enter)"
+ aria-label="Previous match"
+ onClick={onPrev}
+ disabled={!matchCount}
+ >
↑
</button>
- <button className="term-node__find-btn" title="Next (Enter)" onClick={onNext} disabled={!matchCount}>
+ <button
+ type="button"
+ className="term-node__find-btn"
+ title="Next (Enter)"
+ aria-label="Next match"
+ onClick={onNext}
+ disabled={!matchCount}
+ >
↓
</button>
- <button className="term-node__find-btn" title="Close (Esc)" onClick={onClose}>
+ <button
+ type="button"
+ className="term-node__find-btn"
+ title="Close (Esc)"
+ aria-label="Close search"
+ onClick={onClose}
+ >
✕
</button>
</div>
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 5001f9ff2..eb448dbd5 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -92,6 +92,29 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
readBuffer
})
+ // Single source of truth for the on-screen highlight colors (used by both the
+ // initial-highlight effect and the prev/next nav handlers below).
+ const findOpts = {
+ decorations: {
+ matchBackground: '#ffd54f55',
+ activeMatchBackground: '#ffb300',
+ matchOverviewRuler: '#ffd54f',
+ activeMatchColorOverviewRuler: '#ffb300'
+ }
+ }
+
+ // Navigation steps the hook's authoritative cursor AND xterm's on-screen highlight.
+ // The two intentionally desync (the hook also counts transcript-only matches that
+ // xterm can't highlight) — that's expected; this only tracks navigation direction.
+ const handleNext = useCallback(() => {
+ search.next()
+ if (search.query.trim()) searchAddonRef.current?.findNext(search.query, findOpts)
+ }, [search])
+ const handlePrev = useCallback(() => {
+ search.prev()
+ if (search.query.trim()) searchAddonRef.current?.findPrevious(search.query, findOpts)
+ }, [search])
+
// The bridge handles are added/positioned dynamically for bridge-capable nodes; make
// React Flow re-measure them so edges anchor to the (centered) handle, not a stale position.
useEffect(() => {
@@ -342,14 +365,7 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
sa.clearDecorations()
return
}
- sa.findNext(search.query, {
- decorations: {
- matchBackground: '#ffd54f55',
- activeMatchBackground: '#ffb300',
- matchOverviewRuler: '#ffd54f',
- activeMatchColorOverviewRuler: '#ffb300'
- }
- })
+ sa.findNext(search.query, findOpts)
}, [search.query, searchOpen])
// Cmd/Ctrl+F toggles the find-bar while this node is hovered. No main-process interception
@@ -532,8 +548,8 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
matchIndex={search.matchIndex}
matchCount={search.matchCount}
current={search.current}
- onNext={search.next}
- onPrev={search.prev}
+ onNext={handleNext}
+ onPrev={handlePrev}
onClose={() => setSearchOpen(false)}
/>
)}
diff --git a/src/renderer/terminal/useTerminalSearch.ts b/src/renderer/terminal/useTerminalSearch.ts
index 626ef1cdb..64d221046 100644
--- a/src/renderer/terminal/useTerminalSearch.ts
+++ b/src/renderer/terminal/useTerminalSearch.ts
@@ -86,6 +86,8 @@ export function useTerminalSearch({
}, [query, source])
// Reset the cursor to the first match whenever the result set changes.
+ // `matches` is a fresh array on every query/source change (useMemo), so this
+ // intentionally jumps back to the first match on each new search — not a bug.
useEffect(() => {
setCursor(0)
}, [matches])