Skip to content

fix(desktop): capture the whole oversized preview viewport - #36286

Merged
juliusmarminge merged 5 commits into
pingdotgg:mainfrom
shantanuojha:fix/ultrawide-preview-capture
Nov 23, 2026
Merged

juliusmarminge merged 5 commits into
pingdotgg:mainfrom
shantanuojha:fix/ultrawide-preview-capture

Conversation

@shantanuojha

@shantanuojha shantanuojha commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

An oversized background preview can report a 3440×1440 DOM viewport while its screenshot contains only the top-left of the page. Reproduced on public main 9efd960925: Electron 44.10.1 returned 1300×870 from a guest extending beyond a 1000×668 host window, missing the right and bottom corner sentinels.

Fit the background guest inside the host window with a CSS transform, preserving its logical viewport. Reuse the window-size subscription to refit on resize. Visible previews and suspended guests retain their existing placement; capture ownership, serialization, and image downscaling stay unchanged. This is desktop hosting geometry, including screenshots requested by remote clients or agents; headless web hosting and mobile rendering do not need changes.

Validation:

  • Current table regressions cover unscaled guests, width/height constrained fits, and the zero-sized-window guard added by the upstream pipeline.
  • Real Electron fixture: 390×844, 1440×900, 1920×1080, 2560×1440, 3440×1440, then 640×480. All four sentinel pixels pass after the fix at DPR 1 and 2. DPR 2 uses native page zoom on a DPR-1 display. The ultrawide PNGs are 3440×1440 and 6880×2880, respectively. DOM/layout metrics are read after resize settling, not copied from the request.
  • Running development desktop: the real HostedBrowserWebview and native screenshot IPC returned a complete 3440×1440 image. Background presentation/activity was driven through the browser surface store.
  • vp run check:changed passes. The existing ElectronBrowserHost, ServerBrowserPage, and ServerBrowser suites pass 130 tests; the current geometry suite passes 4 tests. check:changed was rerun successfully on dfcfd1a.

Latest-head proof (dfcfd1a versus original base 9efd960): the macOS Electron fixture also includes the requested 1440×1700 band capture. All 14 head captures across seven viewport sizes and DPR 1/2 retain all four corners and all four bands. Base reproduces clipping. Exact metrics and pixel checks · Reproduction bundle. This uses the actual base/head style resolver outputs in native Electron; it is separate from the original integrated desktop pass.

Limits: macOS only; no physical Retina display tested. Covered-window CDP capture can still time out, as tracked separately in #33719. This fixes successful-but-cropped captures, not that stall. Upstream's existing asynchronous desktop resize measurement remains intact. Explicit CDP clips were rejected as a solution because they produced repeated top-left pixels despite returning the requested dimensions.

Generic fixture evidence is hosted on the contributor fork, without committing screenshot assets:

Before:
Clipped ultrawide viewport

After:
Complete ultrawide viewport with four corner sentinels

Capture geometry and pixel verification · Generic HTML fixture

This is a small reproducible capture bug under CONTRIBUTING.md’s obvious-bug exception; no feature or architecture change is included.

Implemented and verified with GPT-6-Astra (ultra) through the Codex harness in T3 Code. The upstream pipeline added the zero-viewport guard in dfcfd1a, co-authored by Claude Opus 5.5.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 13, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 98ba0ce

Macroscope's review found this PR approvable — Oversized background desktop previews are scaled to fit the host window so captures include the whole viewport. Visible previews remain unchanged, and reported Electron capture checks support the limited scope of the correction.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds a helper that calculates how a hidden browser viewport fits within the window. HostedBrowserWebview applies the resulting scale to its viewport transform and container geometry when the browser is inactive or has no panel rectangle.

Changes: Hidden browser viewport fitting

Layer / File(s) Summary
Hidden viewport fit calculation
apps/web/src/browser/browserViewportLayout.ts, apps/web/src/browser/browserViewportLayout.test.ts
The new helper returns a fit scale capped at 1, or 1 if either window dimension is nonpositive. Tests cover four viewport and window size combinations.
Hosted webview scale application
apps/web/src/browser/HostedBrowserWebview.tsx
When the browser is active with a panel rectangle, the component uses scale 1. Otherwise, it calculates the hidden viewport fit scale and applies it to the viewport transform and container position and dimensions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • pingdotgg/t3code#26964 — The issue describes hidden previews being cropped when taller than the window. This change adds a fit scale to the hidden viewport path.

Possibly related PRs

  • pingdotgg/t3code#26965 — Both PRs address cropping in the hidden-preview path. This PR applies a fit scale through the viewport transform; PR #26965 caps the hidden guest size and scales it down.
  • pingdotgg/t3code#31568 — Both changes modify the guest transform path to address rasterization when the preview is scaled.

Suggested reviewers: juliusmarminge, jason5545

Merge Risk: Minimal · up to 90351

This change fits oversized background browser previews inside the host window so desktop screenshots are no longer cropped. No concrete merge-blocking risk was found. The change is localized, and visible previews and suspended guests keep their existing placement.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the desktop capture fix, which matches the changeset. The change fits an oversized background preview guest inside its host window with a CSS transform, so the screenshot captures the …
Description check Passed The description follows the template structure: it covers the problem (oversized preview viewport cropped in screenshots, with a reproduction on a specific commit and Electron version), the change (CS…
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: Title check

Explanation

The title names the desktop capture fix, which matches the changeset. The change fits an oversized background preview guest inside its host window with a CSS transform, so the screenshot captures the full viewport instead of a cropped top-left region. The title follows the conventional commit format and is specific, and it is not vague or misleading.

Full details: Description check

Explanation

The description follows the template structure: it covers the problem (oversized preview viewport cropped in screenshots, with a reproduction on a specific commit and Electron version), the change (CSS transform fit that preserves the logical viewport and refits on resize), scope (desktop hosting geometry, with a bug-fix justification under CONTRIBUTING.md), and verification (focused tests, a real Electron fixture across several viewport sizes and DPR values, and a development desktop run). It also notes limits and includes a model/harness attribution as the template asks. It omits the explicit linked issue for the bug, relying on the obvious-bug exception instead, and the 'Scope' section does not link a tracking issue for the capture bug itself. The description is long and relies on external evidence links, which the template discourages for committed assets, but it does not commit any PR-only assets. Overall it is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a493616 and 90351e8.

Files selected for processing: 3

  • apps/web/src/browser/HostedBrowserWebview.tsx
  • apps/web/src/browser/browserViewportLayout.test.ts
  • apps/web/src/browser/browserViewportLayout.ts

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 13, 2026
A zero viewport would scale the guest to nothing. Trim the geometry
matrix to a table of exact fits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

The automated pipeline stopped on this pull request and will not merge it:

the fix is written and reviewed, but proving it needs something no worker has:

  • Permanent blocker: the reproduction requires the macOS Electron desktop app outside the mobile device pool. This VM runs Linux, and the brief prohibits reaching another machine or substituting for unavailable macOS conditions. Both the 1440×1700 band capture and the 3440×1440 corner-marker capture remain unverified on base and head.

It stays open for a person to finish or close.

@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body and removed takeover:in-progress A takeover lead is working on this PR labels Nov 13, 2026
@shantanuojha

Copy link
Copy Markdown
Contributor Author

I reviewed the published agent feedback and the pipeline's dfcfd1a change. The zero-sized-window guard is valid and retained. CodeRabbit has no actionable findings, and there are no unresolved inline review threads. The PR description now reflects the pipeline's smaller four-case test table and credits its change.

The macOS proof requested in the pipeline stop comment is now available for current head dfcfd1a26622643714e00119a3d3122dadd96e15 against original base 9efd960925f0899c0a6d045d128557c5d82818e8. This was run locally on macOS with Electron 44.10.1 / Chromium 152.0.7977.169, using actual base/head style-resolver outputs in a native webview:

  • 1440×1700 band fixture: base returns 1300×870, missing the cyan/white bands and right/bottom corners. Head returns 1440×1700 with all four bands and corner sentinels.
  • 3440×1440 corner fixture: base returns 1300×870 with only the top-left sentinel. Head returns 3440×1440 with all four sentinels and bands.
  • Full matrix: 390×844 → 1440×900 → 1440×1700 → 1920×1080 → 2560×1440 → 3440×1440 → 640×480, at DPR 1 and 2. All 14 head captures pass PNG dimensions and decoded sentinel/band pixels. DPR 2 uses native Electron page zoom on a DPR-1 display, not physical Retina hardware.
  • vp run check:changed passes on this exact head. GitHub CI is green.

Raw metrics and pixel results · Runnable generic reproduction bundle

1440×1700 before · after

3440×1440 before · after

This is native Electron capture proof, separate from the original integrated development-client pass; it does not claim a new end-to-end MCP run or resolve the covered-window CDP stall in #33719. All assets are generic, and owned test windows/server were cleaned up. Please reassess the takeover:blocked proof blocker with this evidence. No further source changes were necessary.

@juliusmarminge juliusmarminge added takeover:in-progress A takeover lead is working on this PR and removed takeover:blocked Takeover blocked; reason in the PR body labels Nov 14, 2026
@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body and removed takeover:in-progress A takeover lead is working on this PR labels Nov 14, 2026
@juliusmarminge juliusmarminge added takeover:in-progress A takeover lead is working on this PR and removed takeover:blocked Takeover blocked; reason in the PR body labels Nov 23, 2026
juliusmarminge and others added 2 commits November 23, 2026 07:40
Main's merge brought a second `windowSize` into HostedBrowserWebview and
full-detail capture transforms. A plain `scale()` on the wrapper rasterizes
the guest at the reduced size, which the inner matrix3d cannot undo because
the wrapper's overflow clip flattens the 3D context. Fold the window fit into
the webview's own viewport transform instead, so the guest keeps its DOM
viewport and full-detail frames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

macOS 26, Apple silicon, Electron 44.10.1, light theme, fresh synthetic state on each commit. Establish a 1440×698 fill-mode preview, collapse the Browser panel, shrink the host viewport from 1440×790 to 900×600, and capture the remembered logical viewport. Both pages still report 1440×698. Retained stills matched byte-for-byte across captures 500 ms apart.

Before After
9cf81e2a6e 90351e85c3
Before: 1170×698 capture clips the right corner markers After: 1440×698 capture includes all four corner markers
Before recording After recording

Driver, seed script, synthetic page, base measurements, head measurements.

Not shown:

  • The no-content fallback path was not separately exercised; this proof covers remembered content-derived fill-mode dimensions.
  • The original fixed-size 3440×1440 and 1440×1700 sequences were not rerun; this proof exercises the remaining fill-mode scope at 1440×698.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 23, 2026
@juliusmarminge
juliusmarminge merged commit 1368854 into pingdotgg:main Nov 23, 2026
18 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants