Skip to content

feat: show clickable session ID badge next to Auto Run Active status#748

Open
scriptease wants to merge 1 commit intoRunMaestro:rcfrom
scriptease:autorun-live-session
Open

feat: show clickable session ID badge next to Auto Run Active status#748
scriptease wants to merge 1 commit intoRunMaestro:rcfrom
scriptease:autorun-live-session

Conversation

@scriptease
Copy link
Copy Markdown

@scriptease scriptease commented Apr 7, 2026

Bildschirmfoto 2026-04-06 um 20 50 46

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

  • New Features
    • Batch run header now shows the current active agent session as a small labeled badge (e.g., "XXXX (snapshot)").
    • Badge is clickable — opens the corresponding session in a new tab and supports providing a custom session name for easier identification.
    • Improved live tracking of which agent session is currently running during batch executions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

Track 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

Cohort / File(s) Summary
Batch state types
src/renderer/types/index.ts
Add optional currentAgentSessionId?: string to BatchRunState.
Agent listener / batch store update
src/renderer/hooks/agent/useAgentListeners.ts
Detect batch session IDs (extract base via regex) and merge currentAgentSessionId: agentSessionId into existing batch run state via setBatchRunStates.
RightPanel props wiring
src/renderer/hooks/props/useRightPanelProps.ts
Extend UseRightPanelPropsDeps.handleResumeSession signature to (agentSessionId, providedMessages?, sessionName?); adapt onOpenSessionAsTab to call deps.handleResumeSession(agentSessionId, undefined, sessionName).
RightPanel UI
src/renderer/components/RightPanel.tsx
Change onOpenSessionAsTab?: (agentSessionId: string, sessionName?: string) => void; compute badge short ID from currentSessionBatchState.currentAgentSessionId (fallback to last sessionId) and render a snapshot badge that calls onOpenSessionAsTab(currentBadgeSessionId, \${badgeShortId} (snapshot)`)`.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 I hop through batches, nose alight,
I find the live session tucked just right,
A tiny badge—snapshot gleams,
Open a tab and chase the dreams,
Little rabbit, big delight!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main feature: adding a clickable session ID badge next to the Auto Run Active status display.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This 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 — currentAgentSessionId is captured from the onSessionId IPC event, properly absent from the START_BATCH reducer so it resets on each new run, and the (snapshot) title suffix clearly communicates the point-in-time nature of the view.

Confidence Score: 5/5

Safe 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: currentAgentSessionId is captured from IPC, reset to undefined by the START_BATCH reducer on new runs, and the fallback to sessionIds last entry plus the (snapshot) suffix clearly communicates the point-in-time nature of the view.

No files require special attention.

Important Files Changed

Filename Overview
src/renderer/types/index.ts Adds optional currentAgentSessionId field to BatchRunState for tracking the live agent session during Auto Run
src/renderer/hooks/agent/useAgentListeners.ts Updates onSessionId handler to store the live agent session ID into batch store for batch sessions instead of early-returning without capture
src/renderer/hooks/props/useRightPanelProps.ts Adds onOpenSessionAsTab wrapper calling handleResumeSession with an optional session name for the snapshot tab title
src/renderer/components/RightPanel.tsx Renders clickable session ID badge next to Auto Run Active label; uses an IIFE pattern inside JSX and contains a redundant non-null assertion on onOpenSessionAsTab

Sequence Diagram

sequenceDiagram
    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
Loading

Reviews (1): Last reviewed commit: "feat: show clickable session ID badge ne..." | Re-trigger Greptile

Comment on lines +602 to +631
{(() => {
// 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>
);
})()}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 IIFE inside JSX

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!

Comment on lines +616 to +618
onClick={() =>
onOpenSessionAsTab!(currentAgentSessionId, `${shortId} (snapshot)`)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Redundant non-null assertion

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.

Suggested change
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>
@scriptease scriptease force-pushed the autorun-live-session branch from 9053216 to 68753eb Compare April 7, 2026 19:13
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/hooks/props/useRightPanelProps.ts (1)

76-80: Clarify the intentional scope of handleResumeSession in RightPanel props.

The type providedMessages?: undefined is unusually restrictive compared to the actual implementation (handleResumeSession in useAgentSessionManagement accepts providedMessages?: LogEntry[]). While technically valid and consistent with how RightPanel uses it (via the onOpenSessionAsTab wrapper 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 starred and usageStats parameters 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9053216 and 68753eb.

📒 Files selected for processing (4)
  • src/renderer/components/RightPanel.tsx
  • src/renderer/hooks/agent/useAgentListeners.ts
  • src/renderer/hooks/props/useRightPanelProps.ts
  • src/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants