Skip to content

feat(code): a Developer-mode code workspace with preview, checks and tests - #1760

Merged
gregpriday merged 8 commits into
developfrom
feature/issue-1483-upgrade-the-in-app-code-workspace-with
Nov 28, 2026
Merged

gregpriday merged 8 commits into
developfrom
feature/issue-1483-upgrade-the-in-app-code-workspace-with

Conversation

@gregpriday

Copy link
Copy Markdown
Member

Developer mode gets one code workspace for the project's code. It covers code components and the project's own files: helpers under src/lib/, endpoints, loaders, hooks and pages of its own under src/routes/. Each file is edited beside a preview of what was last saved. The project's checks and tests run below it, and a file or the whole project hands off to the developer's own code editor.

Resolves #1483

What changes

  • One workspace, two kinds of file. Edit code (Inspector, Insert, the canvas) and the new Code workspace… command open the same dialog: files on the left, the open file in the middle, the preview on the right, checks below. Each pane can be put away from the header. A code component still opens in its own editor, with its source and properties, saving through the project as before. That editor is now framed by the workspace (ComponentSourceEditor, extracted from SourceModal). Without Developer mode, the dialog is only that component's editor, as before.
  • The project's own code files (src/main/project/code-files.ts, src/shared/code-workspace.ts) are every plain .svelte, .js, .ts, .css or .json file under src/ that the app neither writes nor will write (ProjectSession.appWrites).
    • Read and saved as an outside code editor would: never through the documents, History or the AI.
    • Each folder is reached without following links and must be spelled as the disk spells it. Hidden parts, node_modules, credential-named parts and src/lib/siteorigin/ are refused.
    • A save replaces the file only while it still holds what was read. This is checked again just before the rename and on a Windows retry. Saves of one file take turns. Line breaks, byte order mark and mode are kept.
    • A file changed on disk while there are edits offers Use the newer version (Undo brings the edits back) or Keep my edits (they are rebased on the newer file).
    • Creating, renaming and deleting files is left to the developer's editor.
  • Preview (WorkspacePreview.tsx). A code component is shown on its own with its default content. Anything else shows the canvas's page, or any address of the site typed in. It loads again after each save, so a changed loader or hook runs again.
    • The frame is one of the editor's measuring frames, named before it loads. It never acknowledges an update the preview server waits on the canvas for.
    • A load failure now carries its frame's name (index.ts), and the canvas acts only on its own. Measuring frames leave the canvas's route-retry marker alone (bridge.client.js).
  • Checks (WorkspaceChecks.tsx):
    • Check Svelte files compiles every Svelte file of the site and of the project's own code, through the compile workers and the AI's compile cache. A file it could not read counts against it.
    • Run tests runs the test script the project's package.json declares, through the npm shipped with the app on Electron's Node (runtime/project-tests.ts). A node on the PATH points to that Node, so it works without Node installed. It runs only while the project's setup is still what was trusted and its tools are set up. Output is bounded and its secrets are masked; there is a five-minute deadline and Stop. The whole process tree is ended: its process group on macOS and Linux, taskkill /T on Windows.
    • Runs end when the project closes (the close waits for them), on a takeover, with Developer mode off, or when the editor crashes.
    • Preview log follows what the preview's server logs and what the previewed page threw.
  • Open in editor / Open project (external-editor.ts) hands the file, the component's file or the project's folder to Settings › Code editor. That is the system's default app, or an application chosen with the system's chooser and checked in the main process. A settings patch from the editor window can only set it back to the default. It starts with an argument list and never a shell. On Windows the system default would run a .js file, so a script is shown in File Explorer instead. In automated runs the hand-off is recorded (open-editor intent) and nothing starts.
  • CodeEditor highlights JavaScript, TypeScript, CSS and JSON (@codemirror/lang-css is now declared; it was already installed). A replacement of its text from outside is now its own undo step, so Undo brings your edits back holds however soon after typing it comes.

Testing

  • New: code-files, project-tests (real npm runs plus a Windows case with an injected spawn), code-workspace-controller, external-editor, external-editor-settings, code-workspace-browser.
  • Adjacent: source-refused-browser, code-props-sync-browser, headless-desktop, measuring-frame, developer-mode-lock, command-menu-enter-browser, project-switch, read-only-controller, own-saves, session, runtime, compile-cache, pending-scroll, preview-journey, settings tests: all green.
  • Impact slice: 71 of 710 test files (10%), green.
  • npm run typecheck green.
  • Not run here: tests/e2e/code.mjs, which needs a build, and the test runner on a real Windows machine. There, the node the script finds is a node.cmd batch file, which a program that starts node without a shell does not find, and a helper left running after npm exits is not ended (no Job Object).

…de, its preview, checks and tests

- Lists, reads and saves the project's own code files under src/, refusing links, other spellings, hidden and
  credential-named parts, and files the app writes; a save replaces only what was read
- Frames the code component editor in one workspace with a file list, a passive preview, and checks
- Compiles every Svelte file from the shared cache, and runs the project's declared npm test on Electron's Node,
  bounded, masked, stoppable with its whole process tree, ended before a close lets the lock go
- Hands a file or the project folder to the editor chosen in Settings; a script on Windows is shown, never run;
  automated runs record the hand-off
- Attributes a preview frame's load failure to its frame; measuring frames leave the canvas's retry marker
- Makes an outside replacement of the editor's text its own undo step
…he compile cache to the files there are

- Cmd/Ctrl+S on a removed component's code no longer reaches the old save
- The Svelte check forgets compile outcomes of files no longer in the project
…-upgrade-the-in-app-code-workspace-with

# Conflicts:
#	src/renderer/src/store.ts
…, and swap a file the disk cannot renumber

- Adds the code.workspace row for the Code workspace command
- The save's identity check is tested with the read file moved aside, since a deleted file's inode can be reused on Linux
…-upgrade-the-in-app-code-workspace-with

# Conflicts:
#	src/main/controller.ts
# Conflicts:
#	src/main/index.ts
#	src/preload/index.ts
@gregpriday
gregpriday merged commit 332f88b into develop Nov 28, 2026
1 check failed
@gregpriday
gregpriday deleted the feature/issue-1483-upgrade-the-in-app-code-workspace-with branch November 28, 2026 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade the in-app code workspace with project file editing, live preview, test runner, and external editor launch

1 participant