Skip to content

Issue #764: handle TaskUpdate/TaskStop stream events for team_tasks status#765

Merged
hubertciebiada merged 1 commit into
mainfrom
fix/764-task-update-team-tasks-status
May 27, 2026
Merged

Issue #764: handle TaskUpdate/TaskStop stream events for team_tasks status#765
hubertciebiada merged 1 commit into
mainfrom
fix/764-task-update-team-tasks-status

Conversation

@hubertciebiada
Copy link
Copy Markdown
Owner

Summary

Adds a stream-event handler for the CC 2.1.16+ TaskUpdate / TaskStop tools in team-manager.ts. Captured tasks in team_tasks now correctly transition out of status='pending' — closing the gap that left the Tasks-tab counter permanently wrong because there is no native TaskUpdated hook to drive status changes.

The handler is placed immediately after the existing TodoWrite block in the assistant tool_use parser. It reuses db.upsertTeamTask, broadcasts the existing task_updated SSE event, derives owner from the existing row (preserving attribution), maps TaskStop to 'cancelled', and explicitly skips the wasTaskSeenByHook dedup guard (UPDATE/STOP must always flow through).

Changes

  • src/server/services/team-manager.ts — new 92-line TaskUpdate/TaskStop branch after the TodoWrite block.
  • src/shared/types.ts — extend TeamTask.status union with 'cancelled'.
  • src/server/db.ts — update status cast in mapTeamTaskRow to include 'cancelled'.
  • tests/server/team-manager-task-update.test.ts (new) — 11 scenarios.

No DB schema migration needed (team_tasks.status has no CHECK constraint).

Test plan

  • npx vitest run tests/server/team-manager-task-update.test.ts — 11 passed
  • npm test (full server) — 2308 passed (3 pre-existing failures in cc-spawn.test.ts from env-var leak, unrelated)
  • npx tsc --noEmit (root + client tsconfig) — clean
  • npm run build — clean
  • Manual: after merge, observe that a team running TaskUpdate(..., 'completed') ends with team_tasks row showing completed and the TeamDetail Tasks tab updates live

Closes #764

…tatus

CC 2.1.16+ emits TaskUpdate and TaskStop tool_use blocks inside the
assistant stream, but FC had no handler — rows captured by TaskCreated
were stuck on status='pending' forever, the Tasks-tab counter was
permanently wrong, and there is no native TaskUpdated hook to fall
back on.

Adds a stream-event handler immediately after the existing TodoWrite
block in team-manager.ts that upserts the row, derives owner from the
existing record (preserving attribution across updates), broadcasts
task_updated via SSE, and maps TaskStop -> status='cancelled'. The
wasTaskSeenByHook dedup guard is intentionally NOT applied — it
suppresses redundant CREATE events, and re-using it would silently
drop UPDATE/STOP events. Extends the TeamTask.status union with
'cancelled' (no schema migration needed; the column has no CHECK
constraint).
@hubertciebiada hubertciebiada enabled auto-merge (squash) May 27, 2026 20:19
@hubertciebiada hubertciebiada merged commit ce7ff4d into main May 27, 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.

tasks: TaskUpdate tool calls do not update team_tasks.status (rows stuck on pending)

1 participant