multica/server/internal/handler
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.go feat(upload): signed URLs for CLI + eager load attachments on comments 2026-03-31 15:42:10 +08:00
activity_test.go feat(activity): unified activity timeline with comment reply support 2026-03-28 21:53:08 +08:00
agent.go feat(agent): replace hard delete with archive/restore (#346) 2026-04-02 17:33:52 +08:00
auth.go feat(upload): add file upload API with S3 + CloudFront signed cookies 2026-03-31 14:41:17 +08:00
comment.go feat(agent): replace hard delete with archive/restore (#346) 2026-04-02 17:33:52 +08:00
daemon.go fix(runtime): display multica CLI version instead of agent CLI version (#332) 2026-04-02 14:40:35 +08:00
file.go fix(upload): remove file type allowlist to support all file types (#329) 2026-04-02 13:55:50 +08:00
handler.go feat(runtime): support CLI update from web runtime page (#331) 2026-04-02 14:12:49 +08:00
handler_test.go fix(auth): enforce auth on daemon API routes (#224) 2026-03-31 16:13:58 +08:00
inbox.go fix(inbox): remove hardcoded 50-item limit from inbox list query 2026-03-31 18:36:41 +08:00
issue.go feat(agent): replace hard delete with archive/restore (#346) 2026-04-02 17:33:52 +08:00
issue_reaction.go feat(reactions): add emoji reactions for comments and issue descriptions 2026-03-30 22:37:59 +08:00
personal_access_token.go feat(auth): email verification login and personal access tokens 2026-03-26 14:32:30 +08:00
reaction.go feat(inbox): auto-scroll to comment from notification and add jump-to-bottom button 2026-04-02 13:43:05 +08:00
runtime.go refactor(server): consolidate workspace permission checks into middleware 2026-03-30 03:40:20 +08:00
runtime_ping.go feat(runtimes): add Runtimes tab with usage tracking and connection test 2026-03-26 18:28:36 +08:00
runtime_update.go feat(runtime): support CLI update from web runtime page (#331) 2026-04-02 14:12:49 +08:00
skill.go fix(agent): allow members to manage skills on their own agents 2026-04-02 12:25:19 +08:00
subscriber.go feat(api): strict workspace isolation + agent parity fixes 2026-03-30 16:49:13 +08:00
subscriber_test.go feat(notifications): replace hardcoded inbox notifications with subscriber-driven model 2026-03-28 19:33:20 +08:00
trigger_test.go fix(server): @all mentions should not trigger agent execution 2026-04-02 00:33:21 +08:00
workspace.go refactor(server): consolidate workspace permission checks into middleware 2026-03-30 03:40:20 +08:00