Skip to content

IDE on Tauri 2: walking skeleton (Rust shell, bridge, Node sidecar) beside Electron - #494

Merged
aMonteSl merged 30 commits into
idefrom
claude/project-thread-urap9o
Dec 4, 2026
Merged

aMonteSl merged 30 commits into
idefrom
claude/project-thread-urap9o

Conversation

@aMonteSl

@aMonteSl aMonteSl commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Adrián · project thread

Walking skeleton of epic #477: the real IDE runs on Tauri 2, beside the Electron build, which is unchanged. Parts of R2 (#480), R3 (#481) and R4 (#482), and R5 (#483, the scene view beside the code); the stories stay open until their remaining criteria land. Also records the R1 (#479) spike results on the three OS (go, no CEF fallback).

What

  • One desktop seam (src/main/host/desktop.ts): every electron import of the main process goes through it. The Electron build uses it as is (it re-exports electron); the sidecar build aliases it to src/sidecar/tauriHost.ts and fails on any direct electron import.
  • Shared boot (src/main/boot.ts) for both shells; index.ts keeps only Electron's own steps. ELECTRON_RUN_AS_NODE goes through src/main/nodeRuntime.ts, so the sidecar's children run on a real Node without it.
  • Bridge: window.codexr is built once (src/preload/codexrApi.ts) from an IPC adapter; the Electron preload and the Tauri bridge (src/bridge, injected as an initialization script) both freeze the same object.
  • Node sidecar (src/sidecar): JSON-RPC over stdio with the Rust core; bytes as base64.
  • Rust core (src-tauri, Tauri 2.13): codexr://app/ scheme with the CSP as a header, navigation and new-window guards, single instance, sidecar supervision (killed with the app; an error dialog if it dies), codexr_ipc forwarded to the sidecar (its existing allow-list and origin check decide), one ordered channel per webview for events, dialogs / clipboard / opener / trash / theme, secrets with AES-GCM and a key in the OS keyring.
  • npm run tauri:build | tauri:start | tauri:run (scripts/tauri.mjs); ide-bench.yml gets a Tauri job on the three OS.

Verified here (Linux, Xvfb, WebKitGTK 2.52)

--folder= opens and the explorer lists it; Monaco opens a file with Git blame; the terminal runs bash; settings load; Git status in a trusted folder; --codexr-bench end to end; killing the sidecar shows an error, killing the app stops sidecar and terminals.

Not yet on Tauri (logs "not yet on Tauri (Rn)" once, never crashes)

Extension webviews (R6), menus / About / screen picker / dialogs with more than 3 buttons (R9), --codexr-smoke (R11), bundled Node and dev server (R12), reading Electron's existing secrets (R10).

Numbers (CI, GitHub runners, median of 5 warm runs; two runs of each job)

Electron 45 Tauri (skeleton)
Linux usable / PSS / idle 0.84-1.08 s / 458 MB / 0.8-1.1 % 1.46-1.88 s / 478 MB / 1.0-1.2 %
Windows usable / private / idle 1.21-1.45 s / 272 MB / 0.5-1.2 % 2.08-2.36 s / 347 MB / 1.3-1.6 %
macOS usable / RSS / idle 2.16-2.63 s / 574 MB / 2.2-2.6 % 2.68-7.38 s / 564-576 MB / 0.2-0.5 %

Not a verdict: the skeleton still runs every main-process service in a full Node sidecar beside the webview; the start-up work is in docs/ide/tauri-migration.md section 8.

Also fixed on the way:

  • Windows: the sidecar bundled two copies of the Tauri host (backslashed alias id), so every IPC call found no handler; the build now fails on a second copy.
  • Linux CI: the runner's systemd user bus made GTK wait 25 s + 2 x 5 s on portals at start-up; both shells are benched in a session bus of their own.
  • The page's errors reach the core's log (codexr_log), as Electron's console-message.
  • [Bug] Node debugger shows the inspector's "Debugger ending on" line as program output #495: the Node debugger drops the inspector's "Debugger ending on" line (a flaky Windows test).

Checks

apps/ide: typecheck, lint (0 warnings), 1,204 unit tests, build, smoke (Electron), cargo test --release. apps/vscode-extension untouched.


Generated by Claude Code

aMonteSl and others added 9 commits December 4, 2026 19:32
…480, #482)

Every Node-side module now imports Electron through src/main/host/desktop.ts,
which only re-exports it: the Electron build is unchanged. The Tauri build
will swap that one module for the sidecar's implementation.

nodeRuntime.ts holds the ELECTRON_RUN_AS_NODE variable that children run
on the IDE's own executable need (extension host, TypeScript server, MCP,
local agent, ACP agents), so the sidecar, a real Node, can drop it.
…481)

The API object moves to src/preload/codexrApi.ts and takes an IPC adapter
(invoke a channel, hear an event). The Electron preload passes ipcRenderer
and the context bridge, as before.

src/bridge/index.ts is the Tauri side: an IIFE (out/bridge/index.js) that the
Rust core injects before the page's scripts. It calls one command,
codexr_ipc, hears events on one Tauri channel in order, and defines the same
frozen, non-writable window.codexr. src/shared/jsonCodec.ts carries bytes and
undefined across JSON.
…#482)

src/main/boot.ts holds the boot sequence both shells share (services, IPC
handlers, theme, language, start-up folder); index.ts keeps only what is
Electron's own (protocols, hardening, the window, the smoke run).

src/sidecar/ is the Tauri build's Node half, built to out/sidecar/index.cjs:
- rpc.ts: JSON-RPC 2.0 over newline-delimited stdio; stdio.ts keeps stdout
  for the protocol and sends every log to stderr;
- tauriHost.ts: the desktop seam's Tauri implementation (the sidecar build
  resolves src/main/host/desktop.ts to it and refuses any electron import):
  WebContents/BrowserWindow shims keyed by webview label, dialogs, clipboard,
  opener, trash, theme and an AES-GCM safeStorage keyed from the OS keyring,
  all answered by the Rust core; the scene view (R5), extension webviews
  (R6), menus, the screen picker and dialogs with more than three buttons
  (R9) log 'not yet on Tauri' instead of failing;
- index.ts: boots on a real Node (children drop ELECTRON_RUN_AS_NODE), asks
  the core for the main window and serves the forwarded window.codexr calls.

The CSP builder takes extra connect-src entries for Tauri's IPC scheme.
…481, #482)

apps/ide/src-tauri is the Rust core (Tauri 2.13 stable crates):
- serves out/renderer at codexr://app/ (http://codexr.localhost/ on
  Windows) with the CSP the sidecar builds from src/main/security.ts, sent
  as a header; Tauri's CSP injection is off so no nonce cancels Monaco's
  'unsafe-inline' styles; paths cannot leave the renderer folder;
- blocks navigation off the app and every new window, keeps one instance
  (except benchmark runs, as on Electron);
- starts the sidecar on CODEXR_NODE (or node), speaks JSON-RPC over its
  stdio, kills it with the app and closes with a message if it dies;
  sidecar lines starting with CODEXR_ go to stdout for the harnesses;
- one command, codexr_ipc, forwards window.codexr calls with the page URL
  (the sidecar keeps the allow-list and trusted-origin check), and
  codexr_events gives each page an ordered event channel; a capability
  grants both to the main window's local pages only;
- answers the sidecar's host operations with plugin-dialog,
  plugin-clipboard-manager, plugin-opener, the trash crate, the theme and a
  keyring-held key for the secret store.

npm run tauri:build / tauri:start / tauri:run (scripts/tauri.mjs) build the
web targets, the sidecar and the bridge, then cargo build --release.
The bridge now rejects with Electron's message shape.
…rs (#480, #481, #482)

docs/ide/tauri-migration.md gains section 8: how the seam, the shared boot,
the sidecar protocol and the bridge fit, the deviations from the story
design, what degrades and in which story it returns, what was verified by
running, and Electron vs Tauri benchmark numbers from the same machine.
The README lists the tauri:* scripts and the new folders; electron-builder
leaves the Tauri build's sidecar and bridge out of the Electron app.
@aMonteSl aMonteSl self-assigned this Dec 4, 2026
…car boots in parallel (#480, #482)

The Rust core opens the main window as it starts, hidden until the page
loaded (as Electron waits for ready-to-show), while the Node sidecar boots:
- page requests wait for the sidecar's CSP (window.attach), IPC calls wait
  until every handler is registered (openIpc), none fails;
- ?locale= is the sidecar's last decision (cache folder, src-tauri/src/locale.rs)
  or the environment's language; the sidecar reloads in its own if they differ;
- the sidecar runs with NODE_COMPILE_CACHE in the app's cache folder (taken
  out of its environment so no child inherits it).

A visible WebKitGTK view painted before its web process is up blocked the UI
thread 500 ms (strace: one futex wait timing out). Bench, container, median
of 4: usable 2,223 -> 1,604 ms.
…err when a run fails (#480)

WebView2 has no custom schemes: the page is http://codexr.localhost/, and
wry hands the scheme handler the request rewritten back as
codexr://localhost/ (wry custom_protocol_workaround::revert_uri_work_around).
The handler only accepted the host "app", so every request answered 404 on
Windows and the bench never got its result line. is_app_request accepts that
form on Windows only, with a test.

For CI: the core logs the sidecar start, the main window's URL, each page
load and every refused or missing request; a window whose page has not loaded
after 10 s is shown anyway (logged); bench.mjs keeps the app's last 60
stderr lines and prints them, with its stdout, when a run fails.
…mation (#480)

The idle CPU of both shells was the focused terminal's cursor: xterm.js
blinks it with a 1s step-end infinite CSS animation, which the engine ticks
every frame. Found by counting rAF, timers, DOM mutations and
document.getAnimations() from inside the page in a bench run: no rAF loop, one
5 s interval, no mutations, and three infinite animations at most (the cursor;
the analysis spinner and the live pulse only while an analysis runs).

The blink now toggles data-cursor-phase every 500 ms (visible first, restarted
visible when the cursor row is redrawn, still when unfocused or hidden), and
the hidden half is the animation's 50 % keyframe in styles.css: same look.

Bench, container, median of 4, idle CPU: Electron 4.6 % -> 1.4 %, Tauri
11.8 % -> 11.0 % (WebKitGTK paints are the cost there: next commit).
…er node (#480)

Without a DRM render node (a VM, a container, software GL) WebKitGTK's DMA-BUF
renderer copies every frame through shared memory: each paint of the idle IDE
cost about 25 ms of CPU and the web process 200 MB more. The core now sets
WEBKIT_DISABLE_DMABUF_RENDERER=1 at start-up when /dev/dri has no openable
renderD* node and the variable is not set already, and keeps it out of the
sidecar's environment (terminals do not inherit it).

Container (Xvfb, llvmpipe, no /dev/dri), median of 4: idle CPU 11.0 % -> 1.6 %,
PSS 683 -> 472 MB (WebKitWebProcess 450 -> 256 MB). The R1 spike's WebGL
A-Frame scene still renders (25-29 -> 32-33 FPS). Also tried:
WEBKIT_DISABLE_COMPOSITING_MODE=1 (1.5 %, 490 MB: kept the other, which leaves
compositing on), WEBKIT_SKIA_ENABLE_CPU_RENDERING=1 (no idle gain), NO_AT_BRIDGE
and GTK_A11Y=none (no start-up gain).
localSceneLibraries (off by default, the VS Code plugin is unchanged): pages sent to this machine get the pinned CDN URLs rewritten to /__codexr/scene-libraries/, served from the vendored copies; A-Frame's font root and BabiaXR's default font are rewritten inside the served scripts. Tunnel pages keep the CDNs. The IDE turns it on at start-up: a system webview (Tauri) cannot intercept https as Electron's scene session did. The pattern table moves to the core; the IDE re-exports it.
… its bridge (#483)

Window::add_child (unstable multiwebview) behind the seam's WebContentsView: made on first load, placed in order (scene.setBounds on the reader thread), incognito, kept on its own server's origin. src/sceneBridge (an init script) gives the page CodeXRHostBridge.openInEditor over one command, codexr_scene, allowed to scene-* webviews on loopback pages only and checked again in the core and in ipc.ts. executeJavaScript on a scene answers through the bridge. Windows are looked up with get_window: with two webviews Tauri no longer sees a webview window.
Where the webview has WebXR (WebView2), Enter XR asks the scene to show its own Enter XR button: the click inside the scene is the gesture WebXR needs. Where it has none (WKWebView, WebKitGTK), SceneInfo.xrUnavailable hides the button and the note points at Open in browser and On a headset. Electron is unchanged. Also fixes the LivePanel check, which never matched the <target>-livepanel kinds.
…s are found; Linux start-up variants on CI (#480)

The seam resolver returned a backslashed path on Windows, while the sidecar's
own ./tauriHost.ts import got Vite's forward-slashed id: two module copies, the
handlers registered in one and looked up in the other. The build now fails if
the bundle holds more than one copy.
@aMonteSl
aMonteSl merged commit c3ccb33 into ide Dec 4, 2026
29 checks passed
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.

2 participants