Repository navigation
Fix the Claude Code tab widget fallback and the Codex sidebar contract - #6
Conversation
The Claude desktop Code tab renders the Screens MCP App from servers that Claude Code starts, but never delivers the view's tool calls to them (anthropics/claude-code#106708). The view stayed on a start-up error. The view now keeps listening after its first relay call fails. It reads the local URL from the open_screen tool result, using the text content when structuredContent is missing. It then shows that URL with an Open in browser button that sends ui/open-link. A stand-in host that fails every tool call covers this as app-bridge bridge-no-relay. The README no longer says the Desktop registration reaches Code tab sessions.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6956a95f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| function RelayFallback({ relay }: { relay: AppRelayError }) { | ||
| const [url, setUrl] = useState<string | null | undefined>(undefined); | ||
| const [failed, setFailed] = useState(false); | ||
| useEffect(() => { void relay.browserUrl().then(setUrl); }, [relay]); |
There was a problem hiding this comment.
Update the fallback when a delayed tool result arrives
If the host delivers ui/notifications/tool-result more than three seconds after the relay fails, browserUrl() resolves to null and RelayFallback permanently renders “Ask the agent for the local Screens URL” without an Open in browser button. The message listener subsequently records the correct URL, but the component calls browserUrl() only once and never receives that update. This can occur when the view initializes before open_screen completes, particularly with openBrowser: true, whose launcher can wait up to five seconds. Keep the fallback subscribed to URL notifications after the initial timeout so a late result can populate the address and button.
Useful? React with 👍 / 👎.
12eea4a gave every host one open_screen that returns a 127.0.0.1 URL, takes openBrowser and tells the agent to use a browser when the app cannot connect. In Codex this sent agents away from the sidebar and thread-tab view, which relays its own calls, and dropped the guide text that tells them to work on the Screen get_view reports. Codex gets its own open_screen again: screenId only, no URL, the sidebar guide text. Claude and generic hosts keep the browser fallback. bridge-live now checks that the Codex tool offers no browser URL or launch, and takes its browser-tab URLs from the service origin.
Problem
In the Claude desktop Code tab, the Screens widget renders but never connects. This happens for the dev server from
.mcp.jsonand for any Screens server that Claude Code starts.What I found while reproducing:
open_screenonscreens-devreturned normally. The local service only ever saw the agent's connection, with no canvas connection from the view._screens_call/_screens_eventscalls.mcp_callcontrol request (result_not_for_model,check_permissions) for the app-only_screens_call, and the call reached the server and returned a session."unavailable". This matches the open bug [BUG] MCP App tool calls fail with "IPC not available" in the Claude desktop Code tab anthropics/claude-code#106708 ("IPC not available for MCP tool call"). In that bug the Code-tabui/initializeresult also has noserverTools.claude_desktop_config.jsonregistration from 6b86312 does not reach Code tab sessions. The session's server list does not include it.The MCP Apps spec (2026-01-26), Claude's MCP Apps docs and OpenAI's Apps SDK reference all allow our setup:
_meta.ui.resourceUri,text/html;profile=mcp-app,["app"]helper tools called throughtools/call, and an empty CSP. The relay gap is on the host side. We can't fix it, so the view now handles it.Change
packages/client/src/bridge.ts: if the first relay call fails, the view raisesAppRelayErrorand keeps listening. It reads the local URL fromui/notifications/tool-result, falling back to the text content when a host dropsstructuredContent. It only acceptshttp://127.0.0.1:<port>URLs. It opens the URL withui/open-link.packages/canvas/src/shell/main.tsx: shows "Screens can't connect in this view" with an Open in browser button and the selectable URL. If the host refuses the link, the view asks the person to copy the address.app-bridgegainsbridge-no-relay, a stand-in host that renders the view and fails every tool call the way the Code tab does.Codex sidebar regression
12eea4a replaced the Codex
open_screenwith one tool for every host. That tool returns a 127.0.0.1 URL, takesopenBrowser, and tells the agent to use a browser "if the app cannot display or connect". It also removed the Codex guide line that tells the agent to work on the Screenget_viewreports for the sidebar or thread-tab view. A Codex agent can't tell whether the view connected, so these instructions send it to a browser, away from the view that Codex relays. The view's own relay still works in the current Codex build: the desktop log shows_screens_call,_screens_eventsand_screens_contentcalls, andget_viewfrom a--host codexadapter finds the open sidebar view.packages/mcp/src/main.ts,guide.ts: with--host codex,open_screentakes onlyscreenIdagain. It returns{screenId, open}with no URL, and the guide has the pre-update sidebar text again. Claude and generic hosts keep the browser fallback.bridge-livenow fails if the Codexopen_screenoffers a URL oropenBrowser. Its browser-tab checks build their URLs from the service origin.Verification
probe bridge-no-relay:{"fallback":true,"urlFromText":true,"openLink":true,"browserOpened":true,"relayCalls":1,"localRequests":0}. The view showed the URL from text-only content and sentui/open-linkwith exactly that URL. Opening it showed the same Screen in the browser canvas. The embedded view made no local requests.bridge-live,bridge-claudeandbridge-no-relayeach pass in a fresh session (run --fresh --id …).bridge-claudepasses on its own (--id bridge-claude). Run afterbridge-livein one session, it fails at "image drop did not commit through multiple chunks (0)". It fails the same way on unchanged HEAD, because the image is already stored, so nothing is uploaded again.open_screentakes[screenId]and returns[screenId, open]. Claudeopen_screentakes[screenId, openBrowser]and returns[screenId, url, open]. Both keep the global and thread entrypoints.screens-cli check,npm run typecheck,npm test,npm run release:buildandnpm run release:verifypass.I didn't see the fallback in the real Code tab, or a Codex agent use the restored tool in the Codex app. The pane's widget can't be inspected from a session, and screen capture is blocked here.