feat: show clickable session ID badge next to Auto Run Active status#748
feat: show clickable session ID badge next to Auto Run Active status#748scriptease wants to merge 1 commit intoRunMaestro:rcfrom
Conversation
📝 WalkthroughWalkthroughTrack and expose the live agent session ID for batch runs: add a BatchRunState field, update the agent listener to store current agent session IDs for batch runs, and propagate an optional sessionName through hooks to RightPanel to render a snapshot badge that opens the session as a tab. Changes
Sequence DiagramsequenceDiagram
participant AgentListener as Agent Listener
participant BatchStore as Batch Store
participant RightPanel as Right Panel UI
participant SessionHandler as Session/Tab Handler
AgentListener->>AgentListener: Receive agent session ID
AgentListener->>AgentListener: Is batch session? (regex -> baseSessionId)
AgentListener->>BatchStore: setBatchRunStates(merge currentAgentSessionId)
BatchStore->>BatchStore: Store/merge currentAgentSessionId into BatchRunState
RightPanel->>BatchStore: Read currentSessionBatchState.currentAgentSessionId or sessionIds[-1]
RightPanel->>RightPanel: Compute short uppercase prefix, render badge if present
RightPanel->>SessionHandler: onOpenSessionAsTab(sessionId, "<SHORT> (snapshot)")
SessionHandler->>SessionHandler: Open/resume session tab with provided sessionName
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR adds an additive UI feature: a clickable session ID badge next to the "Auto Run Active" status that opens the current (or last-known) Claude agent session as a read-only snapshot tab. The implementation is logically correct — Confidence Score: 5/5Safe to merge — the feature is purely additive with correct lifecycle handling and no blocking issues. All findings are P2 style/ergonomics (IIFE pattern, redundant non-null assertion). The core logic is correct: No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant IPC as Main Process (IPC)
participant Listeners as useAgentListeners
participant Store as batchStore
participant Panel as RightPanel
participant Resume as handleResumeSession
IPC->>Listeners: onSessionId(batchSessionId, agentSessionId)
Listeners->>Listeners: match /^(.+)-batch-\d+$/
Listeners->>Store: setBatchRunStates({ currentAgentSessionId })
Store->>Panel: re-render (badge resolves currentAgentSessionId)
Panel-->>User: Show shortId pill badge + ExternalLink icon
User->>Panel: Click badge
Panel->>Resume: handleResumeSession(agentSessionId, undefined, "XXXXX (snapshot)")
Resume-->>User: Opens session as snapshot tab
Reviews (1): Last reviewed commit: "feat: show clickable session ID badge ne..." | Re-trigger Greptile |
| {(() => { | ||
| // Use live agent session ID from batch state (set by onSessionId IPC handler), | ||
| // falling back to the last completed session ID | ||
| const currentAgentSessionId = | ||
| currentSessionBatchState.currentAgentSessionId || | ||
| (currentSessionBatchState.sessionIds?.length > 0 | ||
| ? currentSessionBatchState.sessionIds[ | ||
| currentSessionBatchState.sessionIds.length - 1 | ||
| ] | ||
| : null); | ||
| if (!currentAgentSessionId || !onOpenSessionAsTab) return null; | ||
| const shortId = currentAgentSessionId.split('-')[0].toUpperCase(); | ||
| return ( | ||
| <button | ||
| onClick={() => | ||
| onOpenSessionAsTab!(currentAgentSessionId, `${shortId} (snapshot)`) | ||
| } | ||
| 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" | ||
| style={{ | ||
| backgroundColor: theme.colors.accent + '20', | ||
| color: theme.colors.accent, | ||
| border: `1px solid ${theme.colors.accent}40`, | ||
| }} | ||
| title={`Open session ${currentAgentSessionId}`} | ||
| > | ||
| <span className="truncate">{shortId}</span> | ||
| <ExternalLink className="w-2.5 h-2.5 flex-shrink-0" /> | ||
| </button> | ||
| ); | ||
| })()} |
There was a problem hiding this comment.
Using an immediately-invoked function expression inside JSX is non-idiomatic React and creates a new closure on every render. The logic is simple enough to hoist into const declarations above the return statement and render with a plain conditional.
// Before the outer return (…):
const currentBadgeSessionId =
currentSessionBatchState?.currentAgentSessionId ||
(currentSessionBatchState?.sessionIds?.length > 0
? currentSessionBatchState.sessionIds[
currentSessionBatchState.sessionIds.length - 1
]
: null);
const badgeShortId = currentBadgeSessionId
? currentBadgeSessionId.split('-')[0].toUpperCase()
: null;Then replace the IIFE with:
{currentBadgeSessionId && onOpenSessionAsTab && (
<button
onClick={() =>
onOpenSessionAsTab(currentBadgeSessionId, `${badgeShortId} (snapshot)`)
}
…
>
<span className="truncate">{badgeShortId}</span>
<ExternalLink className="w-2.5 h-2.5 flex-shrink-0" />
</button>
)}Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| onClick={() => | ||
| onOpenSessionAsTab!(currentAgentSessionId, `${shortId} (snapshot)`) | ||
| } |
There was a problem hiding this comment.
The guard on line 612 (if (!currentAgentSessionId || !onOpenSessionAsTab) return null) already guarantees onOpenSessionAsTab is defined before this button renders. The ! postfix assertion is unreachable-redundant and misleads the reader into thinking nullability is a real concern here.
| onClick={() => | |
| onOpenSessionAsTab!(currentAgentSessionId, `${shortId} (snapshot)`) | |
| } | |
| onClick={() => | |
| onOpenSessionAsTab(currentAgentSessionId, `${shortId} (snapshot)`) | |
| } |
- 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>
9053216 to
68753eb
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/hooks/props/useRightPanelProps.ts (1)
76-80: Clarify the intentional scope of handleResumeSession in RightPanel props.The type
providedMessages?: undefinedis unusually restrictive compared to the actual implementation (handleResumeSessioninuseAgentSessionManagementacceptsprovidedMessages?: LogEntry[]). While technically valid and consistent with how RightPanel uses it (via theonOpenSessionAsTabwrapper that passes undefined), this pattern may confuse future maintainers who expect the RightPanel handler to match the implementation signature.If the intention is to keep RightPanel's handler surface minimal and only support the undefined case, consider adding a clarifying comment. Alternatively, align the type with the full implementation signature for consistency across the codebase, though this would require also accepting the
starredandusageStatsparameters even if RightPanel doesn't currently use them.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/renderer/hooks/props/useRightPanelProps.ts` around lines 76 - 80, The RightPanel prop type for handleResumeSession is unnecessarily restrictive (providedMessages?: undefined) and should match the implementation in useAgentSessionManagement; update the handleResumeSession signature in useRightPanelProps.ts to accept the same optional parameters as useAgentSessionManagement (e.g., providedMessages?: LogEntry[] and any other optional params the implementation expects) so the prop type aligns with the concrete handler, and update any callers like onOpenSessionAsTab to continue passing undefined when appropriate; alternatively, if you intentionally want the narrower surface, add a one-line comment next to handleResumeSession explaining the deliberate restriction and referring to useAgentSessionManagement for the fuller signature.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/renderer/hooks/props/useRightPanelProps.ts`:
- Around line 76-80: The RightPanel prop type for handleResumeSession is
unnecessarily restrictive (providedMessages?: undefined) and should match the
implementation in useAgentSessionManagement; update the handleResumeSession
signature in useRightPanelProps.ts to accept the same optional parameters as
useAgentSessionManagement (e.g., providedMessages?: LogEntry[] and any other
optional params the implementation expects) so the prop type aligns with the
concrete handler, and update any callers like onOpenSessionAsTab to continue
passing undefined when appropriate; alternatively, if you intentionally want the
narrower surface, add a one-line comment next to handleResumeSession explaining
the deliberate restriction and referring to useAgentSessionManagement for the
fuller signature.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9c2043f0-4505-4a2a-8e02-896047b17744
📒 Files selected for processing (4)
src/renderer/components/RightPanel.tsxsrc/renderer/hooks/agent/useAgentListeners.tssrc/renderer/hooks/props/useRightPanelProps.tssrc/renderer/types/index.ts
✅ Files skipped from review due to trivial changes (1)
- src/renderer/types/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/renderer/hooks/agent/useAgentListeners.ts
- src/renderer/components/RightPanel.tsx
I have a feature proposal for the people like me that need to see something sometimes, it adds the live session id to the auto run status box, but since everything is a snapshot and not updated live it opens the session with (snapshot) but you can see the last message when something is slow or you're just curious.
Summary by CodeRabbit