feat(desktop,host-service): import project setup from external tools

Merged
KI
2mo ago
+5257-76

What

Teams moving to Superset often already have workspace setup written for another tool. This detects it in a project's repo root and turns it into Superset project lifecycle scripts, after showing exactly what will be written.

Detected files, in this order (all candidates are offered when there are several):

ToolFiles
Conductorconductor.json
Orcaorca.yaml, .worktreeinclude
Codex.codex/environments/environment.toml
cmux.cmux/cmux.json, then cmux.json
T3 Codet3.json

Mapping, variable rewrites, and what is not imported are in the new docs page apps/docs/content/docs/switch-to-superset.mdx.

Where it shows up

  • Sidebar setup card: when a project has no Superset scripts and a tool file exists, the card reads "Found Conductor setup" with an Import button. The success toast links to the project's scripts.
  • Project settings → Project lifecycle scripts: an "Import from …" button next to the Setup / Teardown / Run tabs while an import would change something.
  • Dialog: source picker, the commands to be written, a preview of any script file, current vs imported for fields it replaces ("Replace and import"), and a "Not imported" list with the reason for each field.

How

  • packages/host-service/src/runtime/setup/import/: one pure parser per source with Orca's limits (256 KiB file, 64 KiB field, list and line caps), plus variable rewrite, layout, conflict check and apply. Unit tests per source on small fixtures.
  • Multi-line scripts. Superset joins entries with &&, and the editor treats each line as a command. A script where every line is a complete command is imported as one entry per line (comments dropped). Anything else (if/fi, loops, functions, \ continuations, heredocs, inline comments) is written to .superset/<key>.sh with bash + set -e, and the config runs bash "$SUPERSET_ROOT_PATH/.superset/<key>.sh". Splitting those safely is not possible in general, and keeping a visible entry in config.json keeps the editor honest about what runs. A later import that replaces such a script with plain commands deletes it, only if it carries the import header.
  • Orca shared and copied paths become guarded if blocks (skip a missing source or an existing destination, as Orca does), so an Orca setup with them always goes to setup.sh.
  • Never overwrites silently. importSetup refuses with CONFLICT unless overwrite is set, and refuses a malformed config.json with BAD_REQUEST (the dialog warns before Import and disables it).
  • tRPC: two new host-service procedures, config.getSetupImportCandidates and config.importSetup. Nothing existing changed. The renderer treats a host without them as "no candidates" (retry: false).
  • Run button refresh: the v2 Run button reads from a per-host query client, so imports and scripts-editor saves did not refresh it. Added invalidateHostServiceQuery in @superset/workspace-client.

Also

  • SUPERSET_WORKSPACE_NAME in v2 terminals. The docs promise it and v1 sets it; v2 left it out when host-service had no name column. It now comes from workspaces.name, with no fallback to the branch (as #3184 asked). Scripts that use it, including this repo's .superset scripts, get the display name now instead of falling back to the folder name.
  • bun.lock also drops the stale apps/discord-triage entry left by #8474.
  • i18n: all new strings translated into every locale; check:i18n passes.

Validation

Films, edge-case table and screenshots (org-only page): https://app.superset.sh/page/import-setup-from-other-tools-verification-aak94k

  • Dev desktop app over CDP with real input, seven fixture repos. Both entry points, replace, recovery when files change mid-dialog, broken config, keyboard, light theme, Japanese, a new workspace actually running the imported setup (and printing $SUPERSET_WORKSPACE_NAME), Orca links and copies. No console errors.
  • Tests: host-service import, setup, config router and terminal env suites pass (145), i18n (164). Full host-service run: 2 failures (session folder dedupe, terminal disposal with a real daemon); full desktop run: 36 failures, all in tests that drive real git or a login shell. None are in code this branch touches; I did not re-run them on main to confirm.
  • Lint clean. Typecheck shows no errors in this branch's files; locally there are better-auth type errors in packages/auth/packages/trpc from two installed copies of better-auth, which this branch doesn't touch.
  • Docs pass the Vale prose rules.

Not fixed here (existing)

  • Escape inside project settings closes a dialog and also navigates back a level (same with the Delete project dialog).
  • A malformed config.json shows as empty in the scripts editor, and saving there replaces it (updateConfig resets it). The import refuses to do that.

Summary by cubic

Imports an existing project setup from Conductor, Orca, cmux, T3 Code, or Codex into Superset project lifecycle scripts after showing exactly what will be written. Also sets SUPERSET_WORKSPACE_NAME in v2 terminals, which previously was never populated there.

Import behavior

  • Detects conductor.json, orca.yaml with .worktreeinclude, .codex/environments/environment.toml, .cmux/cmux.json or cmux.json, and t3.json in the project's repo root; every candidate is offered when there are several.
  • The import appears in the sidebar setup card and in Project settings → Project lifecycle scripts, with a preview of every command and script file, explicit replacement confirmation, and a list of fields that are not imported along with the reason.
  • Simple multi-line scripts become one entry per line; anything with if/fi, loops, functions, \ continuations, heredocs, inline comments, or multi-line $(...)/backticks is written to .superset/<key>.sh and run via bash with set -e. Imported labels are shown as "to be imported" and replacements as "Replaces current commands".
  • Orca shared and copied paths become guarded if blocks so a missing source or an existing destination is skipped; copy/link destinations that are dangling symlinks are skipped and paths are ./-prefixed.
  • The import never overwrites silently: existing setup requires an explicit overwrite confirmation; a malformed .superset/config.json is refused with BAD_REQUEST; writes refuse to pass through a symlink or a .superset dir resolving outside the project, and an unresolvable project root is refused outright (the dialog warns and disables Import); and importSetup takes the preview's fingerprint and returns CONFLICT if the file changed since preview. Writes are atomic via temp file + rename using node:fs/promises.
  • Two new tRPC procedures, config.getSetupImportCandidates and config.importSetup, are added; no existing procedure changes, and hosts that predate them are treated as having no candidates. The TOML parser rejects out-of-range \U escapes and decodes quoted table and key names, and a failing source no longer hides the others.

Also in this PR

  • SUPERSET_WORKSPACE_NAME now comes from the workspace display name in v2 terminals, with no branch fallback.
  • Adds invalidateHostServiceQuery to @superset/workspace-client so the v2 Run button and scripts editor are refreshed by imports and saves.
  • The full mapping is documented on a new "Switch to Superset" docs page, and all new strings are translated into every locale.
  • bun.lock drops the stale @superset/discord-triage entry.

Summary by CodeRabbit

  • New Features
    • Import setup scripts and configuration from Conductor, Orca, cmux, T3 Code, and Codex into project lifecycle scripts.
    • Review script previews, detected changes, conflicts, and items that cannot be imported before confirming.
    • Start imports from project settings or the dashboard, and choose whether to replace existing scripts when conflicts arise.
    • Imported scripts and working-directory settings are reflected in the project configuration. Unsafe import paths and invalid configuration are flagged.
  • Documentation
    • Added a guide to supported setup imports, mappings, and limitations.