Skip to content

The agent that grows with you

fix(desktop): show why a Kanban task is blocked and let it be unblocked

Brooklyn Nicholsonbb09271d6aa9
diff --git a/apps/desktop/src/plugins/kanban/board.tsx b/apps/desktop/src/plugins/kanban/board.tsx
index d09a1220088..8b05b1fbb2c 100644
--- a/apps/desktop/src/plugins/kanban/board.tsx
+++ b/apps/desktop/src/plugins/kanban/board.tsx
@@ -205,6 +205,16 @@ function CardFooter({ arc, task }: { arc: ArcState | null; task: KanbanTask }) {
<span className="shrink-0 cursor-help font-medium text-amber-500">{k.noHeartbeat}</span>
</Tip>
)}
+ {task.status === 'blocked' && task.block_kind && (
+ // #124391: say WHY the card is blocked — the kind arrives on every
+ // card payload; without it every blocked card reads identically.
+ <Tip label={k.blockKindTip(task.block_kind)}>
+ <span className="inline-flex shrink-0 cursor-help items-center gap-1 text-destructive">
+ <Codicon name="debug-breakpoint-data-unverified" size="0.7rem" />
+ {task.block_kind}
+ </span>
+ </Tip>
+ )}
{unassignedReady && !fallback && (
<Tip label={k.wontRunTip}>
<span className="inline-flex shrink-0 cursor-help items-center gap-1 text-amber-500">
diff --git a/apps/desktop/src/plugins/kanban/drawer.test.tsx b/apps/desktop/src/plugins/kanban/drawer.test.tsx
index cadffd8c6c3..6b7f72bd839 100644
--- a/apps/desktop/src/plugins/kanban/drawer.test.tsx
+++ b/apps/desktop/src/plugins/kanban/drawer.test.tsx
@@ -356,3 +356,78 @@ describe('dependency chips resolve titles', () => {
expect(screen.getByText('child')).toBeTruthy()
})
})
+
+// #124391: block_kind / block_recurrences / consecutive_failures /
+// last_failure_error arrive on every payload — the drawer must show them,
+// and a blocked task's diagnostic unblock action must PATCH the task ready.
+describe('blocked task detail', () => {
+ const blockedDetail = {
+ ...legacyDetail,
+ attachments: [] as [],
+ task: {
+ ...legacyDetail.task,
+ status: 'blocked',
+ block_kind: 'needs_input',
+ block_recurrences: 2,
+ consecutive_failures: 3,
+ last_failure_error: 'RuntimeError: boom',
+ diagnostics: [
+ {
+ kind: 'stuck_in_blocked',
+ severity: 'warning',
+ title: 'Parked in blocked',
+ detail: 'This task has been blocked for a while.',
+ actions: [{ kind: 'unblock', label: 'Unblock task' }],
+ count: 1,
+ last_seen_at: 0,
+ data: {}
+ }
+ ]
+ }
+ }
+
+ it('renders the block kind, recurrences, failures and last error the API returns', async () => {
+ detail = blockedDetail
+ openDrawer()
+
+ expect(await screen.findByText('needs_input')).toBeTruthy()
+ expect(screen.getByText('×2')).toBeTruthy()
+ expect(screen.getByText('3')).toBeTruthy()
+ expect(screen.getByText('RuntimeError: boom')).toBeTruthy()
+ })
+
+ it('hides block detail on legacy payloads and recovered tasks', async () => {
+ // Legacy payload: none of the four fields.
+ detail = { ...legacyDetail, attachments: [] }
+ openDrawer()
+ await screen.findByRole('heading', { name: legacyDetail.task.title })
+ expect(screen.queryByText(en.blockReason)).toBeNull()
+ expect(screen.queryByText(en.consecutiveFailures)).toBeNull()
+ expect(screen.queryByText(en.lastFailureError)).toBeNull()
+ cleanup()
+ })
+
+ it('does not present a retained block kind as current after recovery', async () => {
+ // block_kind is retained across unblock — present but the task is no
+ // longer blocked, so it must not read as a current block reason.
+ detail = {
+ ...blockedDetail,
+ task: { ...blockedDetail.task, status: 'todo', consecutive_failures: 0, last_failure_error: null }
+ }
+ openDrawer()
+ await screen.findByRole('heading', { name: blockedDetail.task.title })
+ expect(screen.queryByText(en.blockReason)).toBeNull()
+ expect(screen.queryByText('needs_input')).toBeNull()
+ })
+
+ it('fires the diagnostic unblock action as a PATCH to ready', async () => {
+ detail = blockedDetail
+ openDrawer()
+
+ fireEvent.click(await screen.findByRole('button', { name: 'Unblock task' }))
+
+ await waitFor(() =>
+ expect(rest).toHaveBeenCalledWith('/tasks/t_example', expect.objectContaining({ method: 'PATCH', body: { status: 'ready' } }))
+ )
+ })
+})
diff --git a/apps/desktop/src/plugins/kanban/drawer.tsx b/apps/desktop/src/plugins/kanban/drawer.tsx
index d540fc3c67d..4235c8c8400 100644
--- a/apps/desktop/src/plugins/kanban/drawer.tsx
+++ b/apps/desktop/src/plugins/kanban/drawer.tsx
@@ -232,12 +232,14 @@ function WorkspaceValue({ kind, path }: { kind: null | string | undefined; path:
/** The dashboard's diagnostics panel: severity-toned, plain-English, with the
* backend's structured recovery actions as buttons. `reassign` is skipped —
* the Assignee control in the meta table IS that action, inline. */
-function Diagnostics({ items, onReclaim }: { items: Diagnostic[]; onReclaim: () => void }) {
+function Diagnostics({ items, onReclaim, onUnblock }: { items: Diagnostic[]; onReclaim: () => void; onUnblock: () => void }) {
const k = useKanban()
const act = (action: DiagnosticAction) => {
if (action.kind === 'reclaim') {
onReclaim()
+ } else if (action.kind === 'unblock') {
+ onUnblock()
} else if (action.kind === 'cli_hint') {
void navigator.clipboard.writeText(String(action.payload?.command ?? action.label))
host.notify({ kind: 'info', message: k.commandCopied })
@@ -248,7 +250,7 @@ function Diagnostics({ items, onReclaim }: { items: Diagnostic[]; onReclaim: ()
<div className="flex flex-col gap-2">
{items.map(diag => {
const tone = SEVERITY_TONE[diag.severity]
- const actions = diag.actions.filter(action => action.kind === 'reclaim' || action.kind === 'cli_hint')
+ const actions = diag.actions.filter(action => action.kind === 'reclaim' || action.kind === 'unblock' || action.kind === 'cli_hint')
return (
<Callout
@@ -1048,6 +1050,7 @@ export function TaskDrawer({
<Diagnostics
items={task.diagnostics}
onReclaim={() => void mutate(() => reclaimTask(task.id))()}
+ onUnblock={() => void mutate(() => patchTask(task.id, { status: 'ready' }), () => host.notify({ kind: 'success', message: k.unblockedMessage(shortId(task.id)) }))()}
/>
</Section>
)}
@@ -1092,6 +1095,33 @@ export function TaskDrawer({
</MetaRow>
)}
{task.tenant && <MetaRow label={k.metaTenant}>{task.tenant}</MetaRow>}
+ {/* #124391 — block detail the API already returns. The kind is
+ retained across unblock, so present it as CURRENT only
+ while the card sits in the blocked column. */}
+ {task.status === 'blocked' && task.block_kind && (
+ <MetaRow label={k.blockReason}>
+ <Tip label={k.blockKindTip(task.block_kind)}>
+ <span className="cursor-help text-destructive">{task.block_kind}</span>
+ </Tip>
+ </MetaRow>
+ )}
+ {typeof task.block_recurrences === 'number' && task.block_recurrences > 0 && (
+ <MetaRow label={k.blockRecurrences}>
+ <Tip label={k.blockRecurrencesTip}>
+ <span className="cursor-help">×{task.block_recurrences}</span>
+ </Tip>
+ </MetaRow>
+ )}
+ {typeof task.consecutive_failures === 'number' && task.consecutive_failures > 0 && (
+ <MetaRow label={k.consecutiveFailures}>{task.consecutive_failures}</MetaRow>
+ )}
+ {task.last_failure_error && (
+ <MetaRow label={k.lastFailureError}>
+ <span className="whitespace-pre-wrap font-mono text-[0.65rem] leading-snug text-(--ui-text-tertiary)">
+ {task.last_failure_error}
+ </span>
+ </MetaRow>
+ )}
{task.workspace_path && (
<MetaRow label={k.workspace}>
<WorkspaceValue kind={task.workspace_kind} path={task.workspace_path} />
diff --git a/apps/desktop/src/plugins/kanban/i18n.ts b/apps/desktop/src/plugins/kanban/i18n.ts
index b7ca3e6cae5..94cee91d6f2 100644
--- a/apps/desktop/src/plugins/kanban/i18n.ts
+++ b/apps/desktop/src/plugins/kanban/i18n.ts
@@ -123,6 +123,14 @@ type KanbanMessages = {
metaCreatedBy: string
metaCreated: string
metaWorkerPid: string
+ /** #124391 — blocked-card detail: why it blocked and what it cost. */
+ blockKindTip: (kind: string) => string
+ blockReason: string
+ blockRecurrences: string
+ blockRecurrencesTip: string
+ consecutiveFailures: string
+ lastFailureError: string
+ unblockedMessage: (id: string) => string
readyUnassignedTitle: string
readyUnassignedBody: string
diagnosticsN: (n: number) => string
@@ -341,6 +349,20 @@ export const en: KanbanMessages = {
metaCreatedBy: 'Created by',
metaCreated: 'Created',
metaWorkerPid: 'Worker pid',
+ blockKindTip: kind =>
+ kind === 'needs_input'
+ ? 'The worker asked for human input.'
+ : kind === 'capability'
+ ? 'The worker hit a capability wall it cannot get past.'
+ : kind === 'transient'
+ ? 'The worker failed on a transient error.'
+ : 'The worker reported a dependency it must wait on.',
+ blockReason: 'Block kind',
+ blockRecurrences: 'Block recurrences',
+ blockRecurrencesTip: 'Times this task re-blocked for the same reason after a human unblock.',
+ consecutiveFailures: 'Consecutive failures',
+ lastFailureError: 'Last failure',
+ unblockedMessage: id => `Unblocked ${id}. Task is ready for the next tick.`,
readyUnassignedTitle: 'Ready, but unassigned — this card will never run.',
readyUnassignedBody:
'The dispatcher only claims Ready cards that have an assignee. Pick a profile in the Assignee field above (or set a default assignee in the orchestration settings) and it runs within a minute.',
@@ -554,6 +576,20 @@ const ja: KanbanMessages = {
metaCreatedBy: '作成者',
metaCreated: '作成',
metaWorkerPid: 'ワーカー PID',
+ blockKindTip: kind =>
+ kind === 'needs_input'
+ ? 'ワーカーが人間の入力を求めています。'
+ : kind === 'capability'
+ ? 'ワーカーが越えられない能力の壁に当たりました。'
+ : kind === 'transient'
+ ? 'ワーカーが一時的なエラーで失敗しました。'
+ : 'ワーカーが待機すべき依存関係を報告しました。',
+ blockReason: 'ブロック種別',
+ blockRecurrences: 'ブロック回数',
+ blockRecurrencesTip: '人間がブロック解除した後、同じ理由で再ブロックされた回数。',
+ consecutiveFailures: '連続失敗',
+ lastFailureError: '直近の失敗',
+ unblockedMessage: id => `${id} をブロック解除しました。次のティックで実行できます。`,
readyUnassignedTitle: 'Ready ですが未割り当て — このカードは実行されません。',
readyUnassignedBody:
'ディスパッチャは担当のある Ready カードのみ取得します。上の担当フィールドでプロフィールを選ぶ(またはオーケストレーション設定でデフォルトの担当を設定する)と、1分以内に実行されます。',
@@ -766,6 +802,20 @@ const zh: KanbanMessages = {
metaCreatedBy: '创建者',
metaCreated: '创建于',
metaWorkerPid: '工作单元 PID',
+ blockKindTip: kind =>
+ kind === 'needs_input'
+ ? '工作单元正在等待人工输入。'
+ : kind === 'capability'
+ ? '工作单元遇到了无法逾越的能力限制。'
+ : kind === 'transient'
+ ? '工作单元因临时性错误失败。'
+ : '工作单元报告了需要等待的依赖。',
+ blockReason: '阻塞类型',
+ blockRecurrences: '阻塞次数',
+ blockRecurrencesTip: '人工解除阻塞后,该任务因同一原因再次阻塞的次数。',
+ consecutiveFailures: '连续失败',
+ lastFailureError: '最近失败',
+ unblockedMessage: id => `已解除 ${id} 的阻塞。任务将在下一轮调度中就绪。`,
readyUnassignedTitle: '就绪但未分配 — 这张卡片永远不会运行。',
readyUnassignedBody:
'调度器只领取有负责人的就绪卡片。在上面的负责人字段选择一个配置档(或在编排设置中设置默认负责人),它会在一分钟内运行。',
@@ -976,6 +1026,20 @@ const zhHant: KanbanMessages = {
metaCreatedBy: '建立者',
metaCreated: '建立於',
metaWorkerPid: '工作單元 PID',
+ blockKindTip: kind =>
+ kind === 'needs_input'
+ ? '工作單元正在等待人工輸入。'
+ : kind === 'capability'
+ ? '工作單元遇到了無法跨越的能力限制。'
+ : kind === 'transient'
+ ? '工作單元因暫時性錯誤失敗。'
+ : '工作單元回報了需要等待的相依關係。',
+ blockReason: '封鎖類型',
+ blockRecurrences: '封鎖次數',
+ blockRecurrencesTip: '人工解除封鎖後,該任務因同一原因再次封鎖的次數。',
+ consecutiveFailures: '連續失敗',
+ lastFailureError: '最近失敗',
+ unblockedMessage: id => `已解除 ${id} 的封鎖。任務將在下一輪排程中就緒。`,
readyUnassignedTitle: '就緒但未指派 — 這張卡片永遠不會執行。',
readyUnassignedBody:
'排程器只領取有負責人的就緒卡片。在上方的負責人欄位選擇一個設定檔(或在編排設定中設定預設負責人),它會在一分鐘內執行。',
diff --git a/apps/desktop/src/plugins/kanban/types.ts b/apps/desktop/src/plugins/kanban/types.ts
index 251c33d1c22..0b8735d4b5c 100644
--- a/apps/desktop/src/plugins/kanban/types.ts
+++ b/apps/desktop/src/plugins/kanban/types.ts
@@ -26,6 +26,14 @@ export interface KanbanTask {
current_run_started_at?: null | number
worker_pid?: null | number
last_heartbeat_at?: null | number
+ /** Typed block reason set by the backend on kanban_block (one of
+ * VALID_BLOCK_KINDS — `dependency`, `needs_input`, `capability`,
+ * `transient`; null for legacy/un-typed blocks). Kept across unblock, so
+ * render it as CURRENT only while status is `blocked`. */
+ block_kind?: null | string
+ /** Unblock-loop counter — how many times this task re-blocked for the same
+ * reason after a human unblock. 0/absent on legacy payloads. */
+ block_recurrences?: number
}
export interface KanbanColumn {