(sessionId: string)
| 293 | |
| 294 | // Confirm delete session |
| 295 | const confirmDeleteSession = async (sessionId: string) => { |
| 296 | const api = getElectronAPI(); |
| 297 | if (!api?.sessions) return; |
| 298 | |
| 299 | const result = await api.sessions.delete(sessionId); |
| 300 | if (result.success) { |
| 301 | const refetchResult = await invalidateSessions(); |
| 302 | if (currentSessionId === sessionId) { |
| 303 | // Switch to another session using fresh data, excluding the deleted session |
| 304 | // Filter to sessions within the same worktree to avoid jumping to a different worktree |
| 305 | const freshSessions = refetchResult?.data ?? []; |
| 306 | const activeSessionsList = freshSessions.filter((s) => { |
| 307 | if (s.isArchived || s.id === sessionId) return false; |
| 308 | const sessionDir = s.workingDirectory || s.projectPath; |
| 309 | return pathsEqual(sessionDir, effectiveWorkingDirectory); |
| 310 | }); |
| 311 | if (activeSessionsList.length > 0) { |
| 312 | onSelectSession(activeSessionsList[0].id); |
| 313 | } else { |
| 314 | onSelectSession(null); |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | setSessionToDelete(null); |
| 319 | }; |
| 320 | |
| 321 | // Delete all archived sessions |
| 322 | const handleDeleteAllArchivedSessions = async () => { |
nothing calls this directly
no test coverage detected