()
| 289 | React.useEffect(() => { |
| 290 | let cancelled = false; |
| 291 | const initializeFlowChat = async () => { |
| 292 | if (!currentWorkspace?.rootPath) return; |
| 293 | |
| 294 | // Remote session index and turns live under ~/.bitfun/remote_ssh/... (local disk). |
| 295 | // Always initialize FlowChat so historical sessions list even when SSH is not connected yet. |
| 296 | try { |
| 297 | const explicitPreferredMode = |
| 298 | sessionStorage.getItem('bitfun:flowchat:preferredMode') || |
| 299 | undefined; |
| 300 | if (explicitPreferredMode) { |
| 301 | sessionStorage.removeItem('bitfun:flowchat:preferredMode'); |
| 302 | } |
| 303 | |
| 304 | const initializationPreferredMode = |
| 305 | currentWorkspace.workspaceKind === WorkspaceKind.Assistant |
| 306 | ? 'Claw' |
| 307 | : explicitPreferredMode; |
| 308 | |
| 309 | const flowChatManager = FlowChatManager.getInstance(); |
| 310 | const hasHistoricalSessions = await flowChatManager.initialize( |
| 311 | currentWorkspace.rootPath, |
| 312 | initializationPreferredMode, |
| 313 | currentWorkspace.workspaceKind === WorkspaceKind.Remote |
| 314 | ? currentWorkspace.connectionId |
| 315 | : undefined, |
| 316 | currentWorkspace.workspaceKind === WorkspaceKind.Remote |
| 317 | ? currentWorkspace.sshHost |
| 318 | : undefined |
| 319 | ); |
| 320 | if (cancelled) { |
| 321 | return; |
| 322 | } |
| 323 | |
| 324 | let sessionId: string | undefined; |
| 325 | const { flowChatStore } = await import('@/flow_chat/store/FlowChatStore'); |
| 326 | if (cancelled) { |
| 327 | return; |
| 328 | } |
| 329 | if (!hasHistoricalSessions) { |
| 330 | const initialSessionMode = |
| 331 | currentWorkspace.workspaceKind === WorkspaceKind.Assistant |
| 332 | ? 'Claw' |
| 333 | : explicitPreferredMode || 'agentic'; |
| 334 | sessionId = await flowChatManager.createChatSession({}, initialSessionMode); |
| 335 | if (cancelled) { |
| 336 | return; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | const activeSessionId = sessionId || flowChatStore.getState().activeSessionId; |
| 341 | if (currentWorkspace.workspaceKind === WorkspaceKind.Assistant && activeSessionId) { |
| 342 | ensureAssistantBootstrapForWorkspace(currentWorkspace, activeSessionId); |
| 343 | } |
| 344 | |
| 345 | const pendingDescription = sessionStorage.getItem('pendingProjectDescription'); |
| 346 | if (pendingDescription && pendingDescription.trim()) { |
| 347 | sessionStorage.removeItem('pendingProjectDescription'); |
| 348 |
no test coverage detected