Skip to content

fix: make in-app UI control work in web and desktop through the server - #4459

Merged
benjaminshafii merged 5 commits into
devfrom
fix/ui-control-via-server
Sep 4, 2026
Merged

benjaminshafii merged 5 commits into
devfrom
fix/ui-control-via-server

Conversation

@benjaminshafii

@benjaminshafii benjaminshafii commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

In OpenWork Web, openwork_context, UI queries, and UI commands could not reach the browser because they relied on Electron discovery files. Route in-app tools through an authenticated, short-lived mailbox on openwork-server, answered by the existing control surface in both desktop and web.

This removes desktop discovery and implicit user-data fallbacks from the in-app plugin. The external desktop UI MCP bridge remains compatible. Every mailbox route requires collaborator or owner scope: read-only tokens cannot submit work, claim requests, or forge replies. The browser uses its existing client token; host credentials stay out of headless web. Requests expire after five seconds, cancelled polls cannot claim work, and each request is delivered to one polling window. Multiple windows connected to one server use the first polling window; this change does not elect a focused tab.

Verification on this branch:

  • Agent/server journey: passed, including no-window behavior, model-visible split context, authentication, and single delivery of queries/commands.

  • Desktop split journey: passed on PR head in Daytona (1 passed, 0 failed, 0 skipped).

  • Actual headless web: created a split in the browser, verified five server snapshots with both session IDs and secondary focus, queried capabilities, and opened Library through a server command.

  • Plugin tests: 26 passed. App/server typechecks and packaged server build passed.

  • PDF attachment model-routing regression: passed on PR head (1 passed, 0 failed, 0 skipped).

All journey evidence is published below for 553289a0a941aaa029ca1d9a718e5392f229ff42. Reproduction:

pnpm evals:pr specs/agent-ui-context-via-server.test.ts
OPENWORK_EVAL_REF=553289a0a941aaa029ca1d9a718e5392f229ff42 pnpm evals:e2e new-split-session
pnpm evals:pr specs/pdf-attachments-model-routing.test.ts
pnpm --filter openwork-server test src/opencode-plugins/openwork-extensions-preview.test.ts
pnpm typecheck
pnpm --filter openwork-server typecheck
pnpm --filter openwork-server build

The E2E runner printed placement: daytona (daytona CLI authenticated); server-boundary specs ran locally. The implementation and journey verdict is Passed.

The optional broad pnpm evals:typecheck exits 2 with 296 diagnostics on both this PR head and clean origin/dev at 2390c79ee06c2910b34ca3d49341409bce5dd2b9, using Node 24.15.0 and the same installs/build prerequisites. All diagnostic signatures match after normalizing checkout paths and line numbers. First failure on both: apps/server/src/agent-context-cloud-probe.ts(216,15): TS1294: This syntax is not allowed when 'erasableSyntaxOnly' is enabled. This check remains red on the base; app/server typechecks and required CI pass.

@vercel

vercel Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

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

4 Skipped Deployments
Project Deployment Actions Updated
openwork-app Ignored Ignored Preview Sep 4, 2026 10:50pm UTC
openwork-den Ignored Ignored Preview Sep 4, 2026 10:50pm UTC
openwork-diagnostics Ignored Ignored Preview Sep 4, 2026 10:50pm UTC
openwork-landing Ignored Ignored Preview Sep 4, 2026 10:50pm UTC

@benjaminshafii
benjaminshafii marked this pull request as ready for review September 4, 2026 22:42
@benjaminshafii benjaminshafii reopened this Sep 4, 2026
@benjaminshafii

benjaminshafii commented Sep 4, 2026 •

Copy link
Copy Markdown
Member Author

Verification on PR head 553289a

Passed — three journey tests, zero failures or skips. Server-boundary tests ran locally; desktop placement was daytona (daytona CLI authenticated).

Test evidence — the-in-app-agent-reads-renderer-context-through-openwork-server-and-gets-an-expl — ✅ passed

✅ passed · 3 expectations passed · 0 failed · 0 pending

[probe] eventually(completed openwork_context tool without a window) · eventually(completed openwork_context tool with a connected window)
steps 1 ✅ without a connected window the tool reports that no OpenWork window is connected and the turn completes (0.9s) · 2 ✅ a connected window's split layout reaches both the tool transcript and the model (0.1s) · 3 ✅ only authenticated clients can exchange requests, and each command is delivered once (0.0s)
verdict passed · 0 user observations · 2 probes · steps 3/3

ℹ️ ASSERTION — 1. Without a polling OpenWork window, the agent receives the server's explicit no-window result and still completes its turn

openwork_context returned context=null and ui.error="No OpenWork window is connected to this server. Open the OpenWork app or its web tab and try again."; the model's reply was "MOCK OK".

  • ✅ PASS Without a polling OpenWork window, the agent receives the server's explicit no-window result and still completes its turn — openwork_context returned context=null and ui.error="No OpenWork window is connected to this server. Open the OpenWork app or its web tab and try again."; the model's reply was "MOCK OK".

ℹ️ ASSERTION — 2. A renderer window's split layout crosses openwork-server into the agent tool result and the model's follow-up request

The fake window handled one context request; the transcript and provider tool result both contained secondarySessionId=ses_right, and the turn replied "MOCK OK".

  • ✅ PASS A renderer window's split layout crosses openwork-server into the agent tool result and the model's follow-up request — The fake window handled one context request; the transcript and provider tool result both contained secondarySessionId=ses_right, and the turn replied "MOCK OK".

ℹ️ ASSERTION — 3. Viewer tokens cannot control the UI, claim pending requests, or forge replies

Unauthenticated calls returned 401, viewer control requests returned 403, viewer poll and forged replies returned 403, invalid kinds returned 400, collaborator replies survived the relay, a second poll was empty, and duplicate replies returned 404.

  • ✅ PASS Viewer tokens cannot control the UI, claim pending requests, or forge replies — Unauthenticated calls returned 401, viewer control requests returned 403, viewer poll and forged replies returned 403, invalid kinds returned 400, collaborator replies survived the relay, a second poll was empty, and duplicate replies returned 404.

Test run created 2026-09-04T22:52:04.208Z · Source: evals/results/test-runs/2026-09-04T22-52-04-207Z-the-in-app-agent-reads-renderer-context-through-openwork-server-and-gets-an-expl/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4459 --test-run 2026-09-04T22-52-04-207Z-the-in-app-agent-reads-renderer-context-through-openwork-server-and-gets-an-expl


Test evidence — new-split-creates-fresh-same-workspace-secondary-sessions-without-moving-the-pri — ✅ passed

✅ 0/2 screenshots passed · 2 assertions · 2 expectations passed · 0 failed · 0 pending

[world] desktop(daytona) · workspace(/tmp/openwork-new-split-session-1788562454883) · session("New split primary")
[probe] eventually(single layout on the seeded primary) · hash
[agent] listSessions
[user] rightClick(text=New split primary) · see(label=New split) · click(label=New split) · see(text=Split view) · see(text=New session)
[probe] eventually(context-menu new split layout) · hash
[agent] listSessions
[probe] eventually(context-menu split session appears in the session list)
[user] screenshot · press(Control+K) · see(placeholder=Search actions, settings, and sessions…) · type(placeholder=Search actions, settings, and sessions…, "new split", replace) · see(label=/^New split/) · press(Enter) · see(text=Split view) · see(text=New session)
[probe] eventually(palette new split replaces the secondary session) · hash
[agent] listSessions
[probe] eventually(palette split session appears in the session list)
[user] screenshot
[agent] run(workbench.session.focus)
[probe] eventually(secondary pane is focused)
[user] press(Control+K) · see(placeholder=Search actions, settings, and sessions…) · type(placeholder=Search actions, settings, and sessions…, "new task", replace) · see(label=/^New session/) · press(Enter)
[probe] eventually(new session replaces the focused secondary)
[agent] listSessions
[probe] eventually(focused-secondary new session appears in the session list)
[agent] run(workbench.session.focus)
[probe] eventually(primary pane is focused)
[user] press(Control+K) · see(placeholder=Search actions, settings, and sessions…) · type(placeholder=Search actions, settings, and sessions…, "new task", replace) · see(label=/^New session/) · press(Enter)
[probe] eventually(new session replaces the focused primary)
[agent] listSessions
[probe] eventually(focused-primary new session appears in the session list)
steps 1 ✅ the seeded session is the single primary pane (0.6s) · 2 ✅ New split in the session context menu opens a fresh secondary (1.5s) · 3 ✅ the context menu creates one same-workspace split session (1.0s) · 4 ✅ New split in the command palette replaces the secondary with another fresh session (2.0s) · 5 ✅ the palette creates one more session while preserving the primary route (1.0s) · 6 ✅ the agent's server path sees the same layout (0.2s) · 7 ✅ New session replaces the focused secondary pane (2.1s) · 8 ✅ the focused secondary is replaced while the primary route stays put (0.6s) · 9 ✅ New session replaces the focused primary pane (2.2s) · 10 ✅ the focused primary is replaced without changing the secondary (1.3s)
verdict passed · 13 user observations (see ×11, screenshot ×2) · 14 probes · steps 10/10

ℹ️ ASSERTION — 1. Desktop split context reaches the agent through the server mailbox

The server returned ok=true with kind=split, primarySessionId=ses_f915e5845ffe1V5vrBadcIu5SQ, secondarySessionId=ses_f915e4180ffexmIMgU7jdTmPzC, and focused=secondary, all matching the rendered split.

  • ✅ PASS Desktop split context reaches the agent through the server mailbox — The server returned ok=true with kind=split, primarySessionId=ses_f915e5845ffe1V5vrBadcIu5SQ, secondarySessionId=ses_f915e4180ffexmIMgU7jdTmPzC, and focused=secondary, all matching the rendered split.

ℹ️ ASSERTION — 2. New splits preserve the primary, and New session replaces only the focused pane

Context-menu and command-palette splits each created one distinct same-workspace secondary session. The focused-secondary and focused-primary New session actions each preserved the opposite pane and created exactly one session.

  • ✅ PASS New splits preserve the primary, and New session replaces only the focused pane — Context-menu and command-palette splits each created one distinct same-workspace secondary session. The focused-secondary and focused-primary New session actions each preserved the opposite pane and created exactly one session.

⚪ UNVALIDATED — 3. new-split-creates-fresh-same-workspace-secondary-sessions-without-moving-the-pri artifact 1

  • ⚪ UNVALIDATED — no visual expectations recorded.

new-split-creates-fresh-same-workspace-secondary-sessions-without-moving-the-pri artifact 1

⚪ UNVALIDATED — 4. new-split-creates-fresh-same-workspace-secondary-sessions-without-moving-the-pri artifact 2

  • ⚪ UNVALIDATED — no visual expectations recorded.

new-split-creates-fresh-same-workspace-secondary-sessions-without-moving-the-pri artifact 2


Test run created 2026-09-04T22:52:46.880Z · Source: evals/results/test-runs/2026-09-04T22-52-46-879Z-new-split-creates-fresh-same-workspace-secondary-sessions-without-moving-the-pri/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4459 --test-run 2026-09-04T22-52-46-879Z-new-split-creates-fresh-same-workspace-secondary-sessions-without-moving-the-pri


Test evidence — each-model-receives-an-attached-pdf-in-the-form-it-can-take-and-the-transcript-k — ✅ passed

✅ passed · 3 expectations passed · 0 failed · 0 pending

steps 1 ✅ attach report.pdf for the vision model (1.6s) · 2 ✅ attach report.pdf for the text model (0.1s) · 3 ✅ attach report.pdf for the native model (0.1s) · 4 ✅ a text-only model reads on-disk.pdf from disk through the Read tool (0.1s)
verdict passed · 0 user observations · 0 probes · steps 4/4

ℹ️ ASSERTION — 1. Inside the real engine, an image-capable model received page images plus text, a text-only model received text, and a PDF-capable model received the PDF itself

OpenCode 1.18.27 behind openwork-server with its shipped plugins; the provider saw vision=image_url:data:image/png,image_url:data:image/png,image_url:data:image/png,text:note,text:Summarize this. text=text:note,text:Summarize this. native=file:report.pdf,text:Summarize this.; every reply completed and every persisted user message kept its application/pdf part.

  • ✅ PASS Inside the real engine, an image-capable model received page images plus text, a text-only model received text, and a PDF-capable model received the PDF itself — OpenCode 1.18.27 behind openwork-server with its shipped plugins; the provider saw vision=image_url:data:image/png,image_url:data:image/png,image_url:data:image/png,text:note,text:Summarize this. text=text:note,text:Summarize this. native=file:report.pdf,text:Summarize this.; every reply completed and every persisted user message kept its application/pdf part.

ℹ️ ASSERTION — 2. A text-only model that reads a PDF from disk through the Read tool receives its text instead of a PDF it cannot take, and the persisted tool result keeps the original attachment

The mock model asked the engine to read on-disk.pdf; the follow-up request carried one tool result containing the OpenWork PDF note and no file or image parts, the turn completed, and the transcript's tool part still holds an application/pdf attachment. Every request advertised the openwork_pdf_pages tool.

  • ✅ PASS A text-only model that reads a PDF from disk through the Read tool receives its text instead of a PDF it cannot take, and the persisted tool result keeps the original attachment — The mock model asked the engine to read on-disk.pdf; the follow-up request carried one tool result containing the OpenWork PDF note and no file or image parts, the turn completed, and the transcript's tool part still holds an application/pdf attachment. Every request advertised the openwork_pdf_pages tool.

ℹ️ ASSERTION — 3. Derived text and page images are kept in the workspace inbox for the agent's tools and later steps

.opencode/openwork/inbox/pdf-pages holds b2fc86b31300ea96-on-disk and f80d003ffc4116df-report.

  • ✅ PASS Derived text and page images are kept in the workspace inbox for the agent's tools and later steps — .opencode/openwork/inbox/pdf-pages holds b2fc86b31300ea96-on-disk and f80d003ffc4116df-report.

Test run created 2026-09-04T22:55:33.661Z · Source: evals/results/test-runs/2026-09-04T22-55-33-661Z-each-model-receives-an-attached-pdf-in-the-form-it-can-take-and-the-transcript-k/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4459 --test-run 2026-09-04T22-55-33-661Z-each-model-receives-an-attached-pdf-in-the-form-it-can-take-and-the-transcript-k


Actual headless web verification

Launched the final checkout with OPENWORK_PORT=18978 OPENWORK_WEB_PORT=15178 pnpm world up dev-headless --detach. In a real browser, opened a seeded session and selected New split. Both panes were visible. Five consecutive authenticated server context requests each returned kind=split, the original primary session, a distinct secondary session, and focused=secondary. help.capabilities returned ok=true; route.extensions.skills returned ok=true and the browser showed the Library heading. The temporary browser and server were then stopped.

Additional checks

  • Plugin suite: 26 passed, 0 failed.
  • App and server typechecks: passed.
  • Packaged server build: passed.
  • Broad optional eval typecheck: existing failure, not included in the Passed runtime verdict. PR head and clean base 2390c79ee06c2910b34ca3d49341409bce5dd2b9 both exit 2 with the same 296 diagnostic signatures. First: agent-context-cloud-probe.ts(216,15): TS1294, unsupported syntax under erasableSyntaxOnly.

The final permission regression also proves that viewer tokens cannot submit context/query/command requests, poll the mailbox, or forge a reply. Collaborator tokens continue to work without exposing host credentials in web.

@benjaminshafii
benjaminshafii enabled auto-merge (squash) September 4, 2026 22:57

@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 (553289a0a941aaa029ca1d9a718e5392f229ff42). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@benjaminshafii
benjaminshafii merged commit f167406 into dev Sep 4, 2026
26 checks passed
yomgui added a commit that referenced this pull request Sep 10, 2026
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.
yomgui added a commit that referenced this pull request Sep 11, 2026
…observation (#4744)

* test(evals): state that a pending consent tab has no hidden host or viewport

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.

* feat(desktop): observe native context menus in development

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.

* test(evals): drive the transcript link menu through the native menu seam

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.

* test(evals): issue the background open at the window boundary

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.

* test(evals): baseline the paused-open comparison after the reading tab 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.

* test(evals): assert task protection through the panel's disabled Suspend 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.

* test(testkit): wait for a seeded session's title like sessions() does

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.

* test(desktop): type the context-menu template fixture against the IPC 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.
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