Files
ThothII/.superpowers/sdd/task-3-report.md
T

2.9 KiB

Task 3 report — reconnect SSE on same-session Resume

Status

Complete. A successful Resume of the currently active session now replaces its existing EventSource connection. Resuming a different session continues to reconnect through the session ID change only, without a generation-driven second connection.

Implementation

  • useSessionStream accepts an optional generation argument (default 0) and includes it in the stream effect dependencies. A generation change therefore runs the existing cleanup, closes the old source, and opens the same URL again.
  • AppShell captures whether the requested Resume ID is already active before its existing optimistic state updates. It increments the stream generation only after resumeSession(id) succeeds and only for that same-ID case.
  • The existing optimistic session switch, phase refresh, and failed-Resume rollback remain unchanged. A failed POST cannot increment the generation.

TDD evidence

  • RED command: cd frontend && npx vitest run src/stream/useSessionStream.test.tsx src/shell/AppShell.session-mgmt.test.tsx
  • RED result: 2 expected failures and 15 passes. The hook test observed first.closed === false; the AppShell test observed one FakeEventSource instead of two after the second same-ID Resume.
  • GREEN focused result: the same command passed 2/2 files and 17/17 tests after the minimal production wiring.

Full verification

  • Baseline before edits: cd frontend && npx vitest run — 42/42 files and 251/251 tests passed.
  • Focused tests: 2/2 files and 17/17 tests passed.
  • Full frontend suite: cd frontend && npx vitest run — 42/42 files and 253/253 tests passed.
  • Typecheck: cd frontend && npx tsc -b — exit 0.
  • Production build: cd frontend && npm run build — exit 0; Vite transformed 4,835 modules and completed the production bundle.
  • git diff --check — passed.

The suite and build retained the pre-existing MSW unhandled-request, React ref/act, Node type stripping, and Vite chunk-size warnings. This task introduced no new warning category.

Files

  • frontend/src/stream/useSessionStream.ts
  • frontend/src/stream/useSessionStream.test.tsx
  • frontend/src/shell/AppShell.tsx
  • frontend/src/shell/AppShell.session-mgmt.test.tsx
  • .superpowers/sdd/task-3-report.md

Self-review

  • Confirmed the old EventSource is closed before the replacement is retained by React's effect lifecycle, and the replacement uses the identical session URL.
  • Confirmed same-ID detection happens before the optimistic setActiveSessionId(id) call.
  • Confirmed the generation increments only after a successful Resume POST; the catch/rollback branch is unchanged.
  • Confirmed a different ID leaves the generation unchanged, so the existing session-ID effect change creates exactly one replacement connection.
  • Confirmed the diff is frontend-only apart from this report and contains no backend, Docker, configuration, or session changes.

Concerns

None.