Repository navigation
fix(browser): notify state on offscreen page navigation commit - #21703
AmethystLiang merged 2 commits into
Conversation
|
Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAfter a committed main-frame navigation, the guest navigation policy now notifies paired clients of the changed browser state. The link-routing end-to-end test adds mirror and host-row diagnostics, waits for background mirroring, and then surfaces the mirrored page before checking pane counts and webview state. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to The change cannot pass the required code-quality check until the prohibited type assertion is replaced, so it should be fixed before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the problem, solution, changed files, and automated testing. It does not follow the repository template and omits the required Linked Issue, Visual Proof or an explicit N/A reason, Why, review, compatibility considerations, and checklist details. Resolution Update the description to include all required template sections. Add the linked issue after “Fixes #”, provide visual proof or write ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 482a857e-d5ea-4989-a8f2-bc0952de3a12
📒 Files selected for processing (2)
src/main/browser/browser-manager-guest-navigation-policy.tstests/e2e/paired-remote-browser-link-open-routing.spec.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
Important
The production change is sound, but the new e2e assertions don't exercise it. The client stages the tab with the link URL before the host round-trip, so the mirrored row is already correct even with the did-navigate notification removed — the spec would stay green with the bug present.
Reviewed changes
- Offscreen commit notification:
didNavigateHandlernow callsnotifyBrowserGuestStateChanged(guest.id), so a committed main-frame navigation on a renderer-less offscreen guest notifies the owning worktree's state listener. Desktop webview guests are unaffected (notifyBrowserGuestStateChangedearly-returns for them). - Link-routing spec: added
readMirroredRows,readHostRowsThroughClient, andwaitForMirroredLinkPageId; the link-open acts now wait for a mirrored row, assert no pane mounts while the tab is backgrounded, then focus the row and assert the streamed pane appears.
ℹ️ Offscreen in-page navigations still don't republish
The commit notification hangs off did-navigate only, so a same-document navigation (history.pushState / hash change) on an offscreen page still never reaches paired clients, leaving the mirrored row's URL stale. The desktop webview path deliberately listens to both did-navigate and did-navigate-in-page (ClientHostedBrowserPagePane.tsx:299-300), so this is an asymmetry in the same publish mechanism — flagging in case it's in scope; it need not block this fix.
Technical details
# Offscreen in-page navigation has no publisher
## Affected sites
- `src/main/browser/browser-manager-guest-navigation-policy.ts:126` — only `did-navigate` notifies; no `did-navigate-in-page` listener is installed for guests.
- `src/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.tsx:299-300` — the desktop path listens to both, so the two backends diverge.
## Required outcome
- If in-page URL changes are meant to mirror for server-placed pages, an offscreen `did-navigate-in-page` notification needs the same treatment. Otherwise document the intentional gap.
## Open questions for the human
- Is offscreen in-page navigation intentionally out of scope for this bug?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
8f3ec67 to
b2ac450
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Test-helper validation: in
readHostRowsThroughClient, replaced the unsaferesponse.result as { tabs: ... }assertion with explicit runtime checks and atab is { type: string; url?: string }predicate, clearing the changed-codeconsistent-type-assertionsgate. - Unchanged production fix: the
did-navigatenotification inbrowser-manager-guest-navigation-policy.tsand the rest of the link-routing spec carry over from the prior reviewed revision.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Offscreen pages have no renderer to publish their row, so the navigation commit is the only moment paired clients learn the new URL. Every failure path already announces; the success path was missing this notification, preventing background links from mirroring. Extend the E2E test with helpers to verify background links mirror before surfacing as panes, reading both client and host state to isolate failure causes.
Replace unsafe type assertion with runtime validation of the response structure. Add defensive checks to ensure tabs exist and have the expected shape before processing, improving test robustness when the remote host response is incomplete or malformed.
b2ac450 to
355bc13
Compare

Problem
When opening a remote link in the background on a paired remote host, the client never mirrored the page the host opened. Offscreen pages (which lack a renderer) had no way to notify paired clients when their URL changed, leaving the browser row stuck at
about:blankor missing entirely.Solution
Call
notifyBrowserGuestStateChanged()when a main frame navigation commits for an offscreen page. This synchronizes the new URL to paired clients at the moment the host confirms the commit, since offscreen pages cannot publish state via a renderer.What Changed
Testing
Test verifies:
Background link opens create a mirrored browser row in the client store
Pane only renders after the row is focused/surfaced
Behavior holds across placement preference changes
Helpers diagnose client store vs. host inventory mismatches
Automated tests added/updated