Skip to content

fix(browser)/test: background tab host bounds and native right-click observation - #4744

Merged
yomgui merged 9 commits into
devfrom
e2e/browser-tab-geometry-native-menu
Sep 11, 2026
Merged

yomgui merged 9 commits into
devfrom
e2e/browser-tab-geometry-native-menu

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

Makes browser-tabs-owned-by-thread green on the Daytona E2E lane. Triage: cluster 6 / brief H in reports/e2e-red-2026-09-09/triage.md ("Product UI changed, owning spec not updated" → browser-tabs-owned-by-thread).

Root cause

Two stale claims plus three latent ones that were unreachable behind them:

  1. Background tab geometry (test "a background conversation reads its owned page silently…"). The spec asserted that the blank consent tab a background conversation allocates has the 1280×800 BACKGROUND_TAB_VIEWPORT. The product (since d9ad918ef Complete browser tasks with site tools, page controls and user takeover #4468, deferBackground) intentionally keeps that tab off every native host and unsized (0×0) with no hidden window until its approved first navigation completes — attaching an uninitialized widget to a hidden host can crash Electron on Linux, and the unit test already states "pending consent needs no hidden native host". Intended geometry, now stated in the spec: pending consent tab → attached:false, aboveApp:false, bounds 0×0, backgroundWindowCount 0; once the page holds a document → single hidden host, bounds 0,0,1280×800, backgroundWindowCount 1. The "released page must not contact its destination" assertion is unchanged.
  2. Native right-click menu (test "a transcript link's menu copies its exact address…"). be5ab613c feat(desktop): use native right-click menus #4650 replaced the overlay.html menu with a native Menu.popup, which has no DOM and no CDP target, so the spec's overlay wait could never succeed.
  3. Latent, reachable only after 1: the pending background open went through POST /experimental/ui-control/request, whose mailbox answers "did not answer within 5 seconds" (fix: make in-app UI control work in web and desktop through the server #4459) while the step needs the user to switch conversations and approve; the paused-open baseline was snapshotted mid re-attach; and the last step clicked a "Suspend tab" button that never existed (the panel renders a disabled Suspend titled "Protected until browser work is released").

What changed

  • Product (dev-mode only): context-menu.mjs records each shown native menu template as plain data (ids/labels/enabled, no callbacks) plus the last selection, and exposes inspect / choose / dismiss. main.mjs registers openwork:context-menu:* handlers only when OPENWORK_DEV_MODE=1 && !app.isPackaged, main-frame only; preload.mjs exposes __OPENWORK_ELECTRON__.contextMenu under the same env gate. Covered by a new case in context-menu.test.mjs. No behaviour change for packaged builds.
  • Spec: re-expressed the consent-tab geometry claim (above); the link-menu steps now read entries and deliver choices through the seam, keep the negative half (no HTML menuitem in the app document), and assert "Copy Link Address" via the recorded selectedId and the clipboard; origin-stamped background open issued at the window boundary (window.__openworkControl.command({…, origin}), exactly what the mailbox hands the window); paused-open baseline taken after the reading tab re-attaches; task protection asserted through the disabled/enabled Suspend control around browser.release_tab.
  • Worlds/behaviors: transcriptLinkWorld gains nativeMenu / chooseMenuItem / dismissMenu; browserBackgroundWorld gains commandFrom; BrowserState (behaviors) now carries backgroundWindowCount.
  • Testkit (shared, flagged): seed.session() now uses renameSessionAndWait like seed.sessions(). Three of five runs of this spec lost a seeded title (sidebar stuck on "New session") in different tests; this is the same retry sessions() already had.

Proof

pnpm evals:e2e browser-tabs-owned-by-thread --daytona with OPENWORK_EVAL_REF=<sha> (sandbox log: source verified <sha> ×7):

  • e74718c47 (PR head): passed 7 / failed 0 / skipped 0 — verdict passed.
    {"command":"evals:e2e","lane":"e2e","daytona":true,"placement":"daytona","engine":"legacy","surface":"legacy","files":["browser-tabs-owned-by-thread"],"passed":7,"failed":0,"skipped":0,"skips":[],"verdict":"passed"} — Duration 864 s, 7 Daytona desktop sandboxes (one per test), all disposed.
  • Iteration history at earlier shas (same command, Daytona): bb53aa068 5/2 (native-menu test green; background test hit the 5 s mailbox), 5d8bd1ed2 6/1 (paused-open baseline race), f11bbcff5 5/2 (Suspend tab never existed + seeded-title flake), 8f5e1fbb2 6/1 (seeded-title flake only, in the link test).
  • Unit: node --test electron/context-menu.test.mjs electron/browser-panel.test.mjs → 73 pass; pnpm --dir apps/desktop test → 397 pass / 0 fail / 1 pre-existing skip.

Noticed, not touched

  • apps/desktop/electron/menu-overlay-preload.mjs, the openwork:menu-overlay:* IPC channels, the overlay.html Vite entry, and pageTargets()'s overlay.html filter are dead since feat(desktop): use native right-click menus #4650.
  • evals/packages/behaviors/src/browser-task.ts BrowserState and evals/worlds/browser-panel.ts BrowserState are two hand-rolled parsers of the same IPC payload.
  • test-run.json records the runner's gitSha/branch, not OPENWORK_EVAL_REF (already listed in the triage "Not clusters").
  • pnpm --dir evals run typecheck has ~365 pre-existing errors unrelated to this change (Promise.withResolvers lib target, JSON import attributes, email templates jsx).

…iewport

A background conversation's browser.open_url allocates a blank consent tab
that stays off every native host and unsized until its approved first
navigation completes (deferBackground, #4468). The spec asserted the
1280x800 background viewport on that blank tab; assert zero bounds and no
hidden window there, and assert the background host geometry once the page
holds a document. Also read state through probe.browserState() in the last
step, which this world never exposed as readBrowserState.
Native popups have no DOM and no CDP target, so nothing outside the main
process can see which entries a right-click offered or deliver a choice.
Record each shown template as plain data (ids, labels, enabled, no callbacks)
plus the last selection, and expose inspect/choose/dismiss to the app's main
frame only when OPENWORK_DEV_MODE=1 and the app is unpackaged.
be5ab61 (#4650) replaced the overlay.html link menu with a native popup,
so the spec's overlay target never appears. Read entries and deliver
choices through the development seam, keep the negative half (no HTML
menu in the app document), and assert Copy Link Address through the
recorded selection and the clipboard.
The spec proved a pending background open through POST
/experimental/ui-control/request, but the server mailbox answers
"did not answer within 5 seconds" (#4459) while the step needs the user
to switch conversations and approve navigation. Stamp the command with its
origin through window.__openworkControl.command instead, which is exactly
what the mailbox hands the window, and print the reply when it lacks a
result.
…b re-attaches

Switching back to the reading conversation re-attaches its view to the
panel asynchronously; snapshotting native state mid-transition made the
rejected paused open look like it changed geometry.
…end control

The panel renders a "Suspend" button that is disabled while a task protects
the page (title: Protected until browser work is released) and never sends
the request, so the "Suspend tab" click and "protected or busy" toast the
step expected could not exist. Assert the disabled control, then that
browser.release_tab enables it.
seed.session fired session.rename and returned; three of five Daytona runs
of browser-tabs-owned-by-thread then never saw the new conversation's title
in the sidebar (it stayed "New session"). Reuse renameSessionAndWait,
which confirms the listed title and retries the rename once.
@vercel

vercel Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 11, 2026 3:27am UTC
openwork-den Ready Ready Preview Sep 11, 2026 3:27am UTC
openwork-diagnostics Ready Ready Preview Sep 11, 2026 3:27am UTC
openwork-landing Ready Ready Preview, v0 Sep 11, 2026 3:27am UTC

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 1. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run

Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (119379 ms), confidentiality-review (127716 ms), spec-provenance-review (175956 ms), desktop-den-sync-review (138685 ms).

Blockers

  • None.

Advisories

  • CM8-6GY · medium · spec-provenance-review · evals/worlds/browser-webmcp.ts:22

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 3
  • Distinct heads in retained window: 3
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 3/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

diff-warden[bot]
diff-warden Bot previously approved these changes Sep 10, 2026

@diff-warden diff-warden 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.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (e74718c471e77a38874c221f200ac0501ae964bb). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

… contract

The typecheck:electron step rejected the inspection fixture because the
request() helper inferred a narrow item shape from its default argument,
so a separator entry could not be passed. Annotate the fixture helpers
with the NativeContextMenuItem contract from @openwork/types/desktop-ipc.
@vercel
vercel Bot temporarily deployed to Preview – openwork-den September 10, 2026 03:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-landing September 10, 2026 03:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics September 10, 2026 03:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – openwork-app September 10, 2026 03:53 Inactive
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Passed · 12/12 tests · 18/18 assertions · 8 images

Commit a6c6d9c39ecee6541b82c0ea9aa2232b4627df80 · selected evidence

Open review report

diff-warden[bot]
diff-warden Bot previously approved these changes Sep 10, 2026

@diff-warden diff-warden 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.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (1c1885cca6ae52da0c35b1e596278427d17363ff). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@yomgui

yomgui commented Sep 10, 2026 •

Copy link
Copy Markdown
Member Author

CI fix (1c1885c): openwork-tests-build → Typecheck Electron main against the IPC contract was red because context-menu.test.mjs let request() infer a narrow { type: string; id; label }[] item shape from its default argument, so the { type: "separator" } entry in the inspection fixture was rejected (TS2345).

Fix is test-only: the fixture helpers (item, request, and the inspection items array) are now annotated with the real NativeContextMenuItem contract from @openwork/types/desktop-ipc via JSDoc, matching how the other electron/*.mjs files reference the IPC types. No any, casts, or ts-ignore; no product code touched.

Verified locally: pnpm --filter @openwork/desktop typecheck:electron exit 0; node --test apps/desktop/electron/context-menu.test.mjs 9/9 pass. openwork-tests-build, openwork-tests-core, openwork-tests-required, and warden are now green on this PR.

Resolves evals/packages/testkit/src/spec/runtime.ts: both sides made the same
change to seed.session() (wait through renameSessionAndWait like sessions()) and
differed only in the comment; dev's landed wording is kept, so the merged file is
identical to dev and its per-spec surface isolation, declared-workspace creation
and lazy provisioning (#4730, #4817, #4762) are untouched.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Deploying openwork with  Cloudflare Pages  Cloudflare Pages

Latest commit: a6c6d9c
Status: ✅  Deploy successful!
Preview URL: https://04fe401e.openwork.pages.dev
Branch Preview URL: https://e2e-browser-tab-geometry-nat.openwork.pages.dev

View logs

@diff-warden diff-warden 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.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (a6c6d9c39ecee6541b82c0ea9aa2232b4627df80). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@yomgui
yomgui merged commit 9622647 into dev Sep 11, 2026
29 checks passed
@yomgui

yomgui commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

Resync with dev — merge commit a6c6d9c39ecee6541b82c0ea9aa2232b4627df80 (pushed before this PR was merged as 96226472d)

Merge of origin/dev @ 08f9e0774 (signed, no rebase/force). Parents: 1c1885cca (PR head) + 08f9e0774.

Conflict — evals/packages/testkit/src/spec/runtime.ts: comment-only. Both sides made the identical change to seed.session() (wait through renameSessionAndWait like sessions()); dev's landed wording was kept, so the merged runtime.ts is byte-identical to dev's. Dev's per-spec surface isolation / declared-workspace creation / lazy provisioning (#4730, #4817, #4762) are untouched and this PR's testkit intent is carried by dev. The merged tree differs from dev only in this PR's 9 files (context-menu seam, spec, worlds, behaviors, browser-globals.d.ts).

Verification on a6c6d9c39

  • node --test packages/testkit/test/*.test.ts packages/cdp/test/*.test.ts → 55 pass / 0 fail. node --test electron/context-menu.test.mjs electron/browser-panel.test.mjs → 82 pass / 0 fail.
  • pnpm --dir evals typecheck → 0 errors in touched files; 420 pre-existing errors vs 422 on a clean origin/dev @ 08f9e0774 control — this PR's spec rewrite removes dev's two browser-tabs-owned-by-thread.e2e.test.ts(425) errors (readBrowserState does not exist). No new errors.
  • Daytona: OPENWORK_EVAL_REF=a6c6d9c39… pnpm evals:e2e browser-tabs-owned-by-thread --daytona → 6 passed / 1 failed / 0 skipped, "sandboxRef":"a6c6d9c39…","sandboxSha":"a6c6d9c39…","refMismatch":false,"verdict":"failed". All 7 sandboxes source verified a6c6d9c39… and deleted.
    • Failed: a transcript link's menu copies its exact address and opens only its own conversation's browser — vitest 600 s timeout. The test-run trace shows every functional assertion of the test passed (native menu inspected, Copy Link Address → clipboard, message-text menu, Open in OpenWork → Select tab: 127.0.0.1:…#thread-link visible and URL bar holds the exact address); the last step's notSee(label=/^Select tab: .*viewport-probe=link-neighbor$/) then hung from 03:41:14 to 03:57:17 and ended with CDP socket is not open. — the desktop's CDP connection dropped inside the sandbox, not an assertion mismatch. The other 6 tests (incl. the background-geometry test this PR re-expressed) passed.
    • I did not rerun: the PR was merged (96226472d) while this lane was running. Verdict for this sha is Incomplete (1 infrastructure-class red). If someone wants the 7/7 at the landed sha, the exact command is OPENWORK_EVAL_REF=96226472d… pnpm evals:e2e browser-tabs-owned-by-thread --daytona.

This branch was successfully deployed

4 active deployments
Preview – openwork-landing — a6c6d9c3 Deployed Sep 11, 2026 by vercel[bot]
Preview – openwork-den — a6c6d9c3 Deployed Sep 11, 2026 by vercel[bot]
Preview – openwork-app — a6c6d9c3 Deployed Sep 11, 2026 by vercel[bot]
Preview – openwork-diagnostics — a6c6d9c3 Deployed Sep 11, 2026 by vercel[bot]
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.

1 participant