Skip to content

feat(app): run the app in a browser and smooth streamed text - #214

Closed
Sma1lboy wants to merge 1 commit into
mainfrom
worktree-theme-tokens-and-web-bridge
Closed

feat(app): run the app in a browser and smooth streamed text#214
Sma1lboy wants to merge 1 commit into
mainfrom
worktree-theme-tokens-and-web-bridge

Conversation

@Sma1lboy

Copy link
Copy Markdown
Contributor

Why

Three things, all in service of being able to develop and verify this app without an Electron window.

1. Web bridge — pnpm dev:web

One command starts the renderer dev server and a loopback bridge, and prints one ready-to-open link. No configuration.

The bridge reuses the existing ipcMain handlers rather than duplicating them for HTTP. createLocalAIAPI() / createMcpAPI() already accepted an ipcRenderer-shaped argument, so the browser just passes a fetch/WebSocket shim. No annotations, no codegen, one implementation.

Security (this channel can run local CLI agents):

  • off unless CONVERA_WEB_BRIDGE=1
  • per-run random token, required on every request and the WS upgrade
  • binds 127.0.0.1; non-loopback Origin rejected
  • channel allowlist — only local AI + MCP. Window control, clipboard, shortcuts and robotjs are not reachable.

Verified against the real CLIs: Claude Code 2.1.219 and codex-cli 0.146.0 detected, and a real chat streamed back through HTTP → WebSocket → browser.

2. Streaming smoothness

Measured first: a reply delivered 412 chars in 5 chunks of ~100, ~220ms apart. That's five paste events, not typing — no renderer tuning could fix it, because the problem is arrival rate.

Text now buffers and releases on animation frames, draining proportionally faster as the backlog grows so it never lags, and flushing on finish/abort so nothing is truncated.

before after
DOM updates 5 40
median chunk ~100 chars 13 chars

3. Theme consistency

Replaced 54 hardcoded palette colors (bg-blue-500, text-gray-600, …) with theme tokens. Most existed because the theme had no success / warning / info — so those were added in the warm palette, with -subtle surfaces and light + dark variants.

Also fixed real inconsistencies found while verifying:

  • dialogs used bg-background while popovers/menus used bg-popover — two surfaces for the same job
  • overlay scrims disagreed (black/30 vs black/50, blur on some) — now one --overlay token
  • two raw <textarea>s bypassed the themed component and showed the browser-default blue focus ring inside a warm dialog

Testing

  • 73 tests pass (5 new for the text drip, 5 for the bridge incl. a real HTTP+WS end-to-end)
  • tsc and eslint clean
  • verified in a real browser, light and dark

Note

pnpm dev:web has no MCP hub (it needs Electron's app paths) — builtin tools only. Run the Electron app for MCP servers.

🤖 Generated with Claude Code

Adds a loopback web bridge so the renderer can run in a plain browser tab
against the real local AI runtime, plus one command to start both halves:

    pnpm dev:web

The bridge reuses the existing IPC handlers rather than duplicating them:
`create*API()` already took an ipcRenderer-shaped argument, so the browser
passes an HTTP/WebSocket shim instead. Only the local AI and MCP channels
are exposed; window control, clipboard and shortcuts have no browser
meaning. Access needs a per-run token, loopback binding and a loopback
Origin, and the whole thing is off unless CONVERA_WEB_BRIDGE=1.

Streaming: the CLI providers deliver ~100 chars every ~220ms, which reads
as paste events rather than typing. Text now drips out on animation
frames, draining faster as the backlog grows and flushing on finish, so
no character is dropped. Measured 5 -> 40 DOM updates for one reply.

Theme: replaces 54 hardcoded palette colors with tokens, and adds the
success/warning/info tokens whose absence caused them. Dialogs, sheets
and drawers now use the popover surface and a shared overlay scrim, so
they match the popovers and menus they sit beside in both themes.
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foxyfox-docs Ready Ready Preview Jul 30, 2026 10:45pm
foxyfox-website Ready Ready Preview Jul 30, 2026 10:45pm

Request Review

@Sma1lboy

Copy link
Copy Markdown
Contributor Author

Superseded: this work landed on main directly and has since evolved past this branch — the web bridge (da6b5e9) now runs tokenless with a loopback-origin check (81cb1d8), text-drip smoothing is identical, and the dev harness gained dotenv loading and the new local-ai IPC contract. Verified file-by-file: everything here is either byte-identical on main (text-drip) or strictly older (server.ts, local-ai-api.ts, web-bridge-dev.mts still carry the token flow that was removed by request). Nothing to salvage; closing.

@Sma1lboy Sma1lboy closed this Jul 31, 2026
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