Now I can open up Tauri frontend inside the browser, like this:
And all functionality works the same as using it inside a normal app window.
You might be thinking:
Why is it something to do with the Designer?
Tauriis some kind of Devtool, no?
To help them design & iterate fast right inside the codebase, with coding agents.
Tauriis using Webview, so running it in any type of browser should work out-of-the-box, no?
Actually, that’s not the case. We had to build fastrepl/char/plugins/relay to enable it.
Like Ryo Lu said, the line between "developer" and "designer" is definitely getting blurry.
He even showed how he works, using something called Baby Cursor, within the "Cursor's integrated browser":
After watching this, I wanted to enable something similar to everyone who works in fastrepl/char.
And I first thought it would be simple. Tauri allows typical web frontend stacks to draw UI inside the Webview. So I could just open up localhost:1422 inside the Cursor, right?
Actually, it was not.
Tauri relies on __TAURI_INTERNALS__ globals that don't exist in a normal browser.invoke (calling Rust commands) and event subscriptions break immediately outside the managed webview.fastrepl/char/plugins/relay does it. fastrepl/char#4007 is almost all it takes. (I pushed a bit more commits after this though)
How it works:
shim.js injected by a Vite plugin replaces the missing __TAURI_INTERNALS__ globals in the browserinvoke() calls route over WebSocket to the Relay server, which runs the real Rust handleremit / listen) are bridged the same wayflowchart LR Browser -->|invoke| Shim[shim.js] Shim -->|WebSocket| Relay[Relay] Relay --> Backend[Tauri] Backend -->|response| Browser
At this point, the problem is solved. But there is one more concern left.
tauri dev command requires Rust and other dependencies.Rust and waiting build is not very approachable. It need lots of compute resource, storage, and time.Then I realized that we have a Staging build that we don't distribute, but just exists for testing. Staging is built with devtools which enables custom devtools we built(like seeding data etc) and right click context menu in webview(like inspect menu).
Now anyone with the Staging build can just run it as Rust backend, and make code changes in TypeScript side for UI iteration.