Skip to content

fix: allow reassigning already-assigned tasks#158

Merged
ChenNima merged 1 commit intoChorus-AIDLC:mainfrom
drstrangerujn:fix/reassign-task-status-check
Apr 14, 2026
Merged

fix: allow reassigning already-assigned tasks#158
ChenNima merged 1 commit intoChorus-AIDLC:mainfrom
drstrangerujn:fix/reassign-task-status-check

Conversation

@drstrangerujn
Copy link
Copy Markdown
Contributor

Closes #12 (reassign part — button layout is a separate CSS issue)

What's wrong

claimTask() in task.service.ts only matches tasks with status: "open":

where: { uuid: taskUuid, status: "open" }

But the UI-side check in actions.ts allows both open and assigned:

if (task.status !== "open" && task.status !== "assigned") {
  return { success: false, error: "Task is not available for claiming" };
}

So when you try to reassign a task that's already assigned to someone, the UI says "go ahead" but the service layer says "nope" — Prisma can't find a matching row and throws P2025, which becomes AlreadyClaimedError.

Fix

where: { uuid: taskUuid, status: { in: ["open", "assigned"] } }

Now reassigning works. If the task is in any other status (in_progress, to_verify, done, closed), it still correctly rejects.

Tests

  • Updated existing test assertion to match the new where filter
  • Added a new test case: "reassigns an already-assigned task to a different agent"
  • All 81 tests pass

claimTask() only accepted tasks with status "open", so reassigning a
task that was already assigned to someone always failed with
AlreadyClaimedError. The UI allowed it (checks for open || assigned)
but the service layer rejected it.

Widen the Prisma where filter to accept both "open" and "assigned"
status, matching the UI-side validation.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@github-actions
Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 96.74% (🎯 95%) 2051 / 2120
🔵 Statements 95.8% (🎯 95%) 2217 / 2314
🔵 Functions 95.07% (🎯 93%) 425 / 447
🔵 Branches 88.33% (🎯 85%) 1348 / 1526
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/services/task.service.ts 89.78% 83.5% 87.27% 91.21% 297, 300, 315-330, 336-340, 342-346, 479-481, 583, 667-713, 921, 924, 945, 995
Generated in workflow #332 for commit c452520 by the Vitest Coverage Report Action

Copy link
Copy Markdown
Contributor

@ChenNima ChenNima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Real bug — UI and MCP callers allow assigned status but service layer only matched open. Fix is correct and minimal. Tests look good.

Minor nits (non-blocking):

  • task.service.ts:589 comment still says "only succeeds if status is open" — could update to include "assigned"
  • developer.ts:20 MCP tool description "(open -> assigned)" could mention reassign

@ChenNima ChenNima merged commit 3b2cbdc into Chorus-AIDLC:main Apr 14, 2026
1 check passed
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.

Reassign task fails and button is pushed off-screen

2 participants