Skip to content

fix(kitchen-sink): put the Flow State page back off live mode (FIX-2506) - #4596

Closed
jhoffner wants to merge 2 commits into
mainfrom
fix/FIX-2506-e2e
Closed

jhoffner wants to merge 2 commits into
mainfrom
fix/FIX-2506-e2e

Conversation

@jhoffner

@jhoffner jhoffner commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

The problem

Since #4404 merged, Kitchen Sink E2E on main fails the same three specs every run (45 others pass). Every PR off main shows a red E2E check, and that check stops catching anything new.

  • background-work.spec.ts:17 — the background-work row never appears.
  • talk-from-page.spec.ts:403 — the page opens a session stream on the assistant's own session.
  • workforce-shell.spec.ts:82 — page.waitForLoadState("networkidle") times out at line 94.

What this does

It puts the Flow State page back to how #4404 said it would leave it. #4404 (FIX-2410) states: "The Flow State page stays off live mode and keeps BackgroundWorkRefresh. Turning live mode on broke three Kitchen Sink E2E specs (background-work, talk-from-page, workforce-shell), so it was dropped from this PR." Its last merge of main into the branch (b13a2d7) resolved the conflict the other way. It kept the branch's live: true on the page's useSession and deleted BackgroundWorkRefresh. That merge reached main as c247ebc.

One cause produces all three failures:

  • live: true opens a GET /api/flows/sessions/:id/stream on the assistant's session and keeps it open while the page is mounted. That is the extra id in talk-from-page's followed list. It is also why the network never goes idle in workforce-shell.
  • No BackgroundWorkRefresh: the background-work list is re-read only when the live stream names a run. Under the full suite's load the row doesn't arrive within 30 s. The spec passes when run alone, so only the full-suite run reproduces it.

The diff puts both files back to their state before #4404 (6443ddf), with one change. The restored stream-end re-read now calls refresh({ items: false }), which #4404 added, so it re-reads state and the background-work list without the item history. A completed turn already re-reads the full history on its own. This change came from Codex review.

What's asked of you

Nothing here is yours to decide. This restores the behaviour #4404 described. Moving the page to live mode is still the follow-up #4404 named, and that change will have to make these three specs pass.

Parts worth reviewing closely

Linear: FIX-2506 · Bug, direct route, no spec · Merges to main.

How to review this

How to review this. This is a bug fix on the direct route: there is no spec and no spec PR, because the hard part was the diagnosis and it happened in code. This PR is the only gate, so unlike a spec-backed change, the approach is in scope. Nothing here was signed off upstream.

Most valuable here: the diagnosis chain. Does the repro reproduce the reported failure? Is the named cause the real one? Does the fix address that cause rather than the symptom? Does the regression test fail without the fix? Then the second path (the legacy shape, the null boundary, the concurrent case, the cancel path).

In scope to challenge: where the guard was placed, any behaviour change a user could notice, and whether this should have been a spec'd feature instead of a fix.

Engineering calls
Everything else — verification

Introducing commit: c247ebc (merge of #4404). Last green main CI is 6443ddf, the base of that merge. On #4404's own head b13a2d7, Kitchen-sink E2E failed these same three specs (run 41539272391: 3 failed / 45 passed). Every later main run with E2E (41556304309 among them) fails the same three. #4485 (9634cdb) and #4513 (spec-only), between them, don't touch Kitchen Sink. #4510 (FIX-2408) and the bus (#4594) are both in this branch's base and the full suite passes with them, so neither is a cause.

Local repro used a production build in test mode (KITCHEN_SINK_TEST_MODE=1 NEXT_PUBLIC_KITCHEN_SINK_TEST_MODE=1), CI=1, --retries=0. The pre-installed Chromium build differs from the one the pinned Playwright expects, so I ran the repo config through an uncommitted wrapper that sets only launchOptions.executablePath.

Run Base Result
Full suite, before main 4425231 3 failed (the three above), 45 passed
The three specs alone, before 4425231 talk-from-page and workforce-shell fail; background-work passes alone (load-dependent)
The three specs alone, after this branch 3 passed
Full suite, after ×4 this branch 48 passed · 47 passed + 1 failed · 48 passed · 48 passed

The one failure in run 2 was claude-code-mode.spec.ts:88: a console 404 on /claude-code, a route that doesn't render the Flow State page. It passed 42 of 42 times on its own (--repeat-each=6) and in the other three full runs. I don't attribute it to this change, and I've noted it as a separate flake.

  • pnpm --filter @flow-state-dev/kitchen-sink typecheck passes.
  • pnpm --filter @flow-state-dev/kitchen-sink test: 52 files, 431 passed. One earlier run had two codex-session.test.ts timing failures under load. That file passes alone 18/18 and doesn't import either changed file.

What would have prevented this: Kitchen-sink E2E is not a required check. #4404 merged with it red on these same three specs, and its description said the change behind them had been dropped.

https://claude.ai/code/session_011UNkLEJU1iqxFYoPadTRfn


Generated by Claude Code

PR #4404 (FIX-2410) said the Flow State page stays off `live` and keeps
`BackgroundWorkRefresh`, because live mode broke three Kitchen Sink E2E
specs. Its final merge of main (b13a2d7) resolved the page and the
background-work panel to the branch side instead: `live: true` on the
assistant's `useSession`, and the stream-end re-read deleted. That merge
landed on main as c247ebc, and from then on the same three specs fail:

- talk-from-page:403 sees the assistant's session followed by a
  `/sessions/:id/stream` it must not open.
- workforce-shell:82 never reaches `networkidle`: the live session stream
  holds a connection open for as long as the page is mounted.
- background-work:17 loses the row under suite load: with the stream-end
  re-read gone, the list only updates when the live stream names a run.

Restore both files to their pre-#4404 contents, which is what #4404
described. Moving the page to live mode stays the follow-up #4404 named.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UNkLEJU1iqxFYoPadTRfn
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Nov 3, 2026 2:46am UTC
flow-state-dev-kitchen-sink Ignored Ignored Nov 3, 2026 2:46am UTC
flow-state-dev-ui Ignored Ignored Preview Nov 3, 2026 2:46am UTC
flow-state-dev-build-site Skipped Skipped Nov 3, 2026 2:46am UTC

Request Review

@linear-code

linear-code Bot commented Nov 3, 2026

Copy link
Copy Markdown

FIX-2506

jhoffner commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

This restores two Kitchen Sink files to their state before #4404. The one thing I'm unsure of: does anything merged since c247ebc depend on the Flow State page being on live mode, or on BackgroundWorkRefresh being absent?


Generated by Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T02:36:28.029019Z 4423dc2 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4423dc2fab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

useEffect(() => {
const finished = wasStreaming.current && !isStreaming;
wasStreaming.current = isStreaming;
if (finished && usesBackgroundWork) void refresh();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the state-only refresh for background-work discovery

Once a conversation has used background work, this effect downloads and paginates its entire item history after every subsequent turn, adding history-sized network and server work even though it only needs to refresh the child-session list. Unlike the pre-#4404 implementation, the current framework supports refresh({ items: false }): packages/react/src/hooks/useSession.ts performs the same child-session refresh without fetching item history. Use that option here; completed requests already trigger their own full snapshot refresh in onRequestStatus.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 756c724. The stream-end re-read is now refresh({ items: false }).

I checked this against packages/react/src/hooks/useSession.ts:

  • refresh({ items: false }) runs refreshState and refreshChildSessions together and reads no item pages.
  • A completed request already gets the full refreshSnapshot() in the terminal branch of onRequestStatus.
  • That branch does not re-read child sessions, so this component is still what brings a just-filed job's row onto the screen.

I updated the component's cost notes to match.

Verification: a test-mode production build, CI=1, --retries=0.

  • The three specs: 3/3 passed.
  • The full Kitchen Sink E2E suite, run twice: 48/48 both times. background-work.spec.ts passed under full-suite load each time.
  • Kitchen Sink typecheck is clean and its unit tests pass (431).

🤖 Generated with Claude Code

https://claude.ai/code/session_011UNkLEJU1iqxFYoPadTRfn


Generated by Claude Code

…FIX-2506)

`BackgroundWorkRefresh` called `refresh()`, which re-reads the whole item
history on every finished turn in a conversation that uses background
work. A completed request already gets that full read from `useSession`'s
terminal branch, so the stream-end re-read only needs the dispatched-run
list: `refresh({ items: false })` reads state and child sessions with no
item pages (Codex review on #4596).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UNkLEJU1iqxFYoPadTRfn
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.

2 participants