Skip to content

[AIDE-99] Worktree Card Cleanup - #79

Merged
chandlerhuff merged 8 commits into
mainfrom
feature/AIDE-99-worktree-card-cleanup
Aug 2, 2026
Merged

[AIDE-99] Worktree Card Cleanup#79
chandlerhuff merged 8 commits into
mainfrom
feature/AIDE-99-worktree-card-cleanup

Conversation

@chandlerhuff

Copy link
Copy Markdown
Member

Summary

Overhauls command run management and cleans up the worktrees page. Command runs now have three concurrency modes — EXCLUSIVE, NON_EXCLUSIVE, EXCLUDED — that behave like a reader-writer lock over a target (a worktree or an agent home), so runs sharing a target no longer blindly overlap. Runs that cannot start yet explain exactly why, and the UI shows the full queue competing for the target. Agent-side, orphaned command processes left behind by a killed agent are reaped at startup, and stop requests whose agent job already ended are finished locally instead of hanging in CANCELLING. The worktrees page gets a group-by-repository view, persisted filters, new highlight colors, and tighter badges.

Changes

  • Command concurrency: new CommandConcurrency enum (EXCLUSIVE / NON_EXCLUSIVE / EXCLUDED), persisted on CommandDefinition and snapshotted onto each CommandRun via migration; dispatcher admission (admitCommandRun) acts as a reader-writer lock with queue-order tie-breaking so exclusive runs can't starve behind a stream of shared work.
  • Serialized dispatch: dispatches are chained (dispatchChain) so two interleaved dispatches cannot both see a free target and both claim it.
  • Queue explanation: evaluateCommandRunQueue derives a run's wait reason (TARGET_BUSY, QUEUED_BEHIND, AGENT_OFFLINE, WAITING_FOR_PREDECESSOR, RESTART_DELAY, etc.) from live rows, so the explanation can't drift from what the dispatcher will actually decide; surfaced as a queue field on CommandRun plus a new GraphQL subscription filter (commandRunsChanged by agent/worktree).
  • Run detail page: alert explaining why a queued run hasn't started (polled every 15s while waiting) and a queue table listing every competing run with concurrency mode, holder/blocking badges, and position.
  • Command editor: concurrency mode radio group with per-mode help text.
  • Quick actions: live-run management dropdown per command (view/terminate/restart), spinner reflects any active run for that command, multiple simultaneous runs supported, live-updates via filtered subscription.
  • Orphaned process reaping: command scripts now live under a per-agent temp prefix (sha256 of agent id); reapOrphanedCommandProcesses runs once at agent startup, signalling leftover process groups so a restarted agent doesn't collide with a still-running server/build.
  • Stop request fix: cancel paths finish the run directly when its job has already reached a terminal state, so runs stop waiting forever in CANCELLING.
  • Busy-codebase retries: the AgentJob_codebaseId_active_key conflict is now recognized (isActiveCodebaseJobConflict) and translated to CodebaseBusyError; command dispatch keeps the run queued and retries instead of failing on a busy codebase.
  • Worktrees page: group-by-repository view (or agent view), remembered filters/group-by in localStorage, agent name badge on each worktree, dirty badge also for staged changes, commit and ahead/behind badges hidden when zero, new highlight colors (lavender, maroon, brown, olive, navy) backed by custom Tailwind theme hues, fixed swatch hover/selected states, and a QuickActionsRow that puts workflow and command quick actions on one responsive line.
  • i18n: new strings added across en, de, es, fr.

Ticket: AIDE-99

- Combine workflow and command quick actions into a single row with a separator that hides when the groups wrap

- Add group-by-agent/repository toggle and persist it along with the worktree filters in localStorage
Show the dirty badge when a worktree has staged changes, not only unstaged ones, so cards and table rows reflect the full repo state.
Add five new worktree highlight/tag colors (lavender, maroon, brown, olive, navy) with matching Tailwind theme colors, tag classes, swatches, and card surfaces. Swatches no longer wash out to gray on hover or selection, and clear-highlight moved from the toggle group into a button beside the menu label.

Translate the AgentJob_codebaseId_active_key unique violation into CodebaseBusyError in agent-control so the workflow runtime retries a busy codebase instead of leaking a raw Prisma P2002 to the UI; the conflict helper now lives in lib/codebase-busy.
A stop request for a run between attempts called cancelJob on a job the
agent had already reported back on (or that never existed), leaving the
run stuck in CANCELLING forever. Treat terminal job statuses as
non-cancellable and close the run out directly instead.
Commands run detached so their whole process tree can be signalled as one
group, which also means they survive an agent that was killed rather than
asked to stop. A restarted run would then collide with the original — a
server holding its port, a build holding its lock.

Match leftover command scripts with pgrep by their temp-directory prefix,
signal each process group, and escalate to SIGKILL after a grace period.
Run once at startup before any job is claimed, and centralize the script
prefix constant so the matcher can never drift from the runner.
- Reap orphaned command processes only for the agent's own enrollment via a hashed marker, leaving development or second agents under the same OS account untouched
- Add DB triggers excluding command runs from sharing a codebase with git/worktree jobs in both insertion orders
- Support statuses filtering on commandRuns and agent/worktree filtering on commandRunsChanged, and use them in quick actions
Show the queue reason and the runs competing for a run's target on the
run detail page. The explanation is derived on read from the same rows
the dispatcher consults, so it cannot drift from the decision the
dispatcher will actually make: WAITING_FOR_AGENT and AGENT_OFFLINE
distinguish a job nobody claimed from an agent that is offline, and
TARGET_BUSY/QUEUED_BEHIND name the exact runs being waited on. The page
re-polls while a run waits so the explanation stays current.
@chandlerhuff chandlerhuff self-assigned this Aug 2, 2026
@chandlerhuff
chandlerhuff merged commit 117115f into main Aug 2, 2026
3 checks passed
@chandlerhuff
chandlerhuff deleted the feature/AIDE-99-worktree-card-cleanup branch August 2, 2026 23:57
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.

1 participant