Skip to content

feat(ui): browser panel scales the live frame instead of resizing the remote viewport - #148187

Closed
slzszyt-ux wants to merge 8 commits into
openclaw:mainfrom
slzszyt-ux:feat/browser-panel-viewport-scale
Closed

slzszyt-ux wants to merge 8 commits into
openclaw:mainfrom
slzszyt-ux:feat/browser-panel-viewport-scale

Conversation

@slzszyt-ux

@slzszyt-ux slzszyt-ux commented Sep 14, 2026 •

Copy link
Copy Markdown

What Problem This Solves

The Control UI browser panel treated itself as the owner of the remote page's layout viewport: opening the panel, resizing the dock, or switching tabs sent resizeBrowserViewport. Dragging UI chrome therefore reflowed the page an agent was working on (media restarts, virtualized lists reset), and the panel's sidebar aspect forced pages away from their intended layout.

This adds an opt-in fixed-viewport mode (toolbar lock toggle, persisted per browser profile). With it enabled the remote page keeps the viewport its agent or document chose, and the panel scales the live frame to fit. The shipped follow-panel default is unchanged while the toggle is off.

Review follow-ups

  • Contain-fit (P1): .bp-shot now uses object-fit: contain with a definite stage height, so the whole page stays visible in short docks instead of overflowing.
  • Normalized geometry (P2): annotation painting translates the canvas to the painted frame origin instead of mixing pixel offsets into normalized coordinates; highlights use the same translation.
  • Default preserved: fixed-viewport viewing is opt-in via the toolbar toggle; no behavior change for existing users.
  • Matching input geometry: pointer mapping measures the painted frame box (letterbox aware) and ignores letterbox margins, so clicks and inspect stay aligned at any scale or dock size.

Evidence

  • node scripts/run-vitest.mjs run ui/src/components/browser -> 259 passed (19 files), including new coverage:
    • viewport stays untouched while the panel resizes in fixed-viewport mode, and resuming follow-panel mode re-syncs the remote;
    • pointer mapping against the letterboxed painted frame, letterbox margins ignored;
    • annotation painting translated to the painted frame origin.
  • i18n: catalog artifacts regenerated with pnpm ui:i18n:sync (English fallbacks recorded for pending keys; the control-ui-locale-refresh workflow translates after merge, which is the documented path when no provider is configured).
  • Runtime: on a live instance driven with the equivalent behavior, dragging the dock leaves the remote viewport size unchanged while the frame scales; clicks land correctly after scaling. Panel screenshots to be added as a follow-up comment.

Review follow-ups (revision 5)

  • Inspection tooltips: queueInspect stores stage-relative coordinates for tooltip placement again, while the letterbox-aware point stays reserved for remote requests, so tooltips stay on the hovered element when the frame letterboxes.
  • Overlay repaint: a dock-geometry change now requests a repaint, so annotation marks stay aligned while the remote viewport is locked.
  • Letterbox clicks: clicks in the margin outside the painted frame no longer capture a previously inspected element, and a stale inspection is invalidated when the pointer leaves the frame.
  • Selected state: toolbar icons (fixed-viewport lock, annotate, inspect) gained a visible pressed state.

Review follow-ups (revision 6)

  • Pending inspections on letterbox exit: leaving the painted frame now invalidates the inspection owner, so a queued or in-flight reply cannot restore a cleared element/tooltip.
  • Native tooltips: native inspection stores stage coordinates for tooltip placement, keeping frame coordinates reserved for remote/native input.

Review follow-ups (revision 7)

  • Native inspections on letterbox entry: the native inspect guard now clears the highlight and advances its inspection generation, so a queued or in-flight native reply cannot restore a stale highlight while the pointer is in the margin.

Runtime evidence

Served-PR-build proof on a real page with measured dock sizes and remote-viewport readings in both modes, plus saved-profile reload behavior: #148187 (comment)

Saved preference scope

openclaw.browserPanel.fixedViewport lives in the Control UI origin's localStorage: opt-in, default off, applies to every browser panel opened from that origin regardless of session or remote profile, and survives reloads. Per-session or per-remote-profile scoping is intentionally not implemented; that origin-wide scope is the point that needs maintainer acceptance.

Additional evidence

Scaled-input alignment in a 0.342× frame (inspect resolves the remote element exactly) and the neutral reload capture: #148187 (comment)

Decision needed: saved preference scope

The lock is remembered in the Control UI origin's localStorage (openclaw.browserPanel.fixedViewport), so after opting in it also applies to browser panels opened later in other sessions and remote profiles on the same origin.

  • Keep as-is (recommended): opt-in, default off, one read/write site, "saved viewing preference" semantics.
  • Narrower, on request: key it per remote profile or per chat session instead; a small change at the read/write sites, no migration needed.

Compatibility: no migration. Existing profiles have no such key, so the lock stays off; any value other than "1" is treated as off. Upgrading or rolling back cannot strand a user in a mode they did not enable.

Maintainer acceptance of the chosen scope is the remaining gate.

…ewport

The browser panel treated itself as the owner of the remote page's layout
viewport: opening the panel, resizing the dock, or switching tabs re-requested
the remote viewport at the panel's size. Dragging UI chrome therefore reflowed
the page an agent is working on (media restarts, virtualized lists reset), and
the panel's sidebar aspect forced pages away from their intended layout.

The panel is a viewer. It now renders the live frame scaled to the panel
(the CSS already preserves aspect), while the remote page keeps the viewport
the agent or page chose. Pointer mapping (clicks, inspect hover) and
stroke/highlight painting map against the rendered frame box so they stay
exact at any scale. The legacy panel-driven resizing stays available via
localStorage["openclaw.browserPanel.followViewport"] = "1".
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Adds a saved browser-panel lock that preserves the remote viewport and scales the displayed frame with aligned input and annotations.

Example: Resize the dock from 480×852 to 656×852 while viewing a 1920×937 page.

  • Before: Follow mode resizes the remote page to fit the panel.
  • After: With the lock enabled, the remote page remains 1920×937 while its displayed frame scales.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong supplied runtime proof and no actionable introduced defect; unresolved product direction caps overall readiness, while conflicts require integration work.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The author exercised the served PR UI against a live Gateway and real Chromium fixture: dock resizing preserves the locked remote dimensions, reload retains the selection, and scaled inspection resolves the intended element; inspected screenshots support those results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Resizing the Browser panel can reflow a managed page while an agent is using it.
Reason: The lock offers demonstrated user value, but adding a persistent cross-session viewing option requires an owner direction decision.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: the optional viewport lock remains meaningful distinct work, and the merged shared-window fix explicitly says it does not replace this PR.

Priority: P2
Reviewed head: af4a7dd8906760f59f50ad21e359b8b735a9fc6a
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should managed-browser viewport locking be offered, and should its saved preference apply across sessions and remote profiles on the same Control UI origin?
  • Recommendation: Sponsor the origin-wide viewing preference: Keep the default-off lock and its single origin-local preference, as proposed.
  • Why: The author explicitly requests acceptance of origin-wide persistence; no maintainer approval settles that choice, while the merged shared-window fix recognizes the proposal as distinct.

Before merge

  • Complete next step - The contributor must resolve GitHub's reported conflicts against the current Solid browser panel, using BrowserPanelViewportOwner and retaining canAutoResizeViewport checks.

Findings

None.

Agent review details

How this fits together

The Control UI browser panel receives remote screenshots and viewport metrics, renders the page, and translates local pointer and annotation coordinates into remote page coordinates.

flowchart LR
  A[Dock and toolbar] --> B[Viewport controller]
  B --> C[Browser request client]
  C --> D[Remote browser]
  D --> E[Frame and metrics]
  E --> F[Scaled panel surface]
  F --> G[Pointer and annotation mapping]
  G --> C
Loading

Technical review

Best possible solution:

If sponsored, integrate the opt-in lock into the current toolbar and viewport owner while preserving browser-owner resize capability checks.

Do we have a high-confidence way to reproduce the issue?

Current main still resizes managed-browser viewports to panel dimensions; supplied live measurements demonstrate that behavior and the proposed opt-in alternative, without executing contributor code during this review.

Is this the best way to solve the issue?

The introduced patch places the preference with the existing viewport controller and shares frame geometry across input and annotation painting; current-main integration should use the replacement Solid owners rather than restore retired controllers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c55eea9b74a1.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +154, Tests +269. Total +423 across 14 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 8 165 11 +154
Tests 6 271 2 +269
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 436 13 +423

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Saved viewing options 1 new default-off toolbar preference The value persists per Control UI origin and affects subsequently opened panels across sessions and remote profiles.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Optional viewport preservation improves browser-agent workflows without changing the shipped follow-panel default.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-15T04:43:19.207Z sha 3faa364 :: needs real behavior proof before merge. :: [P2] Invalidate pending inspections when the pointer enters a margin | [P2] Use stage coordinates for native inspection tooltips too
  • reviewed 2026-09-15T05:02:51.078Z sha 2f912fe :: needs real behavior proof before merge. :: [P2] Invalidate native inspections when entering a letterbox margin
  • reviewed 2026-09-15T05:32:13.569Z sha af4a7dd :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-15T06:21:13.805Z sha af4a7dd :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-15T06:42:13.346Z sha af4a7dd :: blocked before merge. :: none
  • reviewed 2026-09-15T07:01:59.175Z sha af4a7dd :: blocked before merge. :: none
  • reviewed 2026-09-24T06:57:04.410Z sha af4a7dd :: blocked before merge. :: none
  • reviewed 2026-10-05T17:32:48.231Z sha af4a7dd :: blocked before merge. :: none

Reviewed November 22, 2026, 1:57 AM ET / 06:57 UTC (Revision 13).

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: XL and removed size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 15, 2026
Review follow-ups for the browser-panel viewport change:

- Keep the shipped follow-panel default; fixed-viewport viewing is now an
  opt-in toolbar toggle persisted in localStorage.
- Paint annotations with a canvas translation at the painted frame origin
  instead of mixing pixel offsets into normalized coordinates.
- Contain-fit the frame (object-fit) with a definite stage height so the
  whole page stays visible in short docks.
- Map pointer input against the painted frame box and ignore letterbox
  margins so clicks and inspect stay aligned at any scale.
@slzszyt-ux
slzszyt-ux force-pushed the feat/browser-panel-viewport-scale branch from a39ac13 to 9603804 Compare September 15, 2026 03:15
Move the fixed-viewport toggle state and setter into the viewport
controller (which already owns viewport preferences), so the panel
controller file stays under the 700-line lint limit.
The helpers are only used inside the viewport controller after the
toggle moved there; knip flagged the now-unused exports.
E2E proof: with the toolbar lock enabled the panel stops resizing the
remote page when its dock changes, and the frame keeps contain-fitting
the dock. Captures follow/fixed screenshots under OPENCLAW_CAPTURE_UI_PROOF.
@slzszyt-ux

Copy link
Copy Markdown
Author

Runtime proof added

Captured from the Control UI browser panel running this branch (repo e2e harness, real Chromium, OPENCLAW_CAPTURE_UI_PROOF=1):

  • Follow mode (shipped default): the panel owns the remote viewport — resizing the dock sends /act resize.
    follow mode
  • Fixed-viewport mode (toolbar lock on): the remote page keeps its viewport; resizing the dock sends no resize request, and the frame contain-fits.
    fixed viewport

The behavior is asserted in ui/src/e2e/browser-panel-fixed-viewport-proof.e2e.test.ts (new e2e test in this PR): it polls the resize request count — greater than zero in follow mode, unchanged after enabling the lock.

Unit coverage: ui/src/components/browser — 259 tests pass (letterbox-aware pointer mapping, translated annotation painting, fixed-viewport sync).

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Sep 15, 2026
- Inspection tooltips use stage-relative coordinates again; the letterbox
  aware point stays reserved for remote requests.
- Repaint the overlay when the dock geometry changes, including while the
  remote viewport is locked.
- Reject clicks in the letterbox margin before capturing an inspected
  element, and invalidate a stale inspection when the pointer leaves the frame.
- Give the toolbar icons a visible selected state (fixed-viewport lock,
  annotate, inspect).
- Entering the letterbox margin now invalidates the inspection owner, so a
  queued or in-flight reply cannot restore a cleared element/tooltip.
- Native inspection stores stage coordinates for tooltip placement (frame
  coordinates stay reserved for remote/native input).
Native inspect replies do not consult the remote operation owner, so the
margin guard must clear the highlight and advance the native inspection
generation itself.
@slzszyt-ux

Copy link
Copy Markdown
Author

Real-page runtime evidence

Served the PR build (pnpm ui:dev, this working tree) against a live Gateway, drove the UI with Chromium, and pointed the panel at a neutral local fixture page (no private content). Dock size changes use the panel's own layout control ("Swap Chat and Browser"). All screenshots are cropped to the panel element.

Follow mode — shipped default (fresh profile)

  • dock 480×852 → 656×852
  • remote page viewport, measured in the page itself: 1920×937 → 656×765 (the panel resized the remote page)

follow narrow
follow wide

Fixed-viewport mode — lock on (saved preference present in the profile)

  • dock 480×852 → 656×852 (the same size change)
  • remote page viewport, measured: 1920×937 → 1920×937 (unchanged)

fixed narrow
fixed wide

The frame scales with the dock (contain-fit) while the remote page keeps its viewport, which is the visible difference between the two shots.

Saved-profile behavior

  • with the lock on, reloading the Control UI leaves the toggle pressed (aria-pressed=true) and the panel stays in fixed-viewport mode

after reload

Method: viewport numbers come from window.innerWidth/innerHeight evaluated in the remote page through the Gateway; dock/stage sizes from the panel's bounding box; the fixture page is a local static file on 127.0.0.1.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@slzszyt-ux

Copy link
Copy Markdown
Author

Scaled-input alignment proof + sanitized reload capture

Aligned input in a scaled frame (fixed-viewport mode). With the lock on, the dock is 656×852 while the remote page keeps its 1920×937 viewport, so the frame is contain-fit at 0.342× (656×320). Inspecting at the frame-relative position of the fixture's target (remote point 115,686 of 1920×937) resolved the remote element exactly — no offset:

  • panel click at (297,592) → tooltip: div#target 150 × 45 Name alignment target Focusable –
  • scaled inspect alignment

Reload evidence replaced with the neutral fixture capture (same link, updated file). The lock stays pressed after a Control UI reload and the panel reopens in fixed-viewport mode:

  • reload, neutral fixture

Saved preference scope (for the decision). openclaw.browserPanel.fixedViewport in the Control UI origin's localStorage: opt-in, default off, applies to every browser panel opened from that origin regardless of session or remote profile, and survives reloads. It is deliberately not per-session or per-remote-profile; that origin-wide scope is the behaviour that needs maintainer acceptance.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Sep 15, 2026
@slzszyt-ux

Copy link
Copy Markdown
Author

Author's stance on the saved-preference scope (the remaining decision): I'd like to keep the origin-wide opt-in scope as proposed — default off, remembered per Control UI origin, survives reloads — since it matches "saved viewing preference" semantics.

If maintainers prefer a narrower scope (per chat session or per remote profile), say the word and I'll switch the storage key; it is a small change at the read/write sites with no migration. Compatibility notes are in the description: no existing key → off, and any value other than "1" is treated as off, so upgrades and rollbacks cannot enable the mode silently.

@clawsweeper clawsweeper Bot added the proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. label Oct 5, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 22, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale after 7 days without qualifying human activity.
Without new human activity, Barnacle may close it as not planned 7 days after this message was posted. This is administrative inactivity cleanup, not a claim that the problem is fixed.
A human update restarts the inactivity clock; a new PR head also restarts it. A maintainer can add no-stale for a durable hold, or bad-barnacle to suppress Barnacle. Remove the hold when work can resume.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Nov 22, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M stale Marked as stale due to inactivity status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant