feat(agent): Unselect session when archiving currently selected session

When a session is archived and it was the currently selected session,
it is now automatically deselected and the empty state placeholder is
shown in the right panel.

- Updated SessionManagerProps to allow null for onSelectSession callback
- Added logic to deselect session on archive if it was selected
- Added data-testid attributes for testing
This commit is contained in:
Cody Seibert
2025-12-09 01:48:51 -05:00
parent 0af7938798
commit 010e6e139f
3 changed files with 10 additions and 5 deletions

View File

@@ -47,7 +47,7 @@ function generateRandomSessionName(): string {
interface SessionManagerProps {
currentSessionId: string | null;
onSelectSession: (sessionId: string) => void;
onSelectSession: (sessionId: string | null) => void;
projectPath: string;
isCurrentSessionThinking?: boolean;
}
@@ -141,6 +141,10 @@ export function SessionManager({
const result = await window.electronAPI.sessions.archive(sessionId);
if (result.success) {
// If the archived session was currently selected, deselect it
if (currentSessionId === sessionId) {
onSelectSession(null);
}
await loadSessions();
}
};
@@ -357,6 +361,7 @@ export function SessionManager({
variant="ghost"
onClick={() => handleArchiveSession(session.id)}
className="h-7 w-7 p-0"
data-testid={`archive-session-${session.id}`}
>
<Archive className="w-3 h-3" />
</Button>

View File

@@ -471,7 +471,7 @@ export function AgentView() {
{/* Messages */}
{!currentSessionId ? (
<div className="flex-1 flex items-center justify-center">
<div className="flex-1 flex items-center justify-center" data-testid="no-session-placeholder">
<div className="text-center">
<Bot className="w-12 h-12 text-muted-foreground mx-auto mb-4 opacity-50" />
<h2 className="text-lg font-semibold mb-2">