Add clarifying comments to palette ranking retention logic

- Document why capPaletteSection retains the selected match
- Explain retainedResultId's role in keeping keyboard selection visible
- Clarify secondaryMatches exposes additional match offsets
This commit is contained in:
Jinjing
2026-09-06 15:40:48 -07:00
parent 80df9aabf5
commit 280eadd2eb
3 changed files with 3 additions and 0 deletions
@@ -35,6 +35,7 @@ export function capPaletteSection<T>(
return { visible: items, overflowCount: 0 }
}
const visible = items.slice(0, cap)
// Keep the selected match visible after reranking without increasing the DOM row cap.
let retained: T | undefined
if (retain) {
for (let index = cap; index < items.length; index += 1) {
@@ -22,6 +22,7 @@ export type UseOpenTabSearchOptions = {
enabled: boolean
query: string
worktreeId: string
/** Keyboard-selected result's `id`; keep it inside the display cap while it still matches. */
retainedResultId?: string | null
}
@@ -55,6 +55,7 @@ export type BrowserPaletteSearchResult = {
/** Raw page URL, so callers can dedupe a row against another list of destinations. */
url: string
secondaryText: string
/** Matched formatted/raw URLs with highlight offsets into each `text`; exposes hits beyond the displayed URL. */
secondaryMatches: readonly { text: string; ranges: readonly MatchRange[] }[]
workspaceLabel: string | null
repoName: string