Repository navigation
[codex] Continue agent work in a new session - #9170
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (18)
🚧 Files skipped from review as they are similar to previous changes (10)
📝 WalkthroughWalkthroughAdds end-to-end continuation of interrupted agent sessions from terminal panes and AI Vault sessions. The changes create continuation request and prompt utilities, detect available TUI agents, launch new sessions with optional working directories, and add continuation actions to menus, pane headers, sidebar rows, and dialogs. They also add agent selection, focused/full context modes, localized strings, session prompt metadata, and tests covering request preparation, eligibility, launch behavior, UI actions, and detection retry handling. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
|
Hi @brennanb2025, gentle ping when you have a chance. This workflow has become a common need across our team. When an agent reaches its usage limit, people currently have to manually find and carry the context into another session before they can continue working. Some teammates also prefer to use one session for planning, then start a fresh session for implementation while retaining the important context and current workspace. This PR aims to make both workflows a one-click handoff instead of a manual process. We'd really appreciate your review when you have time, and I'm happy to adjust the implementation based on your feedback. Thanks! |
|
Taking a look! |
05a6601 to
97f1ada
Compare
|
Rebased this branch onto the latest upstream/main and resolved the merge conflicts. The updated branch is now pushed and ready for review. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.ts (1)
150-195: 📐 Maintainability & Code Quality | 🔵 TrivialDuplicate target-resolution/error-toast logic with
handleResume.
handleContinueInNewSessionrepeats the sameresolveAiVaultSessionLaunchTarget→missing/unsupported→toast.error+returnpattern already inhandleResume(lines 88-110). Consider extracting a shared helper (e.g.resolveAiVaultLaunchTargetOrToast) that both callbacks call.♻️ Sketch of a shared helper
+function resolveTargetOrToast(args: { + session: AiVaultSession + activeWorktreeId: string | null + targetWorktreeId?: string + targetState: AiVaultSessionResumeTargetState +}): { worktreeId: string } | null { + const targetId = resolveAiVaultSessionLaunchTarget({ + sessionFilePath: args.session.filePath, + sessionExecutionHostId: args.session.executionHostId, + activeWorktreeId: args.activeWorktreeId, + targetWorktreeId: args.targetWorktreeId, + targetState: args.targetState + }) + if (targetId.status === 'missing') { + toast.error(translate(/* ... */)) + return null + } + if (targetId.status === 'unsupported') { + toast.error(aiVaultResumeUnsupportedMessage(targetId.targetStatus)) + return null + } + return { worktreeId: targetId.worktreeId } +}src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsx (1)
108-115: 📐 Maintainability & Code Quality | 🔵 TrivialAdd a "why" comment for the 200ms starting-indicator delay.
Per coding guidelines, non-obvious TypeScript code should explain why the constraint exists. The separate
showStartingstate and its 200ms delay exist to avoid a loading-spinner flicker on fast launches, but that rationale isn't documented.As per coding guidelines, "For non-obvious TypeScript code, add a concise comment explaining why the constraint exists, not how the code works."
Source: Coding guidelines
src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.test.ts (1)
1-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFile name doesn't match what it tests.
This file tests
chooseInitialContinuationAgentfromagent-session-continuation-selection.ts, not theAgentSessionContinuationDialogcomponent. Consider renaming toagent-session-continuation-selection.test.tsfor discoverability, since the Dialog component itself currently has no dedicated test coverage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: ea1568ba-25a3-4a11-ba7d-836c8c6515f8
📥 Commits
Reviewing files that changed from the base of the PR and between 633cad3 and 97f1ada5e957c3f873ab7a31ac96895a57735492.
📒 Files selected for processing (37)
src/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.test.tssrc/renderer/src/components/agent-session-continuation/AgentSessionContinuationDialog.tsxsrc/renderer/src/components/agent-session-continuation/agent-session-continuation-selection.tssrc/renderer/src/components/agent/AgentCombobox.test.tsxsrc/renderer/src/components/agent/AgentCombobox.tsxsrc/renderer/src/components/native-chat/use-native-chat-context-menu.tsxsrc/renderer/src/components/right-sidebar/AiVaultPanel.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionActionMenuItems.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionDetails.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionRow.tsxsrc/renderer/src/components/right-sidebar/AiVaultSessionVirtualList.tsxsrc/renderer/src/components/right-sidebar/SessionRowTrailingActions.test.tsxsrc/renderer/src/components/right-sidebar/SessionRowTrailingActions.tsxsrc/renderer/src/components/right-sidebar/ai-vault-session-continuation.test.tssrc/renderer/src/components/right-sidebar/ai-vault-session-continuation.tssrc/renderer/src/components/right-sidebar/ai-vault-session-launch-actions.tssrc/renderer/src/components/terminal-pane/AgentSessionContinuationMenuItem.tsxsrc/renderer/src/components/terminal-pane/TerminalContextMenu.test.tsxsrc/renderer/src/components/terminal-pane/TerminalContextMenu.tsxsrc/renderer/src/components/terminal-pane/TerminalPane.tsxsrc/renderer/src/components/terminal-pane/TerminalPaneHeaderOverlay.test.tsxsrc/renderer/src/components/terminal-pane/TerminalPaneHeaderOverlay.tsxsrc/renderer/src/components/terminal-pane/terminal-agent-session-continuation.test.tssrc/renderer/src/components/terminal-pane/terminal-agent-session-continuation.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-context-menu.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/agent-session-continuation.tssrc/renderer/src/lib/launch-agent-in-new-tab-cwd.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.test.tssrc/renderer/src/lib/launch-agent-in-new-tab.tssrc/renderer/src/lib/launch-agent-session-continuation.test.tssrc/renderer/src/lib/launch-agent-session-continuation.tssrc/renderer/src/lib/launch-agent-web-host-tab.ts
| useEffect(() => { | ||
| if (!open || !request) { | ||
| return | ||
| } | ||
| let cancelled = false | ||
| void detectAgentSessionContinuationAgents(request.worktreeId) | ||
| .then((detected) => { | ||
| if (cancelled) { | ||
| return | ||
| } | ||
| const enabled = detected.filter((agent) => isTuiAgentEnabled(agent, disabledAgents)) | ||
| setDetectedAgents(enabled) | ||
| setSelectedAgent( | ||
| chooseInitialContinuationAgent({ | ||
| availableAgents: enabled, | ||
| sourceAgent: request.source.sourceAgent, | ||
| defaultAgent: settings?.defaultTuiAgent | ||
| }) | ||
| ) | ||
| }) | ||
| .catch((error) => { | ||
| console.error('Agent detection failed for continuation dialog', error) | ||
| if (!cancelled) { | ||
| setDetectedAgents([]) | ||
| setSelectedAgent(null) | ||
| setDetectionFailed(true) | ||
| } | ||
| }) | ||
| .finally(() => { | ||
| if (!cancelled) { | ||
| setDetecting(false) | ||
| } | ||
| }) | ||
|
|
||
| return () => { | ||
| cancelled = true | ||
| } | ||
| }, [disabledAgents, open, request, settings?.defaultTuiAgent]) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Detection state (detecting, detectionFailed, detectedAgents) is never reset at the start of a new detection run.
The effect only flips detecting to false in .finally and detectionFailed to true in .catch — it never sets detecting back to true or detectionFailed back to false when a new run starts (including on the success path). Since the component takes open as a controlled prop rather than being unmounted per request, any caller that keeps this dialog mounted across multiple continuation requests (toggling open/request) will show a stale "Could not detect Agents" banner forever after one failure, and briefly expose the previous request's stale detectedAgents/selectedAgent during the next request's async detection window.
🐛 Reset detection state at the start of each run
let cancelled = false
+ setDetecting(true)
+ setDetectionFailed(false)
void detectAgentSessionContinuationAgents(request.worktreeId)
.then((detected) => {
if (cancelled) {
return
}
const enabled = detected.filter((agent) => isTuiAgentEnabled(agent, disabledAgents))
setDetectedAgents(enabled)
+ setDetectionFailed(false)
setSelectedAgent(📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| useEffect(() => { | |
| if (!open || !request) { | |
| return | |
| } | |
| let cancelled = false | |
| void detectAgentSessionContinuationAgents(request.worktreeId) | |
| .then((detected) => { | |
| if (cancelled) { | |
| return | |
| } | |
| const enabled = detected.filter((agent) => isTuiAgentEnabled(agent, disabledAgents)) | |
| setDetectedAgents(enabled) | |
| setSelectedAgent( | |
| chooseInitialContinuationAgent({ | |
| availableAgents: enabled, | |
| sourceAgent: request.source.sourceAgent, | |
| defaultAgent: settings?.defaultTuiAgent | |
| }) | |
| ) | |
| }) | |
| .catch((error) => { | |
| console.error('Agent detection failed for continuation dialog', error) | |
| if (!cancelled) { | |
| setDetectedAgents([]) | |
| setSelectedAgent(null) | |
| setDetectionFailed(true) | |
| } | |
| }) | |
| .finally(() => { | |
| if (!cancelled) { | |
| setDetecting(false) | |
| } | |
| }) | |
| return () => { | |
| cancelled = true | |
| } | |
| }, [disabledAgents, open, request, settings?.defaultTuiAgent]) | |
| useEffect(() => { | |
| if (!open || !request) { | |
| return | |
| } | |
| let cancelled = false | |
| setDetecting(true) | |
| setDetectionFailed(false) | |
| void detectAgentSessionContinuationAgents(request.worktreeId) | |
| .then((detected) => { | |
| if (cancelled) { | |
| return | |
| } | |
| const enabled = detected.filter((agent) => isTuiAgentEnabled(agent, disabledAgents)) | |
| setDetectedAgents(enabled) | |
| setDetectionFailed(false) | |
| setSelectedAgent( | |
| chooseInitialContinuationAgent({ | |
| availableAgents: enabled, | |
| sourceAgent: request.source.sourceAgent, | |
| defaultAgent: settings?.defaultTuiAgent | |
| }) | |
| ) | |
| }) | |
| .catch((error) => { | |
| console.error('Agent detection failed for continuation dialog', error) | |
| if (!cancelled) { | |
| setDetectedAgents([]) | |
| setSelectedAgent(null) | |
| setDetectionFailed(true) | |
| } | |
| }) | |
| .finally(() => { | |
| if (!cancelled) { | |
| setDetecting(false) | |
| } | |
| }) | |
| return () => { | |
| cancelled = true | |
| } | |
| }, [disabledAgents, open, request, settings?.defaultTuiAgent]) |
97f1ada to
e1085b7
Compare
|
Thanks for the contribution — I rebased this onto the current main branch and tightened the implementation before handing it back. The update now resets detection state for each request, detects agents in the target workspace runtime, preserves terminal context safely, and routes paired-runtime launches plus post-ready prompt delivery through the host that owns the session; it also distinguishes launch failures from context-delivery failures and applies the review's naming, comment, and AI Vault deduplication nits. I added regression coverage for those paths; the full typecheck, 135 focused tests, and touched-file lint/localization/max-lines checks pass. |
|
Thanks for taking the time to harden the implementation and add the regression coverage. The target-runtime detection and host-owned context delivery changes make a lot of sense. I also really appreciate you and the team maintaining such a great tool. I noticed the PR workflows are currently awaiting approval to run—please let me know if there’s anything else you’d like me to adjust on my side. |
Preview user entries can be tool results or harness-injected skill text, so the continuation prompt's last-prompt hint now comes from the vault scanner's provider-authenticated lastUserPrompt. Also softens the continuation instructions for already-complete tasks and adds a cost warning to the full-transcript option.
Live QA — maintainer verification on merge head (851e36d)Ran the AI Vault → Continue in New Session flow end-to-end in a dev build (macOS, isolated profile) against a real Claude session. Dialog — Focused handoff defaultOriginal agent pre-selected, Focused handoff recommended, original working directory preserved. Full session transcript — cost warningThe full-transcript option now warns about context/plan/API cost before opting in. Launch verifiedStarting the session opened a new tab in the original cwd and delivered the focused handoff prompt (source lines, transcript path, provider-authenticated status hints, untrusted-transcript framing). The receiving agent read the transcript tail, correctly recognized the prior task was already complete, summarized where it stopped, and waited for instruction — exercising the already-complete path added in ec0a550. (Terminal screenshot withheld: it contains real session content.) |
Edge-usage action; keep the resting row at three icons and reveal it with the other session actions on hover, matching Resume's gating.
0e8f2cb to
78dd4d2
Compare
…n-in-codex # Conflicts: # src/renderer/src/components/terminal-pane/TerminalPane.tsx
|
Thanks for the PR, just merged it! Just added a small change: moved the row action into the hover group. The Continue in New Session icon on session rows previously sat with the always-visible controls; since it's an edge-usage action, it now reveals on hover alongside Jump to Pane / Jump to Worktree / Resume. Rows at rest are back to just the details chevron and overflow menu, and the action remains reachable from … without hovering. A test now locks in the hover gating. P.S. your gh profile picture made me laugh, it's so awesome 😂 |
|
Thanks again for the thoughtful review! The hover-group change makes perfect sense, and I learned a lot from the improvements you made. I switched to this profile picture back in college when studying computer science was driving me a little crazy. I thought it was hilarious, so I’ve kept it ever since 😂 |
* feat: continue agent work in a new session * fix: harden new-session continuation * fix: source last prompt from provider-authenticated transcript records Preview user entries can be tool results or harness-injected skill text, so the continuation prompt's last-prompt hint now comes from the vault scanner's provider-authenticated lastUserPrompt. Also softens the continuation instructions for already-complete tasks and adds a cost warning to the full-transcript option. * fix: move Continue in New Session row action into the hover group Edge-usage action; keep the resting row at three icons and reveal it with the other session actions on hover, matching Resume's gating. --------- Co-authored-by: jz.feng <[email protected]> Co-authored-by: Brennan Benson <[email protected]>


Summary
Have you ever been deep in a coding task when the current agent suddenly hits its usage limit? Today that breaks the flow: find the provider's session file, open another agent, paste a path, and explain where the work stopped. The same friction appears when a long session starts losing focus and the user wants a clean context window without abandoning the task.
This PR adds Continue in New Session… as a provider-neutral workflow:
This is intentionally different from resume and fork:
Screenshots
Choose the Agent and context
Start with the original Agent or switch to another detected Agent. Focused handoff is recommended for a clean context window; the full transcript remains available when more history is needed.
Testing
pnpm lint— changed-file lint, React Doctor, styled-scrollbar, reliability, max-lines, skill-manifest, and localization checks pass. The aggregate command currently stops on two unchangedupstream/mainswitch-exhaustiveness errors innative-chat-session-option-labels.tsandskill-freshness-group.tsx.pnpm typecheckpnpm test— Node 24 full run executed 31,326 tests successfully with 54 skipped. Three environment-sensitive tests initially failed because/usr/sbin/lsofwas absent from a narrowed PATH and an SSH fixture timed out; both affected files passed when rerun with the complete system PATH.pnpm buildAI Review Report
The review checked:
TuiAgent; it does not special-case Claude-to-Codex or assume a particular provider's resume command.Security Audit
Notes