Repository navigation
How Scripts Work
The Scripts tool window lists the runnable scripts of the workspace folders and runs one as its own process in the bottom panel's Run tab, with the Node version the project asks for. It has npm and Composer windows and a Run window. The user side is in Scripts.
Every project starts its dev server or tests a little differently: pnpm run dev, composer run-script test, make lint. Two things make it harder in a desktop app:
- An app opened from Finder gets a bare
PATHwithout Homebrew, nvm, pnpm or Composer, sonpmis simply "not found". - Version managers such as nvm pick the Node version in the shell's startup files, which a GUI app never runs.
flowchart TB
Panel["ScriptsPanel.svelte<br/>mounted while shown"] -->|"listProjectScripts(folderPaths)"| Cmd["list_project_scripts"]
Panel -->|"listNodeVersions()"| Node["list_node_versions"]
Cmd --> Env["reload_login_env()<br/>in the background"]
Cmd --> Walk["scripts::list_project_scripts<br/>ignore::WalkBuilder"]
Walk --> Parse["package_json, composer, makefile,<br/>deno, justfile parsers"]
Parse --> Runner["runner: packageManager,<br/>lockfiles, else npm"]
Parse --> Wanted["node_wanted::find, then<br/>volta.node, engines.node"]
Node --> Installs["node_versions::installed_here<br/>folders only, newest first"]
src-tauri/src/scripts/mod.rs walks each workspace folder with the ignore crate: .gitignore is honored even outside a repository, hidden folders and SKIPPED_DIRS (node_modules, vendor, target, dist, build...) are skipped, at most 6 levels deep, 300 manifests and 1 MB per file. A manifest found twice through nested workspace folders is listed once. Results are sorted by workspace folder, then depth, then path. Nothing is cached: every call rescans.
Each parser returns scripts in file order with their 1-based line, for Jump to Source. json.rs is a small parser that keeps lines and reads JSONC. Makefiles list rule targets only (no variables, define blocks or special targets), and justfiles skip private recipes, settings and aliases.
For package.json, package_json::runner takes the packageManager field, else the nearest lockfile up to the workspace folder (LOCKFILES), else npm. node_wanted::find reads .nvmrc, .node-version or .tool-versions from the package folder up to the workspace folder. Without one, volta.node beats engines.node.
node_versions.rs lists installed versions by reading folders only; it never starts node. It checks each manager's default folder as well as its variable (NVM_DIR, VOLTA_HOME...), because a Finder-launched app has none of them. Homebrew's opt/node@20 links are kept as the path, so they survive brew upgrade.
On the frontend, pickNode in src/lib/scripts/nodeVersion.ts matches the wanted spec against the installs: exact versions, 18, 18.x, ^, ~, comparators, ||, hyphen ranges, lts/* and nvm's LTS names. The newest match wins. The choice per package.json (Auto, "default" for Shell Default, or a bin folder) lives in scriptNodeVersions in state.json, at most 200 entries.
sequenceDiagram
participant Panel as ScriptsPanel
participant Act as scriptActions.ts
participant Store as terminalStore
participant View as TerminalView (location run)
participant Rust as run_process.rs
participant Proc as script process in a PTY
Panel->>Act: runProjectScript(source, script, installs)
Act->>Act: nodePickFor, scriptRunSpec
Act->>Store: startRun(spec, "dev (pnpm)")
Store->>Store: same runId running? ask "Process Is Running"
Store->>View: new entry, location "run"
View->>View: write the dim command header
View->>Rust: runScript(program, args, cwd, nodeBinDir)
Rust->>Rust: login_env(), Node bin first on PATH, resolve program
Rust->>Proc: TerminalRegistry::spawn, no shell
Proc-->>View: output on the Channel
Proc-->>Store: "terminal-exited"
View->>View: "Process finished with exit code N"
A run is a TerminalEntry with location: "run" and a RunSpec (runs.ts), shown by RunView.svelte with the same TerminalView and PTY backend as a shell. Output, exit and input use the terminal commands (How the terminal works), but a run never closes by itself. Rerun replaces the entry in the same place, so the output starts fresh.
run_process::prepare builds the process: the login environment, the chosen Node bin folder put first on PATH (path_with), and the program resolved on that PATH. A missing program gives "pnpm was not found. Install it, or add its folder to PATH in your shell's startup file." A missing folder is an error too.
The login environment. capture_login_env runs $SHELL -l -i -c "printf marker; /usr/bin/env -0" with a 10 s timeout. -i loads .zshrc, where nvm and most PATH changes live. Whatever the startup files print comes before the marker and is skipped, and the shell's own variables (PWD, SHLVL, TERM...) are dropped. The result is cached in a static Mutex. list_project_scripts calls reload_login_env on a background thread, so opening or refreshing the panel picks up new tools and the first run rarely waits. When the read fails, fallback_env uses the app's environment with the Homebrew folders added.
| File | What it does |
|---|---|
src-tauri/src/scripts/ |
Scanner, parsers, node_wanted.rs, tests.rs
|
src-tauri/src/node_versions.rs |
Installed Node versions per manager |
src-tauri/src/run_process.rs |
Login environment, PATH, program lookup, start_run
|
src-tauri/src/commands/scripts.rs |
list_project_scripts, list_node_versions, run_script
|
src/lib/scripts/ScriptsPanel.svelte |
The panel (a library List of Rows), lazy loaded from Workspace.svelte
|
src/lib/scripts/scriptsMenu.ts |
The right-click menus and the Node Version menu |
src/lib/views/PanelHead.svelte |
The title row: Collapse All, Refresh and the X that hides the sidebar |
src/lib/scripts/scriptsModel.ts |
Commands, rows, labels |
src/lib/scripts/scriptRun.ts, scriptActions.ts
|
The RunSpec and starting a run |
src/lib/scripts/nodeVersion.ts |
Spec matching and the badge text |
src/lib/terminal/RunView.svelte, runs.ts
|
The Run tab |
The MCP tools list_scripts, run_script and stop_run go through the same scriptRun.ts and scriptActions.ts, so they run a script exactly like the panel. See How MCP and the CLI Work.
No shell. The first version typed PATH=<bin>:"$PATH" pnpm run dev into a new terminal. That depended on the shell's syntax (fish, PowerShell and cmd differ), and it gave no clean exit code, Rerun or Stop. Starting the program directly, fixes all of these.
The login shell's environment, read once. Reading it per run would add about a second to every start.
Node first on PATH, not nvm use. Putting the version's bin folder first works for every manager and needs no shell.
Run With is not saved (runnerOverrides.svelte.ts). It is a quick override, like an unsaved run configuration. The Node choice is saved, because a project's Node needs rarely change.
Running again asks. Stopping a dev server by accident is costly, so the panel asks before restarting a running script. The Rerun button is an explicit restart, so it does not ask.
Rescan on every mount. The panel is mounted only while it shows, and the scan has hard limits (depth, file count and size), so a fresh scan is cheap and no cache can go stale.
-
src-tauri/src/scripts/tests.rs(lists_scripts_across_a_workspace,serializes_for_the_frontend,stops_after_the_file_limit,finds_the_node_version_a_package_asks_for), plus tests in each parser and innode_wanted.rs. -
src-tauri/src/node_versions.rs: every manager, newest first, Herd throughNVM_DIRlisted once. -
src-tauri/src/run_process.rs: the env marker,PATHorder, program lookup and the missing-program message, a real run with its exit code, and.cmdfiles throughcmd.exe. -
src/lib/scripts/scriptsModel.test.ts,scriptRun.test.ts,nodeVersion.test.tsandsrc/lib/terminal/runs.test.ts.
- A new manifest kind needs a parser, a
ScriptKind, a case inscriptArgsand a row in the usage page table. - A new version manager needs a layout in
node_versions.rsand a line in Platforms and Signing when it is Windows only. - Retake
scripts-panel.png,scripts-run-tab.pngandscripts-node-version.pngafter visible changes. See Docs and Screenshots.
None yet.
These pages are generated from docs/wiki. To correct something, open a pull request against the source file; edits made here are overwritten.
Using Nibtree
- Getting Started
- Welcome Screen
- Workspaces
- Files Panel
- File Operations
- File Icons
- Rounded Panels
- Editor and Tabs
- Pin Reorder and Wrap Tabs
- Single Tab Title
- Split Editor
- New File and Unsaved Changes
- Unload Hidden Tabs
- Editing Code
- Code Appearance
- Markdown Editor
- Image and PDF Preview
- Search Everywhere
- Recent Files
- Navigation Bar
- Find and Replace
- Changes and Commits
- Sign In Prompts
- Commit Box Layout
- Repository Actions
- Commit Options
- Ignoring Files
- Diffs
- Inline Diffs
- Staging View
- Revert a Change
- Resolving Conflicts
- Merge Tool
- Blame
- History and Log
- Merge Commits
- Branches and Tags
- Branches Popup
- Remotes
- Stashes
- Shelf
- Git Menu
- Git Dialogs
- Interactive Rebase
- Worktrees
- AI Agents
- AI Tasks
- AI Usage
- Keep Computer Awake
- Submodules
- Git LFS
- GitHub
- Git Console
- Terminal
- Terminal Features
- Scripts
- Navigation
- Menus
- Settings
- Settings Search
- Color Themes
- Settings Terminal and Automation
- Settings Files
- Updates
- Status Bar and Help
- Notifications
- Memory Use
- Clear Cache
- MCP and CLI
- Git Mergetool
- Keyboard Shortcuts
- Keyboard Shortcuts Editor
- Troubleshooting
- Troubleshooting Git
Developers
- Developer Guide
- Architecture
- Project Layout
- Backend
- How Folder Watching Works
- Folder Watching Bugs We Fixed
- How Workspace Files Work
- How the Preview Scheme Works
- Backend Services
- How Terminal Features Work
- Terminal Bugs We Fixed
- Frontend
- How the Rich Markdown Editor Works
- Rich Markdown Bugs We Fixed
- Git Menu Links
- Menu Keys and Routing
- Frontend Modules
- Blame Bugs We Fixed
- Project Color And Title Bar
- One Diff View
- Diff Bugs We Fixed
- Merge Tool Layouts
- Merge Tool Bugs We Fixed
- Color Theme Bugs We Fixed
- How the Connected Diff Works
- Rounded Panels Bugs We Fixed
- Update Bugs We Fixed
- Status Bar Bugs We Fixed
- MCP and CLI Bugs We Fixed
- Repository Actions Bugs We Fixed
- How the Changes Tab Works
- CodeMirror Patterns
- How the Cursor Works
- How Editor Features Work
- How the Path Bar Works
- Commands and Events
- Settings Reference
- Commands Workspace and Changes
- Commands Branches and Remotes
- Commands History and Extras
- Commands App and Tools
- Testing
- Test Suites
- Debugging
- Debugging with MCP
- Measuring Setting Memory
- How Terminal Memory Is Measured
- How Markdown Diagrams Work
- Releases and CI
- Publishing the Wiki
- Versioning and Changelog
- Browser Version Packages
- Browser Release Checks
- Docker Image
- Platforms and Signing
- Windows Support
- Windows Bugs We Fixed
- Windows MCP and CLI
- Docs and Screenshots
- UI Library
- UI Library MCP
- UI Library Bugs
- UI Library Migration
- Contributing
How features work
- Welcome screen
- Workspaces and folders
- Files panel
- File operations
- File icons
- Editor and tabs
- Pin, reorder and wrap tabs
- Single tab title
- Split editor
- New File and unsaved changes
- Unload hidden tabs
- Editing code
- Code appearance
- Markdown editor
- Image and PDF preview
- Search Everywhere
- Recent Files
- Navigation Bar
- Find and replace
- Changes and commits
- Sign-in prompts
- Commit box layout
- Repository actions
- Commit options
- Ignoring files
- Diffs
- Inline diffs
- Staging view
- Revert a change
- Resolving conflicts
- Merge tool
- Blame
- History and log
- Merge commits
- Commit tabs
- Branches and tags
- Branches popup
- Remotes
- Stashes
- Shelf
- Git menu
- Git dialogs
- Interactive rebase
- Worktrees
- AI agents
- AI usage
- Keep computer awake
- AI tasks
- Submodules
- Git LFS
- GitHub account
- Git Console
- Back and Forward
- Integrated terminal
- Scripts tool window
- Menu bar
- Settings
- Search in Settings
- Color themes
- Rounded panels
- Updates and release channels
- Status bar and help links
- Notifications
- Memory readout and memory log
- Clear Cache
- MCP server and command line tool
- git mergetool mode