Skip to content

feat(kit): let launchers offer selectable launch roots#448

Merged
antfu merged 3 commits into
mainfrom
feat/launcher-root-selection
Jul 21, 2026
Merged

feat(kit): let launchers offer selectable launch roots#448
antfu merged 3 commits into
mainfrom
feat/launcher-root-selection

Conversation

@antfubot

Copy link
Copy Markdown
Collaborator

Description

Adds a launch-root picker to launcher docks. When a launcher offers more than the default working directory to run in, the user can now choose where it launches from a dropdown on the launcher card — instead of always spawning in the Vite project root.

What changed

  • KitcreateProcessLauncher gains an optional roots option (DevToolsLaunchRoot[] = { value, label, description? }, where value is the absolute path used as the spawn cwd). The launcher entry type is augmented locally (DevToolsViewLauncher) with launcher.roots; since it's optional, a plain hub DevframeViewLauncher stays assignable. The process factory now receives the launch payload and can read payload.root.
  • CoreViewLauncher.vue renders a native <select> above the launch button whenever the entry carries roots (first root selected by default, disabled while loading). The selection travels with the launch: the devtoolskit:internal:docks:on-launch RPC now accepts a payload and forwards it to the bound command via commands.execute(command, payload).
  • Vitest — the Vitest UI launcher discovers its roots eagerly at setup: the project root, the workspace root, and every directory holding a vitest.config.* / vitest.workspace.* / vite.config.* in the workspace (deduped by absolute path). vitest --ui then spawns in the selected root.

The selection is ephemeral client state — no persistence — kept intentionally small; a schema-driven / json-render form for richer launch inputs is left for a follow-up.

Linked Issues

Additional context

Boundary note for reviewers: roots lives on the hub-owned launcher entry type, augmented locally in kit for now rather than upstreamed to @devframes/hub — worth deciding whether it should move upstream.

This PR was created with the help of an agent.

Add an optional `roots` field to launcher dock entries so a process
launcher can present a root picker before it spawns. The client renders a
`<select>` above the launch button; the chosen root is forwarded through
the on-launch bridge to the bound command and handed to the process
factory as `payload.root` (used as the spawn cwd). The Vitest launcher
populates its roots with the project root, workspace root, and every
directory holding a Vitest/Vite config in the workspace.
@pkg-pr-new

pkg-pr-new Bot commented Jul 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vitejs/devtools

npm i https://pkg.pr.new/@vitejs/devtools@448

@vitejs/devtools-kit

npm i https://pkg.pr.new/@vitejs/devtools-kit@448

@vitejs/devtools-oxc

npm i https://pkg.pr.new/@vitejs/devtools-oxc@448

@vitejs/devtools-rolldown

npm i https://pkg.pr.new/@vitejs/devtools-rolldown@448

@vitejs/devtools-vite

npm i https://pkg.pr.new/@vitejs/devtools-vite@448

@vitejs/devtools-vitest

npm i https://pkg.pr.new/@vitejs/devtools-vitest@448

commit: 3fda649

antfubot added 2 commits July 21, 2026 09:20
A spawned child process has no TTY, so `vitest --ui` defaulted to a single
run and exited, tearing down the server before the embedded UI could open
its WebSocket ("Cannot connect to the server in 60 seconds"). Force
`--watch` so the server stays up. Also sort the config-derived launch
roots for a stable, predictable picker order.
Exclude the project root (cwd) from the launch-root picker unless it
actually contains a Vitest/Vite config, since running Vitest from a
config-less directory isn't meaningful.
@antfu
antfu merged commit 6dd7807 into main Jul 21, 2026
10 checks passed
@antfu
antfu deleted the feat/launcher-root-selection branch July 21, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants