Skip to content

fix(cmux-next pages): a provider's state sent inside subscribe reaches the page - #27468

Merged
lawrencecchen merged 2 commits into
feat-cmux-nextfrom
fix/page-router-early-events
Oct 31, 2026
Merged

lawrencecchen merged 2 commits into
feat-cmux-nextfrom
fix/page-router-early-events

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A page provider that sends its current state from inside subscribe lost that state. The agent activity, icon picker and update surface pages showed nothing until their next change.

PageRouter.subscribe holds the events a provider sends while subscribe runs, and flushes them once after the reply that names the subscription (20066e1). #24617 (4abd404, "replay agent page events across bridge gaps") rewrote that guard for providers that send only after the reply (eventsAfterSubscribeReply). The rewrite inverted the guard:

  • events held during subscribe were released and thrown away. AgentActivityPageProvider, IconPickerProvider and UpdateSurfaceIsland call onEvent inside subscribe, so their first state never reached the page;
  • with nothing held, events sent after the reply were caught and delivered one main turn late.

The guard is now guard early.isHolding, !provider.eventsAfterSubscribeReply. Nothing held: release at once. Held: flush once after the reply. Providers with eventsAfterSubscribeReply (the agent page) are unchanged.

Thanks to #24617 for the bridge-gap replay; this restores the early-event path it changed. The same bug is on perf/chrome-parity and is fixed there in cp/fix-tip-page-script-batch-crash (green proof 74b81ea13b25c872967366ac: PageRouterEarlyEventsTests, PageRouterFrozenDeliveryTests and PageScriptPipelineBatchTests pass).

Changelog

Fixed: The agent activity, icon picker and update surface pages show their current state when they open, not only after their next change.

Testing

Regression test PageRouterEarlyEventsTests (red commit 24e468d first, fix dfce161):

  • cmux-ci run --class light --script scripts/ci/package-test-lane.sh --arg suite --arg Packages/macOS/CmuxNext --arg PageRouterEarlyEventsTests (through proof-step.py):
    • red at 24e468d (fleet e7701605341cd3be38379cc3): failed. aStateSentInsideSubscribeReachesThePageAfterTheReply got [] then [2] (the held state was dropped); anEventAfterTheReplyGoesStraightToThePageInItsTurn got [].
    • green at dfce161 (fleet 4c8d665106a0201dce934030): both pass.
  • Compile: cmux-ci compile-check --app --package CmuxNext --recipe-version 2 at dfce161 (fleet 21a81b1382d0303c8db082c1): passed.

Observed / Not run

Observed: the two fleet runs and the compile above; scripts/cmux-next/prepush-gate.py clean.
Not run: the full CmuxNextPagesTests target, and a live app check of the three pages in a tagged build.

Proof

No capture: the fix is in the page router's event delivery; no view or look changes. The fleet tests above are the proof.

Follow-up (review note, not in this PR): the throw and closed paths of subscribe never call early.release(), so a provider that keeps onEvent after cancel would keep growing the held list. Fixed in #27500 (red 13 allocations over an empty loop for 10 000 events, green 0, in Debug and in a Release build).

Review (independent subagent, correctness first): SHIP at dfce161

Checklist

  • Behavior changes have added or updated tests (PageRouterEarlyEventsTests)
  • Reviewed with a subagent before merge; verdict above. No user-facing strings change, so no localization audit applies.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes the pages' initial state being dropped on open, so the agent activity, icon picker, and update surface pages now show their current state immediately instead of only after the next change.

A previous rewrite of the guard in PageRouter.subscribe inverted it and discarded the events a provider sends while subscribe runs; that path is restored with guard early.isHolding, !provider.eventsAfterSubscribeReply, while the bridge-gap replay for providers that send after the reply is unchanged.

  • Adds regression tests PageRouterEarlyEventsTests covering both the held-state flush and a post-reply event delivered in its own turn.

Written for commit dfce161. Summary will update on new commits.

View guided diff Turn on auto-fix

lawrencecchen added 2 commits October 29, 2026 14:49
…es the page (red)

PageRouterEarlyEventsTests: a provider's state sent from inside subscribe
reaches the page once, after the reply that names its subscription; an
event after the reply goes to the page in its own turn. Both fail on
feat-cmux-next 356f13f: #24617 inverted the guard in
PageRouter.subscribe (fix in the next commit).

Found on perf/chrome-parity, which has the same code
(cp/fix-tip-page-script-batch-crash).
…s the page

PageRouter.subscribe keeps the events a provider sends while subscribe runs
(its current state) and flushes them once after the reply
(20066e1: `guard early.isHolding else { release }`). #24617
(4abd404) rewrote that guard for providers that send only after the
reply and inverted it:

- events held during subscribe were released and thrown away: the first
  state of the agent activity, icon picker and update surface pages
  (AgentActivityPageProvider, IconPickerProvider, UpdateSurfaceIsland call
  onEvent inside subscribe) never reached the page, which showed nothing
  until its next change;
- with nothing held, events after the reply were caught and sent a main
  turn late.

The guard is now `guard early.isHolding, !provider.eventsAfterSubscribeReply`.

Regression test: PageRouterEarlyEventsTests (red in the previous commit).
@lawrencecchen lawrencecchen added the risk:normal Risk tier (docs/ci/risk-tiers.md) label Oct 29, 2026
@cursor

cursor Bot commented Oct 29, 2026

Copy link
Copy Markdown

Bugbot needs on-demand usage enabled

Bugbot uses usage-based billing for this team and requires on-demand usage to be enabled.

A team admin can enable on-demand usage in the Cursor dashboard.

@lawrencecchen lawrencecchen added the ready-to-land Reviewed at this head; next-autoland merges it into feat-cmux-next when its only reds are base reds label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Review dfce161: HQ feed card · gallery before/after runs · checks

App of this head (app.zip, kept 1 day)

gh workflow run reload-build.yml -R manaflow-ai/cmux --ref feat-cmux-next -f tag=pr27468 -f ref=fix/page-router-early-events -f platform=macos -f backend_mode=local

red: cmux-next checks (god files, concurrency, crash safety, l10n); no finished base run on e07b33b to compare; do not merge until green; see lane-rules

Shipped in:

@blacksmith-sh

blacksmith-sh Bot commented Oct 29, 2026

Copy link
Copy Markdown

Found 6 test failures on Blacksmith runners:

Failures

Test View Logs
/tmp/tmpdosl1om8/summary-fail.json (live):/summary-fail.json (live): View Logs
/tmp/tmpy1eyu7bo/summary-missing.json (live):/summary-missing.json (live): View Logs
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows/
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows
View Logs
[new_workspaces] the window draws no frames/[new_workspaces] the window draws no frames View Logs
[tabs] debug.tab_switch timed 0 of 40 switches/
[tabs] debug.tab_switch timed 0 of 40 switches
View Logs
[tabs] the window draws no frames/[tabs] the window draws no frames View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@teamleaderleo

Copy link
Copy Markdown
Collaborator

Bead cx-8yz3is created for this PR by the cmux coordinator.

@teamleaderleo

Copy link
Copy Markdown
Collaborator

Review (codex gpt-6-astra high fast, drain lane): SHIP at dfce161

No blocking findings.

@lawrencecchen
lawrencecchen merged commit 42fd321 into feat-cmux-next Oct 31, 2026
216 of 242 checks passed
@lawrencecchen
lawrencecchen deleted the fix/page-router-early-events branch October 31, 2026 00:34

This branch was previously deployed

1 inactive deployment
ci-routing-agent — dfce1618 Deployed Oct 29, 2026 by lawrencecchen via namespace autofix #6335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-land Reviewed at this head; next-autoland merges it into feat-cmux-next when its only reds are base reds risk:normal Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants