({ open, onClose })
| 52 | }; |
| 53 | |
| 54 | const NavSearchDialog: React.FC<NavSearchDialogProps> = ({ open, onClose }) => { |
| 55 | const { t } = useI18n('common'); |
| 56 | const { openedWorkspacesList, assistantWorkspacesList, setActiveWorkspace } = useWorkspaceContext(); |
| 57 | const { openScene } = useSceneManager(); |
| 58 | const { switchLeftPanelTab } = useApp(); |
| 59 | const setSelectedAssistantWorkspaceId = useMyAgentStore(s => s.setSelectedAssistantWorkspaceId); |
| 60 | const openNurseryAssistant = useNurseryStore(s => s.openAssistant); |
| 61 | const [query, setQuery] = useState(''); |
| 62 | const [activeIndex, setActiveIndex] = useState(0); |
| 63 | const [flowChatState, setFlowChatState] = useState<FlowChatState>(() => flowChatStore.getState()); |
| 64 | /** Persisted session rows for opened workspaces — filled when dialog opens (search filters client-side). */ |
| 65 | const [persistedOpenWorkspaceSessions, setPersistedOpenWorkspaceSessions] = useState< |
| 66 | Array<{ meta: SessionMetadata; workspace: WorkspaceInfo }> |
| 67 | >([]); |
| 68 | const inputRef = useRef<HTMLInputElement>(null); |
| 69 | const listRef = useRef<HTMLDivElement>(null); |
| 70 | const cardRef = useRef<HTMLDivElement>(null); |
| 71 | |
| 72 | useEffect(() => { |
| 73 | if (!open) return; |
| 74 | const unsub = flowChatStore.subscribe(s => setFlowChatState(s)); |
| 75 | return () => unsub(); |
| 76 | }, [open]); |
| 77 | |
| 78 | useEffect(() => { |
| 79 | if (open) { |
| 80 | setQuery(''); |
| 81 | setActiveIndex(0); |
| 82 | } |
| 83 | }, [open]); |
| 84 | |
| 85 | useEffect(() => { |
| 86 | if (!open) { |
| 87 | setPersistedOpenWorkspaceSessions([]); |
| 88 | return; |
| 89 | } |
| 90 | let cancelled = false; |
| 91 | void (async () => { |
| 92 | try { |
| 93 | const rows: Array<{ meta: SessionMetadata; workspace: WorkspaceInfo }> = []; |
| 94 | for (const w of openedWorkspacesList) { |
| 95 | const list = await sessionAPI.listSessions( |
| 96 | w.rootPath, |
| 97 | w.connectionId ?? undefined, |
| 98 | w.sshHost ?? undefined |
| 99 | ); |
| 100 | for (const meta of list) { |
| 101 | rows.push({ meta, workspace: w }); |
| 102 | } |
| 103 | } |
| 104 | if (!cancelled) { |
| 105 | setPersistedOpenWorkspaceSessions(rows); |
| 106 | } |
| 107 | } catch { |
| 108 | if (!cancelled) { |
| 109 | setPersistedOpenWorkspaceSessions([]); |
| 110 | } |
| 111 | } |
nothing calls this directly
no test coverage detected