Connect browser terminal and HTML views to native fx - #810
Draft
nandorojo wants to merge 5 commits into
Draft
Conversation
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.
This lets a web app use libfx’s terminal or HTML UI while native fx runs in Vercel Sandbox. The browser connects through the app’s backend; fx keeps the conversation, calls models, and executes tools in the sandbox.
Browser
Use the existing terminal component:
Or use HTML with fx-owned commands, model choices, and permission controls:
Backend
Start once using the application’s existing sandbox, then retain the private connection for that session:
resolveSession(request)is the app’s authentication hook: return the authenticated user’s stored private connection, or null. Give the browser{url: 'wss://your-app.example/api/fx', sessionId}. Sandbox URLs and credentials stay on the backend.The example needs Node and Python in the sandbox, and Bun to bundle the broker. It reuses the native process across prompts and browser reconnects.
abort()detaches the view;interrupt()cancels the native operation.Limits
HTML currently supports conversation, command suggestions, model selection, and permission prompts; other native screens explicitly offer terminal handoff. Replay is bounded, expired terminal cursors fail explicitly, and one view can write at a time.
Validation
Native/WASM builds, focused SDK tests, and 13 real PTY/relay tests pass. Real Chrome exercised native model selection and streaming; a prompt through the app relay survived reload without another model request. The provider was a local mock, not a live model or paid Vercel Sandbox.
Draft pending exact-commit Full CI across Linux and macOS.