Skip to content

Commit 68753eb

Browse files
feat: show clickable session ID badge next to Auto Run Active status
- Add ExternalLink icon import and session ID badge in RightPanel progress display - Resolve live agent session ID from batch state, busy tab, or active tab - Capture live agent session ID during Auto Run via onSessionId IPC handler (previously skipped for batch sessions entirely) - Add currentAgentSessionId field to BatchRunState type - Opened session tab gets (snapshot) title suffix to indicate point-in-time view - Pass sessionName through onOpenSessionAsTab via useRightPanelProps wrapper Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dcde72d commit 68753eb

4 files changed

Lines changed: 53 additions & 3 deletions

File tree

src/renderer/components/RightPanel.tsx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
AlertTriangle,
1717
Play,
1818
XCircle,
19+
ExternalLink,
1920
} from 'lucide-react';
2021
import type { Session, Theme, RightPanelTab, BatchRunState } from '../types';
2122
import type { FileTreeChanges } from '../utils/fileExplorer';
@@ -100,7 +101,7 @@ interface RightPanelProps {
100101
onResumeAfterError?: () => void;
101102
onJumpToAgentSession?: (agentSessionId: string) => void;
102103
onResumeSession?: (agentSessionId: string) => void;
103-
onOpenSessionAsTab?: (agentSessionId: string) => void;
104+
onOpenSessionAsTab?: (agentSessionId: string, sessionName?: string) => void;
104105

105106
// Modal handlers
106107
onOpenAboutModal?: () => void;
@@ -404,6 +405,17 @@ export const RightPanel = memo(
404405
autoFollowEnabled,
405406
};
406407

408+
// Resolve current agent session ID for the Auto Run badge
409+
const batchSessionIds = currentSessionBatchState?.sessionIds;
410+
const currentBadgeSessionId =
411+
currentSessionBatchState?.currentAgentSessionId ||
412+
(batchSessionIds && batchSessionIds.length > 0
413+
? batchSessionIds[batchSessionIds.length - 1]
414+
: null);
415+
const badgeShortId = currentBadgeSessionId
416+
? currentBadgeSessionId.split('-')[0].toUpperCase()
417+
: null;
418+
407419
return (
408420
<div
409421
ref={panelRef}
@@ -597,6 +609,24 @@ export const RightPanel = memo(
597609
{currentSessionBatchState.isStopping ? 'Stopping...' : 'Auto Run Active'}
598610
</span>
599611
)}
612+
{/* Current agent session ID badge — matches history entry style */}
613+
{currentBadgeSessionId && onOpenSessionAsTab && (
614+
<button
615+
onClick={() =>
616+
onOpenSessionAsTab(currentBadgeSessionId, `${badgeShortId} (snapshot)`)
617+
}
618+
className="flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-bold font-mono uppercase transition-colors hover:opacity-80"
619+
style={{
620+
backgroundColor: theme.colors.accent + '20',
621+
color: theme.colors.accent,
622+
border: `1px solid ${theme.colors.accent}40`,
623+
}}
624+
title={`Open session ${currentBadgeSessionId}`}
625+
>
626+
<span className="truncate">{badgeShortId}</span>
627+
<ExternalLink className="w-2.5 h-2.5 flex-shrink-0" />
628+
</button>
629+
)}
600630
{currentSessionBatchState.worktreeActive && (
601631
<span title={`Worktree: ${currentSessionBatchState.worktreeBranch || 'active'}`}>
602632
<GitBranch className="w-4 h-4" style={{ color: theme.colors.warning }} />

src/renderer/hooks/agent/useAgentListeners.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { notifyToast } from '../../stores/notificationStore';
3030
import type { HistoryEntryInput } from './useAgentSessionManagement';
3131
import { useSessionStore } from '../../stores/sessionStore';
3232
import { useModalStore } from '../../stores/modalStore';
33+
import { useBatchStore } from '../../stores/batchStore';
3334
import { gitService } from '../../services/git';
3435
import { generateId } from '../../utils/ids';
3536
import {
@@ -921,6 +922,19 @@ export function useAgentListeners(deps: UseAgentListenersDeps): void {
921922
const unsubscribeSessionId = window.maestro.process.onSessionId(
922923
async (sessionId: string, agentSessionId: string) => {
923924
if (isBatchSession(sessionId)) {
925+
// Store the live agent session ID in batch state for UI display
926+
const batchMatch = sessionId.match(/^(.+)-batch-\d+$/);
927+
if (batchMatch) {
928+
const baseSessionId = batchMatch[1];
929+
useBatchStore.getState().setBatchRunStates((prev) => {
930+
const existing = prev[baseSessionId];
931+
if (!existing) return prev;
932+
return {
933+
...prev,
934+
[baseSessionId]: { ...existing, currentAgentSessionId: agentSessionId },
935+
};
936+
});
937+
}
924938
return;
925939
}
926940

src/renderer/hooks/props/useRightPanelProps.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ export interface UseRightPanelPropsDeps {
7373
handleAbortBatchOnError: () => void;
7474
handleResumeAfterError: () => void;
7575
handleJumpToAgentSession: (agentSessionId: string) => void;
76-
handleResumeSession: (agentSessionId: string) => void;
76+
handleResumeSession: (
77+
agentSessionId: string,
78+
providedMessages?: undefined,
79+
sessionName?: string
80+
) => void;
7781

7882
// Modal handlers
7983
handleOpenAboutModal: () => void;
@@ -134,7 +138,8 @@ export function useRightPanelProps(deps: UseRightPanelPropsDeps) {
134138
onResumeAfterError: deps.handleResumeAfterError,
135139
onJumpToAgentSession: deps.handleJumpToAgentSession,
136140
onResumeSession: deps.handleResumeSession,
137-
onOpenSessionAsTab: deps.handleResumeSession,
141+
onOpenSessionAsTab: (agentSessionId: string, sessionName?: string) =>
142+
deps.handleResumeSession(agentSessionId, undefined, sessionName),
138143

139144
// Modal handlers
140145
onOpenAboutModal: deps.handleOpenAboutModal,

src/renderer/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ export interface BatchRunState {
329329
// Prompt configuration
330330
customPrompt?: string; // User's custom prompt if modified
331331
sessionIds: string[]; // Claude session IDs from each iteration
332+
currentAgentSessionId?: string; // Live agent session ID for the currently running task
332333
startTime?: number; // Timestamp when batch run started
333334
cumulativeTaskTimeMs?: number; // Sum of actual task durations (most accurate work time measure)
334335
accumulatedElapsedMs?: number; // Accumulated active elapsed time (excludes sleep/suspend time)

0 commit comments

Comments
 (0)