Skip to content

[Task] Add SSE replay for missed session events #396

@Astro-Han

Description

@Astro-Han

Goal

When the app reconnects or misses a short burst of session events, it can recover missed question, permission, and status updates without relying only on frontend fallback polling.

Scope

In scope:

  • Design a server-side event id / cursor model for session-related SSE events.
  • Let the client reconnect with its last seen event id.
  • Replay recent missed events for question, permission, and session/status updates.
  • Keep replay bounded so it does not grow memory unbounded.
  • Preserve the frontend fallback added in refactor(app): modularize session todo and blocker state #394 as a safety net.
  • Fix or unblock the question fallback UI e2e seeding path.
  • Add UI e2e coverage for lost question.asked / delayed question.list recovery.

Out of scope:

  • Rewriting all sync/bootstrap logic.
  • Changing todo identity/revision.
  • Redesigning the composer dock UI.

Relevant files or context

Related PR:

Likely areas:

  • packages/opencode/ event/SSE/session sync code
  • packages/app/src/context/sync.tsx
  • packages/app/src/context/global-sync.tsx
  • packages/app/src/context/global-sync/event-reducer.ts
  • packages/app/src/pages/session/blockers/question-reconcile.ts
  • packages/app/src/pages/session/blockers/use-session-blockers.ts
  • packages/app/e2e/session/session-composer-dock.spec.ts

Context:

  • refactor(app): modularize session todo and blocker state #394 added bounded frontend recovery for missing/delayed question requests.
  • That fallback is useful, but backend replay is the more durable fix for missed SSE events.
  • The current question UI e2e for the fallback path was blocked by test seeding before UI assertions.

Verification

  • Add unit/integration coverage for reconnecting with a last seen event id.
  • Verify duplicate replayed events do not create duplicate questions/permissions.
  • Verify out-of-order or already-resolved question events do not reopen stale UI.
  • Add or unblock UI e2e coverage for delayed/lost question.asked recovery.
  • Existing refactor(app): modularize session todo and blocker state #394 blocker/todo focused tests continue to pass.

Execution mode

Agent should investigate and propose a plan first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priorityappApplication behavior and product flowsharnessModel harness, prompts, tool descriptions, and session mechanicstaskNarrow execution, audit, spike, migration, tracking, or upstream follow-up work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions