@linxin666/dsh-client-ui-task-board 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +28 -22
  3. package/README.zh.md +28 -22
  4. package/lib/client.js +1435 -682
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +356 -366
  7. package/lib/types/client/PluginSettingsCard.d.ts +21 -0
  8. package/lib/types/client/TaskBoardSettingsCard.d.ts +7 -0
  9. package/lib/types/client/board/ExecutionLog.d.ts +16 -0
  10. package/lib/types/client/board/TaskForm.d.ts +4 -0
  11. package/lib/types/client/board/VerificationReport.d.ts +2 -15
  12. package/lib/types/client/body-mutations.d.ts +45 -0
  13. package/lib/types/client/locales.d.ts +42 -6
  14. package/lib/types/client/suppress-schedule-row.d.ts +86 -0
  15. package/lib/types/core/controller.d.ts +1 -1
  16. package/lib/types/core/subtask.d.ts +59 -49
  17. package/lib/types/core/tasks.d.ts +5 -8
  18. package/lib/types/core/use-cases/task-update.d.ts +1 -1
  19. package/lib/types/core/workspace-target.d.ts +23 -3
  20. package/lib/types/host/launch-admission.d.ts +8 -9
  21. package/lib/types/host-ledger.d.ts +72 -48
  22. package/lib/types/host-routes.d.ts +49 -0
  23. package/lib/types/host-runner.d.ts +20 -10
  24. package/lib/types/host-service.d.ts +7 -50
  25. package/lib/types/index.d.ts +61 -63
  26. package/lib/types/loopback.d.ts +21 -0
  27. package/lib/types/protocol.d.ts +0 -5
  28. package/lib/types/tool-surface.d.ts +1 -0
  29. package/package.json +25 -25
  30. package/src/client/CardDefaultPresetField.tsx +1 -1
  31. package/src/client/PluginSettingsCard.tsx +78 -18
  32. package/src/client/TaskBoardSettingsCard.tsx +68 -25
  33. package/src/client/board/ExecutionLog.tsx +140 -0
  34. package/src/client/board/LinkSubtaskModal.tsx +1 -9
  35. package/src/client/board/NewTaskModal.tsx +2 -11
  36. package/src/client/board/TaskCard.tsx +45 -23
  37. package/src/client/board/TaskDetail.tsx +407 -261
  38. package/src/client/board/TaskForm.tsx +19 -4
  39. package/src/client/board/VerificationReport.tsx +143 -104
  40. package/src/client/board/task-markdown.module.css +11 -8
  41. package/src/client/board-settings.module.css +35 -7
  42. package/src/client/board.module.css +855 -115
  43. package/src/client/body-mutations.ts +133 -0
  44. package/src/client/index.ts +10 -0
  45. package/src/client/locales.ts +97 -24
  46. package/src/client/settings-card.module.css +71 -10
  47. package/src/client/suppress-schedule-row.ts +198 -0
  48. package/src/core/controller.ts +1 -3
  49. package/src/core/subtask.ts +81 -76
  50. package/src/core/tasks.ts +5 -9
  51. package/src/core/use-cases/task-update.ts +1 -3
  52. package/src/core/workspace-target.ts +27 -3
  53. package/src/host/agent-tools.ts +14 -15
  54. package/src/host/launch-admission.ts +8 -9
  55. package/src/host-ledger.ts +158 -125
  56. package/src/host-routes.ts +65 -2
  57. package/src/host-runner.ts +53 -28
  58. package/src/host-service.ts +42 -127
  59. package/src/index.ts +84 -106
  60. package/src/loopback.ts +32 -0
  61. package/src/protocol.ts +2 -9
  62. package/src/tool-surface.ts +1 -0
  63. package/lib/types/client/board/team-run-promotion.d.ts +0 -26
  64. package/src/client/board/team-run-promotion.ts +0 -39
@@ -4,22 +4,22 @@
4
4
  * delete (with confirmation), manual status moves, and a jump to the
5
5
  * execution's session transcript.
6
6
  */
7
- import { useCallback, useEffect, useState } from 'react'
7
+ import { useCallback, useEffect, useId, useRef, useState, type ReactNode } from 'react'
8
8
  import type { BoardController, ControllerSnapshot } from '../../core/controller.ts'
9
9
  import type { TaskBoardExtensionActionRequest, TaskBoardExtensionDispatch } from '../../core/extension.ts'
10
10
  import { useTaskBoardSeats } from '../seats.tsx'
11
11
  import { isValidCron } from '../../core/schedule.ts'
12
- import { MANUAL_STATUSES, TASK_PERMISSIONS, canMoveTask, hasOpenExecution, tagTone, type ExecutionRecord, type ScheduleMode, type TaskPermission, type TaskRecord } from '../../core/tasks.ts'
12
+ import { MANUAL_STATUSES, TASK_PERMISSIONS, canMoveTask, hasOpenExecution, tagTone, type ScheduleMode, type TaskPermission, type TaskRecord } from '../../core/tasks.ts'
13
13
  import { canEditTaskContent } from '../../core/use-cases/task-update.ts'
14
14
  import { requiresPermissionConfirmation } from '../../core/handover.ts'
15
- import { DEFAULT_SUBTASK_DEPTH, directSubtasks, joinsCascadeRun, taskDepth } from '../../core/subtask.ts'
15
+ import { DEFAULT_SUBTASK_DEPTH, descendantTasks, directSubtasks, joinsCascadeRun, taskDepth } from '../../core/subtask.ts'
16
16
  import { t, type TaskBoardKey } from '../locales.ts'
17
17
  import { SCHEDULE_PRESETS } from '../schedule-presets.ts'
18
18
  import { budgetLabel, defaultZonedInputValue, endedLabel, nextRunLabel, parseZonedInput, runCapOption, skippedLabel, zonedInputValue, zoneChoices } from '../schedule-zone.ts'
19
19
  import css from '../board.module.css'
20
20
  import { ConfirmDialog } from './ConfirmDialog.tsx'
21
21
  import { EditTaskModal, EditTagsModal } from './EditTaskModal.tsx'
22
- import { IconClose, IconPlus, IconSession } from './icons.tsx'
22
+ import { IconClose, IconPlus } from './icons.tsx'
23
23
  import { LinkSubtaskModal } from './LinkSubtaskModal.tsx'
24
24
  import { NewTaskModal } from './NewTaskModal.tsx'
25
25
  import { useDialog, usePresence, type OverlayPhase } from './overlay.tsx'
@@ -28,70 +28,176 @@ import { ReasoningEffortField } from './ReasoningEffortField.tsx'
28
28
  import { reconcileReasoningEffort } from './model-options.ts'
29
29
  import { formatHostTimestamp, formatTime } from './TaskCard.tsx'
30
30
  import { STATUS_KEY } from './status-key.ts'
31
- import { VerificationReport } from './VerificationReport.tsx'
32
31
  import { ClampedMarkdown } from './ClampedMarkdown.tsx'
32
+ import { EXECUTION_RESULT_KEY, ExecutionLog } from './ExecutionLog.tsx'
33
33
 
34
- /** Execution outcome → locale key. */
35
- const RESULT_KEY: Record<NonNullable<ExecutionRecord['result']>, TaskBoardKey> = {
36
- succeeded: 'detail.result.succeeded',
37
- failed: 'detail.result.failed',
38
- cancelled: 'detail.result.cancelled',
34
+ /** One choice of a compact action menu. */
35
+ interface ActionMenuItem {
36
+ /** Stable identity of the choice (the status id, or an action name). */
37
+ key: string
38
+ label: string
39
+ disabled: boolean
40
+ title?: string
41
+ onSelect: () => void
39
42
  }
40
43
 
41
- /** One execution-history row. */
42
- function ExecutionRow({ execution, timeZone, onOpen }: { execution: ExecutionRecord; timeZone?: string; onOpen: (sessionId: string) => void }) {
43
- const result = execution.result
44
- // An external record is one the Host never observed running: no session, no
45
- // spinner, and a named outside agent instead of the initiating session. The
46
- // data attribute keeps the distinction machine-readable too.
47
- const external = execution.external === true
44
+ /**
45
+ * A compact action menu: one trigger on the panel's control track, the choices
46
+ * only while it is open, Escape or an outside press to close, and focus back on
47
+ * the trigger afterwards. The panel's dialog owns Escape on `document` in the
48
+ * capture phase, so the menu answers from the window leg of the same event —
49
+ * otherwise the press would close the whole detail view under the menu.
50
+ */
51
+ function ActionMenu({ label, items, disabled }: {
52
+ label: string
53
+ items: readonly ActionMenuItem[]
54
+ disabled: boolean
55
+ }) {
56
+ const [open, setOpen] = useState(false)
57
+ const rootRef = useRef<HTMLDivElement | null>(null)
58
+ const triggerRef = useRef<HTMLButtonElement | null>(null)
59
+ const menuRef = useRef<HTMLDivElement | null>(null)
60
+ const menuId = useId()
61
+
62
+ /** Close the menu; a keyboard user gets the trigger back instead of the document body. */
63
+ const close = useCallback((restoreFocus: boolean): void => {
64
+ setOpen(false)
65
+ if (restoreFocus) triggerRef.current?.focus()
66
+ }, [])
67
+
68
+ useEffect(() => {
69
+ if (!open) return
70
+ const onKeyDown = (event: KeyboardEvent): void => {
71
+ if (event.key !== 'Escape') return
72
+ event.stopPropagation()
73
+ setOpen(false)
74
+ triggerRef.current?.focus()
75
+ }
76
+ const onPointerDown = (event: Event): void => {
77
+ const root = rootRef.current
78
+ if (root !== null && event.target instanceof Node && root.contains(event.target)) return
79
+ setOpen(false)
80
+ }
81
+ window.addEventListener('keydown', onKeyDown, true)
82
+ document.addEventListener('mousedown', onPointerDown, true)
83
+ return () => {
84
+ window.removeEventListener('keydown', onKeyDown, true)
85
+ document.removeEventListener('mousedown', onPointerDown, true)
86
+ }
87
+ }, [open])
88
+
89
+ // Focus lands on the first usable choice, so the menu is usable without a
90
+ // mouse and Tab never has to walk the panel behind it.
91
+ useEffect(() => {
92
+ if (!open) return
93
+ menuRef.current?.querySelector<HTMLElement>('[role="menuitem"]:not([disabled])')?.focus()
94
+ }, [open])
95
+
48
96
  return (
49
- <li className={css.executionRow} data-result={result} data-external={external ? 'true' : undefined}>
50
- <span className={css.executionBadge} data-result={result}>
51
- {result === undefined ? t('detail.result.running') : t(RESULT_KEY[result])}
52
- </span>
53
- <span className={css.executionTimes}>
54
- {t('detail.executionStarted')} {formatTime(execution.startedAt, timeZone)}
55
- {execution.endedAt !== undefined && ` · ${t('detail.executionEnded')} ${formatTime(execution.endedAt, timeZone)}`}
56
- </span>
57
- {external && execution.initiatedBy !== undefined && (
58
- <span className={css.executionTimes} title={execution.initiatedBy}>
59
- {t('detail.execution.external', { agent: execution.initiatedBy })}
60
- </span>
61
- )}
62
- {!external && execution.initiatedBy !== undefined && (
63
- <span className={css.executionTimes} title={execution.initiatedBy}>
64
- {t('detail.execution.initiator', { session: execution.initiatedBy })}
65
- </span>
66
- )}
67
- {execution.verification !== undefined && <VerificationReport verification={execution.verification} />}
68
- {execution.sessionId !== undefined && (
69
- <button
70
- type="button"
71
- className={css.linkButton}
72
- onClick={() => { onOpen(execution.sessionId as string) }}
73
- title={execution.sessionId}
74
- >
75
- {t('detail.viewSession')}
76
- <IconSession size={13} />
77
- </button>
97
+ <div className={css.menuRoot} ref={rootRef}>
98
+ <button
99
+ ref={triggerRef}
100
+ type="button"
101
+ className={css.ghostButton}
102
+ aria-haspopup="menu"
103
+ aria-expanded={open}
104
+ aria-controls={menuId}
105
+ disabled={disabled}
106
+ onClick={() => { setOpen(!open) }}
107
+ >
108
+ {label}
109
+ <span className={css.menuChevron} data-open={open} aria-hidden="true" />
110
+ </button>
111
+ {open && (
112
+ <div ref={menuRef} id={menuId} className={css.menuPanel} role="menu" aria-label={label}>
113
+ {items.map(item => (
114
+ <button
115
+ key={item.key}
116
+ type="button"
117
+ role="menuitem"
118
+ className={css.menuItem}
119
+ disabled={item.disabled}
120
+ title={item.title}
121
+ onClick={() => { close(true); item.onSelect() }}
122
+ >
123
+ {item.label}
124
+ </button>
125
+ ))}
126
+ </div>
78
127
  )}
79
- {execution.error !== undefined && execution.error !== '' && (
80
- <span className={css.executionError}>{execution.error}</span>
128
+ </div>
129
+ )
130
+ }
131
+
132
+ /**
133
+ * One folded region of the detail panel.
134
+ *
135
+ * It reuses the task form's region contract verbatim — `.formSection`, the
136
+ * chevron drawn from borders, the one-line summary, `data-open`, the
137
+ * `data-dsh-part="form-section"` part the semantic-attribute contract already
138
+ * owns — and adds the two things a panel fold needs that a dialog region does
139
+ * not: an `aria-controls` target and a paired exit leg (`usePresence` keeps the
140
+ * body mounted until the close has run). The panel cannot reach into the form
141
+ * module to extend its copy, so the shape is mirrored here rather than forked
142
+ * into a third disclosure style.
143
+ */
144
+ function FoldSection({ title, summary, hint, children }: {
145
+ title: string
146
+ /** One-line echo of what the folded region holds, shown while it is closed. */
147
+ summary: string
148
+ /**
149
+ * The whole line, tooltip only. The row drops whatever does not fit, so what
150
+ * the summary had to give up — a rule's cron expression, a one-shot's instant
151
+ * — stays one hover away instead of being lost with the ellipsis.
152
+ */
153
+ hint?: string
154
+ children: ReactNode
155
+ }) {
156
+ const [open, setOpen] = useState(false)
157
+ const presence = usePresence(open)
158
+ const panelId = useId()
159
+ const headerRef = useRef<HTMLButtonElement | null>(null)
160
+ const fullLine = hint ?? summary
161
+ // Collapsing a region whose body holds the focus hands the focus back to the
162
+ // region row instead of dropping it on the document body.
163
+ const toggle = (): void => {
164
+ if (open) {
165
+ const body = panelId === '' ? null : document.getElementById(panelId)
166
+ if (body !== null && body.contains(document.activeElement)) headerRef.current?.focus()
167
+ }
168
+ setOpen(!open)
169
+ }
170
+ return (
171
+ <section className={css.formSection} data-dsh-part="form-section" data-open={open ? 'true' : undefined}>
172
+ <button
173
+ ref={headerRef}
174
+ type="button"
175
+ className={css.formSectionHeader}
176
+ aria-expanded={open}
177
+ aria-controls={panelId}
178
+ title={fullLine === '' ? undefined : fullLine}
179
+ onClick={toggle}
180
+ >
181
+ <span className={css.formSectionChevron} aria-hidden="true" />
182
+ <span className={css.formSectionTitle}>{title}</span>
183
+ {!open && summary !== '' && <span className={css.formSectionSummary}>{summary}</span>}
184
+ </button>
185
+ {presence.mounted && (
186
+ <div className={css.formSectionBody} id={panelId} data-state={presence.phase}>
187
+ {children}
188
+ </div>
81
189
  )}
82
- </li>
190
+ </section>
83
191
  )
84
192
  }
85
193
 
86
194
  /** The execution-target editor: workspace / mode / permission pickers. */
87
- function ExecutionSettingsSection({ controller, task, pending, executionOptions, teamRunAvailable, goalRunEnabled }: {
195
+ function ExecutionSettingsSection({ controller, task, pending, executionOptions, goalRunEnabled }: {
88
196
  controller: BoardController
89
197
  task: TaskRecord
90
198
  pending: boolean
91
199
  /** Picker option sets, owned by the detail overlay's snapshot. */
92
200
  executionOptions: ControllerSnapshot['executionOptions']
93
- /** Whether this deployment serves the Agent Teams service. */
94
- teamRunAvailable: boolean
95
201
  /**
96
202
  * Live GLOBAL native-/goal switch. It only decides whether the card's own
97
203
  * preference takes effect: the option stays operable while it is off, the
@@ -112,10 +218,16 @@ function ExecutionSettingsSection({ controller, task, pending, executionOptions,
112
218
  const workspaceKnown = workspaceId === '' || options.workspaces.some(item => item.workspaceId === workspaceId)
113
219
  const modeKnown = mode === '' || options.presets.some(item => item.id === mode)
114
220
  const modelKnown = model === '' || models.some(item => item.id === model)
221
+ // One line for the closed fold: which switches are on.
222
+ const advancedOn: string[] = []
223
+ if (task.reuseSession === true) advancedOn.push(t('detail.settings.summary.reuseSession'))
224
+ if (task.goalRun === true) advancedOn.push(t('detail.settings.summary.goal'))
225
+ if (task.skipVerification === true) advancedOn.push(t('detail.settings.summary.skipVerification'))
226
+ const advancedSummary = advancedOn.length === 0 ? t('detail.settings.summary.none') : advancedOn.join(' · ')
115
227
  return (
116
228
  <section className={css.detailSection}>
117
229
  <h4>{t('detail.executionSettings')}</h4>
118
- <p className={css.detailText}>{t('exec.hint')}</p>
230
+ <p className={css.detailText} title={t('exec.hint')}>{t('exec.hint.short')}</p>
119
231
  <label className={css.field}>
120
232
  <span className={css.fieldLabel}>{t('new.workspace')}</span>
121
233
  <select
@@ -199,50 +311,44 @@ function ExecutionSettingsSection({ controller, task, pending, executionOptions,
199
311
  pending={pending}
200
312
  onChange={effort => { controller.updateTask(task.id, { reasoningEffort: effort }) }}
201
313
  />
202
- <label className={css.scheduleToggle}>
203
- <input
204
- type="checkbox"
205
- checked={task.reuseSession === true}
206
- disabled={pending}
207
- onChange={event => { controller.updateTask(task.id, { reuseSession: event.target.checked }) }}
208
- />
209
- <span>{t('exec.reuseSession')}</span>
210
- </label>
211
- <p className={css.detailText}>{t('exec.reuseSessionHint')}</p>
212
- <label className={css.scheduleToggle}>
213
- <input
214
- type="checkbox"
215
- checked={task.goalRun === true}
216
- // Always operable (only a pending execution locks it): the global
217
- // switch decides whether the preference takes effect, never whether
218
- // the user may state it, and it never rewrites what is stored here.
219
- disabled={pending}
220
- onChange={event => { controller.updateTask(task.id, { goalRun: event.target.checked }) }}
221
- />
222
- <span>{t('exec.goalRun')}</span>
223
- </label>
224
- <p className={css.detailText}>{t('exec.goalRunHint')}</p>
225
- {!goalRunEnabled && <p className={css.detailText}>{t('settings.goalRunGlobalDisabledTaskOption')}</p>}
226
- <label className={css.scheduleToggle}>
227
- <input
228
- type="checkbox"
229
- checked={task.skipVerification === true}
230
- disabled={pending}
231
- onChange={event => { controller.updateTask(task.id, { skipVerification: event.target.checked }) }}
232
- />
233
- <span>{t('exec.skipVerification')}</span>
234
- </label>
235
- <p className={css.detailText}>{t('exec.skipVerificationHint')}</p>
236
- <label className={css.scheduleToggle}>
237
- <input
238
- type="checkbox"
239
- checked={task.teamRun === true}
240
- disabled={pending || !teamRunAvailable}
241
- onChange={event => { controller.updateTask(task.id, { teamRun: event.target.checked }) }}
242
- />
243
- <span>{t('exec.teamRun')}</span>
244
- </label>
245
- <p className={css.detailText}>{teamRunAvailable ? t('exec.teamRunHint') : t('exec.teamRunUnavailable')}</p>
314
+ <FoldSection title={t('detail.settings.advanced')} summary={advancedSummary}>
315
+ <label className={css.scheduleToggle} title={t('exec.reuseSessionHint')}>
316
+ <input
317
+ type="checkbox"
318
+ checked={task.reuseSession === true}
319
+ disabled={pending}
320
+ onChange={event => { controller.updateTask(task.id, { reuseSession: event.target.checked }) }}
321
+ />
322
+ <span>{t('exec.reuseSession')}</span>
323
+ </label>
324
+ <p className={css.detailMeta}>{t('exec.reuseSessionHint.short')}</p>
325
+ <label className={css.scheduleToggle} title={t('exec.goalRunHint')}>
326
+ <input
327
+ type="checkbox"
328
+ checked={task.goalRun === true}
329
+ // Always operable (only a pending execution locks it): the global
330
+ // switch decides whether the preference takes effect, never whether
331
+ // the user may state it, and it never rewrites what is stored here.
332
+ disabled={pending}
333
+ onChange={event => { controller.updateTask(task.id, { goalRun: event.target.checked }) }}
334
+ />
335
+ <span>{t('exec.goalRun')}</span>
336
+ </label>
337
+ <p className={css.detailMeta}>{t('exec.goalRunHint.short')}</p>
338
+ {!goalRunEnabled && (
339
+ <p className={css.detailMeta} title={t('settings.goalRunGlobalDisabledTaskOption')}>{t('exec.goalRunGlobalOff')}</p>
340
+ )}
341
+ <label className={css.scheduleToggle} title={t('exec.skipVerificationHint')}>
342
+ <input
343
+ type="checkbox"
344
+ checked={task.skipVerification === true}
345
+ disabled={pending}
346
+ onChange={event => { controller.updateTask(task.id, { skipVerification: event.target.checked }) }}
347
+ />
348
+ <span>{t('exec.skipVerification')}</span>
349
+ </label>
350
+ <p className={css.detailMeta}>{t('exec.skipVerificationHint.short')}</p>
351
+ </FoldSection>
246
352
  </section>
247
353
  )
248
354
  }
@@ -440,10 +546,28 @@ function ScheduleSection({ controller, task, pending }: { controller: BoardContr
440
546
  const budget = schedule === undefined ? undefined : budgetLabel(schedule)
441
547
  const ended = schedule === undefined ? undefined : endedLabel(schedule)
442
548
  const skipped = schedule === undefined ? undefined : skippedLabel(schedule)
549
+ // One line for the closed fold: whether the rule is armed, what it will do,
550
+ // and when — or, when it already finished or was skipped, the ledger's own
551
+ // reason. The editor itself is unchanged inside the fold.
552
+ const plannedAt = mode === 'once' ? parseZonedInput(atText, effectiveZone) : undefined
553
+ const planLabel = mode === 'once'
554
+ ? t('detail.schedule.summary.planOnce', { time: plannedAt === undefined ? '—' : formatHostTimestamp(plannedAt, effectiveZone) })
555
+ : t('detail.schedule.summary.planCron', { cron: cron.trim() === '' ? '—' : cron.trim() })
556
+ // The row itself carries only the next instant; the rule that produced it is
557
+ // the fold's tooltip, so a narrow panel clips the row without losing the rule.
558
+ const scheduleHint = enabled && ended === undefined
559
+ ? t('detail.schedule.summary.onFull', { plan: planLabel, next: nextLabel })
560
+ : undefined
561
+ const scheduleSummary = ended !== undefined
562
+ ? t('detail.schedule.ended', { reason: ended })
563
+ : enabled
564
+ ? t('detail.schedule.summary.on', { next: nextLabel })
565
+ : skipped !== undefined
566
+ ? t('detail.schedule.skipped', { reason: skipped })
567
+ : t('detail.schedule.summary.off')
443
568
 
444
569
  return (
445
- <section className={css.detailSection}>
446
- <h4>{t('detail.schedule')}</h4>
570
+ <FoldSection title={t('detail.schedule')} summary={scheduleSummary} hint={scheduleHint}>
447
571
  <label className={css.scheduleToggle}>
448
572
  <input
449
573
  type="checkbox"
@@ -570,19 +694,23 @@ function ScheduleSection({ controller, task, pending }: { controller: BoardContr
570
694
  {t('detail.schedule.cancel')}
571
695
  </button>
572
696
  )}
573
- </section>
697
+ </FoldSection>
574
698
  )
575
699
  }
576
700
 
577
701
  /**
578
- * The run hint of one card: how many subtasks a run opens, counting the same
579
- * members the Host will launch (`joinsCascadeRun` leaves a finished subtask
580
- * alone), or why it opens none even though the card has subtasks.
702
+ * The read-only note under the subtask list. A card with unfinished descendants
703
+ * runs as ONE session — that card's own — which reads the subtasks and hands
704
+ * them off in dependency order, so the note states what the run does instead of
705
+ * promising a session per member. It counts the same members the run hands off
706
+ * (`joinsCascadeRun` leaves a finished subtask alone, and an archived card never
707
+ * runs at all), and stays a sentence: nothing here is a card field.
581
708
  */
582
- function subtaskRunHint(parentId: string, children: readonly TaskRecord[]): string {
583
- const runnable = children.filter(child => joinsCascadeRun(child, parentId))
584
- return runnable.length > 0
585
- ? t('detail.subtasks.runHint', { count: String(runnable.length) })
709
+ function subtaskDispatchNote(task: TaskRecord, tasks: readonly TaskRecord[], maxSubtaskDepth: number): string {
710
+ const pending = descendantTasks(tasks, task.id, maxSubtaskDepth)
711
+ .filter(descendant => descendant.archivedAt === undefined && joinsCascadeRun(descendant, task.id))
712
+ return pending.length > 0
713
+ ? t('detail.subtasks.runHint', { count: String(pending.length) })
586
714
  : t('detail.subtasks.runHintSettled')
587
715
  }
588
716
 
@@ -656,7 +784,7 @@ function SubtaskSection({ controller, task, pending, archived, snapshot }: {
656
784
  </ul>
657
785
  )}
658
786
  {children.length > 0 && (
659
- <p className={css.detailText}>{subtaskRunHint(task.id, children)}</p>
787
+ <p className={css.detailText}>{subtaskDispatchNote(task, tasks, limit)}</p>
660
788
  )}
661
789
  {!archived && (canAddChild
662
790
  ? (controller.isHostBacked()
@@ -716,6 +844,7 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
716
844
  const timeZone = snapshot.host?.scheduler.timeZone
717
845
  const permissionPending = requiresPermissionConfirmation(current, snapshot.host?.sessionDefaultPermission)
718
846
  const subtaskChildren = directSubtasks(snapshot.tasks, current.id)
847
+ const subtaskDepthLimit = snapshot.host?.maxSubtaskDepth ?? DEFAULT_SUBTASK_DEPTH
719
848
  const dialog = useDialog<HTMLDivElement>(() => { controller.closeTask() }, phase)
720
849
  // One presence per nested overlay: the detail view sits under up to four of
721
850
  // them, and each has to run its own exit leg instead of the surface being
@@ -727,6 +856,37 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
727
856
  const editPresence = usePresence(editOpen)
728
857
  const tagsPresence = usePresence(tagsOpen)
729
858
  const duplicatePresence = usePresence(duplicateOpen)
859
+ // The closed history echoes its own ledger: how many runs, and what the latest
860
+ // one was and when — the panel then never repeats that per row.
861
+ const latestExecution = current.executions[current.executions.length - 1]
862
+ const historySummary = latestExecution === undefined
863
+ ? t('detail.noExecution')
864
+ : t('detail.execution.summary', {
865
+ count: String(current.executions.length),
866
+ time: formatTime(latestExecution.endedAt ?? latestExecution.startedAt, timeZone),
867
+ result: latestExecution.result === undefined
868
+ ? t('detail.result.running')
869
+ : t(EXECUTION_RESULT_KEY[latestExecution.result]),
870
+ })
871
+ // Secondary actions leave the footer so it holds exactly three controls on
872
+ // one primary-to-destructive track; they stay one press away in the header.
873
+ const headerActions: ActionMenuItem[] = []
874
+ if (!archived) {
875
+ headerActions.push({
876
+ key: 'duplicate',
877
+ label: canEditTaskContent(current) ? t('detail.duplicate') : t('detail.duplicateAndEdit'),
878
+ disabled: pending,
879
+ onSelect: () => { setShowDuplicate(true) },
880
+ })
881
+ if (current.status === 'done' || current.status === 'failed') {
882
+ headerActions.push({
883
+ key: 'archive',
884
+ label: t('detail.archive'),
885
+ disabled: pending,
886
+ onSelect: () => { controller.archiveTask(current.id) },
887
+ })
888
+ }
889
+ }
730
890
 
731
891
  return (
732
892
  <div className={css.modalBackdrop} data-state={phase} onMouseDown={dialog.onMouseDown}>
@@ -736,6 +896,9 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
736
896
  <span className={css.statusBadge} data-status={archived ? 'archived' : current.status}>
737
897
  {archived ? t('board.archive') : t(STATUS_KEY[current.status])}
738
898
  </span>
899
+ {headerActions.length > 0 && (
900
+ <ActionMenu label={t('detail.more')} items={headerActions} disabled={pending} />
901
+ )}
739
902
  <button
740
903
  type="button"
741
904
  className={css.iconButton}
@@ -756,139 +919,146 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
756
919
  </button>
757
920
  </div>
758
921
  )}
759
- <section className={css.detailSection}>
760
- <h4>{t('detail.description')}</h4>
761
- <ClampedMarkdown source={current.description !== '' ? current.description : '—'} />
762
- </section>
763
-
764
- <SubtaskSection controller={controller} task={current} pending={pending} archived={archived} snapshot={snapshot} />
765
-
766
- {current.tags !== undefined && current.tags.length > 0 && (
767
- <section className={css.detailSection} data-dsh-part="tags">
768
- <h4>{t('new.tags')}</h4>
769
- <div className={css.cardTags}>
770
- {current.tags.map(tag => (
771
- <span
772
- key={tag.name}
773
- className={css.cardTag}
774
- data-tag-tone={tagTone(tag.name)}
775
- data-dsh-part="tag-badge"
776
- data-tag-hint={tag.promptPrefix === undefined ? undefined : tag.promptPrefix}
777
- title={tag.promptPrefix === undefined ? tag.name : tag.promptPrefix}
778
- >
779
- {tag.name}
780
- </span>
781
- ))}
782
- </div>
783
- </section>
784
- )}
785
922
 
786
- {current.freeze !== undefined && (
787
- <section className={css.detailSection} data-dsh-part="freeze">
788
- <h4>{t('detail.freeze')}</h4>
789
- {current.freeze.redacted === true && <p className={css.formError}>{t('detail.freeze.redacted')}</p>}
790
- <p className={css.detailText}><strong>{t('detail.freeze.goal')}</strong></p>
791
- <pre className={css.promptBlock}>{current.freeze.goal}</pre>
792
- <p className={css.detailText}><strong>{t('detail.freeze.progress')}</strong></p>
793
- <pre className={css.promptBlock}>{current.freeze.progress}</pre>
794
- <p className={css.detailText}><strong>{t('detail.freeze.next')}</strong></p>
795
- <pre className={css.promptBlock}>{current.freeze.next}</pre>
796
- <p className={css.detailMeta}>{t('detail.freeze.frozenAt', { time: formatHostTimestamp(current.freeze.frozenAt, timeZone) })}</p>
797
- {current.freeze.frozenBy !== undefined && (
798
- <p className={css.detailMeta}>{t('detail.freeze.frozenBy', { session: current.freeze.frozenBy })}</p>
799
- )}
800
- </section>
801
- )}
923
+ {/* Two columns on a wide panel: what the card says on the left, what
924
+ the board does with it on the right. Both columns open on the same
925
+ baseline and share the 8px spacing rhythm; under 1024px the grid
926
+ collapses to the single reading column. */}
927
+ <div className={css.detailColumns} data-detail-layout="columns">
928
+ <div className={css.detailColumn} data-detail-column="content">
929
+ <section className={css.detailSection}>
930
+ <h4>{t('detail.description')}</h4>
931
+ <ClampedMarkdown source={current.description !== '' ? current.description : '—'} />
932
+ </section>
802
933
 
803
- {current.handover !== undefined && (
804
- <section className={css.detailSection} data-dsh-part="handover">
805
- <h4>{t('detail.handover')}</h4>
806
- <p className={css.detailText}>
807
- {t('new.workspace')}: {current.handover.workspaceId ?? t('exec.workspace.recent')}
808
- {' · '}{t('new.agentPreset')}: {current.handover.mode ?? t('exec.mode.inherit')}
809
- {' · '}{t('new.permission')}: {current.handover.permission === undefined ? t('exec.permission.default') : t(`exec.permission.${current.handover.permission}` as TaskBoardKey)}
810
- </p>
811
- <p className={css.detailText}><strong>{t('detail.handover.references')}</strong></p>
812
- <ul className={css.executionList}>
813
- {current.handover.references.map((reference, index) => (
814
- // References are free text from the freeze block, so the same
815
- // string can appear twice; the index keeps the key unique (#1492).
816
- <li key={`${reference}-${index}`} className={css.executionRow}><code>{reference}</code></li>
817
- ))}
818
- </ul>
819
- <p className={css.detailMeta}>{t('detail.handover.bundledAt', { time: formatHostTimestamp(current.handover.bundledAt, timeZone) })}</p>
820
- </section>
821
- )}
934
+ <section className={css.detailSection}>
935
+ <h4>{t('detail.prompt')}</h4>
936
+ <ClampedMarkdown source={current.prompt !== '' ? current.prompt : current.title} />
937
+ </section>
822
938
 
823
- {permissionPending && (
824
- <section className={css.detailSection} data-dsh-part="permission-gate">
825
- <p className={css.formError}>{t('detail.permissionPending', { permission: t(`exec.permission.${current.handover?.permission ?? current.permission}` as TaskBoardKey) })}</p>
826
- <button type="button" className={css.primaryButton} disabled={pending} onClick={() => { void controller.confirmPermission(current.id) }}>
827
- {t('detail.permissionConfirm')}
828
- </button>
829
- </section>
830
- )}
831
- {current.permissionConfirmedAt !== undefined && (
832
- <p className={css.detailMeta}>{t('detail.permissionConfirmed', { time: formatHostTimestamp(current.permissionConfirmedAt, timeZone) })}</p>
833
- )}
939
+ {current.tags !== undefined && current.tags.length > 0 && (
940
+ <section className={css.detailSection} data-dsh-part="tags">
941
+ <h4>{t('new.tags')}</h4>
942
+ <div className={css.cardTags}>
943
+ {current.tags.map(tag => (
944
+ <span
945
+ key={tag.name}
946
+ className={css.cardTag}
947
+ data-tag-tone={tagTone(tag.name)}
948
+ data-dsh-part="tag-badge"
949
+ data-tag-hint={tag.promptPrefix === undefined ? undefined : tag.promptPrefix}
950
+ title={tag.promptPrefix === undefined ? tag.name : tag.promptPrefix}
951
+ >
952
+ {tag.name}
953
+ </span>
954
+ ))}
955
+ </div>
956
+ </section>
957
+ )}
834
958
 
835
- {seats.detailSection({ task: current, dispatch })}
959
+ <SubtaskSection controller={controller} task={current} pending={pending} archived={archived} snapshot={snapshot} />
836
960
 
837
- <section className={css.detailSection}>
838
- <h4>{t('detail.prompt')}</h4>
839
- <ClampedMarkdown source={current.prompt !== '' ? current.prompt : current.title} />
840
- </section>
961
+ {current.freeze !== undefined && (
962
+ <section className={css.detailSection} data-dsh-part="freeze">
963
+ <h4>{t('detail.freeze')}</h4>
964
+ {current.freeze.redacted === true && <p className={css.formError}>{t('detail.freeze.redacted')}</p>}
965
+ <p className={css.detailText}><strong>{t('detail.freeze.goal')}</strong></p>
966
+ <pre className={css.promptBlock}>{current.freeze.goal}</pre>
967
+ <p className={css.detailText}><strong>{t('detail.freeze.progress')}</strong></p>
968
+ <pre className={css.promptBlock}>{current.freeze.progress}</pre>
969
+ <p className={css.detailText}><strong>{t('detail.freeze.next')}</strong></p>
970
+ <pre className={css.promptBlock}>{current.freeze.next}</pre>
971
+ <p className={css.detailMeta}>{t('detail.freeze.frozenAt', { time: formatHostTimestamp(current.freeze.frozenAt, timeZone) })}</p>
972
+ {current.freeze.frozenBy !== undefined && (
973
+ <p className={css.detailMeta}>{t('detail.freeze.frozenBy', { session: current.freeze.frozenBy })}</p>
974
+ )}
975
+ </section>
976
+ )}
841
977
 
842
- {!archived && (
843
- <>
844
- <ExecutionSettingsSection
845
- controller={controller}
846
- task={current}
847
- pending={pending}
848
- executionOptions={snapshot.executionOptions}
849
- teamRunAvailable={snapshot.host?.teamRunAvailable === true}
850
- goalRunEnabled={snapshot.host?.goalRunEnabled === true}
851
- />
852
- <ScheduleSection controller={controller} task={current} pending={pending} />
853
- </>
854
- )}
978
+ {current.handover !== undefined && (
979
+ <section className={css.detailSection} data-dsh-part="handover">
980
+ <h4>{t('detail.handover')}</h4>
981
+ <p className={css.detailText}>
982
+ {t('new.workspace')}: {current.handover.workspaceId ?? t('exec.workspace.recent')}
983
+ {' · '}{t('new.agentPreset')}: {current.handover.mode ?? t('exec.mode.inherit')}
984
+ {' · '}{t('new.permission')}: {current.handover.permission === undefined ? t('exec.permission.default') : t(`exec.permission.${current.handover.permission}` as TaskBoardKey)}
985
+ </p>
986
+ <p className={css.detailText}><strong>{t('detail.handover.references')}</strong></p>
987
+ <ul className={css.referenceList}>
988
+ {current.handover.references.map((reference, index) => (
989
+ // References are free text from the freeze block, so the same
990
+ // string can appear twice; the index keeps the key unique (#1492).
991
+ <li key={`${reference}-${index}`} className={css.referenceRow}><code>{reference}</code></li>
992
+ ))}
993
+ </ul>
994
+ <p className={css.detailMeta}>{t('detail.handover.bundledAt', { time: formatHostTimestamp(current.handover.bundledAt, timeZone) })}</p>
995
+ </section>
996
+ )}
855
997
 
856
- <section className={css.detailSection}>
857
- <h4>{t('detail.execution')}</h4>
858
- {current.executions.length === 0 ? (
859
- <p className={css.detailText}>{t('detail.noExecution')}</p>
860
- ) : (
861
- <ul className={css.executionList}>
862
- {[...current.executions].reverse().map(execution => (
863
- <ExecutionRow
864
- key={execution.id}
865
- execution={execution}
866
- timeZone={timeZone}
867
- onOpen={sessionId => { controller.openSession(sessionId) }}
868
- />
869
- ))}
870
- </ul>
871
- )}
872
- </section>
998
+ {seats.detailSection({ task: current, dispatch })}
999
+ </div>
873
1000
 
874
- {!archived && (
875
- <section className={css.detailSection}>
876
- <h4>{t('board.status')}</h4>
877
- <div className={css.moveRow}>
878
- {MANUAL_STATUSES.map(status => (
879
- <button
880
- key={status}
881
- type="button"
882
- className={css.ghostButton}
883
- disabled={pending || !canMoveTask(current, status)}
884
- onClick={() => { controller.moveTask(current.id, status) }}
885
- >
886
- {t(`status.move.${status}` as TaskBoardKey)}
1001
+ <div className={css.detailColumn} data-detail-column="execution">
1002
+ {permissionPending && (
1003
+ <section className={css.detailSection} data-dsh-part="permission-gate">
1004
+ <p className={css.formError}>{t('detail.permissionPending', { permission: t(`exec.permission.${current.handover?.permission ?? current.permission}` as TaskBoardKey) })}</p>
1005
+ <button type="button" className={css.primaryButton} disabled={pending} onClick={() => { void controller.confirmPermission(current.id) }}>
1006
+ {t('detail.permissionConfirm')}
887
1007
  </button>
888
- ))}
1008
+ </section>
1009
+ )}
1010
+ {current.permissionConfirmedAt !== undefined && (
1011
+ <p className={css.detailMeta}>{t('detail.permissionConfirmed', { time: formatHostTimestamp(current.permissionConfirmedAt, timeZone) })}</p>
1012
+ )}
1013
+
1014
+ {/* The three folds read as one list. The settings fold closes the
1015
+ section above it, so the group's 8px rhythm governs both the
1016
+ gap it trails and the gap before the history fold, while the
1017
+ blocks around the group keep the panel's 16px rhythm. */}
1018
+ <div className={css.detailFolds}>
1019
+ {!archived && (
1020
+ <>
1021
+ <ExecutionSettingsSection
1022
+ controller={controller}
1023
+ task={current}
1024
+ pending={pending}
1025
+ executionOptions={snapshot.executionOptions}
1026
+ goalRunEnabled={snapshot.host?.goalRunEnabled === true}
1027
+ />
1028
+ <ScheduleSection controller={controller} task={current} pending={pending} />
1029
+ </>
1030
+ )}
1031
+
1032
+ <FoldSection title={t('detail.execution')} summary={historySummary}>
1033
+ {current.executions.length === 0 ? (
1034
+ <p className={css.detailText}>{t('detail.noExecution')}</p>
1035
+ ) : (
1036
+ <ExecutionLog
1037
+ executions={current.executions}
1038
+ timeZone={timeZone}
1039
+ onOpenSession={sessionId => { controller.openSession(sessionId) }}
1040
+ />
1041
+ )}
1042
+ </FoldSection>
889
1043
  </div>
890
- </section>
891
- )}
1044
+
1045
+ {!archived && (
1046
+ <section className={css.detailSection}>
1047
+ <h4>{t('board.status')}</h4>
1048
+ <ActionMenu
1049
+ label={t('detail.moveTo')}
1050
+ disabled={pending}
1051
+ items={MANUAL_STATUSES.map(status => ({
1052
+ key: status,
1053
+ label: t(`status.move.${status}` as TaskBoardKey),
1054
+ disabled: !canMoveTask(current, status),
1055
+ onSelect: () => { controller.moveTask(current.id, status) },
1056
+ }))}
1057
+ />
1058
+ </section>
1059
+ )}
1060
+ </div>
1061
+ </div>
892
1062
  </div>
893
1063
 
894
1064
  <footer className={css.detailFooter}>
@@ -913,24 +1083,13 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
913
1083
  {t('detail.editTags')}
914
1084
  </button>
915
1085
  )}
916
- {!archived && (
917
- <button
918
- type="button"
919
- className={css.ghostButton}
920
- disabled={pending}
921
- onClick={() => { setShowDuplicate(true) }}
922
- title={canEditTaskContent(current) ? t('detail.duplicate') : t('detail.duplicateAndEdit')}
923
- >
924
- {canEditTaskContent(current) ? t('detail.duplicate') : t('detail.duplicateAndEdit')}
925
- </button>
926
- )}
927
1086
  {!archived && (
928
1087
  <button
929
1088
  type="button"
930
1089
  className={css.primaryButton}
931
1090
  disabled={busy || pending}
932
1091
  title={subtaskChildren.length > 0
933
- ? subtaskRunHint(current.id, subtaskChildren)
1092
+ ? subtaskDispatchNote(current, snapshot.tasks, subtaskDepthLimit)
934
1093
  : undefined}
935
1094
  onClick={() => {
936
1095
  void controller.rerunTask(current.id).then(() => {
@@ -941,7 +1100,7 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
941
1100
  {current.executions.length === 0 ? t('detail.run') : t('detail.rerun')}
942
1101
  </button>
943
1102
  )}
944
- {archived ? (
1103
+ {archived && (
945
1104
  <button
946
1105
  type="button"
947
1106
  className={css.primaryButton}
@@ -952,20 +1111,11 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
952
1111
  >
953
1112
  {t('detail.restore')}
954
1113
  </button>
955
- ) : (
956
- (current.status === 'done' || current.status === 'failed') && (
957
- <button
958
- type="button"
959
- className={css.ghostButton}
960
- disabled={pending}
961
- onClick={() => {
962
- controller.archiveTask(current.id)
963
- }}
964
- >
965
- {t('detail.archive')}
966
- </button>
967
- )
968
1114
  )}
1115
+ <span className={`${css.detailMeta} ${css.detailStamp}`}>
1116
+ {t('board.created')} {formatTime(current.createdAt, timeZone)}
1117
+ {archived && ` · ${t('detail.archivedAt', { time: formatTime(current.archivedAt!, timeZone) })}`}
1118
+ </span>
969
1119
  <button
970
1120
  type="button"
971
1121
  className={css.dangerButton}
@@ -974,10 +1124,6 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
974
1124
  >
975
1125
  {t('detail.delete')}
976
1126
  </button>
977
- <span className={css.detailMeta}>
978
- {t('board.created')} {formatTime(current.createdAt, timeZone)}
979
- {archived && ` · ${t('detail.archivedAt', { time: formatTime(current.archivedAt!, timeZone) })}`}
980
- </span>
981
1127
  </footer>
982
1128
  </div>
983
1129