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); 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=<path> 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 Analysis view (second activity item) 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 as LivePanel (deep) shows the same folder as the extension's 2D LivePanel, and a single file is analysed in XR or as a LivePanel from its right-click menu in the explorer, its tab's menu, or the palette's Analyse Active File in XR / as LivePanel (#16 third part); every one runs the extension's own launch through AnalysisOrchestrator and opens in the same column, its header naming the kind (LivePanel · 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. 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.
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 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. |
apps/ide/
├── src/
│ ├── main/ Electron main process (Node): window, menu, IPC handlers, app protocol, hardening
│ ├── preload/ the only bridge to the renderer: exposes window.codexr
│ ├── renderer/ the workbench UI (browser code, no Node, no Electron)
│ │ └── 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)
├── scripts/ build, dev, start and smoke runners (Vite's JS API), syncFileIcons.mjs
├── THIRD_PARTY_NOTICES.md licences of bundled third-party material
└── out/ build output, git-ignored: main/index.cjs, preload/index.cjs, renderer/
The icons are SVGs from Material Icon Theme (MIT, recorded in THIRD_PARTY_NOTICES.md), a devDependency of this package. Only the ones the IDE uses are bundled: src/renderer/fileIcons.ts holds the tables and the pure iconFor(name, kind, expanded?) (whole file name first, then the longest known extension, so a.d.ts beats a.ts), and node scripts/syncFileIcons.mjs (run from apps/ide) copies exactly those SVGs into src/renderer/public/file-icons/; commit the result. test/fileIcons.test.ts fails if the folder and the tables drift, if a copy differs from the package, or if a language of the metric contract (backend/src/utils/metric_language_contract.py) falls back to the generic icon.
They are served from the app like the rest of the renderer, so the CSP did not change (img-src 'self' data:), and the smoke run checks that the icons it shows load. A row's icon is an empty <span> whose class picks the SVG from one stylesheet built from the same tables, with the set's light-theme variants under prefers-color-scheme: light: each SVG is fetched once and a row costs one element, so expanding a 3,000-file folder takes the same time as before (about 280 ms in both builds, Playwright against the built app).
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/<path> 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 host.
src/main/core/electronHost.tsimplements the core'sCodeXRHost(the extension's isapp/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;globalStateis a JSON file (core/jsonStore.ts).core/coreRuntime.tsregisters it at start-up, with the core's storage in<userData>/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 ofnpm run typecheck) finds every@codexr/core/...import undersrc/, emits declarations for them into.core-types/(git-ignored) with the extension's own settings and withoutvscodetypes, andtsconfig.node.jsonmaps the alias there. A core module that still reachedvscodewould 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.
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) andtsconfig.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.
- 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.tssources directly through Node's type stripping (no compile step). Source files therefore use only erasable TypeScript syntax (erasableSyntaxOnly).
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 <userData>/core/workspaces/<hash>. 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 <iframe> in the app's page, so the app's CSP keeps frame-src 'none' and the scene, served over the network, can never reach window.codexr:
- sandboxed, context isolation, its own in-memory session
codexr-scenethat grants no permission; - one preload of its own (
src/scenePreload, not the app's), exposing a single call:CodeXRHostBridge.openInEditor({ path, line? }). The templates use it when present (the dependency graph's Open in editor button on a file or symbol card, a LivePanel row) and behave as before without it, in a browser or in VS Code. The same button works in the VS Code extension and in a scene opened in a browser: without the bridge, a page served on loopback sendsopen-in-editorover the collaboration room, and the shared analysis server (core/server/analysis/editorNavigation.ts) answers it for a peer on this machine only (no tunnel, no LAN) by calling the host'sopenInEditor, which the IDE implements too (openInWindowEditor). The main process accepts the bridge's message only from a scene view's main frame, resolves the path against the analysed folder (analysis/sceneEditorTarget.ts), drops anything outside the window's open folder, and sends the window's renderer the workspace path to open (codexr:analysis:open-in-editor); the contract isshared/sceneBridge.ts; - it may only show, and navigate within, a loopback
http(s)origin with a port (sceneUrl.ts); - nothing leaves the machine: the scene's pinned CDN libraries (A-Frame, BabiaXR...) are answered from
apps/vscode-extension/test/vendor/scene-libraries/(sceneLibraries.ts; a test checks every external script intemplates/has a copy) and every other external request is refused. A-Frame's default text font (cdn.aframe.io/fonts/Roboto-msdf.*) is vendored there too (fonts/), so scene text renders offline. Packaging (#20) must ship the vendored folder.
Dependencies install themselves (#154). Adrián decided that the IDE installs its own analysis dependencies with no question, unlike the VS Code extension (which still asks): at start-up, when the Python environment is missing or incomplete, the IDE creates or repairs it in <userData>/core/python-env/venv with the system Python. It downloads the pinned packages of pythonPackageManifest.ts (lizard, tree-sitter-language-pack...) plus pip, setuptools and wheel from pypi.org, and the dependency graph's language parsers from github.com (tree-sitter-language-pack releases). Then it installs cloudflared (#160), the program behind Share through Cloudflare: the pinned version from github.com/cloudflare/cloudflared, verified with SHA-256, into <userData>/core/remote-access/ (a cloudflared already on PATH is used instead; macOS has no automatic download yet). Nothing is installed system-wide, and every set-up writes this list to the log. Without a Python on the machine, a warning notification says what to install. The smoke run never installs anything.
Notifications (#153). VS Code-style toasts in the window's bottom-right corner (renderer/notifications.ts), moved left of the scene view while it is open (a native view drawn over the page would hide them): the core's messages (host.notifier), one progress notification with a bar for the dependency install, the core's other long tasks (withProgress, on the codexr:progress event), and the analysis while it starts. Info fades after 6 s, warnings and errors stay; a failed install offers Retry. A polite live region announces each one once.
Analyse on open (#139). When a folder opens (at launch with --folder, from File > Open Folder… or Open Recent), the IDE analyses it in XR (deep) without a click, the same analysis as the button. The Analysis view's Analyse in XR when a folder opens checkbox turns it off; the choice is kept in the core's global state (ide.analysis.autoStartOnOpen, xr-deep or off, on by default). Without a ready Python environment it waits for one and never sets it up itself. It never asks first, whatever the project's size (#203): the progress notification counts the files as they are analysed (28/833), and the scene's header then shows how many the analysis took, read from its own data.json (analysis/analysedFiles.ts), so the number always matches the analyser's filters. While the scene is open the IDE watches that data.json (watchAnalysedFileCount, debounced) and the header follows each re-analysis on save (codexr:analysis:scene-files-changed). Reopening the folder a window already shows reuses its running scene; opening another folder closes the old scene and stops its server, so a project left behind is not served on.
Help > About lists the dependencies (#161): Python, the analysis environment, each pinned package, the language parsers (checked with download_parsers.py --check, no network) and cloudflared, each marked [ok], [installing], [missing] or [problem], with Install missing dependencies when the IDE can install one of them.
The scene's header and sharing it through Cloudflare (#155). Above the scene, the header shows the analysis kind (XR · deep), the analysed folder's name (its full path in the tooltip) and the local address (http://localhost:<port>, the server's own URL) with a copy button. Share through Cloudflare starts the core's RemoteAccessManager for that scene's server, exactly as the extension's Active Servers view does: cloudflared is normally installed already at start-up (#160); if it is not, the click downloads it without asking. The tunnel forwards to 127.0.0.1:<port>, not localhost, which Windows resolves to the IPv6 loopback where the server does not listen (#159). While the tunnel starts the button reads Starting tunnel… and is disabled; once shared, the header shows the Cloudflare address under the local one, each with a copy button, and Stop sharing. The Cloudflare copy button copies the invitation link (…trycloudflare.com/join?invite=…), because the core lets a remote guest in only through it and the pairing code the IDE then shows in a native dialog. A failure (cloudflared exited, no link within 30 s) shows its message, with cloudflared's last lines of output, in the header and the button can be pressed again.
- Nothing names a server from the page.
analysis.shareScene(),stopSharingScene()andcopySceneAddress('local' | 'invitation')act on the scene of the calling window, resolved in the main process fromAnalysisService's per-window map; the copy is done there with Electron'sclipboard, from the main process's own state, so the page never sends text to the clipboard and needs no clipboard permission. State changes reach the window through theanalysis:scene-share-changedevent, tagged with the scene's URL; the main process passes on only a status, ahttps://<name>.trycloudflare.comorigin and a bounded error (analysis/sceneShare.ts). - Only on request. The core shares every newly launched server on its own while its cross-network connections setting is on, and that is its default. The IDE turns the setting off at start-up (in its own core storage, not the extension's) and turns it on only for the duration of a click on Share (
startShareOnce), serialised with analysis launches (SerialQueue), so no server is ever launched while it is on and nothing is shared unasked. - No orphan cloudflared. The tunnel stops with Stop sharing, when the scene is closed (its server keeps running, the tunnel does not), when the window opens another folder or closes, when a new analysis replaces the window's scene, and when the app quits (the core's manager is disposed on
will-quit, which stops every tunnel). A tunnel that finishes starting after its scene went is stopped at once.
The renderer only reports the slot's bounds (analysis.setSceneBounds, sanitised in the main process) and may start an analysis kind from a closed list; the main process re-checks that a folder is open and the Python environment is ready, so nothing here can trigger a download.
Commands, the command palette and go to line (#18, epic #163). Every action is a command in one registry (renderer/commands/commandRegistry.ts): an area.action ID, a category and title, an optional key and an enabled check. Registering an ID twice throws, like assertUniqueCommandIds in the extension. The built-in commands live in commands/workbenchCommands.ts; a feature that adds commands (the AI agents, later voice) registers them there and gets the palette and a key for free.
- View > Command Palette… (
Ctrl+Shift+P,Cmd+Shift+Pon macOS, orF1) lists the enabled commands, recently used first, with their keys; typing filters them with a fuzzy match (commands/fuzzy.ts: in-order characters, word starts and runs score higher). Go > Go to Line/Column… (Ctrl+G) opens the same box with:and moves the cursor toline[:column]. The box (commands/quickInput.ts) sits at the top of the window, left of the scene view, and gives the focus back on Escape. - Who listens for a key. Keys shown in the application menu are the menu's accelerators, so they work while the terminal or the scene view has the focus;
MENU_KEYBINDINGSlists them and a unit test checks it againstmain/menu.ts. Other keys (F1,Ctrl+Shift+E) are handled bycommands/keybindingService.ts, a capture-phase listener on the window, so they win over Monaco and xterm. Keys are written as Electron accelerators (CmdOrCtrl+Shift+P) and matched by physical key, so keyboard layouts do not change them.
Quick open (#164). Go > Go to File… (Ctrl+P, Cmd+P on macOS) opens the quick-input box with no prefix: typing searches the workspace's files by fuzzy name (the query typed as is inside a file name first, then letters at word starts, then a match spread over the folders), up to 200 results with their folder and icon; recently opened files are listed first while the field is empty. The main process lists the files (main/workspace/fileIndex.ts, IPC workspace.listFiles) breadth first, up to 50,000, leaving out what the explorer never shows (.git, node_modules) and what the root .gitignore ignores, and without following symbolic links; the list is fetched again each time the box opens, because the watcher only follows expanded folders. > switches to commands, : to a line and @ (or Go to Symbol in Editor…, Ctrl/Cmd+Shift+O) hands over to Monaco's own outline of the file, which has symbols for the languages Monaco has a service for (TypeScript/JavaScript, JSON, CSS, HTML); other languages get them with LSP (#21).
Search across the workspace (#165). The Search view (activity bar, Ctrl+Shift+F / Cmd+Shift+F, which also takes the editor's one-line selection as the query) finds text in every file of the folder: match case, whole word, regular expression (matched per line, so ^/$ are line ends), and comma-separated globs to include or exclude (src, *.ts; a folder name covers everything under it). The main process does the work (main/workspace/textSearch.ts, searchService.ts): the files quick open lists, minus binary files (a NUL in the first 8 KB) and files over 2 MB, 8 read at a time, results streamed to the view every 100 ms as workspace:search-result events tagged with a search id (a new search cancels the window's previous one), and it stops at 20,000 matches and says so. Results are grouped by file with the line around each match; clicking one opens the file with the match selected. Replace (the chevron) previews each change in place; Replace All asks first, then replaces in open editors as one undoable edit each (the tab becomes unsaved, nothing bypasses unsaved text) and writes the other files through the workspace's own readFile/writeFile, so every path is checked and a file that changed in between is reported, not overwritten. A literal search replaces literally; a regular expression expands $1, $&, $<name> and $$ (shared/searchText.ts, shared by both processes).
The editor's status bar (#166). For the active editor the status bar shows Ln 12, Col 5 (with the selection size or the number of cursors), the indentation (Spaces: 4 / Tab Size: 4, Monaco's detection), the encoding, the line endings and the language (editor/editorStatus.ts, texts from editorStatusModel.ts). Clicking the position opens go to line; the indentation, LF/CRLF and the language open a picker in the same quick-input box, also reachable as Editor: Indent Using…, Change End of Line Sequence and Change Language Mode. Changing the line endings is one undoable edit and marks the tab unsaved. Files are read and written as UTF-8; a file that starts with a byte order mark shows UTF-8 with BOM and keeps it when saved (Monaco holds the mark outside the text, so saving used to drop it).
Layout (#169). The side bar, the bottom panel and the scene column resize by dragging the line between them and the editors (a sash; double-click resets it to its default, and a focused sash moves with the arrow keys). Sizes keep their minimums (side bar 170 px, panel 120 px, scene 320 px) and always leave the editors 240 px; the scene is a native view, and the scene panel already reports its slot on every resize, so it follows the sash frame by frame. View > Appearance (also in the palette): Side Bar (Ctrl/Cmd+B; clicking the active activity item does the same), Panel (Ctrl/Cmd+J, the terminal panel), Maximize Panel (also the panel's chevron button), Zen Mode (Ctrl/Cmd+K Z: only the editors and an open scene stay) and Reset Layout. The sizes and whether the side bar is shown are saved in the renderer's storage, which lives in the IDE's user-data folder on every OS, and restored on start (layout/layoutModel.ts, layout/layout.ts); the panel's visibility is not, because its terminals do not survive a restart. Ctrl/Cmd+K Z is a chord, which a menu accelerator cannot express: the workbench's key handler supports two-stroke bindings, lets the first stroke through so Monaco keeps its own Ctrl+K chords, and never starts one from the terminal, where Ctrl+K belongs to the shell.
Editor tabs (#167). A single click in the explorer opens a file in the preview tab (italic), which the next single click replaces; double-clicking the file or the tab, editing it, dragging it or Keep Editor (Ctrl/Cmd+K Enter) keeps it, and Enter in the explorer opens for keeps. Tabs drag to reorder, close with a middle click, cycle with Ctrl+PageDown/Ctrl+PageUp (or Ctrl+Tab/Ctrl+Shift+Tab), move with the arrow keys, Home and End when the strip has the focus, and scroll sideways with the wheel when they overflow. Right-click (or the context-menu key, Shift+F10) opens the tab menu: Close, Close Others, Close to the Right, Close Saved (Ctrl/Cmd+K U), Close All (Ctrl/Cmd+K W), Copy Path, Copy Relative Path (the main process checks the path and writes the clipboard; the renderer has no clipboard permission), Keep Open and Reveal in Explorer. A group close asks once, listing the unsaved tabs it would discard. The open tabs, their order, the preview, the active tab and each tab's view state (cursor, scroll, folding) are a session of the folder, saved in renderer storage under the folder's path and restored when it opens again; a file gone since is skipped (editor/tabsModel.ts, contextMenu.ts).
Split editor (#168). Split Editor Right (Ctrl/Cmd+\, or Split Right in the tab menu) opens the file in a second editor group beside the first; Ctrl/Cmd+1 and Ctrl/Cmd+2 focus a group (the second is created on first use). Both groups share one Monaco model per file, so an edit in either shows in both and the file has a single dirty state; closing a file asks about unsaved changes only when its last tab goes. A tab dragged onto the other group's strip moves there with its view state. The sash between the groups drags (pointer or arrow keys) and resets on double-click; each group keeps at least 120 px, half the editor column's minimum, so the XR scene column keeps its width. The group that has the focus owns the breadcrumbs, the status bar and the commands. A group left without tabs closes. The second group, the split ratio and the focused group are part of the folder's tab session, so a restart restores them; a session saved before the split existed reads as one group (editor/editorGroup.ts, editor/tabsModel.ts). Not implemented: vertical splits and more than two groups.
Markdown preview (#179). Open Preview to the Side (Ctrl/Cmd+K V, or the tab menu of a Markdown file) opens a pane to the right of the editor groups that renders the active Markdown file with GitHub-flavoured Markdown (headings, lists, task lists, tables, code blocks coloured by Monaco's own tokenizer, images). It re-renders as you type, follows the editor's scroll, takes over whichever Markdown file becomes active, and uses the workbench's colours, so it follows the theme. Its sash drags and resets on double-click like the split one. The preview is the only place in the renderer that inserts parsed markup, so it is fenced: DOMPurify sanitises everything (no script, no <style> or style attribute, no forms or frames, document ids prefixed); the window's CSP is unchanged; images of the open folder are read by the main process (workspace.readImage, checked against the folder, PNG/JPEG/GIF/WebP/BMP only, up to 8 MB) and inlined as data: URLs, while a remote image is shown as a link that opens it in the browser, so the preview never goes online; a #heading link scrolls the preview, a relative link opens the file in the IDE, and only http, https and mailto links leave the IDE (workspace.openExternalLink, scheme checked by the main process). Raw HTML that tries an inline event handler still trips the CSP's script-src-attr report while DOMPurify parses it; nothing runs (editor/markdownModel.ts, editor/markdownPreview.ts). Not saved in the session: the preview closes with the window.
Settings (#18, part 2). The Settings view (the gear at the foot of the activity bar, File > Preferences > Settings, Ctrl/Cmd+,) lists every setting with its control, a filter, and two tabs: User (yours, in every folder: settings.json in the IDE's user-data folder) and Folder (the open folder's, in .codexr/settings.json, so it can be committed with the project; Open Folder Settings (JSON) opens it in the editor, and saving it there takes effect). A folder value wins over a user value, which wins over the default; a row marks what its scope sets itself and resets it. The schema (shared/settings.ts) is shared by both processes: the main process (main/settings/settingsService.ts) only stores values it accepts, keeps keys it does not know (a newer IDE's), reads files with comments and trailing commas as VS Code's are, and reports a file it cannot read instead of overwriting it. A change to the user's settings reaches every window. Today's settings cover the editor (font, line height, tab size and indentation detection, word wrap, line numbers, whitespace, minimap, sticky scroll, bracket colours, cursor, smooth scrolling) and the terminal's font size; the analysis and visualisation settings come with the analysis views.
Saving (#170). Four settings shape a save: Format On Save (the language's own formatter: Monaco's for TypeScript, JavaScript, JSON, CSS and HTML today, the language servers' once #21 lands; nothing is downloaded), Trim Trailing Whitespace, Insert Final Newline and Auto Save (off, after a delay, files.autoSaveDelay ms after the last edit, or when the editor loses the focus). The save-time changes are one undoable edit, so the editor shows exactly what was written. A formatter that fails or takes longer than 1.5 s never blocks the save: the file is saved unformatted and the status bar says why. An auto save after a delay leaves the lines holding a cursor alone (no whitespace is trimmed under the person typing) and skips formatting, as VS Code does; no auto save ever asks a question, so a file that changed on disk waits for an explicit save. A project's .editorconfig files (the folder root down to the file's own folder, stopping at root = true) win over the settings per file: indent_style, indent_size, tab_width set the editor's indentation (and the status bar) when the file opens, and end_of_line, charset (utf-8 / utf-8-bom), trim_trailing_whitespace and insert_final_newline apply on save; editing an .editorconfig re-applies it to the open files. Format Document is Shift+Alt+F (editor/editorConfig.ts, editor/saveTransforms.ts, both pure and unit-tested).
Colour theme (#171). Preferences: Color Theme (Ctrl/Cmd+K Ctrl/Cmd+T, or File > Preferences > Color Theme) offers Follow the OS (the default), Dark and Light; moving through the list previews each one, Enter keeps it, Escape goes back. It is a user setting (workbench.colorTheme, also in the Settings view): it applies to every window, so a folder cannot set it, and Follow the OS keeps following live changes. Everything already followed prefers-color-scheme (the workbench tokens, Monaco, the terminals, the file icons, the scene), so the switch is one line in the main process, nativeTheme.themeSource (main/settings/theme.ts), which changes what every page of every window sees; no colour was added.
Keyboard shortcuts (#18, part 3). Keyboard Shortcuts (Ctrl/Cmd+K S, File > Preferences > Keyboard Shortcuts, or the link in Settings) lists every command with its keys and a filter that matches names, IDs and keys (ctrl+s finds Save). Change records a new key: press it (a second key makes a chord), Enter saves, Escape cancels, and the view says which command holds that key now and will lose it. Remove leaves a command without a key; Reset brings back its built-in keys (taking them back from whichever command a rule gave them to). The rules live in keybindings.json in the IDE's user-data folder, in VS Code's shape, and can be edited by hand:
Keys are Electron accelerators, case-insensitive; CmdOrCtrl is Cmd on macOS and Ctrl elsewhere, which is what the recorder writes, so one file serves every OS. An added key is taken from any command that had it, and a later rule wins. The format, its validation and the resolution are one pure module (shared/keybindings.ts) used by both processes: the main process (main/settings/keybindingsService.ts) only writes rules that pass, and the renderer's command registry applies them. Commands the application menu owns keep working from the terminal and the scene: the renderer tells the main process each one's first single-stroke key and the menu is rebuilt with it (a chord cannot be a menu accelerator, so the workbench listens for those). While a key is being recorded the menu's keys are suspended, so pressing Ctrl+S to bind it does not also save. Rules for a command that is not registered yet are kept, so a command added later (an AI agent's) finds its keys waiting. The file is read again when the view opens.
The scene's header has an XR row with three buttons. They act on the window's own scene, never on an address the page sends.
- Enter XR starts an immersive WebXR session on a headset connected to this computer. The IDE first asks the scene's Chromium whether an
immersive-vrsession is supported. If it is, the IDE calls the scene's ownenterVR()as the person's gesture. The XR permission, which the scene view otherwise never grants, is armed for 15 s and for that scene's loopback origin only (main/analysis/sceneXrPolicy.ts). If it is not supported, the row says why and what to do instead. A LivePanel has no XR mode, so the button is hidden there. - Open in browser hands the scene's local address to the system browser.
- On a headset shows the address a standalone headset opens, with its QR code (
@codexr/core/xr/headsetQr, shared with the extension's Open on a headset;qrcode-generator). A headset needs an HTTPS address it can reach, so this is the scene's Cloudflare invitation link (#155). Until the scene is shared, the panel says to press Share through Cloudflare. The headset joins the same collaboration room as the IDE's scene, so the two stay in sync. It is let in with the pairing code the IDE shows.
Support matrix
| Setup | Enter XR in the IDE | What works |
|---|---|---|
| Windows, PC VR headset (SteamVR, Meta Link, WMR) with its OpenXR runtime running | Tried if Electron's Chromium reports immersive-vr; not yet verified on hardware |
Open in browser: Chrome and Edge support WebXR on localhost with an OpenXR runtime |
| macOS | Not supported: no WebXR headset support in Chromium | On a headset (standalone) |
| Linux | Not supported: no headset support in Chromium (checked: isSessionSupported('immersive-vr') is false on Electron 45) |
On a headset (standalone) |
| Standalone headset (Quest browser and similar) | Not applicable | On a headset: scan the QR code or type the invitation link, enter the pairing code, then press the scene's VR button. Verified: the IDE's scene and a second browser client join the same room and receive each other's updates; not yet tried on a real headset |
The core fix that makes this work: a scene opened at the same moment as its server (the IDE's scene view, VS Code's side panel) used to ask for its room before the launch had written the session mapping. It joined codexr-session:port-<port>, while every later client joined codexr-session:<server id>. CollaborationSessionApi now falls back to the active-server registry, which is filled before the page opens.
npm run dist --workspace=code-xr-ide builds the extension's Python backend copy, the IDE, then packages it with electron-builder (electron-builder.config.cjs) for the OS it runs on. Each installer carries the IDE and, as resources, what the extension's core reads from its install folder: the Python backend (dist/code_analysis), templates/, examples/, the icons the scenes use and the vendored A-Frame/BabiaXR libraries, so a scene renders offline exactly as in development (process.resourcesPath is the core's install root when packaged). The TypeScript language server (#21) and node-pty (#137) are unpacked from the asar, because a child process and a native module cannot run from inside it. Python itself is not bundled: the IDE finds the system's and sets up its environment on request, as in development (#15).
| OS | File | First run |
|---|---|---|
| Windows | Code-XR-IDE-Setup-<version>.exe (NSIS; asks where to install) |
The installer is not signed, so SmartScreen shows "Windows protected your PC": More info > Run anyway. |
| macOS (Apple silicon) | Code-XR-IDE-<version>-arm64.dmg |
Signed ad hoc, not notarised, so Gatekeeper refuses a downloaded copy the first time: right-click the app > Open, or run xattr -dr com.apple.quarantine "/Applications/Code-XR IDE.app". |
| Linux | Code-XR-IDE-<version>-x86_64.AppImage, code-xr-ide_<version>_amd64.deb |
AppImage: chmod +x it, then run it. .deb: sudo apt install ./code-xr-ide_<version>_amd64.deb. |
The installers are not signed because the project has no signing certificate (a thesis prototype); nothing in the build needs a secret, so adding one later is a configuration change (CSC_LINK / APPLE_ID), not a code change. Settings and recent folders stay in the same user-data folder as in development (code-xr-ide).
Releases. .github/workflows/ide-release.yml builds the three installers on Windows, Linux and macOS runners. A pull request that touches the packaging, or a manual run, keeps them as workflow artifacts to try one before tagging. Pushing a tag ide-vX.Y.Z that matches apps/ide/package.json's version attaches them to a draft GitHub release, which the maintainer reviews and publishes by hand.
Updates. The IDE does not update itself. Help > Check for Updates… reads the repository's public releases, picks the newest published ide-vX.Y.Z above the running version (drafts and pre-releases skipped) and offers to open its page; nothing is downloaded or installed. The setting Check For Updates On Start-up (update.checkOnStartup, off by default) runs the same check quietly when the IDE starts and speaks only when there is a newer release.
Following Electron's security checklist. Each rule lives in one place and is enforced by a test, a startup assertion or the smoke run:
| Rule | Where | Enforced by |
|---|---|---|
contextIsolation: true, sandbox: true, nodeIntegration: false (also in workers and subframes), webSecurity: true, no insecure content, no <webview> |
src/main/security.ts (secureWebPreferences) |
assertSecureWebPreferences at window creation, against the preferences the window actually runs with: the IDE refuses to start otherwise. Unit tests flip each one. |
| Every renderer sandboxed process-wide | app.enableSandbox() in src/main/hardening.ts |
Smoke: require and process are unreachable from the page. |
Strict Content-Security-Policy: default-src 'none', scripts only from the app, no eval, no inline scripts. Styles allow 'unsafe-inline' because Monaco creates <style> elements at run time (as in VS Code); nothing else is relaxed, so CSS cannot load or send anything off the app |
buildContentSecurityPolicy in src/main/security.ts, sent as a response header (app protocol in production, webRequest in development) |
Unit tests; smoke checks that eval throws in the real page. |
Renderer served from codexr://app/, never file:// |
src/main/appProtocol.ts, src/main/assetPath.ts |
Unit tests for path traversal (.., encoded %2e%2e, %5c, NUL). |
No navigation away from the app, no window.open, no <webview> |
src/main/hardening.ts |
Unit tests for the URL policy; smoke tries both from inside the page. |
| No permission granted (camera, microphone, XR, notifications...) | src/main/hardening.ts |
Each later story allow-lists only what it needs. The one exception so far: the scene view grants XR for 15 s after Enter XR, to that scene only (sceneXrPolicy.ts, unit-tested). |
| The renderer reaches files only inside the open folder, by workspace-relative path | src/main/workspace/ (parseWorkspacePath, Workspace), one folder per window |
Unit tests for .., absolute paths, drive letters, \\, NUL and symlinks that lead out; smoke reads a file and tries ../. |
| IPC only on allow-listed channels, only from trusted frames | IPC_CHANNELS in src/shared/api.ts, src/main/ipc.ts |
Unit tests; startup check that every channel has a handler. |
| Typed, frozen preload API, the only path from renderer to Node | src/preload/index.ts, CodeXRApi in src/shared/api.ts |
Lint forbids electron, node:* and main/preload imports in the renderer; smoke checks the API is frozen and answers. |
| The renderer cannot start a process: a terminal starts only from a detected or user-saved profile, named by id, and only the window that created it can write to it or read it | src/main/terminal/ (ProfileRegistry.resolve, TerminalService) |
Unit tests (unknown ids, foreign windows, bad sizes and input); smoke opens a terminal and reads its output. |
| Git runs without a shell, on paths checked inside the open folder; discard asks natively and trashes untracked files | src/main/git/ (runGit, resolveGitPath, gitIpc.ts) |
Unit tests (.., absolute paths, symlinks out, globs, option-like branch names); smoke refuses git.headContent('../package.json'). |
The renderer cannot start or address a language server: it names documents by codexr-file: URI inside the open folder and sends only allow-listed requests with rebuilt parameters |
src/main/lsp/ (lspUri.ts, lspProtocol.ts), LSP_REQUEST_METHODS in src/shared/lsp.ts |
Unit tests (test/lsp.test.ts: .., encoded separators, other schemes, refused methods, forged completion data). |
No network request unless the person asks: the update check runs from Help > Check for Updates…, or at start-up only if update.checkOnStartup is turned on (off by default); it reads the public GitHub releases list, downloads nothing and only opens the release page in the browser |
src/main/updates/ (updateRelease.ts pure, updateCheck.ts) |
Unit tests (test/updateCheck.test.ts: tags, drafts, pre-releases, versions); never run in the smoke run. |
| The dev server URL is ignored in a packaged build | src/main/index.ts (app.isPackaged) |
Code review. |
Running as root (containers, some CI images) requires --no-sandbox, which the scripts add only in that case. It turns off Chromium's OS-level sandbox and app.enableSandbox(); the per-window sandbox: true preference and its assertion stay.
A folder can bring things that run: Git reads the repository's own hooks, filters and configuration, pyright runs the interpreter a project's config names, and tasks (#176) are commands the folder defines. So the first time a folder opens, a notification asks whether you trust its authors: Trust Folder, Trust All in its parent folder (every folder below a trusted one is trusted), or Restricted Mode. Until it is answered the folder is restricted, and a Restricted Mode shield sits at the start of the status bar; clicking it, or Manage Workspace Trust in the palette, changes the answer later. A folder can be put in Restricted Mode even inside a trusted parent.
In Restricted Mode the main process runs no Git in the folder (Source Control says why), starts no Python language server, and refuses tasks (Run Task and Run Current File say why and offer Manage Workspace Trust). Reading, editing, search, the terminal you open yourself, the IDE's own TypeScript server and the Code-XR analysis (it parses files, it never runs them) work either way. The decisions are stored in workspace-trust.json in the IDE's user-data folder, never in the project, so a folder cannot trust itself; paths compare without case on Windows and macOS (main/trust/, renderer/trustView.ts). The smoke run checks that a new folder starts restricted with Git off, and that trusting it turns Git on.
Tasks: Run Task (palette) lists what the open folder offers to run: the scripts of its root package.json (run with the package manager its lock file names: npm, pnpm, yarn or bun; pre/post hooks are not listed, the package manager runs them), the targets of its root Makefile, and the tasks you write in .codexr/tasks.json (Tasks: Configure Tasks creates it with an example; comments and trailing commas are allowed):
{
"tasks": [
{ "label": "Typecheck", "command": "npx tsc --noEmit", "problemMatchers": ["tsc"] }
]
}Each run gets a terminal tab of its own, in the folder, started with the shell of the default terminal profile (#137) and headed by the command line. The tab stays after the task ends and shows its exit code; a failure is also a notification. Problem matchers read the output once the task ends and send what they find to the Problems panel (source Tasks), replacing that task's previous problems: tsc (plain and --pretty lines) and eslint (its default report). A package.json script or a user task that runs tsc or eslint gets the matcher by itself; problemMatchers in tasks.json sets them explicitly ([] turns them off).
Run: Run Current File (Ctrl/Cmd+F5) saves the active file and runs it with its interpreter: .py with Python Interpreter (run.pythonInterpreter; empty means python3, or python on Windows), .js/.mjs/.cjs/.ts with Node Interpreter (run.nodeInterpreter; node, which runs TypeScript itself from Node 22.18), and .sh, .ps1, .rb, .pl, .php, .lua, .R, .go (go run), .java, .dart, .jl with the usual program. The interpreter is looked up on PATH (with PATHEXT on Windows) before anything starts, so a missing one is a clear message rather than a shell error.
The renderer names a task only by the id the main process listed, or a file by its workspace path; the main process re-reads the folder, builds the command line (quoted for bash/zsh/fish, PowerShell or cmd), checks the trust and starts the terminal (shared/tasks.ts, pure and unit-tested; main/tasks/; renderer/taskRunner.ts). The smoke run checks that a task is refused in an untrusted folder.
Problems (Ctrl/Cmd+Shift+M, or the counts at the left of the status bar) lists, grouped by file, what the editor's languages report on the open files (Monaco's markers: syntax errors for TypeScript and JavaScript, whose semantic checks wait for the language servers of #21, and JSON, CSS and HTML validation) and the Code-XR metric checks: after an analysis of the folder, every function above a limit is a warning on its first line ("'route' has a cyclomatic complexity of 18 (limit 10)."), shown in the list and as a squiggle in the editor. Clicking a row opens the file there. The limits are settings, per user or per folder: Max Cyclomatic Complexity (problems.metrics.maxComplexity, 10, Code-XR's own "high complexity" band), Max Function Lines (problems.metrics.maxFunctionLines, 50, lines of code) and Max Parameters (problems.metrics.maxParameters, 5); 0 turns a check off. The panel has a text filter (words that must all appear; !word excludes), a toggle per severity with its count, a source picker (all, Code-XR metrics, editor) and Collapse All. The header adapts to the panel's own width (a container query: an open scene halves it): a narrow panel drops the source picker, then the severity toggles, whose counts stay in the status bar; the filter always stays. Core messages reach the status bar and the notifications without VS Code's $(icon) syntax (plainCoreText, shared/output.ts).
Where the numbers come from: the scene's data.json keeps one summary row per file, so it cannot say which function is complex. When an analysis opens its scene, the main process runs the backend's functions mode over the folder (backend/src/utils/function_metrics.py, Lizard only, no scene; main/problems/functionMetricsService.ts), and each save of a file re-measures that file alone. The renderer applies the limits (shared/problems.ts, pure and unit-tested), so changing one updates the list and the squiggles at once, without running anything. The metrics describe the folder the analysis ran on and are dropped when the window opens another one. In development the backend runs from backend/src unless a compiled copy exists in apps/vscode-extension/dist (npm run compile refreshes it): an old copy there has no functions mode, and the Core channel of the Output panel says so.
After an analysis, every function it measured carries a CodeLens with its numbers, CCN 18 > 10 · NLOC 22 · 7 params > 5: a value over its Problems limit is marked, and clicking such a lens shows that function's problems in the Problems panel. Functions the scene draws as high or critical complexity (CCN over 10 or over 25, the backend's build_complexity_band, not the Problems limit, so the editor and the scene agree) get a thin strip in the gutter and a mark in the overview ruler, in the warning or error colour. The numbers describe the file on disk: while a tab has unsaved changes its lenses give way to one "out of date" lens, and saving measures the file again; a measured file that changes on disk (another program, a checkout) is measured again too. Show Metrics In The Editor (problems.metrics.showInEditor) turns both off and on without a reload. Code: renderer/editor/metricLens.ts; the titles, bands, checks and the tracker that runs the backend live in the extension's core/metrics/, shared with the VS Code extension, which shows the same warnings, lenses and marks (features/metrics-in-editor/). The renderer may import that pure folder of the core and nothing else of it.
Reveal in XR Scene goes the other way, from the code to the scene: on a file of the open folder, from the editor's, the tab's or the explorer's context menu or the command palette (Code-XR: Reveal Active File in XR Scene), while the window shows a scene. In the classic analysis the file's element in the chart on the table gets a bobbing marker over it and its Babia legend, for eight seconds; in the dependency graph its node's card is pinned (or the card of the deepest folder drawn as one box that holds the file). The comparison and evolution modes show no single file, so nothing is marked there and the status bar says the scene does not show it. The main process resolves the workspace path inside the window's folder and asks only that window's scene (AnalysisService.revealInScene); the core (core/server/analysis/sceneReveal.ts) sends reveal-in-scene { path relative to the analysed folder } to the scene's room, and the scene acts on it only on a page on this machine (analysisTableRuntime/sceneReveal.js), so a guest's view never jumps. The VS Code extension offers the same as CodeXR: Reveal in XR Scene (editor, tab and explorer menus), asking every running scene that holds the file.
The explorer pane holds the file tree and, under it, the Outline section: the symbols of the active file as a tree, each with a letter for its kind (C class, I interface, m method, ƒ function...). It follows the cursor (the innermost symbol around it is marked and scrolled into view), a click or Enter puts the cursor on a symbol, the arrow keys walk and fold the tree, and the header folds the whole section (remembered). The sort button switches between position in the file and name, stored as Outline: Sort By (outline.sortBy). Above the editor, the breadcrumbs show the file's folders, the file and the symbols around the cursor; a folder segment lists its entries (a file opens, a folder is revealed in the explorer), the file segment its top-level symbols, a symbol segment the symbols beside it. Breadcrumbs: Enabled (breadcrumbs.enabled) hides the bar.
Where the symbols come from (renderer/editor/outlineController.ts), first match wins: the language server of the file's language where one runs (#21, languageServerSymbols in renderer/lsp/languageClient.ts: TypeScript and JavaScript always, Python when a server is installed), then Monaco's own TypeScript service (its navigation tree) for TypeScript and JavaScript; both refresh as you type. Every other language uses the functions the Code-XR analysis measures, nested in the classes around them by shared/outline.ts (pure, unit-tested): a scan of the text by indentation for Python and by braces for the C family, Java, C#, Kotlin, Swift, Go, Rust or PHP, plus Lizard's qualified names (Shape::area). A file an analysis covered uses the window's metrics; any other is measured alone by the backend (problems.fileFunctions, FunctionMetricsService.fileFunctions), which does not add it to the Problems panel. Those symbols describe the file on disk, so they are read again when the tab is saved, and the section says they come from the analysis. Without Python set up, or for files the analysis does not read (Markdown, JSON, CSS...), the section says why it is empty. The VS Code extension needs none of this: VS Code has its own Outline and breadcrumbs.
The bottom panel holds several views, VS Code's way: Problems (#173), Output and Terminal, as tabs at the left of the panel's header, the active view's own controls after them, maximise and close at the end (renderer/panel/panelHost.ts). Ctrl+\`` shows the Terminal, **View: Show Output** (Ctrl/Cmd+Shift+U) the Output, **Toggle Panel** (Ctrl/Cmd+J`) the view shown last.
Output shows what the IDE writes, one channel at a time: Code-XR IDE (the main process's own log), Analysis core, Python environment (the venv, pip, the parsers) and Servers and tunnel (the scene servers, SSE, cloudflared). The main process collects every line (main/outputPanel/outputService.ts): its own logger (main/log.ts, one logger per channel) and the core's log sink, whose [SCOPE] picks the channel (channelForScope in shared/output.ts, by whole words of the scope). The core's info and debug lines are shown too, which the extension's log file only keeps in development. Before a line is kept, anything that looks like a secret is replaced by <redacted>: --token style arguments, key=value pairs whose key names a secret, Authorization/Bearer values, Anthropic/OpenAI/GitHub/AWS/Slack key shapes, JWTs (cloudflared's tunnel tokens among them) and passwords in URLs. Each channel keeps its last 5,000 lines (a line over 4,000 characters is cut), in the main process and in the page; new lines reach the window in batches every 80 ms. The view has a channel picker, auto-scroll lock, copy (the selection, or the whole channel) and clear. Error notifications from the analysis, the core and the Python set-up carry a Show Output button that opens the channel explaining them.
The core's sink lives in the extension's platform layer, not in core/, so the IDE reaches it through a second alias, @codexr/logging/<path> (src/platform/logging), handled like @codexr/core by Vite, scripts/coreTypes.mjs and ESLint.
TypeScript, JavaScript and Python files get diagnostics, hover, completion, go to definition (F12, also into another file of the folder) and document symbols (the outline, Ctrl/Cmd+Shift+O) from real language servers, which see the whole project rather than one file.
- Servers. TypeScript and JavaScript: typescript-language-server (a pinned dependency of this package), run by Electron's own Node (
ELECTRON_RUN_AS_NODE) on the IDE's TypeScript (tsserver.path), never a project's ownnode_modules/typescript, which would run code from the folder just by opening it; automatic type acquisition is off, so it downloads nothing. Python:pyright-langserver --stdio, elsepylsp, found onPATH(absolute entries only; on Windows only.exe, never a.cmdthrough a shell). With neither, Python keeps syntax highlighting and the Language servers channel of the Output panel says how to install one; there is no error notification. - Lifetime. The main process owns one server per language family per window (
main/lsp/lspHost.ts,languageServer.ts), spawned over stdio withvscode-jsonrpcon the first document of its language. Servers stop (LSPshutdown/exit, then a kill) when the folder changes, the page reloads, the window closes and on quit (also before the smoke run exits). A server that crashes is restarted with the documents it had open, at most 3 times in 3 minutes, then stays down and says so in the Output panel; reopening the folder starts it again. - The bridge.
renderer/lsp/languageClient.tsis a small hand-written bridge, notmonaco-languageclient: it follows every Monaco model with acodexr-file:URI whose language has a server, sendsdidOpen, the whole text on change (debounced 150 ms, flushed before any request) anddidClose, and registers Monaco providers that forward towindow.codexr.lsp. Diagnostics become markers of the ownercodexr-lsp(LSP_MARKER_OWNER), so any view that lists markers shows them. The features the servers replace (completion, hover, definition, symbols, diagnostics) are turned off in Monaco's built-in single-file TypeScript service; formatting, references and the rest stay. Go to definition into another file goes throughmonaco.editor.registerEditorOpenerto the editor group'sopenAt, which opens the tab and selects the name. - Security. The IPC is four channels (
LSP_IPC_CHANNELSinshared/lsp.ts) and one event. The renderer names documents only bycodexr-file:/<workspace path>(orcodexr-file:///...);main/lsp/lspUri.tsparses them with the workspace's path rules (no.., no absolute paths, drive letters,\or NUL, no query or fragment) intofile://URIs under the open folder, and maps the servers' answers back, dropping every location outside the folder (library definitions,lib.d.ts). Requests must be one ofLSP_REQUEST_METHODS(hover, completion, completion resolve, definition, document symbols);lspProtocol.tsrebuilds their parameters from validated fields. Completion items' server data (which holds absolute paths) is replaced by an opaque token and restored only for the server that produced it. Servers asking the client to edit files (workspace/applyEdit) are refused. Nothing changes in the CSP: everything runs in the main process.
A bottom panel of terminal tabs: xterm.js in the renderer, node-pty in the main process. Each terminal starts in the open folder (the home folder when none is open) and keeps running while you switch tabs or hide the panel.
Shell profiles. src/main/terminal/shellProfiles.ts detects them, as a pure function with the file system, the environment and the registry injected, so every OS is unit-tested on every OS:
- Windows: Git Bash first (
--login -i), found throughHKLM\SOFTWARE\GitForWindowsInstallPath, thenProgram Files\Git,Program Files (x86)\Gitand%LOCALAPPDATA%\Programs\Git; then PowerShell 7 (pwsh.exe), Windows PowerShell,cmd.exe, and WSL whenwsl.exeexists. - macOS / Linux:
$SHELL, then/bin/bash, then/bin/sh(login shells,-l, on macOS, as Terminal.app starts them).
The first detected profile is the default until the person picks another in the panel's profiles menu (the chevron); the choice is saved in terminal-settings.json in the user-data folder (written through a temporary file and a rename, core/jsonStore.ts) and used by every new terminal, after restarts too. A saved default that no longer exists falls back to the first detected profile. #18 will move the picker into the settings UI.
Security model of the pty IPC. A terminal runs whatever its executable is told, so the bridge is narrower than "spawn":
- The renderer never sends an executable path, a command line, an environment or a working folder.
terminal.create(profileId, cols, rows)names a profile fromterminal.profiles()(or null for the default);ProfileRegistry.resolvemaps it to an executable in the main process and refuses anything else. The folder is the one the window has open; the environment is the IDE's minus Electron's own switches (ELECTRON_RUN_AS_NODE,NODE_OPTIONS...), plusTERM=xterm-256color. - Custom profiles are added only through the main process:
terminal.addCustomProfile(args)opens a native file dialog for the executable, then shows the exact command line (executable plus the proposed arguments, split without any shell expansion) in a native confirmation the page cannot answer. A compromised page can propose arguments but cannot save a profile without the person picking the file and confirming. Saved entries are re-validated on every read (absolute path, at most 32 short arguments, no NUL). - A pty never leaves the main process. Terminals are numbered by the main process and owned by the
webContentsthat created them: input, resize, kill and the data and exit events only work for, and only reach, that window. Sizes are integers from 1 to 1000; one input call carries at most 1,000,000 characters; a window holds at most 20 terminals. - No orphans. A window's ptys are killed when it is closed, crashes or reloads (
destroyed,render-process-gone,did-navigate), all of them onwill-quit, and explicitly before the smoke run'sapp.exit. - No CSP change. xterm.js 6 draws with DOM elements and inline styles, which the existing
style-src 'unsafe-inline'(needed by Monaco) already allows; it needs no script, worker, eval or network. The smoke run checks for CSP violations while the terminal runs. Copy usesexecCommand('copy')from the key handler and paste the browser's own paste event, so no clipboard permission is granted.
Keys. Ctrl+` toggles the panel and Ctrl+Shift+` opens a terminal, also from inside a terminal (xterm leaves those keys to the menu). Ctrl+C sends an interrupt. Copy and paste: Ctrl+Shift+C / Ctrl+Shift+V on Windows and Linux (on Windows Ctrl+C copies while text is selected and Ctrl+V pastes, as in Windows Terminal), Cmd+C / Cmd+V on macOS.
node-pty under Electron. node-pty is pinned to 1.2.0-beta.18, an N-API build whose npm package carries prebuilt binaries for win32, darwin and linux (x64 and arm64), so npm ci compiles nothing and the same binary loads in Node and in Electron: no @electron/rebuild, no compiler on a developer machine or a CI runner. (1.1.0, the last stable release, has no Linux prebuilds and packs the macOS spawn-helper without its execute bit, so spawning fails there.) It is the only package the main bundle leaves external (scripts/viteConfigs.mjs), and it is loaded on the first terminal, so a broken native module costs the terminal, not the IDE. Packaging it per OS (outside an asar) belongs to #20.
The Git half of #17 (the terminal half is #137): VS Code's Source Control, kept minimal. The third activity item lists the changed files of the open folder in three groups, Staged Changes, Changes and Untracked, each row with its letter (A added, M modified, D deleted, U untracked, R renamed, C copied, T type changed, ! conflict) and, on hover, Open Changes, Open File, Stage / Unstage and Discard; each group header stages or unstages all of it. Clicking a row opens the file in the editor (a deleted file opens its changes). Open Changes shows Monaco's diff editor, HEAD on the left and the working tree on the right, over the editor area (Escape closes it). The message box commits with the Commit button or Ctrl/Cmd+Enter; with nothing staged, a native dialog offers to stage everything and commit. The activity item carries the number of changed files. The status bar shows the branch (or the detached commit, and ahead/behind counts when there is an upstream); clicking it opens a picker to switch to a local branch or create one from the typed name. With no git on PATH, or a folder outside a repository, the view says so and nothing else happens.
The view refreshes when the repository changes on disk (the main process watches the git directory's index, HEAD, ORIG_HEAD, MERGE_HEAD, packed-refs and refs/heads/, so a commit or checkout from the terminal shows up), when the workspace watcher reports a change, when the window gets focus, and every 5 s while the view is on screen. An unchanged status does not rebuild the list.
Process split. main/git/ runs git; renderer/git/ only shows it. The contract is shared/git.ts (GitApi, GIT_IPC_CHANNELS, GIT_IPC_EVENTS), kept apart from api.ts like the agent hub's and spread into its lists; the preload exposes it frozen as window.codexr.git, and main/git/gitIpc.ts registers its handlers through ipc.ts's handle.
Security model.
- Git runs through
execFile, never a shell, with a timeout (30 s, 120 s for a commit) and an output cap (main/git/gitRunner.ts). Every call carries--literal-pathspecs(a*or:(top)in a file name is a name),-c core.fsmonitor=false(a repository's config cannot name a command for the IDE to run on every status),--no-ext-diff --no-textconvon diff, blame and show for the same reason, andGIT_TERMINAL_PROMPT=0andGIT_OPTIONAL_LOCKS=0(no prompt can hang it, status takes no index lock). Commit hooks still run, as from VS Code or a terminal. - The renderer sends workspace-relative paths and branch names only.
resolveGitPath(main/git/gitPaths.ts) parses each path like the workspace API (parseWorkspacePath: no.., absolute paths, drive letters,\or NUL), then checks the real path of the nearest existing ancestor against the folder's real path, so a deleted file can be staged but a symlink out of the folder is refused. Branch names refuse a leading-and git's forbidden characters beforegit check-ref-format --branchruns; switching only accepts a namefor-each-reflists. - Discard acts only on a file the current status lists under Changes or Untracked, asks in a native dialog the page cannot answer, restores a tracked file from the index (
git restore --worktree) and moves an untracked file to the OS trash (shell.trashItem), never a permanent delete. - The smoke run checks that
window.codexr.gitis frozen, thatgit.statusanswers and thatgit.headContent('../package.json')is refused.
GitService (reusable, main process). main/git/gitService.ts, one per open folder (gitServiceOf(webContents) in gitIpc.ts returns the calling window's). The folder may be the top of a work tree or any folder inside one; only changes inside the folder are reported, and every path in and out is relative to the folder. Every method that takes a path accepts untrusted input and validates it with resolveGitPath.
| Method | Returns |
|---|---|
status() |
GitStatus (shared/git.ts): state (ok, no-git, not-repo, error), branch, abbreviated HEAD, upstream, ahead/behind, staged/changes/untracked lists of { path, letter, origPath? }. Never throws for a missing git or a non-repository. |
diff(file) |
The unified diff (git diff HEAD -- file) of HEAD against the working tree, staged and unstaged changes together; an untracked file, or any file before the first commit, against nothing (--no-index /dev/null). '' when unchanged. |
blame(file, contents?) |
BlameLine[] (main/git/blameParser.ts), one per line of the working-tree file, or of contents when given (--contents -, written to git's stdin: the editor's unsaved text): line, originalLine, originalPath, content and a shared, frozen commit (hash, author, authorMail, authorTime in epoch seconds, authorTz, committer, committerTime, summary, boundary, uncommitted for lines not committed yet). Rejects for a file git does not track. |
headContent(file) |
The file's text at HEAD, or null (no HEAD, or not in HEAD). |
stage(paths), stageAll(), unstage(paths), restore(file), discardPlan(file), commit(message), branches(), switchBranch(name), createBranch(name), repository() |
What the view uses; repository() gives the folder's prefix in the work tree and the absolute git directory. |
The parsers (statusParser.ts, blameParser.ts) are pure and unit-tested on strings; test/scm.test.ts also runs GitService against a real temporary repository (initial commit, globs in names, a subfolder of the work tree, branches, diff and blame). Inline blame and the gutter markers (#175, below) build on blame and headContent.
Not yet: push, pull, fetch, stash, merge-conflict tooling, staging hunks; the diff of a staged-only row is HEAD against the working tree, not against the index.
- Change markers. Each open file is compared with its text at HEAD as you type (
shared/gitGutter.ts, on the agents'lineDiff), and the gutter marks added lines (green), changed lines (blue) and where lines were deleted (red), also in the overview ruler. They sit beside the metric strip of #178. Saving does not clear them, committing does: a commit moves HEAD, the repository watcher fires, and every open file is compared again. - Peek and Revert. Clicking a marker opens, under the change, what HEAD had there with Revert (one edit, undone with
Ctrl/Cmd+Z) and Close. It is a view zone that makes room plus an overlay widget on top of it, because a view zone alone sits under the text and gets no clicks. - Inline blame. The cursor line ends with who last changed it, when and the commit's summary ("Ada, 3 days ago - Fix the parser"); hovering it shows the e-mail, the date and the hash. It blames the editor's text, so a line you have not committed says "You, uncommitted changes". Git: Toggle Inline Blame or the Inline Blame setting (
git.blame.inline) turns it off. - Explorer. Changed files are coloured with their letter (
M,A,D,U,R,!) and each folder above them takes the strongest colour below it;.gitignored entries stay dimmed as before. It follows each status Source Control computes. - Nothing to say, nothing shown. The two calls the editor makes (
git.baseline,git.blame) answer null, never an error, without Git, outside a repository, in Restricted Mode (#177) and for an untracked file.
- Add the method to
CodeXRApiand a channel toIPC_CHANNELS(src/shared/api.ts). - Expose it in
src/preload/index.ts, one member per channel. Never exposeipcRendereror a genericinvoke. - Register the handler in
src/main/ipc.tsthroughhandle(), which already rejects untrusted frames. Validate every argument: the renderer is untrusted. - Add a unit test for any pure logic, and extend the smoke probe if the capability is security-relevant.
The Agents view (activity bar, speech-bubble icon) connects the IDE to LLM providers with the person's own API keys. There is no Code-XR server in between: every call goes straight from the main process to the provider, and nothing is sent until a provider is configured and used.
- Providers: Anthropic, OpenAI, Google Gemini, OpenRouter, Nous Portal, and any OpenAI-compatible endpoint (Ollama, LM Studio…). Three wire protocols cover them (
src/main/agents/providers/: Anthropic Messages, OpenAI Chat Completions, GeministreamGenerateContent), normalised into oneChatEventstream with text, tool calls, usage and a stop reason. 429/5xx are retried twice with backoff before anything is streamed. - Keys:
KeyVault(src/main/agents/keyVault.ts) encrypts them with ElectronsafeStorage(Keychain on macOS, DPAPI on Windows, libsecret/kwallet on Linux) into<userData>/agents/keys.json(mode 0600). If Linux has no keyring, Electron falls back tobasic_text, which is obfuscation only: the vault then keeps keys in memory until the IDE quits and writes nothing, and the view says so. Provider settings (no secrets) are in<userData>/agents/providers.json. - The renderer never sees a stored key. It gets
hasKey, the last four characters and where the key is kept. Fixed providers cannot be pointed at another endpoint from the renderer; a custom endpoint must be https, or http on this machine, with no credentials in the URL. - Contract:
src/shared/agents.ts(types +AGENT_IPC_CHANNELS, spread intoIPC_CHANNELS), exposed aswindow.codexr.agents. - Agents and chats (A3-A5): the view's home lists the open folder's chats, the agents and the providers. An agent (
AgentProfiles,<userData>/agents/agents.json) is a name, a provider, a model, instructions and a temperature; the three starters ("Assistant", "Code reviewer", "Architect") begin unbound, and removing a provider unbinds its agents rather than switching them. Chats (ChatSessions) are one JSON file each under<userData>/agents/sessions/<hash of the folder>/, so each folder keeps its own history.AgentChatsends the newest messages that fit about 100k tokens (the answer says when older ones were left out), streams the answer to the window that asked overcodexr:agents:chat, and stores provider errors and Stop as part of the answer. Answers are Markdown rendered byrenderer/agents/markdownModel.ts+chatMarkdown.tsinto DOM nodes with text only, neverinnerHTML. Commands:Agents: New Chat(Ctrl/Cmd+Alt+I),Agents: Show AI Agents,Agents: Add AI Provider. - Context and tools (A6, A7): the composer attaches project files (type
@, or the paperclip) and the editor selection (@selection). Only paths cross IPC:main/agents/attachments.tsreads them throughWorkspace, refuses files quick open does not list (git-ignored ones) and caps a message at about 120k characters of context. Agents get tools frommain/agents/tools/(ToolCatalog), chosen per agent in its form; the starters get the four read-only ones (list_directory,read_file,find_files,search_text), which run without asking and only throughWorkspace, so they cannot leave the folder.AgentChatloops on tool calls (at most 12 rounds per answer), shows each run in the answer, and stops on a card before any tool whose risk is notread: Allow once, Always for this agent (saved asalwaysAllow, revocable in the agent form) or Deny. Later stories register the risky tools (edits, terminal, Code-XR analyses, MCP). - Edits as diffs (A8):
propose_edit(main/agents/tools/editTools.ts, off by default, ticked per agent) takes exact find/replace pairs (eachfindmust be unique in the file) or a whole new content, keeps the file's line endings, and never writes: it emits areviewevent and waits. The window opensrenderer/agents/editReview.tsover the editor cell, a read-only Monaco diff with the change's hunks (shared/lineDiff.ts) to tick or untick, and writes only the accepted ones: into the open tab as one undoable edit saved through the editor's own save path (EditorGroup.applyAgentEdit, refused when the tab has unsaved edits), or withwriteFile(path, text, mtime)so a file changed on disk meanwhile is not overwritten. The agent is told what was applied, partly applied or rejected; Stop counts as a rejection. - Commands (A9):
run_command(main/agents/tools/commandTool.ts, off by default) always shows the exact command line on an approval card, then runs it in a pty of the default terminal profile (#137, node-pty viaTerminalHost.commandRunner) in the project folder, with-c/-Command//cby shell. It is non-interactive (CI=1, no pager, no colour). The output streams into the chat's tool line while it runs, and the model gets the exit code and the output without colours, cut in the middle past 16k characters. A timeout (120 s by default, 600 s at most) or Stop kills it, and so does quitting the IDE. Unlike the terminal panel, these commands do not appear in a terminal tab. - Code-XR analyses (A10):
get_metrics,get_hotspots,get_dependenciesandget_evolution(main/agents/tools/analysisTools.ts) are read-only and given to the starters. They read what the window's XR analysis already wrote to its scene folder (AnalysisService.outputDirectory):data.json(one metrics record per file),dependency-graph.json(once the scene's dependency mode ran) and the lastevolution/revision-N/movie. They never start an analysis or download anything; without one they tell the model to ask the person to run it. Their lines in the chat carry an Open in XR button that shows the scene. - Supervisor and sub-agents (A11):
delegate_task(opt-in per agent) hands a self-contained task to another of the person's agents by name.AgentChat.runChildruns it through the same model/tool loop as a chat answer (loop), with the child's own profile, a clean context (only the task), the same approval rules (its cards name the sub-agent) and nodelegate_taskof its own, so the run tree is one level deep. The calls of one turn run in parallel, up to the supervisor'smaxParallel(1-8, default 3, set in the agent form). Each call's line in the chat is the run tree: the sub-agent's status, model, tokens, task, tools and streaming answer, plus a Cancel button (agents.cancelRun) that stops that sub-agent alone; Stop stops them all. Sub-agents' tokens are added to the answer's usage. - MCP servers (A12): the MCP servers section of the Agents view adds local (stdio: a command and its arguments) and remote (Streamable HTTP: a URL and an optional bearer token, kept in the OS secret store) servers.
main/agents/mcp/holds a small JSON-RPC client (initialize, pagedtools/list,tools/call, cancellation; server requests such as sampling are refused), the two transports (on Windows,.cmdlaunchers such asnpxgo throughcmd.exewith cross-spawn-style escaping) andMcpRegistry. A new or changed local command is only saved after the person accepts a native dialog that shows the exact command line. Nothing connects at start-up: a server is contacted when it is saved or refreshed and when an agent calls one of its tools; its tool list is cached so agent forms show it without connecting. Tools appear asmcp__<server>__<tool>in the agent form (with a filter once the list is long) and have risknetwork, so every call goes through the approval card. Server processes are stopped on quit. - Usage, cost and limits (A13):
main/agents/usageLedger.tsrecords every model call (agent, provider, model, tokens) inusage.json, by month. Two costs are kept apart everywhere: the estimate (tokens × the person's price table, USD per million tokens, exact model ids orprefix*, empty until the person fills it) and the reported cost when the provider sends one (OpenRouter'susage.cost, read by the OpenAI-compatible adapter). Each answer stores its provider, model and usage, and shows them under it; the chat shows its own total; the Usage and budget section shows the month by agent, provider and model, the budget form and the price table. The monthly budget counts each call once (its reported cost, or its estimate when none was reported), warns from a chosen share and, with the hard stop on, refuses new model calls (answers and sub-agents) once it is spent.
[ { "key": "CmdOrCtrl+Shift+S", "command": "file.saveAll" }, // add a key { "key": "CmdOrCtrl+Alt+S", "command": "-file.saveAll" }, // remove one built-in key { "command": "-view.toggleZenMode" } // remove all of them ]