fix(desktop): install plugins on disk without a CLI login

Closed
HA
7h ago
+499-84

What & why

Fixes SUPER-2155.

Installing, uninstalling, enabling or disabling a plugin from the desktop app did nothing on disk unless the user had separately run superset auth login. Desktop ran superset plugins install|uninstall|enable|disable. Those commands go through the CLI's auth middleware, which threw "Not logged in" before anything was written. The call was fire-and-forget (void queuePluginCli(...)) and its error went to log.warn, so the UI still showed "installed". The plugin's skills never reached any agent.

Changes:

  • CLI: a new hidden superset plugins local <install|uninstall|enable|disable> <plugin> command. It uses skipMiddleware: true and changes this machine only, through the existing installPlugin / removePlugin / setPluginEnabled in lib/plugins/install.ts. installed_plugins.json is still the one record every provisioner reads.
    • Uninstalling or disabling a plugin that isn't on this machine does nothing and succeeds, which is the state this bug left behind. Enabling a plugin that isn't on this machine installs it.
  • Desktop: plugin-installs.ts now runs plugins local and awaits it. The local-db record is written only after the CLI step succeeds, so a failed install doesn't leave a record that the boot-time MCP sync would turn into a half-installed plugin. A failure now rejects the tRPC mutation, and the renderer's existing "Install failed" / "Uninstall failed" toasts show the CLI's error.
  • I removed the SUPERSET_CLI_AUDIENCE: "internal" override. plugins is public, so the override did nothing.

I didn't pass the desktop's bearer as SUPERSET_API_KEY, the ticket's other option. The renderer already makes the account calls itself (cloudTrpc.plugins.* in usePluginMutations), so the CLI's account calls would have been a second write racing it. For uninstall, the losing call gets NOT_FOUND, and the renderer would show "set up on this machine, but not on your account".

Behaviour change: installing now waits for the CLI to finish, including the first marketplace download, so the busy state lasts longer (up to the existing 60 s timeout).

Follow-up commit (review feedback)

  • Desktop passes name@superset to plugins local. A bare name failed when another marketplace offered the same name, and uninstall could remove the other marketplace's copy.
  • plugins local reports the MCP config write error as mcpError, as plugins install already does. Desktop shows it as a warning toast ("Agents cannot reach {plugin}'s tools") on install and update. This addresses Greptile's "Tool setup failures stay hidden".
  • Toggling a plugin that isn't in the catalog no longer runs the CLI.
  • A CLI timeout shows "The plugin change did not finish in 60 seconds." instead of the raw command line.
  • Two new strings, translated in every locale; check:i18n passes.
  • Rewrote the stale auth/mcp-headers comment that still reasoned from the removed audience override.

Tested: with ~/.claude.json symlinked into a read-only directory (the Nix case), plugins local install linear@superset exits 0 and returns the EACCES text in mcpError. New desktop tests cover mcpError parsing past the [agent-setup] stdout logs, and the timeout message with a 50 ms timeout. CLI 448, i18n 166 and desktop 8869 tests pass, and typecheck is clean.

How I tested it

  • I reproduced the bug on main: superset plugins enable linear with no login and an empty HOME gives Error: Not logged in and exit 1.
  • With this branch, I ran the CLI from source with no login, an empty HOME/SUPERSET_HOME_DIR, and this repo as the default marketplace. plugins local disable autumn (not installed) did nothing and exited 0. install, disable and uninstall then succeeded and updated installed_plugins.json each time. plugins local enable linear installed linear-duplicate-sweep, linear-file-issue and linear-project-status into ~/.agents/skills.
  • New tests:
    • packages/cli/src/commands/plugins/local/command.test.ts: the command skips the auth middleware, and uninstall or disable of an absent plugin does nothing.
    • apps/desktop/src/main/lib/plugin-cli.test.ts: runs plugins local … against a stub CLI script, and checks that a CLI failure rejects with the CLI's Error: line.
  • CLI: bun test (448 pass) and typecheck pass. Desktop: bun test (8867 pass) and typecheck pass.
  • bun run lint fails only on an untracked local .claude/settings.local.json, which is not in the repo. It fails the same way on main.
  • Not tested: the install flow in the running desktop app.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too)
  • "Allow edits from maintainers" is checked on fork PRs
  • I have signed the CLA (the bot asks on your first PR)

Summary by cubic

Fixes SUPER-2155: installing, uninstalling, enabling, or disabling a plugin from the desktop app did nothing on disk unless the user had separately run superset auth login. The auth-required CLI commands threw "Not logged in" before writing anything; the error was swallowed into a log line while the UI reported success, so the plugin's skills never reached any agent.

The desktop now runs a new hidden plugins local <install|uninstall|enable|disable> <plugin> CLI command that skips the auth middleware and changes only this machine. It passes name@superset so a bare name can't resolve to a different marketplace and uninstall can't remove another marketplace's copy. The desktop awaits the CLI step and writes its installed_plugins.json record only after it succeeds; a failure rejects the tRPC mutation, so the existing "Install failed"/"Uninstall failed" toasts show the CLI error.

  • Uninstalling or disabling a plugin that isn't on this machine is a no-op; enabling an absent plugin installs it, and toggling a plugin not in the catalog skips the CLI.
  • When the CLI can't write the MCP config, install and update show a warning toast ("Agents cannot reach {plugin}'s tools") so a read-only agent config no longer hides that the plugin's tools are unavailable.
  • Behavior change: installing now waits for the CLI to finish, including the first marketplace download, so the busy state lasts longer (up to the existing 60 s timeout); a timeout reports "did not finish in N seconds" instead of the raw command line.

Summary by CodeRabbit

  • New Features

    • Added local plugin actions for installing, removing, enabling, and disabling plugins. Actions on plugins that aren’t installed return a clear “not installed” result.
  • Bug Fixes

    • Plugin installation, removal, and enablement now wait for the operation to finish before updating the app’s saved state. If the bundled command fails, the change is not saved and an error is reported.
    • When the bundled command is unavailable, plugin changes can still be saved.
    • Plugin changes report when agents can’t reach a plugin’s tools, and timeout errors explain when an operation takes too long.