Skip to content

Document questions from app API calls shown on the calling app's pages - #535

Draft
tnkuehne wants to merge 2 commits into
mainfrom
app-questions-docs
Draft

tnkuehne wants to merge 2 commits into
mainfrom
app-questions-docs

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Updates Ask the user before continuing and Approve changes for #534 and #536: a question from an app call reaches the person where they started, in the agent's client when an agent called the app, or in a dialog on the calling app's open page. The calling app receives the method's result; withInput is no longer part of bindings.

Blocked until a release contains #534 and #536. The required runtime version reads "released after 0.7.23"; adjust it if that release carries another number.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 280e43d Dec 01 2026, 03:30 PM

tnkuehne added a commit that referenced this pull request Dec 1, 2026
…534)

When an app calls another app's API as the signed-in person and that API
asks a question, such as a template asking before it deletes, the person
now answers it in a dialog on the calling app's open page. The calling
app's code awaits the method and receives its result. It no longer
receives `input_required`, needs no question UI of its own and cannot
answer in the person's place.

## How it works

- **Pages:** the runtime adds `<script src="/.widefleet/questions.js"
defer>` to every HTML document with a `<head>` (fragments without one
are left alone, so pages that insert fetched HTML do not load it twice).
The 850-byte script keeps a WebSocket to the runtime and loads the
dialog module (`/.widefleet/questions-dialog.js`) only when a question
arrives. The dialog renders in a shadow root with the shared form fields
of the MCP input form, and follows the device's light or dark setting.
- **Questions:** `AppQuestions` is a Durable Object per app and person.
Pages connect with hibernatable WebSockets after the runtime checks the
upgrade and the page's origin. A binding call whose provider returns
`input_required` connects as a second kind of hibernatable socket and
sends the question; the object stores it, shows it on every open page
and sleeps until someone answers. The first answer continues the call,
which the gateway runs again with `ctx.props.input` as before.
- **Unanswered questions:** without an open page, after the last page
closes, after five minutes or once the caller's delegation expires, the
provider is called again with every question cancelled and returns its
own result. A provider that asks again after a cancellation fails the
call.
- **Bindings:** `withInput` is removed from app bindings, from the
generated binding types and from the reserved method names. Generated
`Result<R>` types no longer include questions.
- **Configuration:** the runtime binds `WIDEFLEET_APP_QUESTIONS`
(wrangler migration `v6`, and the self-hosted runtime configuration).
The auth proxy rebuilds WebSocket handshakes with its usual cookie
handling, so renewed sign-in cookies reach the browser.

Direct MCP calls keep their native dialogs and MCP Apps forms.

## Screenshots

There was no dialog before: the calling app received `input_required`
and had to show the question itself.

A template approval, 1280 px light and dark:

<img
src="https://gist.githubusercontent.com/tnkuehne/4fdcdcba59fa1dce0427408fc9cd6f39/raw/ccba4e7052297867729fbd1830d131e2696ac081/approval-desktop-light.png"
width="640"> <img
src="https://gist.githubusercontent.com/tnkuehne/4fdcdcba59fa1dce0427408fc9cd6f39/raw/ccba4e7052297867729fbd1830d131e2696ac081/approval-desktop-dark.png"
width="640">

A question with a form field, 390 px light and dark:

<img
src="https://gist.githubusercontent.com/tnkuehne/4fdcdcba59fa1dce0427408fc9cd6f39/raw/ccba4e7052297867729fbd1830d131e2696ac081/form-mobile-light.png"
width="260"> <img
src="https://gist.githubusercontent.com/tnkuehne/4fdcdcba59fa1dce0427408fc9cd6f39/raw/ccba4e7052297867729fbd1830d131e2696ac081/form-mobile-dark.png"
width="260">

<details><summary>Remaining variants</summary>

<img
src="https://gist.githubusercontent.com/tnkuehne/4fdcdcba59fa1dce0427408fc9cd6f39/raw/ccba4e7052297867729fbd1830d131e2696ac081/approval-mobile-light.png"
width="260"> <img
src="https://gist.githubusercontent.com/tnkuehne/4fdcdcba59fa1dce0427408fc9cd6f39/raw/ccba4e7052297867729fbd1830d131e2696ac081/approval-mobile-dark.png"
width="260">

<img
src="https://gist.githubusercontent.com/tnkuehne/4fdcdcba59fa1dce0427408fc9cd6f39/raw/ccba4e7052297867729fbd1830d131e2696ac081/form-desktop-light.png"
width="640"> <img
src="https://gist.githubusercontent.com/tnkuehne/4fdcdcba59fa1dce0427408fc9cd6f39/raw/ccba4e7052297867729fbd1830d131e2696ac081/form-desktop-dark.png"
width="640">

</details>

Not checked: Safari and Firefox rendering, apps that set their own
restrictive CSP in HTML.

## Tests

- `app-services-runtime.test.ts` on workerd and celld: a question
reaches an open page and the answer continues the call; questions are
cancelled without a page and when the last page closes; a question near
the 16 KiB limit with a character outside Latin-1; pages of other
origins are refused; the dialog in Chromium from click to result.
- Page HTML and ETag expectations in the Cloudflare runtime and dynamic
celld suites; binding type expectations.
- `pnpm check`, `cargo test -p platform-agent runtime`.

The lint error in `templates/hubspot/tests/provider.ts` comes from
`main`.

## Documentation

The guides "Ask the user before continuing" and "Approve changes" are
updated in the draft docs PR #535.
Base automatically changed from app-questions-in-runtime to main December 1, 2026 12:19
@tnkuehne
tnkuehne changed the base branch from main to mcp-question-runner December 1, 2026 13:09
Base automatically changed from mcp-question-runner to main December 1, 2026 15:28

This branch has not been deployed

No deployments
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