feat(automations): "Same workspace" option and simpler session chip

Merged
KI
24d ago
+851-389

Replaces #9347, which GitHub closed when its base branch (#9377) was deleted on merge. The review there is still the reference.

Summary

  • The automation editor sentence now reads "using workspace and session mode":
    • Workspace: "New workspace" (each run makes its own), "Same workspace" (the first run makes one, later runs reuse it), or a workspace picked by hand.
    • Session mode: "Start fresh" (a new agent conversation each run) or "Continue" (the agent picks up where the last run left off). It only shows when runs share a workspace.
  • "Same workspace" works with both session modes and keeps reading "Same workspace" after the first run. The menu shows "Reusing name" once a run has made the workspace.

Why / Context

Before, continuing a session needed a workspace picked by hand. The old wording was also confusing: "using New workspace … running continuing the last session" reads as a contradiction, and it doesn't say that anything is kept.

How It Works

  • API: new optional reuseWorkspace on automation.create and automation.update, and on the detail output.
  • planTarget:
    • Picking a different workspace turns reuse off. A client sending back the workspace a run kept (older desktops send the whole draft) leaves reuse on.
    • Asking to continue with no pin, without saying anything about reuse, is read as reuse, so the CLI's --continue-session without --workspace works.
    • Continue is dropped when there is neither a pin nor reuse, which is the old behaviour.
  • Dispatch: when reuseWorkspace is on, the workspace a run creates becomes the pin (pinCreatedWorkspace), unless someone pinned one in the meantime. This covers both local and cloud runs, and runs that replace a deleted pinned workspace. replacePin no longer turns continue off.
  • Desktop: WorkspacePicker and CloudWorkspacePicker share a new RunWorkspaceItems component for the "New / Same" options and their hints. SessionModePicker now reads "Start fresh / Continue", joined to the workspace chip by "and".
  • CLI: removed the client-side --session + --continue-session refusal; help text and cli-reference.mdx updated.

Compatibility

  • Input and output fields are only added.
  • Older desktops don't send reuseWorkspace. Their saves keep the existing value, and they show a kept workspace by name.
  • Released CLIs still refuse --session --continue-session locally, which is harmless.

Manual QA Checklist

Not yet done in a running app:

  • Local, "Same workspace" + "Continue": run 1 makes a workspace, and run 2 continues its session in that workspace. The chip still reads "Same workspace", and the menu says "Reusing name".
  • Local, "Same workspace" + "Start fresh": run 2 reuses the workspace with a new agent conversation.
  • Cloud, both modes: same as above.
  • "New workspace": the session chip is hidden, and every run makes its own workspace.
  • Pick a workspace by hand: "Same workspace" turns off, and the session chip stays.
  • Delete the kept workspace: the next run makes a new one and keeps that.
  • Project-less automation: the options read "New session" / "Same session".

Review follow-ups (from #9347)

  • The auto-pin now records the run's host with a local workspace, so an automation with no fixed device goes back to the device that has it.
  • The editor sends a pin only when the user changed it, so saving a draft loaded before a run kept a workspace no longer unpins it.
  • MCP tool descriptions no longer say continuing needs a pinned workspace.
  • Not changed: for pull request triggers with "Same workspace", later PRs run in the first PR's checkout. That follows from the option; use "New workspace" for PR automations.

Testing

  • bun test src/router/automation in packages/trpc: 49 pass. New planTarget tests cover reuse with and without continue, sending the kept pin back, picking another workspace, and changing device. I checked that the "picking another workspace" test fails when that rule is removed.
  • bun test on the desktop automations routes: 192 pass.
  • bun run typecheck passes in packages/trpc and packages/cli. In apps/desktop, the only errors are TS1149 file-casing errors from this worktree's path, none in changed files.
  • bun run check:i18n passes. I translated the 8 new strings into all 17 locales.
  • biome check passes on the changed files.
  • pinCreatedWorkspace has no unit test: packages/trpc has no database harness.

Summary by CodeRabbit

  • New Features
    • Automations can now reuse the workspace created by their first run, even when no workspace is preselected.
    • Choose whether runs start a fresh agent conversation or continue the previous one. Workspace and session choices are available for both local and cloud runs.
    • CLI automation commands support continuing sessions without requiring a pinned workspace.
  • Improvements
    • Workspace and session settings are clearer, with updated labels and descriptions.
    • Updated translations for the revised automation options across supported languages.

Summary by cubic

Gives automations a "Same workspace" option so runs can continue an agent session without pinning a workspace by hand.

  • The editor now offers "New workspace" or "Same workspace" (the first run creates one, later runs reuse it) and "Start fresh"/"Continue" session modes.
  • reuseWorkspace is a new optional field on create/update; when set, the first run's workspace becomes the pin.
  • Picking a different workspace turns reuse off; continue no longer clears when the host or project changes.
  • Older clients that don't send reuseWorkspace keep the existing value; the CLI no longer refuses --session with --continue-session and its help and docs updated.