Skip to content

Commit 33799e0

Browse files
fix(schedules): open repo session for finished worktree runs using run branch
Teardown clears worktree_path when a run finishes, so the previous check never matched and Open session navigated to the original session whose worktree directory had been removed. run_branch persists and reliably identifies worktree runs.
1 parent 52b6147 commit 33799e0

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎frontend/src/components/schedules/RunDetailPanel.test.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ describe('RunDetailPanel open session', () => {
204204
})
205205

206206
it('opens the original session while a worktree run is still running', async () => {
207-
renderPanel({ ...run, status: 'running', sessionId: 'ses_run', worktreePath: '/abs/worktrees/run-1' })
207+
renderPanel({ ...run, status: 'running', sessionId: 'ses_run', worktreePath: '/abs/worktrees/run-1', runBranch: 'schedule/1/run-1' })
208208

209209
await clickOpenSession()
210210

@@ -219,7 +219,7 @@ describe('RunDetailPanel open session', () => {
219219
sessionId: 'ses_run',
220220
sessionTitle: 'Daily recap',
221221
finishedAt: Date.UTC(2026, 9, 2),
222-
worktreePath: '/abs/worktrees/run-1',
222+
worktreePath: null,
223223
runBranch: 'schedule/run-1',
224224
commitHash: 'abc123',
225225
})
@@ -236,7 +236,7 @@ describe('RunDetailPanel open session', () => {
236236

237237
it('includes the error and notes no committed changes for a failed worktree run', async () => {
238238
apiMocks.createSessionWithContext.mockResolvedValue({ id: 'ses_new' })
239-
renderPanel({ ...run, status: 'failed', responseText: null, errorText: 'Model timed out', worktreePath: '/abs/worktrees/run-1' })
239+
renderPanel({ ...run, status: 'failed', responseText: null, errorText: 'Model timed out', worktreePath: null, runBranch: 'schedule/1/run-1' })
240240

241241
await clickOpenSession()
242242

@@ -250,7 +250,7 @@ describe('RunDetailPanel open session', () => {
250250
})
251251

252252
it('shows a single open session button', async () => {
253-
renderPanel({ ...run, sessionId: 'ses_run', worktreePath: '/abs/worktrees/run-1' })
253+
renderPanel({ ...run, sessionId: 'ses_run', worktreePath: null, runBranch: 'schedule/1/run-1' })
254254

255255
await waitFor(() => expect(screen.getByRole('button', { name: 'Open session' })).toBeEnabled())
256256
expect(screen.getAllByRole('button', { name: /session|repo/i })).toHaveLength(1)

‎frontend/src/components/schedules/RunDetailPanel.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function RunDetailPanel({ repoId, activeRun, selectedRunLoading, onCancel
7070

7171
const { sessionId } = activeRun
7272

73-
const opensNewRepoSession = Boolean(activeRun.worktreePath) && activeRun.status !== 'running'
73+
const opensNewRepoSession = Boolean(activeRun.runBranch) && activeRun.status !== 'running'
7474

7575
const handleOpenSession = async () => {
7676
if (!opensNewRepoSession) {

0 commit comments

Comments
 (0)