Skip to content

Commit f943fb8

Browse files
PR Batch Testerclaude
andcommitted
fix(client): MCP apps open full screen only after a tap in the app
An app could ask for full screen at any time. One that asks on load or on every reconnect attempt pulled the client back into full screen each time the user left it, so the thread could never be reached. Full screen now needs a recent tap or click in the app on web, desktop and mobile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 48595c7 commit f943fb8

3 files changed

Lines changed: 33 additions & 9 deletions

File tree

‎apps/mobile/src/features/threads/McpAppWebView.tsx‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ const confirm = (title: string, message: string, action: string) =>
9797
/** Largest file an app may hand the user through `ui/download-file`. */
9898
const MAX_DOWNLOAD_BYTES = 25 * 1024 * 1024;
9999

100+
/**
101+
* How long after a touch in the app it may go full screen, the same window a
102+
* browser gives a click (transient user activation).
103+
*/
104+
const FULLSCREEN_AFTER_TOUCH_MS = 5_000;
105+
100106
/**
101107
* A captured MCP App, hosted in a WebView over the MCP Apps bridge: inline as
102108
* a content-sized row of the thread feed, or full screen in its own modal screen. A
@@ -282,6 +288,9 @@ export function ThreadMcpApp(props: {
282288
}, [props.environmentId, props.threadId, props.itemId, app.tool]);
283289
const webView = useRef<WebView<object>>(null);
284290
const hostRef = useRef<McpAppHost | null>(null);
291+
// When the reader last touched the app; a WebView has no user activation
292+
// to ask, so full screen is gated on this instead.
293+
const lastTouchAt = useRef(0);
285294

286295
// One host per loaded document.
287296
useEffect(() => {
@@ -399,11 +408,16 @@ export function ThreadMcpApp(props: {
399408
},
400409
requestDisplayMode: async (mode) => {
401410
const current = latest.current.props;
402-
// Full screen would cover the approval or question the agent waits
403-
// on, or a screen the user moved to.
411+
// Full screen opens only right after the reader touched the app: one
412+
// that asks on load or on every retry would otherwise reopen it each
413+
// time the reader closes it, and the thread could never be reached.
414+
// It would also cover the approval or question the agent waits on,
415+
// or a screen the user moved to.
404416
if (
405417
mode === "fullscreen" &&
406-
(latest.current.awaitingUser || !latest.current.navigation.isFocused())
418+
(Date.now() - lastTouchAt.current > FULLSCREEN_AFTER_TOUCH_MS ||
419+
latest.current.awaitingUser ||
420+
!latest.current.navigation.isFocused())
407421
) {
408422
return current.displayMode ?? "inline";
409423
}
@@ -546,7 +560,12 @@ export function ThreadMcpApp(props: {
546560
}
547561

548562
return (
549-
<View style={fullscreen ? { flex: 1 } : { height, marginBottom: ROW_BOTTOM_MARGIN }}>
563+
<View
564+
style={fullscreen ? { flex: 1 } : { height, marginBottom: ROW_BOTTOM_MARGIN }}
565+
onTouchStart={() => {
566+
lastTouchAt.current = Date.now();
567+
}}
568+
>
550569
{navigatedAway ? (
551570
<View className="flex-1 items-center justify-center">
552571
<Text className="text-sm text-foreground-muted">

‎apps/web/src/components/chat/McpAppFrame.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,18 @@ export function McpAppFrame(props: {
377377
if (result._tag !== "Success") throw commandFailure(result);
378378
},
379379
requestDisplayMode: async (mode) => {
380-
// Full screen would cover the approval or question the agent waits
381-
// on, or a confirmation any app is waiting on. Another app already
382-
// full screen keeps the page; two would stack.
380+
// Full screen opens only right after the reader used this frame, as
381+
// links do: an app that asks on load or on every retry would otherwise
382+
// take the page back each time the reader leaves. It would also cover
383+
// the approval or question the agent waits on, or a confirmation any
384+
// app is waiting on. Another app already full screen keeps the page;
385+
// two would stack.
383386
const otherFullscreen = document.querySelector("[data-mcp-app-fullscreen]");
384387
if (
385388
mode === "fullscreen" &&
386-
(latest.current.props.awaitingUser === true ||
389+
(document.activeElement !== frameRef.current ||
390+
!navigator.userActivation?.isActive ||
391+
latest.current.props.awaitingUser === true ||
387392
isConfirmDialogActive() ||
388393
(otherFullscreen !== null && otherFullscreen !== boxRef.current))
389394
) {

‎docs/user/html-renders.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Some MCP servers return an interactive app with their tool results, following th
1414

1515
Apps follow your theme. An app can call tools on its own server and post a message to the thread; T3 Code asks first unless the server marks the tool as read-only, and it asks before every message. On mobile, an app also asks before opening a link, and T3 Code asks before saving a file an app offers. An app stays viewable after its agent stops, but using it needs the agent of the thread that created it running, so send a message in that thread first if the app says it is unavailable. An app that navigates away from its own page is stopped.
1616

17-
An app can open full screen; use the button in its top corner, or press Escape outside the app, to return it to the thread. Anything else that needs your attention, such as an approval, also returns it to the thread. On mobile, full screen opens the app again in its own screen, so anything the app does not save itself starts over. An app can also keep the agent informed of what you did in it, such as a filter you picked; T3 Code sends the latest note from each app with your next message.
17+
An app can open full screen right after you tap or click in it; use the button in its top corner, or press Escape outside the app, to return it to the thread. Anything else that needs your attention, such as an approval, also returns it to the thread. On mobile, full screen opens the app again in its own screen, so anything the app does not save itself starts over. An app can also keep the agent informed of what you did in it, such as a filter you picked; T3 Code sends the latest note from each app with your next message.

0 commit comments

Comments
 (0)