feat(desktop,service,database): start an agent from an issue, and move its issue into progress as it starts
Merged
DA
12d ago+518+518+012345678901234567890123456789-71-71-01234567890123456789
Summary
This is part (b) of "Link issues to tasks and agents" in the Improve Issues board plan. It builds on #3648, which linked tasks to issues and added Start task…, and it adds Start agent… plus the move to In progress.
- Behavior change: an issue moves to In progress when an agent starts on a task linked to it. It only moves issues in Backlog or Todo that aren't archived. Once eve has taken the agent, the service (
startCodingAgent→beginIssueWork) makes the move as oneUPDATE, gated on the starter's membership of the issue's workspace. It locks the issue's row before reading the clock, aschangeIssuedoes. It's idempotent, it never moves an issue back, and a failure is logged without failing the Start. It fires for every agent started on such a task: forks, continues, and later agents included. This is the one change in this work that a user doesn't trigger by a press. - Start agent… sits beside Start task… in the issue's ⋯ menu and in each card's or row's menu. It opens the New task card as a new agent's:
- The title reads "New agent from ACME-7".
- There's no Plan switch: the task starts without its planning phase, and the kept switch setting isn't touched.
- It asks for a repository ("Choose a repository for the agent to work in.").
- Pressing Start agent starts the task linked to the issue. Once the host has that task open with its repository, the window presses the task's own Start: the agent gets the plan plus the issue block from #3648, on the account's default model, and its tab opens. If the agent doesn't start, the reason shows beside the task's Start, as for any other Start. Reusing the task's Start avoids a second start path.
- Out of scope: agents that automations start with no task can't link an issue, so starting one never moves an issue.
Evidence
pnpm check:affected: every task passed except@luke/desktop#typecheck, which the sandbox killed for running out of memory (exit 137). It passes when run alone (pnpm --filter @luke/desktop typecheck).check:migrationspasses.- New tests, each failing without this change:
packages/database/src/models/__tests__/issue-store.test.ts:- Backlog and Todo move once; In progress, Done, Canceled, and archived issues stay put, and a settled issue's
updatedAtdoesn't move. - An account outside the issue's workspace moves nothing.
- Backlog and Todo move once; In progress, Done, Canceled, and archived issues stay put, and a settled issue's
packages/service/src/agents/coder-host/coder-start.test.ts: an agent started on a task from an issue moves it into progress, leaves a Done one as it was, and touches no other issue.apps/desktop/src/renderer/tasks/use-tasks-tab.test.ts: Start agent… starts the task with no planning and linked to the issue. No agent starts before the task is open; once it is, its Start is pressed and the agent's tab opens. A failure shows its reason beside the Start. A Start agent… whose task the developer left before its agent could start starts nothing when the task is opened again.apps/desktop/src/renderer/tasks/new-task-dialog.test.ts: the new agent's card has no Plan switch, asks for a repository, and starts without planning with an agent asked for.apps/desktop/src/renderer/desktop/issues-page.test.ts: Start agent… from the issue's ⋯ and from a card's menu, and the page itself moves no issue.
Invariants
-
./scripts/check.shgreen. (CI) - JSON Schema goldens unchanged.
- Every behavior change has, in this PR, the test that fails without it; no change-detector test added.
- Gateway envelope goldens unchanged.
- No new
astype assertion. - No
Effect.runPromise/runSync/runForkoutside the edges. - No new raw async primitives.
- No discarded Effect.
- Test count rises by the 7 tests listed above.
- No hand-rolled file replaced.
- No
CLAUDE.md/AGENTS.mdsentence names a changed part. -
PRIVACY.mdunchanged. - Package deps unchanged.
- Barrel/door rule unchanged.
Notes
- This changes the hosted service, so it needs a
./scripts/run.sh --previewrun on a Mac before merge. Don't arm auto-merge until that run is done. - If #3664 (the issue peek) lands first, this rebases onto it and puts Start agent… in
IssueMenubeside Start task…, so the peek offers it too.
Made with Luke