(e: React.MouseEvent, projectId: string)
| 36 | }; |
| 37 | |
| 38 | const handleNewSession = async (e: React.MouseEvent, projectId: string) => { |
| 39 | e.stopPropagation(); |
| 40 | const now = new Date().toISOString(); |
| 41 | const session = { id: generateId(), projectId, title: 'New Chat', createdAt: now, updatedAt: now }; |
| 42 | addSession(session); |
| 43 | setActiveSessionId(session.id); |
| 44 | setExpandedProjects((prev) => new Set(prev).add(projectId)); |
| 45 | |
| 46 | try { |
| 47 | const createdSession = await invoke<Session>('create_session', { projectId, title: 'New Chat' }); |
| 48 | const currentSessions = useSessionStore.getState().sessions; |
| 49 | setSessions(currentSessions.map((existing) => (existing.id === session.id ? createdSession : existing))); |
| 50 | setActiveSessionId(createdSession.id); |
| 51 | } catch (error) { |
| 52 | console.error('Failed to persist session creation:', error); |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | const handleDeleteSession = (e: React.MouseEvent, sessionId: string) => { |
| 57 | e.stopPropagation(); |
no test coverage detected