multica/server/pkg/db/queries
LinYushen 09764c5f51
feat(agent): replace hard delete with archive/restore (#346)
* feat(agent): replace hard delete with archive/restore

Replace agent deletion with soft archive pattern. Archived agents
are preserved in the database with all historical references intact
but cannot be assigned, mentioned, or trigger tasks.

Backend:
- Add archived_at/archived_by columns to agent table (migration 031)
- Replace DELETE /api/agents/{id} with POST /api/agents/{id}/archive
- Add POST /api/agents/{id}/restore endpoint
- ListAgents excludes archived by default (?include_archived=true to include)
- Skip archived agents in task triggers (on_assign, on_comment, on_mention)
- Block assignment to archived agents
- Cancel pending tasks on archive
- New events: agent:archived, agent:restored (replacing agent:deleted)

Frontend:
- Agent type includes archived_at/archived_by fields
- Mention autocomplete and assignee picker filter out archived agents
- Agent list shows archived agents with muted styling
- Agent detail shows archive banner with restore button
- Delete button replaced with Archive button and updated confirmation dialog
- API client: archiveAgent/restoreAgent replace deleteAgent

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(agent): self-review fixes for archive feature

- Fix: workspace store now fetches agents with include_archived=true
  so archived agents are actually visible in the frontend (the archived
  UI was dead code before — ListAgents excludes archived by default)
- Fix: add error logging for CancelAgentTasksByAgent in ArchiveAgent
- Fix: add idempotency guards — return 409 Conflict when archiving
  an already-archived agent or restoring a non-archived agent
- Fix: revert unnecessary extra GetAgent query in ReconcileAgentStatus
  (archived agents won't have running tasks after CancelAgentTasksByAgent)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 17:33:52 +08:00
..
activity.sql fix(activity): address code review feedback and improve timeline UX 2026-03-29 00:21:46 +08:00
agent.sql feat(agent): replace hard delete with archive/restore (#346) 2026-04-02 17:33:52 +08:00
attachment.sql fix(upload): link attachments to comments via client-side ID tracking 2026-03-31 16:47:27 +08:00
comment.sql feat(api): strict workspace isolation + agent parity fixes 2026-03-30 16:49:13 +08:00
daemon_token.sql feat(daemon): add authentication for daemon API routes 2026-03-31 16:19:02 +08:00
inbox.sql fix(inbox): remove hardcoded 50-item limit from inbox list query 2026-03-31 18:36:41 +08:00
issue.sql Revert "feat: add global issue search" 2026-04-01 22:24:35 +08:00
issue_reaction.sql feat(reactions): add emoji reactions for comments and issue descriptions 2026-03-30 22:37:59 +08:00
member.sql feat(server): implement full REST API with JWT auth and real-time WebSocket 2026-03-22 11:50:03 +08:00
personal_access_token.sql feat(auth): email verification login and personal access tokens 2026-03-26 14:32:30 +08:00
reaction.sql feat(reactions): add emoji reactions for comments and issue descriptions 2026-03-30 22:37:59 +08:00
runtime.sql feat(tasks): add coalescing queue and task lifecycle guards 2026-03-29 17:52:35 +08:00
runtime_usage.sql feat(runtimes): add usage charts, activity heatmap, and hourly distribution 2026-03-29 15:44:10 +08:00
skill.sql feat(api): strict workspace isolation + agent parity fixes 2026-03-30 16:49:13 +08:00
subscriber.sql feat(notifications): replace hardcoded inbox notifications with subscriber-driven model 2026-03-28 19:33:20 +08:00
task_message.sql feat(agent): stream live agent output to issue detail page 2026-03-30 22:53:28 +08:00
user.sql feat(server): implement full REST API with JWT auth and real-time WebSocket 2026-03-22 11:50:03 +08:00
verification_code.sql feat(auth): email verification login and personal access tokens 2026-03-26 14:32:30 +08:00
workspace.sql feat(issues): add human-readable issue identifiers (e.g. JIA-1) 2026-03-29 16:49:55 +08:00