fix(recovery): stabilize delegated reuse response

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-07-31 23:30:44 +00:00
1 parent ba86e74dd3
commit 1ca659d9e9
2 files changed
+10 -7

No files matched your search

@@ -1441,6 +1441,10 @@ describeEmbeddedPostgres("issue recovery actions", () => {
expect(second.body).toMatchObject({
reused: true,
issue: {
id: sourceIssueId,
activeRecoveryAction: null,
},
recoveryIssue: {
id: first.body.recoveryIssue.id,
},
+6 -7
View File
@@ -4347,11 +4347,7 @@ export function issueRoutes(
return false;
}
async function resolveDelegatedRecoveryTargetAgentId(companyId: string, target: "ceo") {
if (target !== "ceo") {
throw unprocessable("Unsupported delegated recovery target");
}
async function resolveDelegatedRecoveryTargetAgentId(companyId: string) {
const ceoCandidates = await db
.select({
id: agents.id,
@@ -5753,7 +5749,10 @@ export function issueRoutes(
const recoveryIssue = await svc.getById(resolvedAction.recoveryIssueId);
if (recoveryIssue && recoveryIssue.companyId === existing.companyId) {
res.json({
issue: existing,
issue: {
...existing,
activeRecoveryAction: null,
},
recoveryIssue,
recoveryAction: resolvedAction,
reused: true,
@@ -5778,7 +5777,7 @@ export function issueRoutes(
}
const actor = getActorInfo(req);
const assigneeAgentId = await resolveDelegatedRecoveryTargetAgentId(existing.companyId, target);
const assigneeAgentId = await resolveDelegatedRecoveryTargetAgentId(existing.companyId);
await assertCanAssignTasks(req, existing.companyId, {
projectId: await resolveAssignmentProjectId({
companyId: existing.companyId,