Skip to content

fix(wiki-compose): stop auto-start effect from aborting SSE mid-run#993

Draft
cursor[bot] wants to merge 2 commits into
developfrom
cursor/critical-bug-investigation-1c64
Draft

fix(wiki-compose): stop auto-start effect from aborting SSE mid-run#993
cursor[bot] wants to merge 2 commits into
developfrom
cursor/critical-bug-investigation-1c64

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 27, 2026

Bug and impact

Fresh Wiki Compose sessions (startPolicy: when-backend-ready, no sessionId in the URL) could stall immediately after session creation: the row reached pending but POST /run SSE was aborted before events arrived, so Brief/research/draft UI never progressed.

Root cause

PR #992 refactored auto-start into a useEffect that listed awaitingFreshStart in its dependency array and called abortRef.current?.abort() in the effect cleanup. When createSession committed, awaitingFreshStart flipped to false, React re-ran the effect, cleanup aborted the in-flight stream, and streamRun exited without updating status beyond pending.

The pre-refactor hook used [] deps and only aborted on unmount.

Fix

  • Auto-start cleanup no longer aborts the SSE controller (only suppresses stale start() error reporting).
  • Unmount-only effect aborts the stream when leaving the page.
  • Regression test reproduces the race with a gated createSession and delayed runSession.

Validation

  • bunx vitest run src/hooks/useWikiComposeSession.test.ts (10/10 pass)
  • New test fails on the pre-fix hook and passes with this patch
Open in Web View Automation 

cursoragent and others added 2 commits May 27, 2026 05:52
- Align frontend backend resolution with Google-fixed Wiki Compose model
- Extract session reducer module; slim useWikiComposeSession hook
- Consolidate auto-start via startPolicy and canRetryStart
- Deduplicate compose session locale prep on API routes
- Remove duplicate props and dead outline preview ternary

Co-authored-by: Akimasa Sugai <otomatty@users.noreply.github.com>
When createSession commits, awaitingFreshStart flips and the auto-start
useEffect cleanup called abort() on the in-flight POST /run stream.
Fresh compose sessions could stall at pending with no SSE progress.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant