fix(desktop): suspend hidden previews, open OAuth popups from the preview - #165
Merged
Conversation
(cherry picked from commit ff1761012af46ceb5f1ecc9b2be00aae288a1691)
Co-authored-by: Julius Marminge <julius0216@outlook.com> (cherry picked from commit 0e2905eb783fd2385f358a95f0b25bbf07ff7122)
`POPUP_WINDOW_OPTIONS` from pingdotgg/t3code#8435 overrides contextIsolation, nodeIntegration, and sandbox, but `preload` is a webPreference too and an unset one is inherited from the opener. Preview guests load Pylon's pick/annotation preload, which imports `ipcRenderer` and registers pick, annotation-theme, human-input, and mouse-navigate channels. That was written for the trusted preview surface, not a third-party sign-in page. contextIsolation keeps the page out of the preload's world, so this is defence in depth rather than a live escape.
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two clean cherry-picks from the
f94a0d646..bcb855a63upstream review, plus one security fix found in review.#8567— hidden browser previews kept rendering and drained battery. Rendering is now suspended unless the surface is active, has background activity, is picture-in-picture, or is recording.#8435— scriptedwindow.openfrom a preview now opens a real popup instead of navigating the preview away, so OAuth flows complete.New: popups no longer inherit the preview guest's preload. Upstream's
POPUP_WINDOW_OPTIONSoverridescontextIsolation,nodeIntegration, andsandbox— butpreloadis a webPreference too, and an unset one is inherited from the opener. Preview guests load Pylon's pick/annotation preload, which importsipcRendererand registers pick, annotation-theme, human-input, and mouse-navigate channels. That was written for the trusted preview surface, not a third-party sign-in page.contextIsolationkeeps the page out of the preload's world, so this is defence in depth rather than a live escape.Two upstream regressions to preview automation, documented not fixed
Both are upstream's design, both survive here, and both affect the preview browser agents drive:
preview_statusdropsviewportfor any non-rendering tab. It is the only automation op that does not take the render lease, soreadRenderedViewportis skipped and the key is simply omitted (viewportisSchema.optional, so it decodes clean). An agent asking for pixel dimensions on a background tab silently gets nothing and falls back to the CSS setting — wrong on a zoomed or fitted surface.captureAutomationSnapshotcallscapturePage()with no retry, whilestartFrameCapture500 lines earlier retries with a comment naming exactly this failure ("Chromium can return UnknownVizError while a hidden guest is warming its first compositor frame"). Result is a failedpreview_snapshotor a 0×0 image returned with no error.Neither is confirmable without a running Electron build. A follow-up is proposed: the automation path already holds a CDP debugger session (
Manager.ts:1162, used forRuntime.evaluateandAccessibility.getFullAXTree), so moving screenshots toPage.captureScreenshotover that same session would decouple them from window visibility entirely.Verification
Both commits are byte-identical to upstream and Pylon never diverged in the preview subsystem; the one divergence in the touched set, Pylon's
persist:pylon-code-preview-partition names, is preserved.Manager.test.ts66/66 pass. Web browser suites 26/26. Desktop and web typechecks clean. Adversarial review confirmed every acquire has a matching release and that recording and picture-in-picture stay covered by the new lease terms.Model: Claude Opus 5. Harness: Claude Code.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.