Refactor TaskWithAttemptStatus (vibe-kanban) (#777)

* ##  Refactoring Complete

Successfully refactored [`TaskWithAttemptStatus`](file:///private/var/folders/m1/9q_ct1913z10v6wbnv54j25r0000gn/T/vibe-kanban/worktrees/vk-f864-refactor-t/crates/db/src/models/task.rs#L32-L41) to eliminate field duplication:

### Changes Made:
1. **Struct refactored** with `#[serde(flatten)]` and `#[ts(flatten)]` to embed `Task`
2. **Database mapping updated** to construct nested `Task` struct
3. **Deref implementation added** for backward compatibility
4. **Call sites fixed** in routes and MCP server

### Verification:
-  All tests pass
-  TypeScript generation produces identical interface structure
-  JSON serialization maintains exact same format for frontend compatibility

The refactoring eliminates 8 duplicated fields while maintaining all existing functionality.

* Fix stream_tasks_raw bug (vibe-kanban d05247f3)

crates/services/src/services/events.rs

The function returns TaskWithAttemptStatus, however an update is not streamed when the non-task fields change:
    pub has_in_progress_attempt: bool,
    pub has_merged_attempt: bool,
    pub last_attempt_failed: bool,
    pub executor: String,
This commit is contained in:
Louis Knight-Webb
2025-09-18 15:41:13 +01:00
committed by GitHub
parent 941fe3e230
commit 21c9a5472c
5 changed files with 93 additions and 28 deletions

View File

@@ -44,7 +44,7 @@ export type TaskStatus = "todo" | "inprogress" | "inreview" | "done" | "cancelle
export type Task = { id: string, project_id: string, title: string, description: string | null, status: TaskStatus, parent_task_attempt: string | null, created_at: string, updated_at: string, };
export type TaskWithAttemptStatus = { id: string, project_id: string, title: string, description: string | null, status: TaskStatus, parent_task_attempt: string | null, created_at: string, updated_at: string, has_in_progress_attempt: boolean, has_merged_attempt: boolean, last_attempt_failed: boolean, executor: string, };
export type TaskWithAttemptStatus = { has_in_progress_attempt: boolean, has_merged_attempt: boolean, last_attempt_failed: boolean, executor: string, id: string, project_id: string, title: string, description: string | null, status: TaskStatus, parent_task_attempt: string | null, created_at: string, updated_at: string, };
export type TaskRelationships = { parent_task: Task | null, current_attempt: TaskAttempt, children: Array<Task>, };