Skip to content

fix(browser): notify state on offscreen page navigation commit - #21703

Merged
AmethystLiang merged 2 commits into
mainfrom
jinjing/sta-7740-bug-remote-pane-link-open-never-creates-the-second-remote
Sep 22, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
jinjing/sta-7740-bug-remote-pane-link-open-never-creates-the-second-remote

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​138 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​133
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

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:blank or 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

  • Browser manager: Added state notification on offscreen page navigation commit
  • Test: Enhanced with helpers to verify mirrored pages appear before surfacing and to diagnose state mismatches between client and host

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

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

We 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 @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

After 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 8f3ec

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 re… Update the description to include all required template sections. Add the linked issue after “Fixes #”, provide visual proof or write N/A with a reason, explain why this approach was selected, document review and cross-platform or remote-…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: notifying paired clients after offscreen page navigation commits.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

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 N/A with a reason, explain why this approach was selected, document review and cross-platform or remote-environment considerations, and complete the required testing and checklist items.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 482a857e-d5ea-4989-a8f2-bc0952de3a12

📥 Commits

Reviewing files that changed from the base of the PR and between 3ad6b7e and 8f3ec67.

📒 Files selected for processing (2)
  • src/main/browser/browser-manager-guest-navigation-policy.ts
  • tests/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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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: didNavigateHandler now calls notifyBrowserGuestStateChanged(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 (notifyBrowserGuestStateChanged early-returns for them).
  • Link-routing spec: added readMirroredRows, readHostRowsThroughClient, and waitForMirroredLinkPageId; 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?

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@AmethystLiang
AmethystLiang force-pushed the jinjing/sta-7740-bug-remote-pane-link-open-never-creates-the-second-remote branch from 8f3ec67 to b2ac450 Compare September 21, 2026 05:29

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Test-helper validation: in readHostRowsThroughClient, replaced the unsafe response.result as { tabs: ... } assertion with explicit runtime checks and a tab is { type: string; url?: string } predicate, clearing the changed-code consistent-type-assertions gate.
  • Unchanged production fix: the did-navigate notification in browser-manager-guest-navigation-policy.ts and the rest of the link-routing spec carry over from the prior reviewed revision.

Pullfrog  | View workflow run | Using 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.
@AmethystLiang
AmethystLiang force-pushed the jinjing/sta-7740-bug-remote-pane-link-open-never-creates-the-second-remote branch from b2ac450 to 355bc13 Compare September 22, 2026 05:48
@AmethystLiang
AmethystLiang merged commit c3c4b4e into main Sep 22, 2026
3 of 4 checks passed
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