()
| 293 | }, [messages]); |
| 294 | |
| 295 | const loadSessionHistory = async () => { |
| 296 | if (!session) return; |
| 297 | |
| 298 | try { |
| 299 | setIsLoading(true); |
| 300 | setError(null); |
| 301 | |
| 302 | const history = await api.loadSessionHistory(session.id, session.project_id); |
| 303 | |
| 304 | // Save session data for restoration |
| 305 | if (history && history.length > 0) { |
| 306 | SessionPersistenceService.saveSession( |
| 307 | session.id, |
| 308 | session.project_id, |
| 309 | session.project_path, |
| 310 | history.length |
| 311 | ); |
| 312 | } |
| 313 | |
| 314 | // Convert history to messages format |
| 315 | const loadedMessages: ClaudeStreamMessage[] = history.map(entry => ({ |
| 316 | ...entry, |
| 317 | type: entry.type || "assistant" |
| 318 | })); |
| 319 | |
| 320 | setMessages(loadedMessages); |
| 321 | setRawJsonlOutput(history.map(h => JSON.stringify(h))); |
| 322 | |
| 323 | // After loading history, we're continuing a conversation |
| 324 | setIsFirstPrompt(false); |
| 325 | |
| 326 | // Scroll to bottom after loading history |
| 327 | setTimeout(() => { |
| 328 | if (loadedMessages.length > 0) { |
| 329 | rowVirtualizer.scrollToIndex(loadedMessages.length - 1, { align: 'end', behavior: 'auto' }); |
| 330 | } |
| 331 | }, 100); |
| 332 | } catch (err) { |
| 333 | console.error("Failed to load session history:", err); |
| 334 | setError("Failed to load session history"); |
| 335 | } finally { |
| 336 | setIsLoading(false); |
| 337 | } |
| 338 | }; |
| 339 | |
| 340 | const checkForActiveSession = async () => { |
| 341 | // If we have a session prop, check if it's still active |
no test coverage detected