agent-orchestrator
agent-orchestrator copied to clipboard
fix(web): killing session from session page shows error instead of returning to dashboard
Summary
When a worker session is killed via the Terminate button on the session detail page (/sessions/[id]), the dashboard does not navigate away. Instead the now-invalid session URL renders the error boundary (error.tsx) because the session no longer exists / is no longer restorable.
Expected: after a successful kill from the session detail page, navigate the user back to the dashboard (or the project view they came from).
Repro
- Spawn a worker session:
ao spawn. - Open the session detail page in the browser:
/sessions/<id>. - Click the Terminate button.
- Observe: the page transitions to an error screen (the App Router
error.tsxboundary) rather than going back to/.
Root cause (likely)
- Kill handler POSTs to
/api/sessions/[id]/killand updates local state. - The session detail page re-renders. Either:
- SSE / page data fetch returns 404 / error for the killed session and throws, triggering
error.tsx, or - Server component re-renders with no session data and the page component errors on null access.
- SSE / page data fetch returns 404 / error for the killed session and throws, triggering
- No
router.push('/')(or equivalent) is fired after a successful kill.
Relevant files:
packages/web/src/components/Dashboard.tsx—killSession(~L337) already handles navigation from the dashboard context.packages/web/src/components/BottomSheet.tsx— `confirm-kill` flow and `onRequestKill` callback.packages/web/src/app/sessions/[id]/page.tsx— session detail page; needs a post-kill redirect.packages/web/src/app/sessions/[id]/error.tsx— currently what the user sees after kill.
Proposed fix
- In whatever component hosts the kill button on the session detail page, after the
POST /api/sessions/[id]/killcall resolves successfully:- Use
useRouter()fromnext/navigationand callrouter.push('/')(or the referring project URL if tracked). - Do not rely on state updates / SSE to re-render the detail page — navigate explicitly before the next render can fail.
- Use
- If the kill request fails, stay on the page and surface an error toast; don't navigate.
- Confirm the same flow works from both:
- The session detail page Terminate button.
- The dashboard BottomSheet confirm-kill path (already works; just verify no regression).
Acceptance criteria
- [ ] Clicking Terminate on
/sessions/[id]and confirming routes the user to/(or the originating project dashboard) after success. - [ ] The App Router error boundary is not triggered during the kill flow.
- [ ] Kill failures leave the user on the session page with a visible error indication.
- [ ] Test added to
packages/web/src/app/sessions/[id]/__tests__/(or the component test file) covering post-kill navigation — mockuseRouterand assertpush('/')is called on success. - [ ]
pnpm --filter @composio/ao-web test,typecheck, andlintpass.
Out of scope
- Changing where the session lands after merge / cleanup (separate flow).
- Redesigning the kill confirmation UX — keep existing BottomSheet / confirm dialog.
References
- Kill API route:
packages/web/src/app/api/sessions/[id]/kill/route.ts - Dashboard kill handler:
packages/web/src/components/Dashboard.tsx(~L337)
@harsh-batheja , not able to reproduce this. When I kill the session, I am routed to the orchestrator