From 96cd5b7c5a7f8c0af1d5395547436b3ee63a40b7 Mon Sep 17 00:00:00 2001 From: Jack Wotherspoon Date: Sat, 14 Mar 2026 19:53:04 +0100 Subject: [PATCH] chore: update --- .../cli/src/ui/components/PoliciesDialog.tsx | 16 +++++++++------- .../__snapshots__/PoliciesDialog.test.tsx.snap | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/ui/components/PoliciesDialog.tsx b/packages/cli/src/ui/components/PoliciesDialog.tsx index f3aef1ce7e..a02320e01f 100644 --- a/packages/cli/src/ui/components/PoliciesDialog.tsx +++ b/packages/cli/src/ui/components/PoliciesDialog.tsx @@ -7,14 +7,15 @@ import type React from 'react'; import { useState, useMemo, useEffect, useCallback } from 'react'; import { Box, Text } from 'ink'; -import { AsyncFzf } from 'fzf'; +import { AsyncFzf, type FzfResultItem } from 'fzf'; import { PolicyDecision, type PolicyRule } from '@google/gemini-cli-core'; import { theme } from '../semantic-colors.js'; import { useKeypress, type Key } from '../hooks/useKeypress.js'; import { useSearchBuffer } from '../hooks/useSearchBuffer.js'; import { TextInput } from './shared/TextInput.js'; import { TabHeader, type Tab } from './shared/TabHeader.js'; -import { keyMatchers, Command } from '../keyMatchers.js'; +import { Command } from '../key/keyMatchers.js'; +import { useKeyMatchers } from '../hooks/useKeyMatchers.js'; import { buildPolicyListItems, type PolicyListItem, @@ -46,15 +47,12 @@ const TABS = [ }, ] as const; -interface FzfResult { - item: PolicyListItem; -} - export function PoliciesDialog({ rules, toolDisplayNames, onClose, }: PoliciesDialogProps): React.JSX.Element { + const keyMatchers = useKeyMatchers(); const { terminalHeight, terminalWidth, staticExtraHeight, constrainHeight } = useUIState(); @@ -172,7 +170,11 @@ export function PoliciesDialog({ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const results = await fzf.find(searchQuery); if (!active) return; - setFilteredItems(results.map((r: FzfResult) => r.item)); + const matched: PolicyListItem[] = []; + results.forEach((r: FzfResultItem) => { + matched.push(r.item); + }); + setFilteredItems(matched); }; void doSearch(); diff --git a/packages/cli/src/ui/components/__snapshots__/PoliciesDialog.test.tsx.snap b/packages/cli/src/ui/components/__snapshots__/PoliciesDialog.test.tsx.snap index d83739eebc..e2ea782d7e 100644 --- a/packages/cli/src/ui/components/__snapshots__/PoliciesDialog.test.tsx.snap +++ b/packages/cli/src/ui/components/__snapshots__/PoliciesDialog.test.tsx.snap @@ -30,7 +30,7 @@ exports[`PoliciesDialog > renders with Allow tab active by default 1`] = ` │ │ │ │ │ 3 Allow policies │ -│ (↑↓ navigate, type to search, Tab to cycle tabs, Esc close) │ +│ (Use ↑↓ to navigate, ←/→ or Tab to cycle, Esc to close) │ │ │ ╰──────────────────────────────────────────────────────────────────────────────╯ "