@linxin666/dsh-client-ui-task-board 0.4.7 → 0.4.9

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 (75) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +29 -22
  3. package/README.zh.md +29 -22
  4. package/lib/client.js +1553 -670
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +757 -419
  7. package/lib/types/client/PluginSettingsCard.d.ts +60 -0
  8. package/lib/types/client/TaskBoardSettingsCard.d.ts +14 -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 +44 -6
  14. package/lib/types/client/suppress-schedule-row.d.ts +86 -0
  15. package/lib/types/client/telemetry.d.ts +14 -2
  16. package/lib/types/core/controller.d.ts +1 -1
  17. package/lib/types/core/execution-summary.d.ts +52 -0
  18. package/lib/types/core/extension.d.ts +34 -0
  19. package/lib/types/core/spend-budget.d.ts +28 -0
  20. package/lib/types/core/subtask.d.ts +59 -49
  21. package/lib/types/core/tasks.d.ts +37 -9
  22. package/lib/types/core/use-cases/task-update.d.ts +1 -1
  23. package/lib/types/core/workspace-target.d.ts +23 -3
  24. package/lib/types/host/launch-admission.d.ts +8 -9
  25. package/lib/types/host-ledger.d.ts +96 -50
  26. package/lib/types/host-routes.d.ts +49 -0
  27. package/lib/types/host-runner.d.ts +24 -11
  28. package/lib/types/host-service.d.ts +38 -50
  29. package/lib/types/host-spend.d.ts +52 -0
  30. package/lib/types/index.d.ts +70 -61
  31. package/lib/types/loopback.d.ts +41 -1
  32. package/lib/types/protocol.d.ts +0 -5
  33. package/lib/types/tool-surface.d.ts +1 -0
  34. package/package.json +25 -25
  35. package/src/client/CardDefaultPresetField.tsx +1 -1
  36. package/src/client/PluginSettingsCard.tsx +140 -20
  37. package/src/client/TaskBoardSettingsCard.tsx +104 -24
  38. package/src/client/board/ExecutionLog.tsx +140 -0
  39. package/src/client/board/LinkSubtaskModal.tsx +1 -9
  40. package/src/client/board/NewTaskModal.tsx +2 -11
  41. package/src/client/board/TaskCard.tsx +45 -23
  42. package/src/client/board/TaskDetail.tsx +407 -261
  43. package/src/client/board/TaskForm.tsx +19 -4
  44. package/src/client/board/VerificationReport.tsx +143 -104
  45. package/src/client/board/task-markdown.module.css +11 -8
  46. package/src/client/board-settings.module.css +35 -7
  47. package/src/client/board.module.css +855 -115
  48. package/src/client/body-mutations.ts +133 -0
  49. package/src/client/index.ts +10 -0
  50. package/src/client/locales.ts +101 -24
  51. package/src/client/settings-card.module.css +141 -11
  52. package/src/client/suppress-schedule-row.ts +198 -0
  53. package/src/client/telemetry.ts +47 -2
  54. package/src/core/controller.ts +1 -3
  55. package/src/core/execution-summary.ts +96 -0
  56. package/src/core/extension.ts +34 -0
  57. package/src/core/spend-budget.ts +35 -0
  58. package/src/core/store.ts +4 -0
  59. package/src/core/subtask.ts +81 -76
  60. package/src/core/tasks.ts +48 -10
  61. package/src/core/use-cases/task-update.ts +1 -3
  62. package/src/core/workspace-target.ts +27 -3
  63. package/src/host/agent-tools.ts +14 -15
  64. package/src/host/launch-admission.ts +8 -9
  65. package/src/host-ledger.ts +218 -127
  66. package/src/host-routes.ts +65 -2
  67. package/src/host-runner.ts +68 -35
  68. package/src/host-service.ts +136 -132
  69. package/src/host-spend.ts +105 -0
  70. package/src/index.ts +115 -104
  71. package/src/loopback.ts +57 -1
  72. package/src/protocol.ts +2 -9
  73. package/src/tool-surface.ts +1 -0
  74. package/lib/types/client/board/team-run-promotion.d.ts +0 -26
  75. package/src/client/board/team-run-promotion.ts +0 -39
@@ -0,0 +1,140 @@
1
+ /**
2
+ * The execution history of one card.
3
+ *
4
+ * A card accumulates dozens of runs, and each run carried the full acceptance
5
+ * report inline: the same machine explanation repeated once per row buried the
6
+ * one row a reader needed. The history therefore renders newest first, keeps
7
+ * the five latest rows visible and puts the rest behind one disclosure that
8
+ * opens and closes as one motion pair (the presence hook keeps the extra rows
9
+ * mounted through the exit leg instead of pulling them out on the click's
10
+ * tick). Each row is two lines: identity on top (status, start/end in one
11
+ * format, the session jump) and the evidence the run produced underneath.
12
+ *
13
+ * Deliberately adds no new `data-dsh-part` value: the part enum belongs to the
14
+ * cross-repository semantic-attribute contract.
15
+ */
16
+ import { useId, useState } from 'react'
17
+ import type { ExecutionRecord } from '../../core/tasks.ts'
18
+ import { isMissingWorkspaceReason } from '../../core/workspace-target.ts'
19
+ import { t, type TaskBoardKey } from '../locales.ts'
20
+ import css from '../board.module.css'
21
+ import { IconSession } from './icons.tsx'
22
+ import { usePresence } from './overlay.tsx'
23
+ import { formatTime } from './TaskCard.tsx'
24
+ import { VerificationReport } from './VerificationReport.tsx'
25
+
26
+ /** Rows shown before the history asks to be expanded. */
27
+ export const VISIBLE_EXECUTIONS = 5
28
+
29
+ /** Execution outcome → locale key, shared with the history's folded summary. */
30
+ export const EXECUTION_RESULT_KEY: Record<NonNullable<ExecutionRecord['result']>, TaskBoardKey> = {
31
+ succeeded: 'detail.result.succeeded',
32
+ failed: 'detail.result.failed',
33
+ cancelled: 'detail.result.cancelled',
34
+ }
35
+
36
+ /** One execution-history row: identity on the head line, evidence below it. */
37
+ function ExecutionRow({ execution, timeZone, onOpen }: {
38
+ execution: ExecutionRecord
39
+ timeZone?: string
40
+ onOpen: (sessionId: string) => void
41
+ }) {
42
+ const result = execution.result
43
+ // An external record is one the Host never observed running: no session, no
44
+ // spinner, and a named outside agent instead of the initiating session. The
45
+ // data attribute keeps the distinction machine-readable too.
46
+ const external = execution.external === true
47
+ return (
48
+ <li
49
+ className={css.executionRow}
50
+ data-result={result}
51
+ data-execution-id={execution.id}
52
+ data-external={external ? 'true' : undefined}
53
+ >
54
+ <div className={css.executionRowHead}>
55
+ <span className={css.executionBadge} data-result={result}>
56
+ {result === undefined ? t('detail.result.running') : t(EXECUTION_RESULT_KEY[result])}
57
+ </span>
58
+ <span className={css.executionTimes}>
59
+ {t('detail.executionStarted')} {formatTime(execution.startedAt, timeZone)}
60
+ {execution.endedAt !== undefined && ` · ${t('detail.executionEnded')} ${formatTime(execution.endedAt, timeZone)}`}
61
+ </span>
62
+ {execution.sessionId !== undefined && (
63
+ <button
64
+ type="button"
65
+ className={css.executionSession}
66
+ onClick={() => { onOpen(execution.sessionId as string) }}
67
+ title={execution.sessionId}
68
+ >
69
+ {t('detail.viewSession')}
70
+ <IconSession size={13} />
71
+ </button>
72
+ )}
73
+ </div>
74
+ <div className={css.executionRowEvidence}>
75
+ {external && execution.initiatedBy !== undefined && (
76
+ <span className={css.executionTimes} title={execution.initiatedBy}>
77
+ {t('detail.execution.external', { agent: execution.initiatedBy })}
78
+ </span>
79
+ )}
80
+ {!external && execution.initiatedBy !== undefined && (
81
+ <span className={css.executionTimes} title={execution.initiatedBy}>
82
+ {t('detail.execution.initiator', { session: execution.initiatedBy })}
83
+ </span>
84
+ )}
85
+ {execution.verification !== undefined && <VerificationReport verification={execution.verification} />}
86
+ {execution.error !== undefined && execution.error !== '' && (
87
+ <span className={css.executionError}>
88
+ {isMissingWorkspaceReason(execution.error) ? t('exec.error.noWorkspace') : execution.error}
89
+ </span>
90
+ )}
91
+ </div>
92
+ </li>
93
+ )
94
+ }
95
+
96
+ /**
97
+ * Render one card's execution history.
98
+ * @param props - the card's executions, its time zone and the session jump.
99
+ * @returns the newest rows, the disclosure for the rest, and nothing else.
100
+ */
101
+ export function ExecutionLog({ executions, timeZone, onOpenSession }: {
102
+ executions: readonly ExecutionRecord[]
103
+ timeZone?: string
104
+ onOpenSession: (sessionId: string) => void
105
+ }) {
106
+ const [expanded, setExpanded] = useState(false)
107
+ const presence = usePresence(expanded)
108
+ const logId = useId()
109
+ // Newest first: the row a reader wants is the run that just settled.
110
+ const recent = [...executions].reverse()
111
+ const visible = recent.slice(0, VISIBLE_EXECUTIONS)
112
+ const older = recent.slice(VISIBLE_EXECUTIONS)
113
+ const row = (execution: ExecutionRecord) => (
114
+ <ExecutionRow key={execution.id} execution={execution} timeZone={timeZone} onOpen={onOpenSession} />
115
+ )
116
+ return (
117
+ <div className={css.executionLog} id={logId}>
118
+ <ul className={css.executionList}>{visible.map(row)}</ul>
119
+ {older.length > 0 && presence.mounted && (
120
+ <div className={css.executionExtra} data-execution-fold={presence.phase}>
121
+ <ul className={css.executionList}>{older.map(row)}</ul>
122
+ </div>
123
+ )}
124
+ {older.length > 0 && (
125
+ <button
126
+ type="button"
127
+ className={`${css.linkButton} ${css.executionDisclosure}`}
128
+ aria-expanded={expanded}
129
+ aria-controls={logId}
130
+ onClick={() => { setExpanded(!expanded) }}
131
+ >
132
+ {expanded
133
+ ? t('detail.collapse')
134
+ : t('detail.execution.showAll', { count: String(recent.length) })}
135
+ <span className={css.disclosureChevron} data-open={expanded} aria-hidden="true" />
136
+ </button>
137
+ )}
138
+ </div>
139
+ )
140
+ }
@@ -12,7 +12,6 @@ import { t } from '../locales.ts'
12
12
  import css from '../board.module.css'
13
13
  import { useDialog, type OverlayPhase } from './overlay.tsx'
14
14
  import { STATUS_KEY } from './status-key.ts'
15
- import { parentAwaitsTeamRunPromotion, promoteParentForTeamRun } from './team-run-promotion.ts'
16
15
 
17
16
  /** Link-subtask overlay props. */
18
17
  export interface LinkSubtaskModalProps {
@@ -57,10 +56,6 @@ export function LinkSubtaskModal({ controller, parent, onClose, phase = 'open' }
57
56
  setPending(true)
58
57
  setError(undefined)
59
58
  if (await controller.setParent(taskId, parent.id)) {
60
- // The link is confirmed, so a parent that just gained a subtask is opted
61
- // in where Agent Teams are served; a refused opt-in never undoes a link
62
- // the Host already committed.
63
- await promoteParentForTeamRun(controller, parent)
64
59
  onClose()
65
60
  return
66
61
  }
@@ -72,9 +67,6 @@ export function LinkSubtaskModal({ controller, parent, onClose, phase = 'open' }
72
67
  <div ref={dialog.attach} className={css.modal} role="dialog" aria-modal="true" aria-label={t('link.subtask.title')} tabIndex={-1}>
73
68
  <h2 className={css.modalTitle}>{t('link.subtask.title')}</h2>
74
69
  <p className={css.fieldHint}>{t('link.subtask.hint')}</p>
75
- {parentAwaitsTeamRunPromotion(controller, parent) && (
76
- <p className={css.fieldHint}>{t('exec.teamRunAutoHint')}</p>
77
- )}
78
70
  {candidates.length === 0
79
71
  ? <p className={css.detailText}>{t('link.subtask.empty')}</p>
80
72
  : (
@@ -85,7 +77,7 @@ export function LinkSubtaskModal({ controller, parent, onClose, phase = 'open' }
85
77
  <span className={css.statusBadge} data-status={task.status}>{t(STATUS_KEY[task.status])}</span>
86
78
  <button
87
79
  type="button"
88
- className={css.primaryButton}
80
+ className={css.ghostButton}
89
81
  disabled={pending}
90
82
  onClick={() => { void link(task.id) }}
91
83
  >
@@ -19,7 +19,6 @@ import { readParseModelPreference, writeParseModelPreference } from './parse-mod
19
19
  import { inheritPresetLabel, presetChoiceRows, presetLabel } from './preset-label.ts'
20
20
  import { ReasoningEffortField } from './ReasoningEffortField.tsx'
21
21
  import { reconcileReasoningEffort } from './model-options.ts'
22
- import { parentAwaitsTeamRunPromotion, promoteParentForTeamRun } from './team-run-promotion.ts'
23
22
  import css from '../board.module.css'
24
23
 
25
24
  export interface NewTaskModalProps {
@@ -273,11 +272,6 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
273
272
  setError(controller.getSnapshot().transportError ?? t('new.required'))
274
273
  return
275
274
  }
276
- // The join is confirmed, so a parent that just gained a subtask is opted in
277
- // where Agent Teams are served. The write is a convenience, not part of the
278
- // creation: a refused one (the card was archived meanwhile) already
279
- // surfaced through the snapshot and never fails the created task.
280
- await promoteParentForTeamRun(controller, parentTask)
281
275
  if (isDuplicate && archiveOriginal && initialTask !== undefined) {
282
276
  if (onDuplicateSuccess !== undefined) {
283
277
  await onDuplicateSuccess(initialTask.id)
@@ -426,7 +420,7 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
426
420
  : (
427
421
  <button
428
422
  type="button"
429
- className={css.primaryButton}
423
+ className={css.ghostButton}
430
424
  disabled={parseText.trim() === ''}
431
425
  onClick={() => { void runParse() }}
432
426
  >
@@ -444,9 +438,6 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
444
438
  <p className={css.detailText} data-dsh-part="subtask-inherit">
445
439
  {t('detail.parent')}: {parentTask.title} · {t('new.subtaskInherit')}
446
440
  </p>
447
- {parentAwaitsTeamRunPromotion(controller, parentTask) && (
448
- <p className={css.detailText}>{t('exec.teamRunAutoHint')}</p>
449
- )}
450
441
  </>
451
442
  )}
452
443
 
@@ -460,7 +451,7 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
460
451
  onPromptChange={setPrompt}
461
452
  />
462
453
  {isDuplicate && (
463
- <label className={css.checkboxLabel}>
454
+ <label className={css.scheduleToggle}>
464
455
  <input
465
456
  type="checkbox"
466
457
  checked={archiveOriginal}
@@ -168,6 +168,36 @@ function TaskCardInner({
168
168
  outcome.declared ? t('card.declaredHint') : '',
169
169
  ].filter(Boolean).join('\n')
170
170
 
171
+ // The status rail is one reserved row in every state: a label while a run is
172
+ // in flight, the settled result badge beside the run count, and the spinner
173
+ // box that is the same size whether or not it holds a spinner. Nothing here
174
+ // can add or remove a row, so a state change cannot resize the card.
175
+ const runningLabel = !archived && latest !== undefined && executionLabel(latest) === 'running'
176
+ ? (runningKey !== undefined
177
+ ? t(runningKey)
178
+ : latest.ownResult === undefined ? t('detail.result.running') : t('detail.subtasks.waiting'))
179
+ : ''
180
+ // Archived cards settle outside the board's judgement, so they keep the plain
181
+ // text result instead of a badge that would paint a tone they do not own.
182
+ const settledResult = archived ? undefined : latest?.result
183
+ const resultPrefix = settledResult === undefined && !busy && resultText !== '' ? `${resultText} · ` : ''
184
+ const runLine = latest === undefined ? undefined : (
185
+ <span
186
+ className={css.cardRun}
187
+ data-dsh-part="card-run"
188
+ data-result={settledResult}
189
+ data-declared={outcome.declared || undefined}
190
+ title={outcome.declared ? t('card.declaredHint') : undefined}
191
+ >
192
+ {settledResult !== undefined && (
193
+ <span className={css.cardResult} data-result={settledResult}>{resultText}</span>
194
+ )}
195
+ <span className={css.cardRuns}>
196
+ {resultPrefix}{runs} {t('board.runs')}
197
+ {outcome.declared ? ` · ${t('card.declared')}` : ''}
198
+ </span>
199
+ </span>
200
+ )
171
201
  const sessionMark = sessionId !== undefined && (onOpenSession !== undefined ? (
172
202
  <button
173
203
  type="button"
@@ -220,7 +250,9 @@ function TaskCardInner({
220
250
  <span className={css.cardMeta}>
221
251
  {decoration}
222
252
  {timeLabel}
223
- {!archived && (busy || pending) && <span className={css.cardSpinner} aria-hidden="true" />}
253
+ <span className={css.cardSpinnerSlot} aria-hidden="true">
254
+ {!archived && (busy || pending) && <span className={css.cardSpinner} />}
255
+ </span>
224
256
  </span>
225
257
  ) : (
226
258
  <>
@@ -281,30 +313,20 @@ function TaskCardInner({
281
313
  {t(task.schedule.mode === 'once' ? 'card.scheduledOnce' : 'card.scheduled')}
282
314
  </span>
283
315
  )}
284
- {latest !== undefined && (
285
- <span
286
- className={css.cardRun}
287
- data-dsh-part="card-run"
288
- data-result={archived || latest.result === undefined ? undefined : latest.result}
289
- data-declared={outcome.declared || undefined}
290
- title={outcome.declared ? t('card.declaredHint') : undefined}
291
- >
292
- {!busy && resultText !== '' ? `${resultText} · ` : ''}
293
- {runs} {t('board.runs')}
294
- {outcome.declared ? ` · ${t('card.declared')}` : ''}
295
- </span>
296
- )}
297
- {sessionMark}
298
- {!archived && (busy || pending) && <span className={css.cardSpinner} aria-hidden="true" />}
299
316
  </span>
300
- {!archived && pending && <span className={css.cardRunningLabel}>{t('board.pending')}…</span>}
301
- {!archived && latest !== undefined && executionLabel(latest) === 'running' && (
302
- <span className={css.cardRunningLabel}>
303
- {runningKey !== undefined
304
- ? t(runningKey)
305
- : latest.ownResult === undefined ? t('detail.result.running') : t('detail.subtasks.waiting')}…
317
+ <span className={css.cardStatus}>
318
+ <span className={css.cardStatusText}>
319
+ {!archived && pending && <span className={css.cardRunningLabel}>{t('board.pending')}…</span>}
320
+ {runningLabel !== '' && <span className={css.cardRunningLabel}>{runningLabel}…</span>}
321
+ {runLine}
306
322
  </span>
307
- )}
323
+ <span className={css.cardStatusTrail}>
324
+ <span className={css.cardSpinnerSlot} aria-hidden="true">
325
+ {!archived && (busy || pending) && <span className={css.cardSpinner} />}
326
+ </span>
327
+ {sessionMark}
328
+ </span>
329
+ </span>
308
330
  </>
309
331
  )}
310
332
  </article>