Phase 2: Refactor Tasks cluster to MCP SDK types

Replace ad hoc TaskCardProps data shape with SDK Task type across the
Tasks group components and TasksScreen.

- TaskCard: accept `task: Task` instead of flat props (taskId, status,
  method, target, progress, etc.); derive all display fields from the
  SDK Task object (taskId, status, ttl, createdAt, lastUpdatedAt,
  statusMessage); remove fields not present on SDK Task (method, target,
  progress as number, error, completedAt, elapsed)
- TaskControls: type statusFilter as `TaskStatus | undefined`; add
  runtime validation guard on Select onChange
- TaskListPanel: accept `Task[]` instead of `TaskCardProps[]`; pass
  `onCancel(taskId)` through to each TaskCard; use `task.taskId` as key
- TasksScreen: accept `Task[]` + `onCancel(taskId)` callback; type
  internal statusFilter state as `TaskStatus | undefined`
- Delete re-export of `TaskStatus` from TaskCard (import directly from
  SDK where needed)
- Update all stories with real SDK `Task` fixtures
- Update ConnectedView TasksActive story

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
cliffhall 2026-04-20 10:28:24 -04:00
commit 6abb39a5fe

View file

@ -549,55 +549,37 @@ export const TasksActive: Story = {
{
taskId: "d0b22eba71fa36229ce5c4dfadeaa7de",
status: "working",
method: "tools/call",
target: "batch_process",
progress: 65,
progressDescription: "Processing records 650 of 1000...",
startedAt: "3/29/2026, 8:18:20 PM",
lastUpdated: "3/29/2026, 8:18:22 PM",
ttl: 300000,
isListExpanded: true,
onCancel: fn(),
createdAt: "2026-03-29T20:18:20Z",
lastUpdatedAt: "2026-03-29T20:18:22Z",
statusMessage: "Processing records 650 of 1000...",
},
{
taskId: "4100b5e0b0ed9cd0023330342d1bf647",
status: "input_required",
method: "resources/read",
target: "file:///data/large-dataset.csv",
startedAt: "3/29/2026, 8:17:55 PM",
lastUpdated: "3/29/2026, 8:17:55 PM",
ttl: 300000,
isListExpanded: true,
onCancel: fn(),
createdAt: "2026-03-29T20:17:55Z",
lastUpdatedAt: "2026-03-29T20:17:55Z",
},
{
taskId: "d487b49aa39023d907b5a2a5b506cb3",
status: "completed",
method: "tools/call",
target: "send_message",
startedAt: "3/29/2026, 8:16:47 PM",
completedAt: "3/29/2026, 8:16:49 PM",
lastUpdated: "3/29/2026, 8:16:49 PM",
ttl: 300000,
isListExpanded: true,
onCancel: fn(),
createdAt: "2026-03-29T20:16:47Z",
lastUpdatedAt: "2026-03-29T20:16:49Z",
},
{
taskId: "e6ebffd9cca84ddd1646d3c579a4d453",
status: "failed",
method: "tools/call",
target: "delete_records",
startedAt: "3/29/2026, 8:17:27 PM",
completedAt: "3/29/2026, 8:17:57 PM",
lastUpdated: "3/29/2026, 8:17:57 PM",
ttl: 300000,
error: "Timeout waiting for tool response after 30s",
isListExpanded: true,
onCancel: fn(),
createdAt: "2026-03-29T20:17:27Z",
lastUpdatedAt: "2026-03-29T20:17:57Z",
statusMessage: "Timeout waiting for tool response after 30s",
},
]}
onRefresh={fn()}
onClearCompleted={fn()}
onCancel={fn()}
/>
),
},