Skip to content

fix(browser): restore viewport controls for client-hosted pages - #30353

Closed
oliver-mee wants to merge 12 commits into
stablyai:mainfrom
oliver-mee:fix/client-hosted-browser-controls
Closed

oliver-mee wants to merge 12 commits into
stablyai:mainfrom
oliver-mee:fix/client-hosted-browser-controls

Conversation

@oliver-mee

@oliver-mee oliver-mee commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Give a remote workspace's This device browser the same viewport presets and page-targeted DevTools action as a fully local page.

What Changed

Shares the viewport preset menu and sizing helpers, applies native guest metrics, reapplies them after DOM readiness, routes panning and scroll reporting to the client page, and clips retained guests without reparenting. Default resets both guest metrics and size. The DevTools action targets the actual desktop guest.

Why

A menu-only change would not change the rendered page. Sharing the preset behavior and testing actual guest width checks the workflow rather than just the button. External opening of host-only URLs stays disabled to avoid targeting the wrong machine.

Linked Issue

Fixes #30352

Visual Proof

Paired Electron interaction evidence from the combined integration checkout, not the standalone controls head. These show the same patched build before selecting a preset, after choosing Mobile M, and after resetting to Default. They are not screenshots of an unpatched build.

Default Mobile M Reset
Default viewport Mobile preset Reset viewport

The test asserts actual guest innerWidth is 375 and grows after reset. A repeat run also passed annotation capture and real PTY submission using an adaptation of #19417. That delivery adaptation is not part of this PR. This remains stacked on #22813 and must not merge ahead of it.

Testing

October 25 refresh: merged current main at 1d2b5361efa7851e95c4b24e5a9b298863f8fb7b, preserving the existing contribution history. Current head ce6f5f50a844b488976ba84a56ca82c2262b4f5d: 41 focused tests across annotations, viewport presets, retained guests and shared toolbar behavior; renderer native typecheck and scoped lint/format pass. Kept upstream’s new-tab page, loading progress, link status and failure recovery. Added a regression proving Stop still stops the loading guest. Earlier application/Electron acceptance below belongs to its recorded earlier heads and was not repeated for this refresh. Substantive upstream CI remains a separate maintainer approval gate.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Previously: 1,027 browser-pane tests across 128 files passed, plus renderer typecheck and scoped lint. Actual Linux Electron tests passed for both local and paired pages: choose Mobile M, verify guest innerWidth is 375, reset to Default and verify it grows. The paired test also picks an element and saves its annotation.

Refreshed against upstream ba6599eab: 35 focused viewport, retained-guest and client-pane tests pass, as does renderer typecheck. App and CLI builds completed at 22e9ec69f.

The initial paired annotation run failed because the card did not appear after the fixture dispatched its synthetic click. Test-only commit e0030b578 now waits for the guest's actual selection listener (cancelAwait) before clicking and retains picker-state diagnostics on failure. With the same unchanged app build, that fixture passed once and then twice more in a serial repeat run, with retries disabled. This is three passes after a fixture change, not a clean initial run or proof of every intermittent startup condition. Mobile width, reset and saved annotation assertions all passed. The original failure trace is retained.

Scoped lint passes for the changed spec. Full E2E typecheck was attempted and fails in other E2E/tool files, including terminal wheel and transcript fixtures; it reports no diagnostic for this changed spec. This is not a full typecheck pass. Windows and packaged-app testing remain unverified. Annotation Send submission is not implemented here; the separately adapted #19417 evidence above is not standalone acceptance of this PR.

Dependency

Stacked on #22813 by clodus-dev at a6d1729. Its annotation implementation is preserved, not replaced. The commits specific to this PR are 6f23792 and 93bc444, plus the current-main merge. Do not merge this as a competing annotation implementation; land #22813 first and then refresh this branch so the review diff contains only controls.

AI Disclosure

OpenAI GPT-6.1 Sol implemented and tested this change under human direction.

Review

Please review native viewport metrics, reset behavior and retained guest clipping. Annotation capture is inherited from #22813; independent delivery verification remains separate.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Upstream validation for e0030b5785 is waiting for maintainer approval: PR Checks. Focused local evidence above remains unchanged; no substantive current-head CI pass is claimed.

This PR does not add profile selection, change cookie policy, or restore unsafe external URL routing.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with GPT-6.1 Sol
🧑‍💻 Ideated, directed and reviewed by a human, @oliver-mee

clodus-dev and others added 7 commits October 14, 2026 16:49
A remote-server page that renders on this desktop ("This device") showed
only the Draw button: Grab and Annotate were never wired up, although
main already registers the page's local guest, so the picker, selection
capture and annotation viewport bridge resolve to it unchanged.

The client-hosted pane now uses the shared BrowserChromeToolbar and
BrowserGuestAnnotateOverlays. The grab/annotation/markup wiring moves out
of the workspace preview into use-browser-guest-element-tools, shared by
both surfaces. Reloading the guest clears its annotations, matching local
tabs. Renderer-only; no IPC, RPC or wire change.

Fixes stablyai#20486
Refs stablyai#17384

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
An armed or confirming grab kept its window-level C/S listener and
blocked Draw after the pane deactivated or the guest started a new load.
Main settles only an awaiting pick on navigation, so a confirming one
stayed armed. Cancel it on deactivation and on load start.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A comment card left open when the pane deactivated or the host replaced
the guest survived, so Add could later attach element rects captured on
a document that is no longer shown. Clear it alongside the markup
capture on the same deactivation, replacement, failure and unmount
triggers.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ent-hosted pages

Main now keeps browser notes across navigation and reload, retiring only
their badges, and lets the comment card follow the picked element through
guest viewport reports. Client-hosted pages adopt both: a document boundary
(load start or main-frame navigation, including in-place) retires badges
and drops a half-made pick instead of deleting saved notes, and the guest's
console-message reports reach the shared overlay.

The shared toolbar now folds tools into a required overflow menu on narrow
panes; client-hosted pages get one with the folded tools and reload.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@oliver-mee
oliver-mee marked this pull request as ready for review October 18, 2026 13:58
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fdf00c0e-b236-45ba-81db-8855fde02f31
📥 Commits

Reviewing files that changed from the base of the PR and between 22e9ec6 and e0030b5.

📒 Files selected for processing: 1
  • tests/e2e/paired-client-hosted-browser-annotate.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

The client-hosted browser pane now uses shared guest tools, annotation overlays, a hosted toolbar, viewport presets, guest viewport sizing and panning, and retained-guest clipping. Load failures use a dedicated component. Tests cover tool lifecycles, viewport behavior, clipping, and paired-client interactions.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to e0030

The reviewed change only extends an end-to-end test for the client-hosted browser viewport and annotation flow. No merge-blocking risk was found.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Out of Scope Changes check Warning The whole-PR diff also adds and integrates annotation controls that issue #30352 explicitly excludes. The changes add useBrowserGuestElementTools and useClientHostedBrowserGuestTools, modify `Clie… Remove the annotation-specific implementation, integration, and annotation-only tests from this pull request, or move them to #22813. Refresh the branch so the reviewed diff contains only the #30352 changes and the supporting integration re…
Docstring Coverage Warning Docstring coverage is 40.91% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 19 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: restoring viewport controls for client-hosted browser pages.
Linked Issues check Passed Issue #30352 requires shared viewport presets, guest metric application and reset, page-scoped panning and scroll reporting, retained-guest clipping, and guest-targeted DevTools. `BrowserViewportPrese…
Description check Passed The pull request description follows the required template. It includes the user-facing summary, changes, rationale, linked issue, visual proof, testing details, AI disclosure, review guidance, depend…
Full details: Linked Issues check

Explanation

Issue #30352 requires shared viewport presets, guest metric application and reset, page-scoped panning and scroll reporting, retained-guest clipping, and guest-targeted DevTools. BrowserViewportPresetMenu uses the shared preset list. useClientHostedBrowserViewport applies size styles, sends the guest override, reapplies it on dom-ready, and routes matching scroll events to the client page scroller. Retained attachment code applies the scroller clip path. ClientHostedBrowserPageToolbar opens DevTools with browserPageId and keeps host-only external opening disabled. Focused tests cover these behaviors, and the E2E test checks Mobile M width and reset growth.

Full details: Description check

Explanation

The pull request description follows the required template. It includes the user-facing summary, changes, rationale, linked issue, visual proof, testing details, AI disclosure, review guidance, dependency notes, scope notes, and checklist status. It also clearly records unverified platforms and incomplete full-suite validation.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff also adds and integrates annotation controls that issue #30352 explicitly excludes. The changes add useBrowserGuestElementTools and useClientHostedBrowserGuestTools, modify ClientHostedBrowserPagePane for annotation binding and overlays, replace use-client-hosted-browser-markup, refactor useDocPreviewGuestTools, and add annotation unit and paired E2E tests. These changes implement #22813 behavior rather than viewport presets, guest metrics, panning, clipping, or guest-targeted DevTools.

Resolution

Remove the annotation-specific implementation, integration, and annotation-only tests from this pull request, or move them to #22813. Refresh the branch so the reviewed diff contains only the #30352 changes and the supporting integration required to preserve existing behavior.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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: 3


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2c0de6f7-d74d-40b7-b358-e42637f14ed7
📥 Commits

Reviewing files that changed from the base of the PR and between d7aea6d and 2dfab77.

📒 Files selected for processing: 20
  • src/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.guest-tools.test.tsx
  • src/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.tsx
  • src/renderer/src/components/browser-pane/annotate/use-browser-guest-element-tools.ts
  • src/renderer/src/components/browser-pane/annotate/use-client-hosted-browser-guest-tools.ts
  • src/renderer/src/components/browser-pane/annotate/use-client-hosted-browser-markup.tsx
  • src/renderer/src/components/browser-pane/assemble-chrome/browser-toolbar-menu-dropdown.tsx
  • src/renderer/src/components/browser-pane/assemble-chrome/browser-viewport-preset-menu.tsx
  • src/renderer/src/components/browser-pane/assemble-chrome/client-hosted-browser-page-toolbar.tsx
  • src/renderer/src/components/browser-pane/browser-client-page-retained-registry.test.ts
  • src/renderer/src/components/browser-pane/browser-client-page-visible-attachment.ts
  • src/renderer/src/components/browser-pane/client-hosted-browser-load-failure.tsx
  • src/renderer/src/components/browser-pane/client-hosted-browser-pane-test-rig.ts
  • src/renderer/src/components/browser-pane/host-guest/browser-page-viewport.ts
  • src/renderer/src/components/browser-pane/host-guest/use-browser-page-viewport-scroll-reporting.ts
  • src/renderer/src/components/browser-pane/use-client-hosted-browser-viewport.test.tsx
  • src/renderer/src/components/browser-pane/use-client-hosted-browser-viewport.ts
  • src/renderer/src/components/browser-pane/workspace-doc/use-doc-preview-guest-tools.ts
  • tests/e2e/browser-viewport-control-parity.spec.ts
  • tests/e2e/helpers/client-hosted-browser-fixture.ts
  • tests/e2e/paired-client-hosted-browser-annotate.spec.ts
💤 Files with no reviewable changes: 1
  • src/renderer/src/components/browser-pane/annotate/use-client-hosted-browser-markup.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks for this! #43777 brings viewport presets to This-device pages using your approach (preset-sized box, clipping the retained host, reapplying the override on load), on top of the files that have since moved. You're credited as a co-author.

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks @oliver-mee! The This-device page toolbar now reuses the shared browser toolbar, which brings the ⋯ menu along with hard reload, zoom, favicon and download cancel. That landed in #43777, with a Co-authored-by line for you on the merge. Closing this one in favour of that.

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.

[Bug]: This device browser lacks viewport presets and page-targeted DevTools

3 participants