diff --git a/.claude/docs/DEVELOPMENT.md b/.claude/docs/DEVELOPMENT.md index 537cd8389..c47fc8d1e 100644 --- a/.claude/docs/DEVELOPMENT.md +++ b/.claude/docs/DEVELOPMENT.md @@ -24,7 +24,7 @@ | `npm run compile-tests` | Removes `out/`, then `tsc -p . --outDir out`. Starting empty matters: tsc never deletes output for a source that is gone, so a module deleted from `src/` would keep a compiled twin the suites still load | Part of `test:basic` | | `npm run watch-tests` | `tsc -p . -w --outDir out`: keeps `out/` current while iterating on tests (the runner's stale-output check is per file, so this stays valid) | Iterating with `npm run test:unit` | | `npm test` = `npm run test:basic` | `typecheck` + `lint` + `compile-tests` (tsc → `out/`) + `test:unit`. Needs **no** webpack build. At the root it then runs `ide:test` | **The default gate. Run before declaring any change done.** | -| `npm run ide:test` / `ide:dev` / `ide:build` / `ide:start` / `ide:smoke` (root only; workspace `code-xr-ide`) | The Code-XR IDE (`apps/ide`, epic #11). `ide:test`: `tsc` over `tsconfig.node.json` and `tsconfig.web.json` + ESLint with `--max-warnings 0` + `node --test` over `apps/ide/test/**/*.test.ts` (Node's type stripping, no compile step); the root `npm test` runs it after the extension gate. `ide:dev`: Vite dev server + Electron restart on main/preload changes. `ide:smoke`: build, launch hidden with `--codexr-smoke`, assert the security baseline from inside the real window (CI job `ide-smoke` on the three OSes; Linux needs `xvfb-run -a`). Details: `apps/ide/README.md` | After touching `apps/ide/` | +| `npm run ide:test` / `ide:dev` / `ide:build` / `ide:start` / `ide:smoke` (root only; workspace `code-xr-ide`) | The Code-XR IDE (`apps/ide`, epic #11). `ide:test`: the legacy-shell gate (`apps/ide/scripts/legacyShellGate.mjs`, R13 #491) + `tsc` over `tsconfig.node.json` and `tsconfig.web.json` + ESLint with `--max-warnings 0` + `node --test` over `apps/ide/test/**/*.test.ts` (Node's type stripping, no compile step); the root `npm test` runs it after the extension gate. The IDE is Tauri 2 + a Node sidecar: `ide:build` needs the Rust toolchain and Tauri's system libraries. `ide:dev`: build, run, rebuild the bundles and restart the app on every change. `ide:smoke`: build, launch hidden with `--codexr-smoke`, run the probes inside the real page through the Rust core (CI: `ide-tauri.yml` on the three OSes; Linux needs `xvfb-run -a dbus-run-session --`). Details: `apps/ide/README.md` | After touching `apps/ide/` | | `npm run test:unit` | `test/runners/run-node-tests.cjs` → first refuses to start if `out/` does not match `src/` (a source newer than its output, an uncompiled source, or a compiled file whose source is gone), then collects `test/**/*.test.cjs` and runs `node --test --test-isolation=none --test-concurrency=1` — **every suite in one process**, so a test must never leave global state behind | Unit/runtime tests only (fast) | | `npm run test:python` (root `test:backend` runs the same file directly) | `backend/scripts/run-python-tests.cjs` → `unittest discover` over `backend/tests/`. A test folder **needs an `__init__.py`** or discovery skips it silently. With no interpreter it skips locally and **fails under `CI`** | After touching `backend/src/` | | `npm run lint:python` (root only) | `backend/scripts/run-ruff.cjs` → `ruff check` in `backend/` with `backend/ruff.toml`: pyflakes (`F`) plus the pycodestyle error classes `E4`/`E7`/`E9` and the modernization lock-ins of story #56 (`E722`, `UP004`, `UP008`, `UP031`, `UP032`, and `FA100`/`UP006`/`UP007`/`UP037`/`UP045`: builtin generics in annotations behind `from __future__ import annotations`, and `UP012`/`UP015`/`RUF010`; `docs/cleanup/modernization.md`), target Python 3.7, fixture corpora (`manual_test/`, `tests/fixtures/`) excluded, `E402` ignored per file (with the reason) where a module bootstraps `sys.path` before its imports. **Lint only — no formatter, no isort**: tests pin import lines and statement order. Ruff is pinned in `backend/requirements-dev.txt` (`python -m pip install -r backend/requirements-dev.txt`); a missing ruff is a failure, never a skip | After touching `backend/` | diff --git a/.github/actions/ide-tauri-installers/action.yml b/.github/actions/ide-tauri-installers/action.yml new file mode 100644 index 000000000..5632c4dd3 --- /dev/null +++ b/.github/actions/ide-tauri-installers/action.yml @@ -0,0 +1,142 @@ +name: IDE installers +description: >- + Builds the Code-XR IDE's installers for the runner's OS (R12 #490, + docs/ide/tauri-migration.md section 15), installs them into a scratch folder, + runs the smoke run against the INSTALLED binary without CODEXR_NODE (so on the + Node it ships, with the resources it ships), and measures download and + installed sizes. Expects the repository checked out, Node set up and npm ci done. + Used by ide-release.yml (releases) and ide-tauri.yml (pushes). + +runs: + using: composite + steps: + - name: Tauri system libraries (Linux) + if: runner.os == 'Linux' + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev xvfb + + # Ubuntu 24.04 restricts unprivileged user namespaces, which WebKitGTK's bubblewrap + # sandbox needs (desktop Ubuntu ships an AppArmor profile for it). + - name: Allow the web sandbox (Linux) + if: runner.os == 'Linux' + shell: bash + run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 + + - name: Rust toolchain + shell: bash + run: rustup toolchain install stable --profile minimal && rustup default stable + + - name: Cargo registry cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index + ~/.cargo/registry/cache + ~/.cargo/git/db + key: cargo-registry-${{ runner.os }}-${{ hashFiles('apps/ide/src-tauri/Cargo.lock') }} + restore-keys: cargo-registry-${{ runner.os }}- + + # The pinned Node runtime (scripts/bundledNode.mjs): checked against its pinned SHA-256 + # whether it comes from the cache or from nodejs.org. + - name: Bundled Node cache + uses: actions/cache@v4 + with: + path: ~/.cache/codexr-ide/node + key: codexr-bundled-node-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('apps/ide/scripts/bundledNode.mjs') }} + + # The extension's Python backend copy (dist/code_analysis), the IDE (out/), the stage + # (src-tauri/target/stage), then `tauri build` into apps/ide/release/. + # The AppImage tools are AppImages themselves: extracted, as the runner has no FUSE 2. + - name: Build the installers + shell: bash + env: + APPIMAGE_EXTRACT_AND_RUN: '1' + run: npm run tauri:bundle --workspace=code-xr-ide + + - name: Install into a scratch folder (Linux, .deb extracted) + if: runner.os == 'Linux' + shell: bash + run: | + dir="$RUNNER_TEMP/codexr-installed" + rm -rf "$dir" && mkdir -p "$dir" + dpkg-deb --info apps/ide/release/*.deb + dpkg-deb -x apps/ide/release/*.deb "$dir" + echo "CODEXR_INSTALLED_DIR=$dir" >> "$GITHUB_ENV" + echo "CODEXR_INSTALLED_BIN=$dir/usr/bin/code-xr-ide" >> "$GITHUB_ENV" + + # The NSIS installer, silently, per user, into a scratch folder (/D must come last). + - name: Install into a scratch folder (Windows, NSIS silent) + if: runner.os == 'Windows' + shell: pwsh + run: | + $dir = Join-Path $env:RUNNER_TEMP 'codexr-installed' + $setup = Get-ChildItem apps/ide/release/*.exe | Select-Object -First 1 + $process = Start-Process -FilePath $setup.FullName -ArgumentList '/S', "/D=$dir" -Wait -PassThru + if ($process.ExitCode -ne 0) { throw "The installer exited with $($process.ExitCode)" } + Get-ChildItem $dir + "CODEXR_INSTALLED_DIR=$dir" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + "CODEXR_INSTALLED_BIN=$(Join-Path $dir 'code-xr-ide.exe')" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + + - name: Install into a scratch folder (macOS, .app copied from the .dmg) + if: runner.os == 'macOS' + shell: bash + run: | + dir="$RUNNER_TEMP/codexr-installed" + mount="$RUNNER_TEMP/codexr-dmg" + rm -rf "$dir" && mkdir -p "$dir" "$mount" + hdiutil attach -nobrowse -readonly -mountpoint "$mount" apps/ide/release/*.dmg + cp -R "$mount/Code-XR IDE.app" "$dir/" + hdiutil detach "$mount" + codesign --verify --verbose "$dir/Code-XR IDE.app" || true + echo "CODEXR_INSTALLED_DIR=$dir/Code-XR IDE.app" >> "$GITHUB_ENV" + echo "CODEXR_INSTALLED_BIN=$dir/Code-XR IDE.app/Contents/MacOS/code-xr-ide" >> "$GITHUB_ENV" + + # The installed IDE, with no CODEXR_NODE: it must run on the Node it ships and find the + # Python backend, templates, scene libraries and TypeScript server it ships (smoke.mjs --installed). + - name: Smoke on the installed IDE (Linux, virtual display) + if: runner.os == 'Linux' + shell: bash + env: + WEBKIT_DISABLE_DMABUF_RENDERER: '1' + run: env -u CODEXR_NODE xvfb-run -a -s "-screen 0 1920x1080x24" dbus-run-session -- node apps/ide/scripts/smoke.mjs --installed "$CODEXR_INSTALLED_BIN" + + # The AppImage as people run it: its runtime mounts (here: extracts) it and starts usr/bin + # with APPDIR set, which is how the core finds its resource folder in an AppImage. + - name: Smoke on the AppImage (Linux, virtual display) + if: runner.os == 'Linux' + shell: bash + env: + WEBKIT_DISABLE_DMABUF_RENDERER: '1' + APPIMAGE_EXTRACT_AND_RUN: '1' + run: | + chmod +x apps/ide/release/*.AppImage + env -u CODEXR_NODE xvfb-run -a -s "-screen 0 1920x1080x24" dbus-run-session -- node apps/ide/scripts/smoke.mjs --installed "$(ls apps/ide/release/*.AppImage | head -n 1)" + + - name: Smoke on the installed IDE + if: runner.os != 'Linux' + shell: bash + run: env -u CODEXR_NODE node apps/ide/scripts/smoke.mjs --installed "$CODEXR_INSTALLED_BIN" + + # The Code-XR extension installed from its .vsix into the installed IDE: the extension host + # runs on the bundled Node too. The plugin is packaged here, never changed. + - name: Package the Code-XR extension + shell: bash + run: npm run package:vsix + + - name: Code-XR extension in the installed IDE (Linux, virtual display) + if: runner.os == 'Linux' + shell: bash + env: + WEBKIT_DISABLE_DMABUF_RENDERER: '1' + run: env -u CODEXR_NODE xvfb-run -a -s "-screen 0 1920x1080x24" dbus-run-session -- node apps/ide/scripts/vsixE2e.mjs --installed "$(ls apps/vscode-extension/artifacts/*.vsix | head -n 1)" "$CODEXR_INSTALLED_BIN" + + - name: Code-XR extension in the installed IDE + if: runner.os != 'Linux' + shell: bash + run: env -u CODEXR_NODE node apps/ide/scripts/vsixE2e.mjs --installed "$(ls apps/vscode-extension/artifacts/*.vsix | head -n 1)" "$CODEXR_INSTALLED_BIN" + + - name: Installer and installed sizes + shell: bash + run: node apps/ide/scripts/benchSizes.mjs --label=tauri --installed="$CODEXR_INSTALLED_DIR" --out="apps/ide/release-sizes-${{ runner.os }}.json" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6b1e2136..ec102c035 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,9 +38,6 @@ env: npm_config_fund: 'false' npm_config_update_notifier: 'false' PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' - # The Electron binary (~100 MB) is only needed by the IDE smoke job, which - # turns this back off. Type checking and unit tests use the package's types. - ELECTRON_SKIP_BINARY_DOWNLOAD: '1' jobs: gate: @@ -69,7 +66,9 @@ jobs: run: npm ci # Extension: typecheck + lint + compile-tests + unit suites (no webpack - # build). IDE: typecheck + lint + unit tests. + # build). IDE: the legacy-shell gate (R13 #491) + typecheck + lint + unit + # tests. The IDE's smoke run, the extension installed in it and its + # installers run in ide-tauri.yml (they need the Rust toolchain). - name: Gate run: npm test @@ -136,54 +135,6 @@ jobs: - name: Core without VS Code run: node apps/vscode-extension/test/runners/run-core-smoke.cjs - ide-smoke: - name: IDE smoke (${{ matrix.os }}) - # Builds the Code-XR IDE and launches it hidden with --codexr-smoke: the - # real window must open and, from inside the page, prove that the renderer - # is sandboxed (no require/process), the CSP blocks eval, navigation and - # window.open are blocked, and the preload API answers over IPC (#12). - # #137: it also opens the terminal panel with the default profile (Git - # Bash on windows-latest, $SHELL elsewhere), types `echo codexr-smoke` and - # reads the output back. node-pty is a native module, but an N-API one - # with prebuilt binaries for win32/darwin/linux x64 and arm64 in its npm - # package, so `npm ci` compiles nothing and the same binary loads in - # Electron: no @electron/rebuild step, no compiler on the runner. - runs-on: ${{ matrix.os }} - env: - ELECTRON_SKIP_BINARY_DOWNLOAD: '0' - strategy: - fail-fast: false - matrix: - os: [windows-latest, ubuntu-latest, macos-latest] - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: npm - - - name: Install - run: npm ci - - # Ubuntu 24.04 restricts unprivileged user namespaces through AppArmor, - # which Chromium's sandbox needs. Re-allow them on the runner instead of - # launching Electron with --no-sandbox, so the smoke run keeps the real - # sandbox. - - name: Allow the Chromium sandbox (Linux) - if: runner.os == 'Linux' - run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 - - - name: Smoke (Linux, virtual display) - if: runner.os == 'Linux' - run: xvfb-run -a npm run ide:smoke - - - name: Smoke - if: runner.os != 'Linux' - run: npm run ide:smoke - harnesses: name: browser harnesses (ubuntu-latest) # Real A-Frame scenes in headless Chromium (S15, #87). The harnesses block @@ -252,45 +203,6 @@ jobs: retention-days: 14 if-no-files-found: error - vsix-in-ide: - name: Code-XR extension in the IDE (ubuntu-latest) - # #262: the .vsix the package job built installs from file in the built - # IDE, activates, and shows its Code-XR tree (apps/ide/scripts/vsixE2e.mjs, - # Playwright against the real window); any vscode API it uses at start-up - # that the IDE's extension host lacks fails the job. - needs: package - if: github.event_name != 'push' - runs-on: ubuntu-latest - env: - ELECTRON_SKIP_BINARY_DOWNLOAD: '0' - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version-file: .nvmrc - cache: npm - - - name: Install - run: npm ci - - - name: Download the VSIX - uses: actions/download-artifact@v4 - with: - name: code-xr-vsix - path: vsix - - - name: Allow the Chromium sandbox - run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 - - - name: Build the IDE - run: npm run ide:build - - - name: Install and run the extension (virtual display) - run: xvfb-run -a node apps/ide/scripts/vsixE2e.mjs "$(ls vsix/apps/vscode-extension/artifacts/*.vsix | head -n 1)" - extensions-compat: name: Popular extensions in the extension host (ubuntu-latest) # #264: downloads popular extensions from Open VSX and runs each one in diff --git a/.github/workflows/ide-bench.yml b/.github/workflows/ide-bench.yml index 66dc48d56..45cd04980 100644 --- a/.github/workflows/ide-bench.yml +++ b/.github/workflows/ide-bench.yml @@ -8,6 +8,13 @@ name: IDE benchmark # docs/ide/tauri-migration.md): the same driver and the same numbers before and # after. Not a gate: runners are noisy, so it only reports (job summary + JSON # artifact). Runs on a manual dispatch and on pull requests that touch it. +# +# R13 (#491) removed Electron from the tree. The "before" side is now the last commit +# that had it, BASELINE_SHA below, checked out next to the working tree and built there +# with its own scripts; nothing of the current tree depends on Electron. This file and +# apps/ide/scripts/benchCompare.mjs are the only places allowed to name it +# (apps/ide/scripts/legacyShellGate.mjs). Change BASELINE_SHA only to re-measure an +# older Electron build: any later commit has no Electron to build. on: workflow_dispatch: @@ -18,6 +25,7 @@ on: - '.github/workflows/ide-bench.yml' - 'apps/ide/scripts/bench.mjs' - 'apps/ide/scripts/benchSizes.mjs' + - 'apps/ide/scripts/benchCompare.mjs' - 'apps/ide/scripts/tauri.mjs' - 'apps/ide/src-tauri/**' push: @@ -27,6 +35,7 @@ on: - '.github/workflows/ide-bench.yml' - 'apps/ide/scripts/bench.mjs' - 'apps/ide/scripts/benchSizes.mjs' + - 'apps/ide/scripts/benchCompare.mjs' - 'apps/ide/scripts/tauri.mjs' - 'apps/ide/src-tauri/**' @@ -43,19 +52,29 @@ env: npm_config_fund: 'false' npm_config_update_notifier: 'false' PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' - CSC_IDENTITY_AUTO_DISCOVERY: 'false' + # The Electron baseline: the branch head right before R13 (#491) removed Electron + # (commit 58adf3a0, "fix(ide): Dark preview reaches WebView2, parity fixtures stay LF + # on Windows (#489)"). Pinned, never a branch name: the baseline must not move. + BASELINE_SHA: 58adf3a035a0a0f4859da67163354b9c69cab48e jobs: - electron: - name: electron (${{ matrix.os }}) + # The Electron installers and installed app at the baseline commit, built by that + # commit's own electron-builder configuration and measured by its own benchSizes.mjs. + baseline-sizes: + name: electron baseline sizes (${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [windows-latest, ubuntu-latest, macos-latest] + env: + # No signing identity is looked up on macOS (mac.identity in the baseline's config). + CSC_IDENTITY_AUTO_DISCOVERY: 'false' steps: - - name: Checkout + - name: Checkout the baseline uses: actions/checkout@v4 + with: + ref: ${{ env.BASELINE_SHA }} - name: Setup Node uses: actions/setup-node@v4 @@ -66,36 +85,19 @@ jobs: - name: Install run: npm ci - - name: Allow the Chromium sandbox (Linux) - if: runner.os == 'Linux' - run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 - - name: Build the installers run: npm run dist --workspace=code-xr-ide - name: Sizes run: node apps/ide/scripts/benchSizes.mjs --label=electron --out=apps/ide/bench-sizes-electron-${{ runner.os }}.json - # Same build, run from the workspace (the packaged app adds nothing the bench measures). - # Both shells run in a session bus of their own, as on a desktop: the runner's systemd - # user bus activates portals that cannot reach the virtual display, and GTK (Tauri) - # waits 25 s + 2 x 5 s on them at start-up (measured, #480); Electron is unaffected. - - name: Bench (Linux, virtual display) - if: runner.os == 'Linux' - run: xvfb-run -a -s "-screen 0 1920x1080x24" dbus-run-session -- node apps/ide/scripts/bench.mjs --runs=6 --idle-seconds=20 --out=apps/ide/bench-electron-${{ runner.os }}.json - - - name: Bench - if: runner.os != 'Linux' - run: node apps/ide/scripts/bench.mjs --runs=6 --idle-seconds=20 --out=apps/ide/bench-electron-${{ runner.os }}.json - - name: Summary if: always() shell: bash run: | { - echo "### Electron on ${{ runner.os }}" + echo "### Electron baseline (${BASELINE_SHA:0:8}) installer sizes on ${{ runner.os }}" echo '```json' - node -e "const r=require('./apps/ide/bench-electron-${{ runner.os }}.json');console.log(JSON.stringify({first:r.first,median:r.median},null,2))" || true cat apps/ide/bench-sizes-electron-${{ runner.os }}.json || true echo '```' } >> "$GITHUB_STEP_SUMMARY" @@ -108,10 +110,12 @@ jobs: if-no-files-found: warn path: apps/ide/bench-*.json - # The same bench on the Tauri build (epic #477). Until R12 bundles a Node runtime, the - # sidecar runs on the runner's Node (CODEXR_NODE); sizes come with the Tauri bundler (R12). - tauri: - name: tauri (${{ matrix.os }}) + # The Electron baseline against the Tauri build of this commit on the same runner, + # interleaved round by round (scripts/benchCompare.mjs): runner noise lands on both. + # The baseline is checked out and built outside the working tree, so the opened folder + # (the repository) is the same for both. + compare: + name: compare (${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -119,11 +123,16 @@ jobs: os: [windows-latest, ubuntu-latest, macos-latest] env: CARGO_TERM_COLOR: never - ELECTRON_SKIP_BINARY_DOWNLOAD: '1' steps: - name: Checkout uses: actions/checkout@v4 + - name: Checkout the baseline + uses: actions/checkout@v4 + with: + ref: ${{ env.BASELINE_SHA }} + path: baseline-checkout + - name: Setup Node uses: actions/setup-node@v4 with: @@ -133,54 +142,56 @@ jobs: - name: Install run: npm ci + # Its own npm ci (Electron's binary included) and its own IDE build (out/main, out/preload...). + - name: Build the baseline + shell: bash + run: | + mv baseline-checkout "$RUNNER_TEMP/baseline" + cd "$RUNNER_TEMP/baseline" + npm ci + # npm 11 may skip dependency install scripts; fetch Electron's binary explicitly. + test -f node_modules/electron/path.txt || node node_modules/electron/install.js + npm run ide:build + - name: Tauri system libraries (Linux) if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev - # As for the Electron job: Ubuntu 24.04 restricts unprivileged user namespaces, which - # WebKitGTK's bubblewrap sandbox needs too (desktop Ubuntu ships an AppArmor profile for it). - # Without this the first page load stalls ~35 s on the runner. - - name: Allow the web sandbox (Linux) + # Ubuntu 24.04 restricts unprivileged user namespaces, which Chromium's sandbox (the + # baseline) and WebKitGTK's bubblewrap sandbox need (desktop Ubuntu ships AppArmor + # profiles for both). + - name: Allow the web sandboxes (Linux) if: runner.os == 'Linux' run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 - name: Rust toolchain run: rustup toolchain install stable --profile minimal && rustup default stable - - name: Build (web, sidecar, bridge, Rust core) - run: npm run tauri:build --workspace=code-xr-ide + - name: Build (bundles, sidecar, bridges, Rust core) + run: npm run build --workspace=code-xr-ide - - name: Bench (Linux, virtual display) + # Both run in a session bus of their own, as on a desktop: the runner's systemd user + # bus activates portals that cannot reach the virtual display, and GTK (Tauri) waits + # 25 s + 2 x 5 s on them at start-up (measured, #480); the baseline is unaffected. + - name: Compare (Linux, virtual display) if: runner.os == 'Linux' shell: bash - run: CODEXR_NODE="$(node -p process.execPath)" xvfb-run -a -s "-screen 0 1920x1080x24" dbus-run-session -- node apps/ide/scripts/bench.mjs --label=tauri --runs=6 --idle-seconds=20 --out=apps/ide/bench-tauri-${{ runner.os }}.json -- apps/ide/src-tauri/target/release/codexr-ide + run: CODEXR_NODE="$(node -p process.execPath)" xvfb-run -a -s "-screen 0 1920x1080x24" dbus-run-session -- node apps/ide/scripts/benchCompare.mjs --baseline="$RUNNER_TEMP/baseline" --baseline-ref="$BASELINE_SHA" --rounds=4 --runs=3 --trace-tauri --out=apps/ide/bench-compare-${{ runner.os }}.json --summary="$GITHUB_STEP_SUMMARY" -- apps/ide/src-tauri/target/release/codexr-ide - - name: Bench + - name: Compare if: runner.os != 'Linux' shell: bash run: | exe=apps/ide/src-tauri/target/release/codexr-ide if [ "$RUNNER_OS" = "Windows" ]; then exe="$exe.exe"; fi - CODEXR_NODE="$(node -p process.execPath)" node apps/ide/scripts/bench.mjs --label=tauri --runs=6 --idle-seconds=20 --out=apps/ide/bench-tauri-${{ runner.os }}.json -- "$exe" - - - name: Summary - if: always() - shell: bash - run: | - { - echo "### Tauri on ${{ runner.os }}" - echo '```json' - node -e "const r=require('./apps/ide/bench-tauri-${{ runner.os }}.json');console.log(JSON.stringify({first:r.first,median:r.median},null,2))" || true - echo '```' - } >> "$GITHUB_STEP_SUMMARY" - node -e "const r=require('./apps/ide/bench-tauri-${{ runner.os }}.json');console.log(JSON.stringify({first:r.first,median:r.median,byProcess:r.results.at(-1).byProcess},null,2))" || true + CODEXR_NODE="$(node -p process.execPath)" node apps/ide/scripts/benchCompare.mjs --baseline="$RUNNER_TEMP/baseline" --baseline-ref="$BASELINE_SHA" --rounds=4 --runs=3 --trace-tauri --out=apps/ide/bench-compare-${{ runner.os }}.json --summary="$GITHUB_STEP_SUMMARY" -- "$exe" - name: Keep the numbers if: always() uses: actions/upload-artifact@v4 with: - name: ide-bench-tauri-${{ runner.os }} + name: ide-bench-compare-${{ runner.os }} if-no-files-found: warn path: apps/ide/bench-*.json diff --git a/.github/workflows/ide-release.yml b/.github/workflows/ide-release.yml index 1443144cf..b8aec2e10 100644 --- a/.github/workflows/ide-release.yml +++ b/.github/workflows/ide-release.yml @@ -1,10 +1,15 @@ name: IDE installers -# Builds the Code-XR IDE installers (#20) on the three operating systems: +# Builds the Code-XR IDE installers (#20, R12 #490) on the three operating systems: # Linux AppImage and .deb -# Windows NSIS installer (.exe) +# Windows NSIS installer (.exe), with the WebView2 bootstrapper # macOS .dmg (Apple silicon; the runner's architecture) # +# The Tauri bundler (apps/ide/scripts/tauriBundle.mjs) puts the Rust core, the IDE, the +# pinned Node runtime and the Code-XR resources inside; each installer is installed into a +# scratch folder and smoke-tested there without CODEXR_NODE, and its sizes are measured +# (scripts/benchSizes.mjs). +# # A tag `ide-vX.Y.Z` (matching apps/ide/package.json's version) builds them # and attaches them to a DRAFT GitHub release, which the maintainer reviews # and publishes by hand: nothing reaches users from here on its own. A pull @@ -27,8 +32,11 @@ on: - ide paths: - '.github/workflows/ide-release.yml' - - 'apps/ide/electron-builder.config.cjs' + - '.github/actions/ide-tauri-installers/**' - 'apps/ide/package.json' + - 'apps/ide/src-tauri/tauri.conf.json' + - 'apps/ide/scripts/tauriBundle.mjs' + - 'apps/ide/scripts/bundledNode.mjs' workflow_dispatch: permissions: @@ -44,19 +52,18 @@ env: npm_config_fund: 'false' npm_config_update_notifier: 'false' PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' - # electron-builder downloads the Electron release it packages itself. - ELECTRON_SKIP_BINARY_DOWNLOAD: '1' - # No signing identity is looked up on macOS (mac.identity in the config). - CSC_IDENTITY_AUTO_DISCOVERY: 'false' jobs: installers: name: installers (${{ matrix.os }}) runs-on: ${{ matrix.os }} + timeout-minutes: 75 strategy: fail-fast: false matrix: os: [windows-latest, ubuntu-latest, macos-latest] + env: + CARGO_TERM_COLOR: never steps: - name: Checkout uses: actions/checkout@v4 @@ -80,10 +87,9 @@ jobs: exit 1 fi - # Builds the extension's Python backend copy (dist/code_analysis), the - # IDE (out/), then the installers into apps/ide/release/. - - name: Build the installers - run: npm run dist --workspace=code-xr-ide + # Build, install into a scratch folder, smoke the installed IDE, measure. + - name: Installers + uses: ./.github/actions/ide-tauri-installers - name: Keep the installers uses: actions/upload-artifact@v4 @@ -96,9 +102,15 @@ jobs: apps/ide/release/*.exe apps/ide/release/*.dmg + - name: Keep the sizes + uses: actions/upload-artifact@v4 + with: + name: sizes-${{ runner.os }} + path: apps/ide/release-sizes-*.json + draft-release: name: draft release - needs: installers + needs: [installers] if: startsWith(github.ref, 'refs/tags/ide-v') runs-on: ubuntu-latest permissions: @@ -108,6 +120,7 @@ jobs: uses: actions/download-artifact@v4 with: path: installers + pattern: code-xr-ide-* merge-multiple: true - name: Create the draft release diff --git a/.github/workflows/ide-tauri-spike.yml b/.github/workflows/ide-tauri-spike.yml index 9aecf85d2..96377684c 100644 --- a/.github/workflows/ide-tauri-spike.yml +++ b/.github/workflows/ide-tauri-spike.yml @@ -1,6 +1,6 @@ name: IDE Tauri spike -# Story R1 of the Electron to Tauri 2 migration (docs/ide/tauri-migration.md): +# Story R1 of the move to Tauri 2 (docs/ide/tauri-migration.md): # can the IDE's web stack (Monaco and its workers, xterm, pdf.js, A-Frame scenes # over WebGL) run in each OS webview? apps/ide/spike/tauri-engines builds a tiny # Tauri 2 app that runs the probes and prints one result line; run.mjs builds it, @@ -29,7 +29,6 @@ env: npm_config_fund: 'false' npm_config_update_notifier: 'false' PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' - ELECTRON_SKIP_BINARY_DOWNLOAD: '1' CARGO_TERM_COLOR: never jobs: diff --git a/.github/workflows/ide-tauri.yml b/.github/workflows/ide-tauri.yml new file mode 100644 index 000000000..d1f2b19d5 --- /dev/null +++ b/.github/workflows/ide-tauri.yml @@ -0,0 +1,222 @@ +name: IDE on Tauri + +# The Code-XR IDE (Tauri 2 + a Node sidecar, docs/ide/tauri-migration.md sections 14-16) +# built and tested on the three operating systems on every pull request and every push to +# the IDE branches: +# +# - the legacy-shell gate (apps/ide/scripts/legacyShellGate.mjs, R13 #491); +# - the Rust core: cargo clippy -D warnings and cargo test (release profile, as built); +# - the IDE's unit tests (Node's runner, as in ci.yml's gate); +# - the smoke run (apps/ide/scripts/smoke.mjs): the probes run inside the real page through +# the core (no WebDriver, which macOS lacks), plus the native menu, the message box path +# and the profile migration's "no trace in a smoke run"; +# - the Code-XR extension installed from its .vsix into the IDE (vsixE2e.mjs), and the +# compatibility probe on the built extension host as the sidecar runs it +# (extensionCompat.mjs --built). +# +# The VS Code plugin is only packaged here, never changed. The `tauri` job runs the build +# from the source tree, on the runner's Node (CODEXR_NODE). +# +# On pushes (not pull requests, to keep them fast) the `installers` job also builds the +# installers (R12 #490: AppImage + .deb, NSIS, .dmg), installs each into a scratch folder +# and runs the smoke run against the installed binary WITHOUT CODEXR_NODE, so on the Node +# runtime and resources the installer ships; the installers and their sizes are kept as +# artifacts (.github/actions/ide-tauri-installers, shared with ide-release.yml). + +on: + workflow_dispatch: + pull_request: + branches: + - master + - 'v[0-9]*' + - ide + paths: + - '.github/workflows/ide-tauri.yml' + - '.github/actions/ide-tauri-installers/**' + - 'apps/ide/**' + - 'apps/vscode-extension/src/core/**' + - 'package.json' + - 'package-lock.json' + - '.nvmrc' + push: + branches: + - ide + - 'claude/**' + paths: + - '.github/workflows/ide-tauri.yml' + - '.github/actions/ide-tauri-installers/**' + - 'apps/ide/**' + - 'apps/vscode-extension/src/core/**' + - 'package.json' + - 'package-lock.json' + - '.nvmrc' + +permissions: + contents: read + +concurrency: + group: ide-tauri-${{ github.ref }} + cancel-in-progress: true + +env: + DO_NOT_TRACK: '1' + npm_config_audit: 'false' + npm_config_fund: 'false' + npm_config_update_notifier: 'false' + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' + CARGO_TERM_COLOR: never + +jobs: + tauri: + name: tauri (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + + - name: Install + run: npm ci + + - name: Legacy-shell gate (R13 #491) + run: node apps/ide/scripts/legacyShellGate.mjs + + - name: Tauri system libraries (Linux) + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libxdo-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev + + # Ubuntu 24.04 restricts unprivileged user namespaces, which WebKitGTK's bubblewrap + # sandbox needs (desktop Ubuntu ships an AppArmor profile for it). + - name: Allow the web sandbox (Linux) + if: runner.os == 'Linux' + run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 + + - name: Rust toolchain + run: rustup toolchain install stable --profile minimal --component clippy && rustup default stable + + - name: Cargo registry cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index + ~/.cargo/registry/cache + ~/.cargo/git/db + key: cargo-registry-${{ runner.os }}-${{ hashFiles('apps/ide/src-tauri/Cargo.lock') }} + restore-keys: cargo-registry-${{ runner.os }}- + + - name: Build (web, sidecar, bridges, Rust core) + run: npm run build --workspace=code-xr-ide + + - name: cargo clippy (-D warnings) + working-directory: apps/ide/src-tauri + run: cargo clippy --release --locked --all-targets -- -D warnings + + - name: cargo test + working-directory: apps/ide/src-tauri + run: cargo test --release --locked + + - name: Unit tests + run: npm run test:unit --workspace=code-xr-ide + + # A session bus of its own, as on a desktop: the runner's systemd user bus activates + # portals that cannot reach the virtual display, and GTK waits 25 s + 2 x 5 s on them + # at start-up (#480). No GPU render node on the runner: WebKitGTK's DMA-BUF renderer off + # (the core decides the same on its own; set here so the run does not depend on it). + - name: Smoke (Linux, virtual display) + if: runner.os == 'Linux' + shell: bash + env: + WEBKIT_DISABLE_DMABUF_RENDERER: '1' + run: CODEXR_NODE="$(node -p process.execPath)" xvfb-run -a -s "-screen 0 1920x1080x24" dbus-run-session -- node apps/ide/scripts/smoke.mjs + + - name: Smoke + if: runner.os != 'Linux' + shell: bash + run: CODEXR_NODE="$(node -p process.execPath)" node apps/ide/scripts/smoke.mjs + + # #498: the same probes with a keyring that never answers (the core holds every keyring + # call, CODEXR_SMOKE_KEYRING=hang): the folder, Search, Quick Open, the tab session and + # terminal links must not wait for the Secret Service, the Keychain or the Credential Manager. + - name: Smoke, keyring that never answers (Linux, virtual display) + if: runner.os == 'Linux' + shell: bash + env: + WEBKIT_DISABLE_DMABUF_RENDERER: '1' + run: CODEXR_NODE="$(node -p process.execPath)" xvfb-run -a -s "-screen 0 1920x1080x24" dbus-run-session -- node apps/ide/scripts/smoke.mjs --hung-keyring + + - name: Smoke, keyring that never answers + if: runner.os != 'Linux' + shell: bash + run: CODEXR_NODE="$(node -p process.execPath)" node apps/ide/scripts/smoke.mjs --hung-keyring + + # The VS Code plugin as users install it; packaged only, its sources are untouched. + - name: Package the Code-XR extension + run: npm run package:vsix + + - name: Code-XR extension in the IDE (Linux, virtual display) + if: runner.os == 'Linux' + shell: bash + env: + WEBKIT_DISABLE_DMABUF_RENDERER: '1' + run: CODEXR_NODE="$(node -p process.execPath)" xvfb-run -a -s "-screen 0 1920x1080x24" dbus-run-session -- node apps/ide/scripts/vsixE2e.mjs "$(ls apps/vscode-extension/artifacts/*.vsix | head -n 1)" + + - name: Code-XR extension in the IDE + if: runner.os != 'Linux' + shell: bash + run: CODEXR_NODE="$(node -p process.execPath)" node apps/ide/scripts/vsixE2e.mjs "$(ls apps/vscode-extension/artifacts/*.vsix | head -n 1)" + + # The extension host bundle the sidecar starts, on the sidecar's Node. + - name: Compatibility probe on the built extension host + shell: bash + run: CODEXR_NODE="$(node -p process.execPath)" node --experimental-strip-types --no-warnings apps/ide/scripts/extensionCompat.mjs --built "$(ls apps/vscode-extension/artifacts/*.vsix | head -n 1)" + + installers: + name: installers (${{ matrix.os }}) + if: github.event_name != 'pull_request' + runs-on: ${{ matrix.os }} + timeout-minutes: 75 + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + + - name: Install + run: npm ci + + # Build, install into a scratch folder, smoke the installed IDE, measure. + - name: Installers + uses: ./.github/actions/ide-tauri-installers + + - name: Keep the installers + uses: actions/upload-artifact@v4 + with: + name: code-xr-ide-${{ runner.os }} + retention-days: 7 + if-no-files-found: error + path: | + apps/ide/release/*.AppImage + apps/ide/release/*.deb + apps/ide/release/*.exe + apps/ide/release/*.dmg + apps/ide/release-sizes-*.json diff --git a/CLAUDE.md b/CLAUDE.md index 4fdb9b236..842e5fcf8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -15,7 +15,7 @@ Since 2026-11-25 this is an **npm-workspaces monorepo** (details: `docs/monorepo | `apps/vscode-extension/` | The extension (workspace `code-xr`): `src/`, `test/`, `templates/`, `examples/`, `resources/`, `scripts/`, `docs/` (not shipped since 1.2.1), `package.json`, README/CHANGELOG | | `backend/src/`, `backend/tests/` | The Python backend (was `src/code_analysis/python/`) and its suites (was `test/python/`), with their fixtures (`backend/tests/fixtures/`) | | `backend/manual_test/`, `backend/scripts/` | The per-language analysis corpus for `npm run test:analysis` (was `manual_test/`) and the backend's tools (the `test:python` / `test:analysis` / `lint:python` runners, `report-manual-metrics.py`) | -| `apps/ide/` | Code-XR IDE (Electron + Monaco), workspace `code-xr-ide`, epic #11 — read `apps/ide/README.md` before touching it (process split, security baseline, IPC contract) | +| `apps/ide/` | Code-XR IDE (Tauri 2 + a Node sidecar + Monaco; Rust core in `apps/ide/src-tauri`), workspace `code-xr-ide`, epic #11 — read `apps/ide/README.md` before touching it (process split, security baseline, IPC contract) | | `packages/` | Planned shared workspaces (`core`, `xr-scenes`) — empty, see `packages/README.md` | | root | `package.json` (workspaces + mirrored scripts), the only `package-lock.json`, `media/`, `pages/`, `.github/`, `.claude/`, `.vscode/`, `docs/` | @@ -43,8 +43,8 @@ Since 2026-11-25 this is an **npm-workspaces monorepo** (details: `docs/monorepo |---|---| | `npm run compile` / `npm run watch` | webpack build → `dist/` (also copies the Python backend; `templates/` and `examples/` ship from the package root, not from `dist/`) | | `npm run typecheck` / `npm run lint` | tsc --noEmit / ESLint over `src/`, `test/`, `scripts/`, the standalone `templates/` runtimes and the config files | -| `npm test` | **Default gate**: typecheck + lint + compile-tests + unit tests of the extension, then typecheck + lint + unit tests of the IDE | -| `npm run ide:dev` / `ide:smoke` | IDE with hot reload / build the IDE and launch it hidden to check the security baseline from inside the real window | +| `npm test` | **Default gate**: typecheck + lint + compile-tests + unit tests of the extension, then the legacy-shell gate + typecheck + lint + unit tests of the IDE | +| `npm run ide:dev` / `ide:smoke` | IDE rebuilt and restarted on every change / build the IDE (bundles + Rust core, needs the Rust toolchain) and launch it hidden to check the security baseline from inside the real window | | `npm run test:unit` | Node native runner over `test/**/*.test.cjs` (not Mocha) | | `npm run test:python` (= `test:backend`) / `test:analysis` / `test:all` | Python suites in `backend/tests` / per-language end-to-end metrics / everything | | `npm run lint:python` | `ruff check` over `backend/` (config `backend/ruff.toml`, ruff pinned in `backend/requirements-dev.txt`); lint only, never a formatter | diff --git a/README.md b/README.md index 20476c498..14d5b2ba6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Code-XR analyzes source code and lets you walk through it in extended reality: code metrics, the dependency graph, Git history and collaborative sessions, all local, VR optional. -This repository is an **npm-workspaces monorepo**. It holds the published VS Code extension, the Python analysis backend it runs, and the standalone Code-XR IDE (Electron + Monaco), under construction. +This repository is an **npm-workspaces monorepo**. It holds the published VS Code extension, the Python analysis backend it runs, and the standalone Code-XR IDE (Tauri 2 + a Node sidecar + Monaco), under construction. > Looking for the extension itself, its features and how to install it? Read **[apps/vscode-extension/README.md](apps/vscode-extension/README.md)**. That file is also the Marketplace page. @@ -11,7 +11,7 @@ This repository is an **npm-workspaces monorepo**. It holds the published VS Cod | Path | What lives there | Status | |---|---|---| | [`apps/vscode-extension/`](apps/vscode-extension/) | The VS Code extension (`aMonteSl.code-xr`): TypeScript sources, XR scene templates and browser runtimes, examples, resources, user docs, tests and packaging scripts. | Active, published | -| [`apps/ide/`](apps/ide/) | The standalone Code-XR IDE (Electron + Monaco): secure Electron shell, workbench layout, dev/build/smoke scripts. See [`apps/ide/README.md`](apps/ide/README.md). | In development (epic #11) | +| [`apps/ide/`](apps/ide/) | The standalone Code-XR IDE (Tauri 2 + a Node sidecar + Monaco): Rust core, workbench layout, dev/build/smoke scripts, installers. See [`apps/ide/README.md`](apps/ide/README.md). | In development (epic #11) | | [`backend/`](backend/) | The Python analysis backend (its own code-metrics analyzer, dependency engine, XR/LivePanel/DOM data producers) and its unit tests. Shipped inside the extension at `dist/code_analysis/python`. | Active | | [`packages/`](packages/) | Code shared between the apps. Empty today: see [`packages/README.md`](packages/README.md) for what moves here and when. | Planned | | [`docs/`](docs/) | Repository-level documentation (monorepo layout, cross-platform notes). Extension user docs stay in `apps/vscode-extension/docs/`, next to the README that links them. | Active | diff --git a/apps/ide/.gitignore b/apps/ide/.gitignore new file mode 100644 index 000000000..ff7e297b0 --- /dev/null +++ b/apps/ide/.gitignore @@ -0,0 +1,10 @@ +# Already ignored by the repository's .gitignore files. Repeated here because the +# IDE reads only the opened folder's root .gitignore (search, quick open): the smoke +# runs open apps/ide, and without these lines its Search probe walks the Rust build +# (src-tauri/target, gigabytes after cargo test and clippy) and times out (#489). +/node_modules/ +/out/ +/release/ +/src-tauri/target/ +/src-tauri/gen/ +/release-tauri/ diff --git a/apps/ide/README.md b/apps/ide/README.md index a1774a832..c8d4fa76e 100644 --- a/apps/ide/README.md +++ b/apps/ide/README.md @@ -1,6 +1,6 @@ # Code-XR IDE -The standalone Code-XR IDE: a desktop environment built on **Electron + Monaco** where editing code, analysing it and exploring it in XR are one workflow. The platform decision is ADR 0001 ([`adr/0001-code-xr-ide-platform.md`](../../adr/0001-code-xr-ide-platform.md)); the work is tracked in epic #11. +The standalone Code-XR IDE: a desktop environment built on **Tauri 2 + a Node sidecar + Monaco** where editing code, analysing it and exploring it in XR are one workflow. The platform decision is ADR 0001 ([`adr/0001-code-xr-ide-platform.md`](../../adr/0001-code-xr-ide-platform.md)), the move to Tauri is epic #477 ([`docs/ide/tauri-migration.md`](../../docs/ide/tauri-migration.md)); the work is tracked in epic #11. **Status:** stories #12 (secure scaffold) and #14 (open a project, edit with Monaco) are done, pending a manual try; story #15 (the Python environment) is in progress; story #138 (file and language icons) is done, pending a manual try; story #137 (the integrated terminal) is done on Linux and pending a manual try on Windows and macOS. A folder opens from File > Open Folder… (Ctrl/Cmd+O), the explorer's button or `--folder=` on the command line; without `--folder` the IDE reopens the folder worked on last (#151, the head of the recent list; one that is gone leaves the list and the IDE starts empty; never in the smoke run), and the explorer shows it as a lazily loaded tree (`.git` and `node_modules` hidden, root `.gitignore` matches dimmed). Every entry of the explorer and every tab shows the icon of its language or type, VS Code style: by file name first (`package.json`, `Dockerfile`, `.gitignore`), then by extension, with open and closed folder icons and special ones for `src`, `test`, `.github`, `node_modules` and other common folders (#138; every language of the metric contract has one, anything else gets a generic icon). Files open in Monaco tabs (loaded on the first open, in its own chunk) with syntax highlighting, a dirty mark, File > Save (Ctrl/Cmd+S), Save All (Ctrl/Cmd+Alt+S) and Close Editor (Ctrl/Cmd+W); the explorer and the open files follow the disk (one non-recursive watcher per expanded folder and per open file's folder): a clean tab reloads, an unsaved one keeps your text and is marked as changed or deleted on disk, and saving over a newer file asks first. Closing the window with unsaved tabs asks Save All / Don't Save / Cancel. The explorer creates files and folders (its toolbar, File > New File… Ctrl/Cmd+N, File > New Folder…), renames with F2 and moves to the OS trash with Delete (never a permanent delete); names that Windows would refuse are refused on every OS so a project stays portable. File > Open Recent and the empty explorer list the last 10 folders (kept in the user-data folder); the renderer can only reopen a folder from that list, never an arbitrary path. The Code-XR view (its activity item; Python environment section) and the status bar show the Python environment the analyses run in (#15): whether a Python was found, a set-up that asks in a native dialog listing every package and its source before anything is downloaded (the language parsers for the dependency graph included, so an analysis never downloads anything), progress, repair and removal. From the same view, **Analyse project in XR (deep)** runs the extension's directory XR analysis over the open folder (#16, first part) and shows its scene in a column beside the code, and runs on its own when a folder opens unless turned off (#139); the scene's header shows what ran, on what and at which local address, and shares it through a Cloudflare tunnel on request (#155); the scene follows the saves (the core re-runs the analysis on save and the header's file count follows), and a dependency-graph node or a LivePanel row opens its file in the editor (**Open in editor**, #16 second part). **Analyse Project (LivePanel Deep)** shows the same folder as the extension's 2D LivePanel, and every other analysis of the extension (a file, a folder, the project, Visualize DOM; #16 third part, #398) runs from the **Code-XR: Analysis** submenu of the explorer, the tab and the editor, or the palette's **Code-XR: Analyse ...** commands; every one runs the extension's own launch through `AnalysisOrchestrator` and opens in the same column, its header naming the kind (`LivePanel · project, deep`, `XR · file`). View > Terminal (Ctrl+\`) opens a terminal panel under the editor (#137): xterm.js tabs running the default shell in the open folder, with New Terminal (Ctrl+Shift+\`), rename (double-click or F2), kill, a resizable panel, and a profiles menu to start any detected shell, change the default and add a custom one; see [Terminal](#terminal-137). The Source Control view (#17, the Git half) lists the changed files, stages, unstages, discards, shows HEAD against the working tree and commits, with the branch in the status bar; see [Source Control](#source-control-17). @@ -10,32 +10,31 @@ Run them from the repository root after `npm ci`: | Command | What it does | |---|---| -| `npm run ide:dev` | Vite dev server with hot reload for the renderer; main and preload are rebuilt and Electron restarted on every change. | -| `npm run ide:build` | Production build into `apps/ide/out/`. | -| `npm run ide:start` | Build, then run the built IDE (no dev server). | -| `npm run ide:smoke` | Build, launch the IDE hidden with `--codexr-smoke`, probe the security baseline from inside the real renderer, open a terminal with the default profile and read back the output of `echo codexr-smoke`, exit 0 or 1. On Linux without a display use `xvfb-run -a npm run ide:smoke`. | -| `npm run ide:test` | Typecheck (Node and web targets separately), lint with zero warnings, unit tests. Part of the root `npm test`. | -| `npm run tauri:start --workspace=code-xr-ide -- --folder=` | The Tauri 2 build (epic #477, walking skeleton): web build, Node sidecar and bridge into `out/`, `cargo build --release` in `src-tauri/`, then run it (arguments after `--` go to the app). `tauri:build` only builds, `tauri:run` runs the last build. Needs Rust and Tauri's system libraries; the sidecar runs on `CODEXR_NODE` (default: the Node running the script). See [`docs/ide/tauri-migration.md`](../../docs/ide/tauri-migration.md#walking-skeleton). | -| `npm run dist --workspace=code-xr-ide` | Build the installers for the OS it runs on into `apps/ide/release/` (#20): AppImage and `.deb` on Linux, an NSIS `.exe` on Windows, a `.dmg` on macOS. See [Installers](#installers-20). | +| `npm run ide:dev` | Builds the IDE (bundles, sidecar, bridges, Rust core), runs it, then rebuilds the bundles on every change and restarts the app (arguments after `--` go to the app). | +| `npm run ide:build` | Build: the web and Node bundles into `apps/ide/out/`, then `cargo build --release` in `src-tauri/`. Needs Rust and Tauri's system libraries. | +| `npm run ide:start` | Build, then run the built IDE (arguments after `--` go to the app, e.g. `-- --folder=`); `npm run start:last --workspace=code-xr-ide` runs the last build. The sidecar runs on `CODEXR_NODE` (default: the Node running the script). | +| `npm run ide:smoke` | Build, launch the IDE hidden with `--codexr-smoke` and run the probes inside the real page through the Rust core (#489): the security baseline, a terminal with the default profile reading back `echo codexr-smoke`, the native menu, the message box path and the profile migration's "no trace"; exit 0 or 1. `node scripts/smoke.mjs` reruns it on the last build, `--installed ` on an installed IDE. On Linux without a display: `xvfb-run -a dbus-run-session -- npm run ide:smoke`. `scripts/vsixE2e.mjs ` and `npm run compat:built -- ` are the extension checks. See [`docs/ide/tauri-migration.md`](../../docs/ide/tauri-migration.md), section 14. | +| `npm run ide:test` | The legacy-shell gate (`scripts/legacyShellGate.mjs`, R13 #491), typecheck (Node and web targets separately), lint with zero warnings, unit tests. Part of the root `npm test`. | +| `npm run tauri:bundle --workspace=code-xr-ide` | Build the installers for the OS it runs on into `apps/ide/release/` (#20, R12 #490): AppImage and `.deb` on Linux, an NSIS `.exe` on Windows, a `.dmg` on macOS, with the Node runtime and the Code-XR resources inside. See [Installers](#installers-20-r12-490). | ## Layout ``` apps/ide/ ├── src/ -│ ├── main/ Electron main process (Node): window, menu, IPC handlers, app protocol, hardening; -│ │ boot.ts is the boot sequence both shells share, host/desktop.ts the desktop seam -│ ├── preload/ the only bridge to the renderer: exposes window.codexr (built by codexrApi.ts) -│ ├── bridge/ the Tauri build's window.codexr (the same object over Tauri's invoke) -│ ├── sidecar/ the Tauri build's Node sidecar: main's services, desktop answered by the Rust core -│ ├── renderer/ the workbench UI (browser code, no Node, no Electron) +│ ├── main/ the main-process services (Node): menu, IPC handlers, analysis, terminals, agents...; +│ │ boot.ts is the boot sequence, host/desktop.ts the desktop seam (re-exports sidecar/tauriHost.ts) +│ ├── sidecar/ the Node sidecar the Rust core starts: runs main's services, desktop answered by the core +│ ├── bridge/ the only bridge to the renderer: window.codexr (built by codexrApi.ts) over Tauri's invoke +│ ├── sceneBridge/ the scene view's bridge (CodeXRHostBridge.openInEditor) +│ ├── renderer/ the workbench UI (browser code, no Node) │ │ └── public/file-icons/ bundled SVG icons (#138), published with the renderer │ └── shared/ the renderer <-> main contract (api.ts), imported by all three ├── test/ unit tests (node:test, TypeScript run by Node's type stripping) -├── src-tauri/ the Tauri 2 shell (Rust core) of the walking skeleton (#480-#482) -├── scripts/ build, dev, start and smoke runners (Vite's JS API), syncFileIcons.mjs, tauri.mjs +├── src-tauri/ the Tauri 2 shell (Rust core): windows, webviews, menu, dialogs, workspace and terminal channels +├── scripts/ build, dev and smoke runners (Vite's JS API), tauri.mjs, tauriBundle.mjs + bundledNode.mjs (installers), syncFileIcons.mjs, legacyShellGate.mjs ├── THIRD_PARTY_NOTICES.md licences of bundled third-party material -└── out/ build output, git-ignored: main/index.cjs, preload/index.cjs, renderer/ +└── out/ build output, git-ignored: sidecar/, bridge/, sceneBridge/, renderer/, extensionHost/, codexrMcp/, localAgent/ ``` ### File icons (#138) @@ -46,18 +45,18 @@ They are served from the app like the rest of the renderer, so the CSP did not c ### Using the extension's core (#15) -The analysis engine is the extension's vscode-free core (`apps/vscode-extension/src/core`, #13). The IDE's main process imports it as `@codexr/core/` and Vite bundles those sources into `out/main/index.cjs`. The renderer and the preload may not import it (ESLint), so everything the core does reaches the page through `window.codexr` like any other capability. +The analysis engine is the extension's vscode-free core (`apps/vscode-extension/src/core`, #13). The IDE's main process imports it as `@codexr/core/` and Vite bundles those sources into the sidecar (`out/sidecar/index.cjs`, which sends the window's policy, then loads the services from its `session` chunk in `out/sidecar/assets`, #499). The renderer and the bridges may not import it (ESLint), so everything the core does reaches the page through `window.codexr` like any other capability. -- **The host.** `src/main/core/electronHost.ts` implements the core's `CodeXRHost` (the extension's is `app/host/vscodeHost.ts`): questions a person must answer (`confirm`, consent) are native modal dialogs in the main process, never something the renderer can answer; notifications and progress are forwarded to the views; `globalState` is a JSON file (`core/jsonStore.ts`). `core/coreRuntime.ts` registers it at start-up, with the core's storage in `/core` (a throwaway folder in the smoke run). +- **The host.** `src/main/core/ideHost.ts` implements the core's `CodeXRHost` (the extension's is `app/host/vscodeHost.ts`): questions a person must answer (`confirm`, consent) are native modal dialogs in the main process, never something the renderer can answer; notifications and progress are forwarded to the views; `globalState` is a JSON file (`core/jsonStore.ts`). `core/coreRuntime.ts` registers it at start-up, with the core's storage in `/core` (a throwaway folder in the smoke run). - **Type checking.** The core is written for the extension's compiler options, not this package's stricter ones, so the IDE never type-checks core sources. `scripts/coreTypes.mjs` (first step of `npm run typecheck`) finds every `@codexr/core/...` import under `src/`, emits declarations for them into `.core-types/` (git-ignored) with the extension's own settings and **without `vscode` types**, and `tsconfig.node.json` maps the alias there. A core module that still reached `vscode` would fail that step. -- **Tests.** Unit tests cover the IDE's side (`pythonStatus.ts`, `jsonStore.ts`); modules that import the core run in the built app (the smoke run, Playwright checks), since Node's type stripping cannot load the core's sources. +- **Tests.** Unit tests cover the IDE's side (`pythonStatus.ts`, `jsonStore.ts`); modules that import the core run in the built app (the smoke run), since Node's type stripping cannot load the core's sources. The move of the core into `packages/core` (step 10 of the plan in `docs/ide/vscode-api-inventory.md`) would replace the alias with a workspace dependency and change nothing else here. Technology choices for the scaffold: -- **TypeScript everywhere, strict.** Two type-check targets: `tsconfig.node.json` (main, preload, shared, tests; Node types, no DOM) and `tsconfig.web.json` (renderer, shared; DOM, no Node types), so a Node API used in the renderer fails the type check. -- **Vite** builds all three targets: main and preload as self-contained CommonJS bundles (a sandboxed preload cannot load local files), the renderer as a normal web build. +- **TypeScript everywhere, strict.** Two type-check targets: `tsconfig.node.json` (main, sidecar, shared, tests; Node types, no DOM) and `tsconfig.web.json` (renderer, bridges, shared; DOM, no Node types), so a Node API used in the renderer fails the type check. +- **Vite** builds every target: the sidecar, the extension host, the MCP server and the local agent as self-contained CommonJS bundles, the two bridges as IIFEs the Rust core injects, the renderer as a normal web build. - **No UI framework in the renderer for now.** The workbench is built with plain DOM APIs. Monaco, the XR scene and the LivePanel are themselves framework-free, and VS Code's workbench is too; a framework can still be introduced later for complex panels if it pays for itself. - **Unit tests with `node:test`**, like the extension, running the `.ts` sources directly through Node's type stripping (no compile step). Source files therefore use only erasable TypeScript syntax (`erasableSyntaxOnly`). @@ -65,12 +64,12 @@ Technology choices for the scaffold: `src/main/analysis/analysisService.ts` runs the extension's own pipeline (`AnalysisOrchestrator`) with a `CoreContext` built from the IDE's host; the workspace storage VS Code would give is a folder per project under `/core/workspaces/`. The IDE registers its own `LaunchNotifier`, so a finished launch opens in the window that asked instead of a browser, and its server settings use the core's `lateralPanel` open mode: scenes are served over plain HTTP on loopback (a secure context, so WebXR still works) with no self-signed certificate to accept. -The scene is a `WebContentsView` laid over the slot the renderer reserves (`analysis/sceneView.ts`), never an `