agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

fix(web): killing session from session page shows error instead of returning to dashboard

Open harsh-batheja opened this issue 7 months ago • 1 comments

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

  1. Spawn a worker session: ao spawn.
  2. Open the session detail page in the browser: /sessions/<id>.
  3. Click the Terminate button.
  4. Observe: the page transitions to an error screen (the App Router error.tsx boundary) rather than going back to /.

Root cause (likely)

  • Kill handler POSTs to /api/sessions/[id]/kill and 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.
  • 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

  1. In whatever component hosts the kill button on the session detail page, after the POST /api/sessions/[id]/kill call resolves successfully:
    • Use useRouter() from next/navigation and call router.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.
  2. If the kill request fails, stay on the page and surface an error toast; don't navigate.
  3. 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 — mock useRouter and assert push('/') is called on success.
  • [ ] pnpm --filter @composio/ao-web test, typecheck, and lint pass.

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 avatar Apr 20 '26 22:04 harsh-batheja

@harsh-batheja , not able to reproduce this. When I kill the session, I am routed to the orchestrator

miniMaddy avatar May 01 '26 12:05 miniMaddy