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

@@ -16,7 +16,7 @@
"3. archive it", "3. archive it",
"4. expect empty state placeholder in right panel" "4. expect empty state placeholder in right panel"
], ],
"status": "in_progress" "status": "verified"
}, },
{ {
"id": "feature-1765260557163-86b3tby5d", "id": "feature-1765260557163-86b3tby5d",
@@ -37,7 +37,7 @@
"category": "Kanban", "category": "Kanban",
"description": "show a error toast when concurrency limit is hit and someone tries to drag a card into in progress to give them feedback why it won't work.", "description": "show a error toast when concurrency limit is hit and someone tries to drag a card into in progress to give them feedback why it won't work.",
"steps": [], "steps": [],
"status": "in_progress" "status": "backlog"
}, },
{ {
"id": "feature-1765260791341-iaxxt172n", "id": "feature-1765260791341-iaxxt172n",
@@ -58,7 +58,7 @@
"category": "Kanban", "category": "Kanban",
"description": "add a count up timer for showing how long the card has been in progress", "description": "add a count up timer for showing how long the card has been in progress",
"steps": [], "steps": [],
"status": "in_progress" "status": "verified"
}, },
{ {
"id": "feature-1765261027396-b78maajg7", "id": "feature-1765261027396-b78maajg7",

View File

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

View File

@@ -471,7 +471,7 @@ export function AgentView() {
{/* Messages */} {/* Messages */}
{!currentSessionId ? ( {!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"> <div className="text-center">
<Bot className="w-12 h-12 text-muted-foreground mx-auto mb-4 opacity-50" /> <Bot className="w-12 h-12 text-muted-foreground mx-auto mb-4 opacity-50" />
<h2 className="text-lg font-semibold mb-2"> <h2 className="text-lg font-semibold mb-2">