Repository navigation
fix(dashboard): delegate display-capture to embedded cross-origin panes - #9112
Conversation
UX Review (Fable 5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS Browser panes get working snip; in the packaged app the same live-looking snip button still fails silently, acknowledged but unfixed. Watch
No evidence gap: the diff adds one non-rendering [UX-REVIEWED] bc55640 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Identity-based capture trust with fail-closed wiring is the right shape; the rejected shape-test alternative is argued and pinned, and the Electron pane limitation is deliberate. Suggestions
[DESIGN-REVIEWED] bc55640 |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of All premises verified against the base checkout. The dashboard view has First-Principles-Verdict: PASS Verify on the packaged app that the dashboard's own snip still gets a grant — the fail-closed gate now fronts every capture, so a registration/origin mismatch fails silently. Not justified as shipped
What this change shipsInventory (4 items) — 3 justifiedIntent: FIX — make the screen-snip buttons inside an embedded instances pane actually capture instead of silently rejecting on click.
Evidence run: grepped WatchThe identity gate's runtime glue ( [FIRST-PRINCIPLES-REVIEWED] bc55640 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
@javenciu Thanks for this. I audited it against Nothing of this goal exists on The blocker is the security finding, and it is substantiated in the code rather than theoretical. The PR body says every capture runs the browser's own source picker on a user gesture. That does not hold in the packaged app: Two smaller items. The branch is well behind Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong. |
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: Picking this up to drive it to green. The The finding, verified on main. Plan.
Net effect after the realignment: in a browser the pane's snip starts working through the engine's own source picker; in the packaged app the pane's request is refused instead of silently answered with the desktop. The dashboard's own top-level snip is unchanged, and the browser panel loses an auto-grant it should never have had. Authorship stays with @javenciu — the commit keeps them as author with a |
d78e9cd to
d104cdd
Compare
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: @bolichen97 — both of your asks are in, on head Rebase. Done: one commit, level with Subframe capture gating. Done, and your read of it was right — the gap was wider than the delegation. The gate is
Both legs are load-bearing on their own, which is what the revert-verify measures: removing the frame leg leaves 2 tests failing, removing the origin leg leaves 3. A pane is served from loopback exactly like the dashboard, so origin alone admits it; the browser panel's main frame is top-level, so frame alone admits it. Port is deliberately not part of the origin leg — remote hosts arrive through an SSH forward onto that same port, per Fail-closed on absent/ Deny tests assert a One consequence worth naming explicitly, since it is a deliberate scope call rather than an oversight: in the packaged app a pane's snip is now refused by the gate rather than by the missing delegation. Same user-visible outcome as today, no silent whole-screen grant. In a browser it starts working through the engine's own picker, which is the bug this PR set out to fix. Making pane snips work under Electron too needs a real in-app source picker with the requesting frame shown — a separate change, and one that wants a maintainer decision on the UI rather than a rider here. I also dropped the PR body's "every capture runs the browser's own source picker" claim, which was the sentence the GPT 5.6 lane correctly voided, and added the |
b9b6f30 to
aa1e71d
Compare
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: self-added: yes
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: self-added: yes
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: Correcting my own note on the
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: Ready for maintainer review —
|
| Lane | Verdict |
|---|---|
| GPT 5.6 | clean, no findings |
| Opus 4.8 | clean, no findings |
| First Principles | PASS |
| Design | CONCERNS (advisory) — "sound identity-based capture gate" |
| UX | CONCERNS (advisory) |
Zero line-level findings. 17 disposition comments, 17 from verified writers, no rule violations. Every advisory item has its own disposition and a tracker.
What the change is
@javenciu's display-capture delegation, kept as written, plus the gate the review rounds asked for.
website/electron/capture-trust.js authorizes a capture request by identity, not by the shape of the request. All three must hold: the requesting webContents is one this app registered as its own capture surface; the frame is that webContents' main frame; and the document's origin still exactly matches the registered origin, port included.
That third leg is what closed the target="_top" promotion the GPT lane found on the previous head. frame.parent === null means "top-level frame of this webContents", not "a document this app loaded" — a page inside a non-sandboxed iframe can navigate the top frame and inherit its position, passing both a frame-position test and a loopback-hostname origin test. The port is what separates them, and the binding is per webContents, so a secondary window on a remote gateway keeps capture on its own origin without authorizing a sibling's.
display-media.js now holds no trust rule of its own and denies when the dep is absent — a capability gate must fail closed when nobody wired its decision.
Three capture surfaces are registered at their creation sites (dashboard view, Mochi panel window, Mochi crop window), traced from every captureScreen consumer rather than assumed, since missing one would cost that window its snip silently. capture-trust.js is in the packaged files list.
Eight revert-verify mutations, all caught, including one that reintroduces the hostname-only rule this replaces. Full Electron suite 1892 passing.
The two reds are one inherited cause
Backend Tests (3.12, 1) fails on ModuleNotFoundError: No module named 'httpx', and Coverage Gate fails closed off it (backend-test=failure). Filed and fully diagnosed as #10723.
The trigger is that this PR is frontend-only — zero .py files — which puts the backend lane on the reduced-scope path, where test files are passed to pytest as explicit arguments, and an explicitly-named path is not subject to the collect_ignore_glob that container_tests/conftest.py relies on to decline that tree when the image deps are absent. Main runs the full suite, so the ignore applies there and main is green. Nothing in this diff can avoid it short of adding unrelated backend code.
One thing I got wrong, so the status field is not trusted
PR Readiness currently reads failure | 1 blocking readiness item(s). That value is from my own manual re-fire and it is not reliable: the event-driven run computed at 06:07, before CI finished, and my two re-fires produced contradictory lane snapshots that listed lanes as in_progress which had completed an hour earlier — one reported failed=[], the other failed=[GPT 5.6 Review (failure)] while both GPT check-runs on this head are SUCCESS. Re-firing readiness is the documented remedy when every check is green and the status is stale; here the checks are not all green, so it could not produce passed and only republished a racing snapshot. My mistake, and I stopped rather than dispatch again.
Read the check-runs instead. The only two non-green on this head are the pair above:
completed/failure Backend Tests (3.12, 1)
completed/failure Coverage Gate
What is left for a human
- A packaged-build check. The Design lane asked for it across rounds and it is the one thing I could not do — this host has no display server, so I did not run it and did not record it as done. On a platform taking the
desktopCapturerfallback (Linux): the dashboard's own snip captures; the Mochi crop window captures; a pane snip logs[display-media] DENY capture: requester is not a registered capture surface; and the same holds after a pane navigates the top frame. - container_tests collect-ignore guard is bypassed on frontend-only diffs, reddening a backend shard on httpx #10723, or a decision to merge past it. This PR cannot reach
failing=0while it is open. - Display-media trust gate authorizes by frame shape, so a top-navigated pane passes it #10657 — the two supporting fixes for the promotion vector: a
will-navigateguard on the dashboard webContents (wider than capture — a promoted document inherits every default-session grant, including the microphone) andsandboxwithoutallow-top-navigationon the pane iframe. Both deliberately out of this PR: the guard refuses navigations on the dashboard window, and a wrongly-scoped one bricks it, which wants someone who can launch the app. - Packaged-app pane snips fail silently after the display-capture trust gate #10655 — packaged-app pane snips still fail silently. Three fix shapes; it is a product call between hiding the affordance and explaining it.
drive-to-green left on. Nothing merged, no auto-merge armed.
An instances pane is the same SPA on the tunnel's loopback port, so it is
a CROSS-ORIGIN iframe and `getDisplayMedia()` is denied there unless the
parent delegates `display-capture` via Permissions-Policy. The snip
affordances still RENDER inside the pane, because the presence gate
(`isScreenSnipSupported`) only checks that the function EXISTS -- true in
any frame -- so ChatInput's snip flow, WebPreviewPanel's crop-to-chat and
MochiSnipHost are live buttons that die on click with NotAllowedError.
Adding `display-capture` to the pane iframe's `allow` list is the same
one-token delegation microphone, fullscreen and clipboard-write already
carry.
Delegating it also opens a second path, and that path was not safe. In
the packaged app the renderer's call is answered by the main process, and
`display-media.js` was the app's OWN picker: it ignored the request
argument, took the first `screen:*` source `desktopCapturer` returned,
and granted it. `{ useSystemPicker: true }` prefers the OS picker where
one exists, but the fallback runs everywhere it does not. An iframe
shares its parent's session, so a delegated pane's request would have
reached that grant -- the whole local screen, from one gesture, with no
confirmation UI.
Fix: authorize the request by IDENTITY, in a new `capture-trust.js`.
A request is granted only when all three hold:
1. Its webContents is REGISTERED as one of the app's own capture
surfaces. `registerCaptureSurface` is called where each is created
-- the dashboard view and the Mochi panel/crop windows -- so
anything else is refused by default rather than by remembering to
deny it.
2. Its frame IS that webContents' main frame, which refuses an
embedded pane and every other subframe.
3. Its document's origin still EXACTLY matches the origin registered
for that webContents, port included.
Shape is deliberately not the test. `frame.parent === null` means
"top-level frame of this webContents", NOT "a document this app loaded":
a page inside a non-sandboxed iframe can navigate the top frame with
`target="_top"` on a user click, and the promoted document then holds the
dashboard's main frame. It would pass a frame-position test, and a
loopback-HOSTNAME origin test as well, since a pane is served from the
same host. Leg 3 compares the port, which is what separates them, and it
is bound per webContents so a secondary window on a remote gateway keeps
capture on its own origin without authorizing a sibling's.
`display-media.js` therefore holds no trust rule of its own and denies
when `deps.isTrustedRequest` is absent: a capability gate must fail
closed when nobody wired its decision. The check still runs before
`getSources()`, so a refused requester never triggers macOS's Screen
Recording prompt or enumerates open-window titles. A refusal reports
`untrusted-frame`, which the call site logs rather than turning into a
System Settings dialog: nothing the user can change there makes an
unregistered surface grantable.
The embedded browser panel is out of reach of all of this by
construction, not by the gate -- it runs on the `persist:kirocrew-browser`
partition, which registers no display-media handler, and a session with
no handler rejects the call.
Net effect: a browser pane's snip starts working through the engine's own
source picker, and the packaged app refuses a pane whether it asks from
inside the iframe or promotes itself to the top frame. The dashboard's
own snip and both Mochi capture windows are unchanged.
Tests: the `allow`-list contract pin; `capture-trust.js` covered per leg,
including a same-origin subframe (which only the main-frame leg can
refuse), a promotion to a pane origin, a promotion to the app's own
origin (still granted -- that origin is the app's own gateway), sibling
surfaces on different ports, an unregistered webContents, an
unregistered opaque origin, and every read throwing; `display-media.js`
asserted per verdict with a getSources CALL COUNTER, including that it
denies with no trust dep at all; and the session-security registration
test drives the handler `configureSession` actually registered, with the
subframe, the promoted frame and an unregistered surface all refused.
Revert-verify: eight mutations -- each leg, the hostname-only rule this
replaces, an accepted opaque origin, the fail-open handler default, the
missing registration call, and the unwired predicate -- each redden.
## Pattern harvest
Defect class: authorizing a capability by the SHAPE of a request instead
of the identity of its requester. `frame.parent === null` reads as "is
the app" and means "is top-level", and the two diverge the moment
something else can occupy the top frame.
Rule candidate: in `website/electron/**`, a grant path that decides on a
frame's position (`parent`, `isMainFrame`) or on hostname alone is a
finding. Bind the decision to an identity the app itself recorded --
`browser-view.js`'s `untrustedContents` WeakSet and this module's
`captureSurfaces` WeakMap are the shape to match -- and compare origins
whole, port included, unless there is a stated reason not to.
Co-authored-by: Joe Guo <zejiangg@amazon.com>
00229b8 to
bc55640
Compare
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: Rebased onto current main to pick up the httpx fix —
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: self-added: yes
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]:
|
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: Best state this PR has been in —
|
| Lane | Verdict |
|---|---|
| GPT 5.6 | clean, no findings |
| Opus 4.8 | clean, no findings |
| Design | PASS |
| First Principles | PASS |
| UX | CONCERNS (advisory, dispositioned) |
0 failing checks. 21 disposition comments, 21 from verified writers, no rule violations. Design has moved BLOCK → CONCERNS → PASS across the three rounds.
What is still running
Five macOS jobs — Build Desktop (macos-15), Backend Tests (macOS) 1-3, E2E Gateway Boot (macos-15) — have been QUEUED for roughly 100 minutes without starting, plus the readiness recompute behind them. Hosted macOS runner shortage: nothing has started and failed, so there is nothing to re-run or classify.
I am standing my polling loop down rather than keep waking to re-read an unmoving queue. If one of those jobs goes red once it starts, it will need a look — everything else on this head is settled.
What needs a human, unchanged
- A packaged-build check. The one item open across every round, and the one I cannot do — this host has no display server, so I never ran it and never recorded it as done. First Principles pointed it at the right risk on this head: the gate fails CLOSED, so a wrong assumption about
webContents.fromFramecosts the DASHBOARD its snip, not the pane's. On macOS or Linux: the dashboard's own snip captures; the Mochi crop window captures; a pane snip logs[display-media] DENY capture: requester is not a registered capture surface; and the same after a pane navigates the top frame. The first two are the regression check, the last two are the property the gate exists for. - Approval.
PR Readinessis the only required status check; beyond it the rules need one approving review, code-owner review, and the team required forwebsite/src/**andwebsite/electron/**.dismiss_stale_reviews_on_pushandrequire_last_push_approvalare both on, so the rebase was deliberately done BEFORE asking for review and no further push should land once an approval does.
#10657 (dashboard will-navigate guard, pane iframe sandbox) and #10655 (silent pane snips under Electron) remain open follow-ups. Neither gates this PR.
drive-to-green left on. Nothing merged, no auto-merge armed.
…es (kirodotdev#9112) An instances pane is the same SPA on the tunnel's loopback port, so it is a CROSS-ORIGIN iframe and `getDisplayMedia()` is denied there unless the parent delegates `display-capture` via Permissions-Policy. The snip affordances still RENDER inside the pane, because the presence gate (`isScreenSnipSupported`) only checks that the function EXISTS -- true in any frame -- so ChatInput's snip flow, WebPreviewPanel's crop-to-chat and MochiSnipHost are live buttons that die on click with NotAllowedError. Adding `display-capture` to the pane iframe's `allow` list is the same one-token delegation microphone, fullscreen and clipboard-write already carry. Delegating it also opens a second path, and that path was not safe. In the packaged app the renderer's call is answered by the main process, and `display-media.js` was the app's OWN picker: it ignored the request argument, took the first `screen:*` source `desktopCapturer` returned, and granted it. `{ useSystemPicker: true }` prefers the OS picker where one exists, but the fallback runs everywhere it does not. An iframe shares its parent's session, so a delegated pane's request would have reached that grant -- the whole local screen, from one gesture, with no confirmation UI. Fix: authorize the request by IDENTITY, in a new `capture-trust.js`. A request is granted only when all three hold: 1. Its webContents is REGISTERED as one of the app's own capture surfaces. `registerCaptureSurface` is called where each is created -- the dashboard view and the Mochi panel/crop windows -- so anything else is refused by default rather than by remembering to deny it. 2. Its frame IS that webContents' main frame, which refuses an embedded pane and every other subframe. 3. Its document's origin still EXACTLY matches the origin registered for that webContents, port included. Shape is deliberately not the test. `frame.parent === null` means "top-level frame of this webContents", NOT "a document this app loaded": a page inside a non-sandboxed iframe can navigate the top frame with `target="_top"` on a user click, and the promoted document then holds the dashboard's main frame. It would pass a frame-position test, and a loopback-HOSTNAME origin test as well, since a pane is served from the same host. Leg 3 compares the port, which is what separates them, and it is bound per webContents so a secondary window on a remote gateway keeps capture on its own origin without authorizing a sibling's. `display-media.js` therefore holds no trust rule of its own and denies when `deps.isTrustedRequest` is absent: a capability gate must fail closed when nobody wired its decision. The check still runs before `getSources()`, so a refused requester never triggers macOS's Screen Recording prompt or enumerates open-window titles. A refusal reports `untrusted-frame`, which the call site logs rather than turning into a System Settings dialog: nothing the user can change there makes an unregistered surface grantable. The embedded browser panel is out of reach of all of this by construction, not by the gate -- it runs on the `persist:kirocrew-browser` partition, which registers no display-media handler, and a session with no handler rejects the call. Net effect: a browser pane's snip starts working through the engine's own source picker, and the packaged app refuses a pane whether it asks from inside the iframe or promotes itself to the top frame. The dashboard's own snip and both Mochi capture windows are unchanged. Tests: the `allow`-list contract pin; `capture-trust.js` covered per leg, including a same-origin subframe (which only the main-frame leg can refuse), a promotion to a pane origin, a promotion to the app's own origin (still granted -- that origin is the app's own gateway), sibling surfaces on different ports, an unregistered webContents, an unregistered opaque origin, and every read throwing; `display-media.js` asserted per verdict with a getSources CALL COUNTER, including that it denies with no trust dep at all; and the session-security registration test drives the handler `configureSession` actually registered, with the subframe, the promoted frame and an unregistered surface all refused. Revert-verify: eight mutations -- each leg, the hostname-only rule this replaces, an accepted opaque origin, the fail-open handler default, the missing registration call, and the unwired predicate -- each redden. ## Pattern harvest Defect class: authorizing a capability by the SHAPE of a request instead of the identity of its requester. `frame.parent === null` reads as "is the app" and means "is top-level", and the two diverge the moment something else can occupy the top frame. Rule candidate: in `website/electron/**`, a grant path that decides on a frame's position (`parent`, `isMainFrame`) or on hostname alone is a finding. Bind the decision to an identity the app itself recorded -- `browser-view.js`'s `untrustedContents` WeakSet and this module's `captureSurfaces` WeakMap are the shape to match -- and compare origins whole, port included, unless there is a stated reason not to. Co-authored-by: Joe Guo <zejiangg@amazon.com>
Problem / Motivation
The screen-snip buttons inside an embedded instances pane are dead. Clicking one does nothing — no picker, no error, no snip.
An instances pane is the same dashboard SPA served on the tunnel's loopback port, so it is a cross-origin iframe (same host, different port).
navigator.mediaDevices.getDisplayMedia()is denied in a cross-origin frame unless the parent delegatesdisplay-capturethrough Permissions-Policy, andwebsite/src/components/InstancesViewport.tsxdelegated onlymicrophone; fullscreen; clipboard-write.The affordances still render, because the presence gate (
isScreenSnipSupported) checks only that the function EXISTS — true inside any iframe. So three surfaces are live buttons that reject on click withNotAllowedError: ChatInput's snip flow, WebPreviewPanel's crop-to-chat, and MochiSnipHost.Why it matters
Anyone driving a remote crew through an embedded pane — the normal way to use a remote instance — cannot snip at all, and gets no feedback saying why. The failure is silent: the snip code treats the rejection as "user cancelled". Locally (top-level) the same buttons work, so the capability looks intermittent rather than undelegated.
What changed (motivation → approach → change)
The delegation.
display-capturejoins the pane iframe'sallowlist, the same one-token delegationmicrophone,fullscreenandclipboard-writealready carry (clipboard-writelanded by the same route in #8907).clipboard-readstays undelegated — read is the more sensitive grant class and out of scope here.The path that delegation opens, and why it was not safe. In a browser, the engine runs its own source picker and delegation only lets the pane ASK. In the packaged app it does not: the renderer's
getDisplayMedia()is answered by the main process, andwebsite/electron/display-media.jswas the app's own picker.createDisplayMediaHandlerignored its request argument (_request), andchooseDisplaySourcetook the firstscreen:*sourcedesktopCapturerreturned and granted it.{ useSystemPicker: true }at thesetDisplayMediaRequestHandlercall site prefers the OS picker where one exists, but the fallback runs everywhere it does not.So the handler answered every requester on its session identically, with no frame or origin check. An iframe shares its parent's session, so delegating
display-captureto panes puts a pane's request in front of it — and the answer would be the entire local screen, from one gesture, with no confirmation UI.The embedded browser panel is NOT part of this: it runs on the
persist:kirocrew-browserpartition (window-lifecycle.jspartition: BROWSER_PARTITION), which registers no display-media handler at all, and a session with no handler rejects the call outright — the premise this module exists for.browser-view.js's header prose still says it shares the default session; the code at the view's construction site does not, and that prose is left for a separate change.The gate.
website/electron/capture-trust.jsauthorizes a request by identity, not by the shape of the request. All three must hold:registerCaptureSurfaceis called at each such creation site (the dashboard view, the Mochi panel window, the Mochi crop window), so anything else is refused by default instead of by remembering to deny it.Why shape is not enough, and this is the part worth reading. The obvious test is
request.frame.parent === null, and an earlier revision of this PR used it. It is not sound.parent === nullmeans "top-level frame of this webContents", not "a document this app loaded". The instances-pane iframe carries nosandboxattribute, and the dashboard's webContents has nowill-navigateguard (setWindowOpenHandlergoverns new-window requests only), so a page inside a pane cantarget="_top"-navigate on a user click and its document then holds the dashboard's main frame. It would pass a frame-position test — and a loopback-hostname origin test as well, since a pane is served from the same host as the dashboard.Leg 3 compares the port, which is what actually separates them, and it is bound per webContents rather than globally: a secondary window pointed at a remote gateway is a legitimate capture surface on a different loopback port, and it keeps capture on its own origin without authorizing a sibling's document. A promotion to the app's own origin stays granted, deliberately — that origin is the local gateway serving this app's own token-authed pages, so the document is the app's either way.
This is the shape
browser-view.jsalready uses for the same reason:untrustedContentsis aWeakSetof webContents identities because an origin heuristic was not enough there either.captureSurfacesis the positive-direction twin, aWeakMapso an entry vanishes with its window.display-media.jsholds no trust rule of its own and denies whendeps.isTrustedRequestis absent — a capability gate must fail closed when nobody wired its decision, which is the state this module started in. The check still runs first, beforegetSources(), so a refused requester never triggers macOS's Screen Recording prompt and never enumerates open-window titles. A refusal reportsuntrusted-frame, which the call site logs rather than turning into a System Settings dialog: nothing a user changes there makes an unregistered surface grantable.Three capture surfaces, all registered.
ChatInput/useChatPageResourcesControllerandWebPreviewPanelcapture from the dashboard view;MochiSnipHostcaptures from the Mochi panel window;mochi/snip/main.tsxcaptures from the Mochi crop window at native resolution. Missing one would have silently cost that window its snip, so each is registered at its creation site andcapture-trust.jsis added to the packagedfileslist.The browser panel is out of reach of all of this by construction, not by the gate: it runs on the
persist:kirocrew-browserpartition, which registers no display-media handler at all, and a session with no handler rejects the call outright — the premise this module exists for.browser-view.js's header prose still says it shares the default session; the view's construction site passespartition: BROWSER_PARTITION, and that stale line is left for a separate change.Net effect. In a browser, a pane's snip starts working through the engine's own source picker — the bug this PR set out to fix. In the packaged app, a pane is refused whether it asks from inside the iframe or promotes itself to the top frame: same user-visible outcome as today (the click does nothing), no silent whole-screen grant. The dashboard's own snip and both Mochi capture windows are unchanged, and all of those paths are pinned through the registered handler in
website/electron/test/window-lifecycle.test.js.Making pane capture work under Electron too needs a real in-app source picker that names the requesting frame. That is a separate change and a maintainer decision on the UI, deliberately not a rider here.
Tests
website/src/test/InstancesViewport.test.tsxallow-list contract pin, extended todisplay-capture(exact-string andtoContain), withclipboard-read's absence still pinned.website/electron/test/capture-trust.test.js(new)"null"would make two unrelated opaque documents compare equal.request.frame,fromFrame,wc.mainFrameandframe.urleach deny instead of letting the throw escape into Chromium's request handling.createCaptureTrust({})throws.website/electron/test/display-media.test.jsuntrusted-frameand agetSourcescall count of 0, a throwing predicate denies via the existingerrorpath, the request is passed through untouched, and — new — with no trust dep at all, nothing is granted.website/electron/test/window-lifecycle.test.jsconfigureSessionactually registered, through the realcreateCaptureTrust: the dashboard's registered main frame is granted, and a pane subframe, a promoted top frame and an unregistered surface are all refused withdesktopCapturer's call count stuck at 1.setupWindowContentsregisters the dashboard view against that window's gateway origin — the harness registers a surface of its own, which would otherwise mask the production call going missing.Revert-verify — eight mutations, each redden the suites together: the registry leg failing open (3 failing), the main-frame leg removed (1), the origin leg weakened to hostname only, i.e. the rule this replaces (3), the origin leg removed (3), an opaque origin accepted at registration (1), the handler defaulting to trust (1), the dashboard registration call deleted (1), the predicate not passed to the handler (1).
Manual verification
Not performed in a packaged app, and that is a real gap — recorded rather than papered over. The build host this was prepared on has no display server, so
electron .cannot be launched to click a real snip.What IS verified without one:
configureSession, so the wiring, the grant for the dashboard's own surface, and all three deny paths are covered against the real call site rather than against a module in isolation.electron@^43.2.0'selectron.d.tsdeclaresDisplayMediaRequestHandlerHandlerRequest.frame: WebFrameMain | nullandsecurityOrigin: string,WebContents.fromFrame(frame), andWebFrameMain.parent/.url. The gate reads only those.windowBackendUrl, the MochibaseUrl), and the origin — not the URL — is stored, so in-app routing and token query params cannot break capture.What a reviewer with a packaged build should confirm, on a platform that takes the
desktopCapturerfallback rather than a native picker (Linux):[display-media] DENY capture: requester is not a registered capture surfaceinstead of capturing.Screenshots / video
Why no screenshot: the diff is one token in an iframe
allowattribute (a non-rendering Permissions-Policy attribute) plus Electron main-process permission logic. No component, layout, style or state changes, and no element is added or removed — a before/after capture would be two identical images. The user-visible difference is that an already-rendered snip button stops rejecting when clicked, which a still frame cannot show.Related Issues
no linked issue: reported and verified from the code path, not from a filed issue. The
clipboard-writedelegation referenced above landed by the same route and is cited as precedent for the pattern, not as an issue this PR closes.Pattern harvest
Pattern: authorizing a capability by the SHAPE of a request instead of the identity of its requester.
frame.parent === nullreads as "is the app" and means "is top-level", and the two diverge the moment something else can occupy the top frame. The sibling defect this started from is the same family one step earlier: a handler that discards its request argument entirely, so nothing about the requester is consulted at all.Rule candidate: lint / review-prompt, scoped to
website/electron/**. Two shapes are findings on a grant path: (a) aset*RequestHandler/set*Handlercallback that names its request or details parameter with a leading underscore, or omits it, and (b) a decision that rests on a frame's POSITION (parent,isMainFrame) or on hostname alone. Bind the decision to an identity the app itself recorded —browser-view.js'suntrustedContentsWeakSet andcapture-trust.js'scaptureSurfacesWeakMap are the shape to match — and compare origins whole, port included, unless there is a stated reason not to.Checklist