@fish-under-sea/dsh-client-ui-task-board-fish 1.0.2 → 2.0.0

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 (125) hide show
  1. package/NOTICE +1 -1
  2. package/README.en.md +6 -4
  3. package/README.md +6 -4
  4. package/README.zh.md +6 -4
  5. package/icon.png +0 -0
  6. package/lib/client.js +4428 -1508
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +2670 -496
  9. package/lib/types/client/CardDefaultPresetField.d.ts +35 -0
  10. package/lib/types/client/PluginSettingsCard.d.ts +130 -19
  11. package/lib/types/client/RangeBubble.d.ts +46 -0
  12. package/lib/types/client/SegmentGroup.d.ts +28 -0
  13. package/lib/types/client/TaskBoardSettingsCard.d.ts +63 -0
  14. package/lib/types/client/board/AttachmentField.d.ts +70 -0
  15. package/lib/types/client/board/ExecutionLog.d.ts +24 -0
  16. package/lib/types/client/board/ReasoningEffortField.d.ts +25 -0
  17. package/lib/types/client/board/TaskForm.d.ts +4 -0
  18. package/lib/types/client/board/VerificationReport.d.ts +2 -15
  19. package/lib/types/client/board/model-options.d.ts +87 -0
  20. package/lib/types/client/board/preset-label.d.ts +21 -0
  21. package/lib/types/client/board/preset-roster.d.ts +45 -0
  22. package/lib/types/client/board/source-group.d.ts +27 -0
  23. package/lib/types/client/body-mutations.d.ts +45 -0
  24. package/lib/types/client/host-api.d.ts +25 -0
  25. package/lib/types/client/locales.d.ts +87 -9
  26. package/lib/types/client/pending-verify.d.ts +47 -0
  27. package/lib/types/client/plugin-card-seat.d.ts +3 -1
  28. package/lib/types/client/service.d.ts +4 -1
  29. package/lib/types/client/settings-form.d.ts +73 -51
  30. package/lib/types/core/attachment.d.ts +132 -0
  31. package/lib/types/core/card-defaults.d.ts +78 -0
  32. package/lib/types/core/controller.d.ts +57 -8
  33. package/lib/types/core/execution-summary.d.ts +52 -0
  34. package/lib/types/core/extension.d.ts +116 -0
  35. package/lib/types/core/launch-width.d.ts +31 -0
  36. package/lib/types/core/reasoning-effort.d.ts +57 -0
  37. package/lib/types/core/session-reuse.d.ts +7 -1
  38. package/lib/types/core/spend-budget.d.ts +28 -0
  39. package/lib/types/core/subtask.d.ts +100 -37
  40. package/lib/types/core/tasks.d.ts +94 -10
  41. package/lib/types/core/use-cases/task-create.d.ts +10 -5
  42. package/lib/types/core/use-cases/task-tag.d.ts +36 -0
  43. package/lib/types/core/use-cases/task-update.d.ts +22 -1
  44. package/lib/types/core/wire-projection.d.ts +35 -0
  45. package/lib/types/core/workspace-target.d.ts +23 -3
  46. package/lib/types/host/attachments.d.ts +250 -0
  47. package/lib/types/host/extension-registry.d.ts +40 -0
  48. package/lib/types/host/launch-admission.d.ts +71 -0
  49. package/lib/types/host-ledger.d.ts +114 -47
  50. package/lib/types/host-routes.d.ts +63 -0
  51. package/lib/types/host-runner.d.ts +164 -18
  52. package/lib/types/host-service.d.ts +182 -46
  53. package/lib/types/host-spend.d.ts +52 -0
  54. package/lib/types/index.d.ts +173 -54
  55. package/lib/types/loopback.d.ts +41 -1
  56. package/lib/types/protocol.d.ts +52 -11
  57. package/lib/types/tool-surface.d.ts +1 -0
  58. package/locale/en.json +6 -0
  59. package/locale/zh.json +6 -0
  60. package/package.json +36 -29
  61. package/src/client/CardDefaultPresetField.tsx +101 -0
  62. package/src/client/PluginSettingsCard.tsx +385 -111
  63. package/src/client/RangeBubble.tsx +164 -0
  64. package/src/client/SegmentGroup.tsx +93 -0
  65. package/src/client/TaskBoardSettingsCard.tsx +332 -37
  66. package/src/client/board/AttachmentField.tsx +383 -0
  67. package/src/client/board/EditTaskModal.tsx +63 -0
  68. package/src/client/board/ExecutionLog.tsx +154 -0
  69. package/src/client/board/LinkSubtaskModal.tsx +1 -1
  70. package/src/client/board/NewTaskModal.tsx +154 -45
  71. package/src/client/board/ReasoningEffortField.tsx +50 -0
  72. package/src/client/board/TagManagerModal.tsx +151 -2
  73. package/src/client/board/TaskBoard.tsx +47 -10
  74. package/src/client/board/TaskCard.tsx +45 -23
  75. package/src/client/board/TaskDetail.tsx +468 -258
  76. package/src/client/board/TaskForm.tsx +19 -4
  77. package/src/client/board/VerificationReport.tsx +143 -104
  78. package/src/client/board/model-options.ts +208 -0
  79. package/src/client/board/preset-label.ts +32 -0
  80. package/src/client/board/preset-roster.ts +58 -0
  81. package/src/client/board/source-group.ts +94 -0
  82. package/src/client/board/task-markdown.module.css +11 -8
  83. package/src/client/board-settings.module.css +35 -7
  84. package/src/client/board.module.css +1044 -105
  85. package/src/client/body-mutations.ts +133 -0
  86. package/src/client/host-api.ts +70 -0
  87. package/src/client/index.ts +109 -95
  88. package/src/client/locales.ts +205 -48
  89. package/src/client/pending-verify.ts +90 -0
  90. package/src/client/plugin-card-seat.ts +8 -2
  91. package/src/client/service.ts +24 -0
  92. package/src/client/settings-card.module.css +466 -89
  93. package/src/client/settings-entry-form.ts +0 -1
  94. package/src/client/settings-form.ts +102 -60
  95. package/src/core/attachment.ts +287 -0
  96. package/src/core/card-defaults.ts +132 -0
  97. package/src/core/controller.ts +90 -11
  98. package/src/core/execution-summary.ts +96 -0
  99. package/src/core/extension.ts +120 -0
  100. package/src/core/launch-width.ts +38 -0
  101. package/src/core/reasoning-effort.ts +92 -0
  102. package/src/core/session-reuse.ts +7 -1
  103. package/src/core/spend-budget.ts +35 -0
  104. package/src/core/store.ts +19 -1
  105. package/src/core/subtask.ts +144 -68
  106. package/src/core/tasks.ts +117 -10
  107. package/src/core/use-cases/task-create.ts +27 -16
  108. package/src/core/use-cases/task-tag.ts +56 -0
  109. package/src/core/use-cases/task-update.ts +33 -5
  110. package/src/core/wire-projection.ts +81 -0
  111. package/src/core/workspace-target.ts +27 -3
  112. package/src/host/agent-tools.ts +33 -21
  113. package/src/host/attachments.ts +650 -0
  114. package/src/host/extension-registry.ts +150 -5
  115. package/src/host/launch-admission.ts +139 -0
  116. package/src/host-ledger.ts +248 -117
  117. package/src/host-routes.ts +233 -15
  118. package/src/host-runner.ts +395 -61
  119. package/src/host-service.ts +512 -139
  120. package/src/host-spend.ts +105 -0
  121. package/src/index.ts +312 -92
  122. package/src/loopback.ts +57 -1
  123. package/src/protocol.ts +83 -18
  124. package/src/tool-surface.ts +1 -0
  125. package/icon.svg +0 -3
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Bounded verification of the one board state the mirror knows is transient.
3
+ *
4
+ * A pushed frame is how the panel normally learns that the Host moved, and the
5
+ * browser cannot verify that frames still arrive: an SSE connection that stops
6
+ * delivering without closing leaves `EventSource` open and silent, so no error
7
+ * fires and no frame comes. While the mirror still shows an execution the Host
8
+ * has not settled, that silence looks exactly like a run still in progress —
9
+ * the row a reader is looking at keeps saying "running" long after the Host
10
+ * wrote the session id and settled it.
11
+ *
12
+ * So the mirror verifies exactly that state and nothing else: one state read per
13
+ * {@link PENDING_VERIFICATION_MS} while at least one execution is still open,
14
+ * disarmed by the snapshot itself as soon as the last one settles. A board with
15
+ * nothing in flight reads nothing (the package rule: an idle board does not
16
+ * poll), and a hidden page defers its reads until it is looked at again.
17
+ *
18
+ * @module dsh-task-board/client/pending-verify
19
+ */
20
+
21
+ /**
22
+ * Verification cadence while an execution is open. It matches the interval the
23
+ * transport already uses to recover from a stream error, so a missed frame and
24
+ * a broken stream converge within the same bound.
25
+ */
26
+ export const PENDING_VERIFICATION_MS = 15_000
27
+
28
+ /** What the loop needs from the mirror and from the Host transport. */
29
+ export interface PendingVerificationFace {
30
+ /** Whether the mirror still shows an execution the Host has not settled. */
31
+ pending(): boolean
32
+ /** Re-read the authoritative Host snapshot. */
33
+ refresh(): void
34
+ /** Follow mirror changes; the loop is armed and disarmed by them. */
35
+ subscribe(listener: () => void): () => void
36
+ /** Whether a read is useful right now; defaults to the page being visible. */
37
+ visible?(): boolean
38
+ /** Timer arming; defaults to the page's own interval. */
39
+ schedule?(run: () => void): unknown
40
+ /** Timer release, paired with {@link PendingVerificationFace.schedule}. */
41
+ cancel?(handle: unknown): void
42
+ }
43
+
44
+ /**
45
+ * Watch the mirror and re-read the Host snapshot while it shows work in flight.
46
+ * @param face - the mirror, the read, and the seams the loop runs on.
47
+ * @param intervalMs - verification cadence in milliseconds.
48
+ * @returns the disposer that releases the timer and the subscription.
49
+ */
50
+ export function startPendingVerification(
51
+ face: PendingVerificationFace,
52
+ intervalMs: number = PENDING_VERIFICATION_MS,
53
+ ): () => void {
54
+ const schedule = face.schedule ?? ((run: () => void): unknown => globalThis.setInterval(run, intervalMs))
55
+ const cancel = face.cancel ?? ((handle: unknown): void => {
56
+ globalThis.clearInterval(handle as ReturnType<typeof setInterval>)
57
+ })
58
+ const visible = face.visible ?? pageVisible
59
+ let handle: unknown
60
+ const stop = (): void => {
61
+ if (handle === undefined) return
62
+ const current = handle
63
+ handle = undefined
64
+ cancel(current)
65
+ }
66
+ const tick = (): void => {
67
+ if (!face.pending()) {
68
+ stop()
69
+ return
70
+ }
71
+ if (!visible()) return
72
+ face.refresh()
73
+ }
74
+ const arm = (): void => {
75
+ if (handle !== undefined || !face.pending()) return
76
+ handle = schedule(tick)
77
+ }
78
+ const unsubscribe = face.subscribe(arm)
79
+ arm()
80
+ return () => {
81
+ unsubscribe()
82
+ stop()
83
+ }
84
+ }
85
+
86
+ /** Whether the page is being looked at; a composition without a document counts as visible. */
87
+ function pageVisible(): boolean {
88
+ const state = (globalThis as { document?: { visibilityState?: string } }).document?.visibilityState
89
+ return state === undefined || state === 'visible'
90
+ }
@@ -52,6 +52,8 @@ export const FAMILY_GROUP_SERVICE = 'webUiSettings'
52
52
  export interface PluginCardSlots {
53
53
  /** Contribution of one card entry. */
54
54
  register(options: never, component: never): unknown
55
+ /** Declaration probe: a target seat may appear after this plugin applies. */
56
+ spec?(key: string): unknown
55
57
  }
56
58
 
57
59
  /** The slice of the client context a card contribution needs. */
@@ -60,7 +62,7 @@ export interface PluginCardContext {
60
62
  /** Service lookup; absent on a context double that only models the slots. */
61
63
  get?(name: string): unknown
62
64
  /** Event subscription seat; absent on an event-less test double. */
63
- on?(event: string, listener: (...args: never[]) => void): unknown
65
+ on?(event: never, listener: never): unknown
64
66
  }
65
67
 
66
68
  /** Owner share of a family list-seat card (that seat supplies nothing). */
@@ -154,6 +156,10 @@ export function installPluginCard(ctx: PluginCardContext, seat: PluginCardSeat):
154
156
  if (reconciling) return
155
157
  const target = familyGroupLoaded(ctx) ? FAMILY_PLUGIN_CARD_SEAT : OFFICIAL_PLUGIN_CARD_SEAT
156
158
  if (current === target) return
159
+ // The group's child seat can be declared after this card applies (the
160
+ // parent mounts its pages through the extension service). Wait for the
161
+ // declaration instead of logging a refused registration on every boot.
162
+ if (typeof slots.spec === 'function' && slots.spec(target) === undefined) return
157
163
  reconciling = true
158
164
  const previous = dispose
159
165
  dispose = undefined
@@ -187,7 +193,7 @@ export function installPluginCard(ctx: PluginCardContext, seat: PluginCardSeat):
187
193
 
188
194
  if (typeof ctx.on === 'function') {
189
195
  try {
190
- ctx.on('slots/changed', () => { reconcile() })
196
+ ctx.on('slots/changed' as never, (() => { reconcile() }) as never)
191
197
  } catch {
192
198
  // An event seat that refuses the subscription leaves the initial
193
199
  // decision in place; the card still renders in the seat chosen below.
@@ -14,16 +14,25 @@ import type {
14
14
  TaskBoardClientFace,
15
15
  TaskBoardClientMirror,
16
16
  TaskBoardExtensionActionRequest,
17
+ TaskBoardGroupingSelector,
17
18
  TaskBoardVisibilityPredicate,
18
19
  } from '../core/extension.ts'
19
20
  import type { TaskRecord } from '../core/tasks.ts'
20
21
 
22
+ interface PendingGroupingRegistration {
23
+ selector: TaskBoardGroupingSelector
24
+ active: boolean
25
+ dispose?: () => void
26
+ }
27
+
21
28
  export class TaskBoardClientService implements TaskBoardClientFace {
22
29
  private controller: BoardController | undefined
23
30
  private enabled = false
24
31
  private unsubscribeController: (() => void) | undefined
25
32
  /** Predicates registered before the controller exists, replayed on attach. */
26
33
  private readonly pendingVisibility: TaskBoardVisibilityPredicate[] = []
34
+ /** Source selectors registered before the controller exists, replayed on attach. */
35
+ private readonly pendingGrouping: PendingGroupingRegistration[] = []
27
36
  private readonly listeners = new Set<(mirror: TaskBoardClientMirror) => void>()
28
37
 
29
38
  /** Bind the live board controller (called when the UI mounts). */
@@ -33,6 +42,9 @@ export class TaskBoardClientService implements TaskBoardClientFace {
33
42
  this.controller = controller
34
43
  this.unsubscribeController = controller.subscribe(() => { this.notify() })
35
44
  for (const predicate of this.pendingVisibility.splice(0)) controller.registerVisibility(predicate)
45
+ for (const registration of this.pendingGrouping.splice(0)) {
46
+ if (registration.active) registration.dispose = controller.registerGrouping(registration.selector)
47
+ }
36
48
  this.notify()
37
49
  }
38
50
 
@@ -66,6 +78,18 @@ export class TaskBoardClientService implements TaskBoardClientFace {
66
78
  }
67
79
  }
68
80
 
81
+ registerGrouping(selector: TaskBoardGroupingSelector): () => void {
82
+ if (this.controller !== undefined) return this.controller.registerGrouping(selector)
83
+ const registration: PendingGroupingRegistration = { selector, active: true }
84
+ this.pendingGrouping.push(registration)
85
+ return () => {
86
+ registration.active = false
87
+ registration.dispose?.()
88
+ const index = this.pendingGrouping.indexOf(registration)
89
+ if (index !== -1) this.pendingGrouping.splice(index, 1)
90
+ }
91
+ }
92
+
69
93
  subscribe(callback: (mirror: TaskBoardClientMirror) => void): () => void {
70
94
  this.listeners.add(callback)
71
95
  return () => { this.listeners.delete(callback) }