Issue #764: handle TaskUpdate/TaskStop stream events for team_tasks status#765
Merged
Merged
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a stream-event handler for the CC 2.1.16+
TaskUpdate/TaskStoptools inteam-manager.ts. Captured tasks inteam_tasksnow correctly transition out ofstatus='pending'— closing the gap that left the Tasks-tab counter permanently wrong because there is no nativeTaskUpdatedhook to drive status changes.The handler is placed immediately after the existing
TodoWriteblock in the assistanttool_useparser. It reusesdb.upsertTeamTask, broadcasts the existingtask_updatedSSE event, derives owner from the existing row (preserving attribution), mapsTaskStopto'cancelled', and explicitly skips thewasTaskSeenByHookdedup guard (UPDATE/STOP must always flow through).Changes
src/server/services/team-manager.ts— new 92-lineTaskUpdate/TaskStopbranch after theTodoWriteblock.src/shared/types.ts— extendTeamTask.statusunion with'cancelled'.src/server/db.ts— update status cast inmapTeamTaskRowto include'cancelled'.tests/server/team-manager-task-update.test.ts(new) — 11 scenarios.No DB schema migration needed (
team_tasks.statushas no CHECK constraint).Test plan
npx vitest run tests/server/team-manager-task-update.test.ts— 11 passednpm test(full server) — 2308 passed (3 pre-existing failures incc-spawn.test.tsfrom env-var leak, unrelated)npx tsc --noEmit(root + client tsconfig) — cleannpm run build— cleanTaskUpdate(..., 'completed')ends withteam_tasksrow showingcompletedand the TeamDetail Tasks tab updates liveCloses #764