fix(mcp): render the widget in ChatGPT (window.openai runtime) - #135
Merged
Conversation
The widget only spoke the MCP Apps postMessage bridge, and blocked on an awaited ui/initialize response. In ChatGPT the tool CALLS worked but the widget sat on its 'Warming up the kitchen…' loading note forever, because ChatGPT's Apps runtime delivers tool output via window.openai (globals + the 'openai:set_globals' event), not that bridge — and it never answers ui/initialize, so the await hung. - Add a window.openai path: render from window.openai.toolOutput on mount and on 'openai:set_globals' (event.detail.globals.toolOutput); apply theme from the globals. - Route widget-initiated tool calls through window.openai.callTool and link-opens through window.openai.openExternal when present. - Make the MCP Apps ui/initialize handshake NON-BLOCKING (.then/.catch instead of await) so a host that never answers it can't freeze the widget. Claude/MCP-Apps rendering path is otherwise unchanged. JS syntax-checked; go build/vet + mcpserver tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In ChatGPT, SaltyBytes tool calls succeed (the model gets the recipe data) but the interactive widget sits on its
Warming up the kitchen…loading note forever and never renders the recipe cards.Root cause: the widget only implemented the MCP Apps
postMessagebridge andawaited aui/initializeresponse. ChatGPT's Apps runtime (a) never answers that handshake (so theawaithangs) and (b) delivers the tool's structured output viawindow.openai(window.openai.toolOutput+ theopenai:set_globalsevent), which the widget never read. Confirmed live in ChatGPT Developer Mode.Fix (
internal/mcpserver/widget/app.html)window.openairender path — render fromwindow.openai.toolOutputon mount and re-render onopenai:set_globals(event.detail.globals.toolOutput); apply theme from the globals.window.openai.callTool/window.openai.openExternalwhen present.ui/initializehandshake non-blocking (.then/.catch, noawait) so a host that never answers it can't freeze the widget.postMessagepath is otherwise unchanged (dual-bridge:window.openaifor ChatGPT,postMessagefor Claude).Verification
JS syntax-checked (
node --check),go build/go vet/go test ./internal/mcpserver/...pass. Will re-test live in ChatGPT after deploy.🤖 Generated with Claude Code