Archive: also cancel open Paperclip issues to clear agent widget
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 32s

When a case is archived, the legal-ai UI's AgentStatusWidget kept showing
"agents started working, waiting for first report" because related
Paperclip issues remained in 'todo' / 'in_progress' status. Concrete
example: case 1130-25 had two open issues (CMP-15 ניתוח תכנוני, CMP-21
כתיבת החלטה) that lingered after the case was finalized; 1194-25 had
two more (CMP-37, CMP-44).

Extended pc_archive_project to also UPDATE issues SET status='cancelled',
cancelled_at=now() WHERE project_id matches AND status IN
('backlog','todo','in_progress','blocked','in_review'). Returns the list
of cancelled issues so the toast can announce the count.

Updated cases.ts ArchiveResult.paperclip.issues_cancelled type and the
toast message in case-archive-action to surface "(N משימות פתוחות בוטלו)"
when relevant.

Restore is intentionally unchanged — we don't auto-recreate cancelled
issues; if work needs to resume, a fresh issue should be created.

Stale issues for 1130-25 / 1194-25 cancelled directly in DB as a one-off
cleanup (CMP-15, CMP-21, CMP-37, CMP-44).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-27 19:14:12 +00:00
parent 2b7f291928
commit 7d86ed4a62
3 changed files with 36 additions and 5 deletions

View File

@@ -19,7 +19,11 @@ import { useArchiveCase, useRestoreCase, type ArchiveResult } from "@/lib/api/ca
function paperclipMessage(res: ArchiveResult, action: "archive" | "restore"): string {
const verb = action === "archive" ? "אורכן" : "שוחזר";
switch (res.paperclip?.status) {
case "archived":
case "archived": {
const cancelled = res.paperclip.issues_cancelled?.length ?? 0;
const issuesNote = cancelled > 0 ? ` (${cancelled} משימות פתוחות בוטלו)` : "";
return `התיק ${verb}. גם הפרויקט ב-Paperclip${issuesNote}.`;
}
case "restored":
return `התיק ${verb}. גם הפרויקט ב-Paperclip ${verb}.`;
case "not_found":

View File

@@ -100,7 +100,13 @@ export type ArchiveResult = {
status: string;
case_number: string;
archived_at?: string | null;
paperclip?: { status: string; project_id?: string; archived_at?: string | null; message?: string };
paperclip?: {
status: string;
project_id?: string;
archived_at?: string | null;
message?: string;
issues_cancelled?: Array<{ identifier: string; title: string }>;
};
};
export function useArchiveCase(caseNumber: string | undefined) {