@fish-under-sea/dsh-client-ui-task-board-fish 0.0.0-stage → 1.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 (167) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +23 -0
  3. package/README.en.md +29 -0
  4. package/README.i18n.yaml +6 -0
  5. package/README.md +28 -2
  6. package/README.zh.md +29 -0
  7. package/cordis.patch.yml +12 -0
  8. package/icon.svg +3 -0
  9. package/lib/client.js +12941 -0
  10. package/lib/client.js.map +1 -0
  11. package/lib/index.js +10471 -0
  12. package/lib/types/client/PluginSettingsCard.d.ts +144 -0
  13. package/lib/types/client/TaskBoardSettingsCard.d.ts +92 -0
  14. package/lib/types/client/apply-guard.d.ts +25 -0
  15. package/lib/types/client/board/ClampedMarkdown.d.ts +3 -0
  16. package/lib/types/client/board/ConfirmDialog.d.ts +15 -0
  17. package/lib/types/client/board/EditTaskModal.d.ts +17 -0
  18. package/lib/types/client/board/LinkSubtaskModal.d.ts +14 -0
  19. package/lib/types/client/board/NewTaskModal.d.ts +26 -0
  20. package/lib/types/client/board/TagManagerModal.d.ts +26 -0
  21. package/lib/types/client/board/TaskBoard.d.ts +26 -0
  22. package/lib/types/client/board/TaskCard.d.ts +36 -0
  23. package/lib/types/client/board/TaskDetail.d.ts +9 -0
  24. package/lib/types/client/board/TaskForm.d.ts +72 -0
  25. package/lib/types/client/board/VerificationReport.d.ts +23 -0
  26. package/lib/types/client/board/card-view.d.ts +113 -0
  27. package/lib/types/client/board/icons.d.ts +32 -0
  28. package/lib/types/client/board/overlay.d.ts +69 -0
  29. package/lib/types/client/board/parse-model-pref.d.ts +4 -0
  30. package/lib/types/client/board/preset-label.d.ts +22 -0
  31. package/lib/types/client/board/status-key.d.ts +19 -0
  32. package/lib/types/client/board/task-markdown.d.ts +19 -0
  33. package/lib/types/client/host-api.d.ts +63 -0
  34. package/lib/types/client/index.d.ts +128 -0
  35. package/lib/types/client/locales.d.ts +443 -0
  36. package/lib/types/client/main-session.d.ts +32 -0
  37. package/lib/types/client/native-panel.d.ts +48 -0
  38. package/lib/types/client/plugin-card-seat.d.ts +108 -0
  39. package/lib/types/client/schedule-presets.d.ts +10 -0
  40. package/lib/types/client/schedule-zone.d.ts +97 -0
  41. package/lib/types/client/seats.d.ts +18 -0
  42. package/lib/types/client/service.d.ts +32 -0
  43. package/lib/types/client/settings-entry-form.d.ts +49 -0
  44. package/lib/types/client/settings-form.d.ts +213 -0
  45. package/lib/types/core/controller.d.ts +373 -0
  46. package/lib/types/core/degraded-reason.d.ts +46 -0
  47. package/lib/types/core/extension.d.ts +283 -0
  48. package/lib/types/core/freeze-snapshot.d.ts +71 -0
  49. package/lib/types/core/handover.d.ts +70 -0
  50. package/lib/types/core/issue-form.d.ts +16 -0
  51. package/lib/types/core/package-name.d.ts +9 -0
  52. package/lib/types/core/poll-cadence.d.ts +31 -0
  53. package/lib/types/core/schedule.d.ts +124 -0
  54. package/lib/types/core/session-reuse.d.ts +24 -0
  55. package/lib/types/core/store.d.ts +64 -0
  56. package/lib/types/core/subtask.d.ts +141 -0
  57. package/lib/types/core/tasks.d.ts +601 -0
  58. package/lib/types/core/use-cases/task-archive.d.ts +20 -0
  59. package/lib/types/core/use-cases/task-create.d.ts +27 -0
  60. package/lib/types/core/use-cases/task-delete.d.ts +27 -0
  61. package/lib/types/core/use-cases/task-parent.d.ts +21 -0
  62. package/lib/types/core/use-cases/task-schedule.d.ts +96 -0
  63. package/lib/types/core/use-cases/task-tag.d.ts +48 -0
  64. package/lib/types/core/use-cases/task-update.d.ts +56 -0
  65. package/lib/types/core/verification-budget.d.ts +52 -0
  66. package/lib/types/core/verification.d.ts +753 -0
  67. package/lib/types/core/workspace-target.d.ts +41 -0
  68. package/lib/types/dsh-home.d.ts +16 -0
  69. package/lib/types/host/agent-tools.d.ts +27 -0
  70. package/lib/types/host/extension-registry.d.ts +111 -0
  71. package/lib/types/host/llm-dispatch.d.ts +63 -0
  72. package/lib/types/host/verification-gate.d.ts +95 -0
  73. package/lib/types/host/verification-runner.d.ts +139 -0
  74. package/lib/types/host/workspace-evidence.d.ts +53 -0
  75. package/lib/types/host-ai.d.ts +51 -0
  76. package/lib/types/host-ledger.d.ts +385 -0
  77. package/lib/types/host-routes.d.ts +36 -0
  78. package/lib/types/host-runner.d.ts +252 -0
  79. package/lib/types/host-service.d.ts +379 -0
  80. package/lib/types/http.d.ts +59 -0
  81. package/lib/types/index.d.ts +322 -0
  82. package/lib/types/loopback.d.ts +24 -0
  83. package/lib/types/mount-once.d.ts +55 -0
  84. package/lib/types/power-inhibitor.d.ts +73 -0
  85. package/lib/types/protocol.d.ts +212 -0
  86. package/lib/types/tool-surface.d.ts +71 -0
  87. package/package.json +110 -4
  88. package/src/client/PluginSettingsCard.tsx +564 -0
  89. package/src/client/TaskBoardSettingsCard.tsx +539 -0
  90. package/src/client/apply-guard.ts +35 -0
  91. package/src/client/board/ClampedMarkdown.tsx +69 -0
  92. package/src/client/board/ConfirmDialog.tsx +44 -0
  93. package/src/client/board/EditTaskModal.tsx +110 -0
  94. package/src/client/board/LinkSubtaskModal.tsx +97 -0
  95. package/src/client/board/NewTaskModal.tsx +718 -0
  96. package/src/client/board/TagManagerModal.tsx +235 -0
  97. package/src/client/board/TaskBoard.tsx +558 -0
  98. package/src/client/board/TaskCard.tsx +315 -0
  99. package/src/client/board/TaskDetail.tsx +985 -0
  100. package/src/client/board/TaskForm.tsx +264 -0
  101. package/src/client/board/VerificationReport.tsx +322 -0
  102. package/src/client/board/card-view.ts +220 -0
  103. package/src/client/board/icons.tsx +89 -0
  104. package/src/client/board/overlay.tsx +189 -0
  105. package/src/client/board/parse-model-pref.ts +35 -0
  106. package/src/client/board/preset-label.ts +44 -0
  107. package/src/client/board/status-key.ts +41 -0
  108. package/src/client/board/task-markdown.module.css +137 -0
  109. package/src/client/board/task-markdown.tsx +106 -0
  110. package/src/client/board-settings.module.css +66 -0
  111. package/src/client/board.module.css +1837 -0
  112. package/src/client/css-modules.d.ts +5 -0
  113. package/src/client/host-api.ts +336 -0
  114. package/src/client/index.ts +501 -0
  115. package/src/client/locales.ts +905 -0
  116. package/src/client/main-session.ts +43 -0
  117. package/src/client/native-panel.tsx +140 -0
  118. package/src/client/plugin-card-seat.ts +199 -0
  119. package/src/client/schedule-presets.ts +13 -0
  120. package/src/client/schedule-zone.ts +233 -0
  121. package/src/client/seats.tsx +58 -0
  122. package/src/client/service.ts +94 -0
  123. package/src/client/settings-card.module.css +444 -0
  124. package/src/client/settings-entry-form.ts +142 -0
  125. package/src/client/settings-form.ts +468 -0
  126. package/src/core/controller.ts +871 -0
  127. package/src/core/degraded-reason.ts +81 -0
  128. package/src/core/extension.ts +376 -0
  129. package/src/core/freeze-snapshot.ts +213 -0
  130. package/src/core/handover.ts +132 -0
  131. package/src/core/issue-form.ts +19 -0
  132. package/src/core/package-name.ts +9 -0
  133. package/src/core/poll-cadence.ts +41 -0
  134. package/src/core/schedule.ts +363 -0
  135. package/src/core/session-reuse.ts +40 -0
  136. package/src/core/store.ts +371 -0
  137. package/src/core/subtask.ts +341 -0
  138. package/src/core/tasks.ts +843 -0
  139. package/src/core/use-cases/task-archive.ts +91 -0
  140. package/src/core/use-cases/task-create.ts +110 -0
  141. package/src/core/use-cases/task-delete.ts +43 -0
  142. package/src/core/use-cases/task-parent.ts +65 -0
  143. package/src/core/use-cases/task-schedule.ts +251 -0
  144. package/src/core/use-cases/task-tag.ts +110 -0
  145. package/src/core/use-cases/task-update.ts +126 -0
  146. package/src/core/verification-budget.ts +115 -0
  147. package/src/core/verification.ts +1594 -0
  148. package/src/core/workspace-target.ts +59 -0
  149. package/src/dsh-home.ts +42 -0
  150. package/src/host/agent-tools.ts +762 -0
  151. package/src/host/extension-registry.ts +509 -0
  152. package/src/host/llm-dispatch.ts +87 -0
  153. package/src/host/verification-gate.ts +487 -0
  154. package/src/host/verification-runner.ts +702 -0
  155. package/src/host/workspace-evidence.ts +176 -0
  156. package/src/host-ai.ts +158 -0
  157. package/src/host-ledger.ts +1826 -0
  158. package/src/host-routes.ts +306 -0
  159. package/src/host-runner.ts +755 -0
  160. package/src/host-service.ts +1112 -0
  161. package/src/http.ts +127 -0
  162. package/src/index.ts +722 -0
  163. package/src/loopback.ts +63 -0
  164. package/src/mount-once.ts +142 -0
  165. package/src/power-inhibitor.ts +321 -0
  166. package/src/protocol.ts +591 -0
  167. package/src/tool-surface.ts +95 -0
@@ -0,0 +1,501 @@
1
+ /**
2
+ * Task-board client plugin: wires the framework-free core (controller,
3
+ * execution service, store) to the real client runtime and mounts the two
4
+ * DOM surfaces — the sidebar entry row and the board view in the center
5
+ * column.
6
+ *
7
+ * Failure policy: DOM mounting problems are logged, never thrown — the web
8
+ * shell fails the whole boot when a plugin apply throws, and an external
9
+ * plugin must not take the GUI down.
10
+ */
11
+ import type { Context as ClientContext } from '@deepseek-ai/cordis'
12
+ import type { ClientRemote, SessionId } from '@deepseek-ai/dsh-api-remotes/client'
13
+ import type { ISessions } from '@deepseek-ai/dsh-api-session-controller/client'
14
+ import type { IWorkspaces } from '@deepseek-ai/dsh-api-workspace-controller/client'
15
+ import type { ConfigForm, ConfigForms } from '@deepseek-ai/dsh-client-ui-settings/client'
16
+ import type {} from '@deepseek-ai/dsh-api-remotes/client'
17
+ import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
18
+ import type {} from '@deepseek-ai/dsh-client-ui-slots'
19
+ // Type-only: pulls the locale plugin's Context merge (ctx.locale) and its
20
+ // LocaleNamespaceMap merge table.
21
+ import type {} from '@deepseek-ai/dsh-client-locale/client'
22
+ // Type-only: pulls the shared-forms Context merge (ctx.configForms).
23
+ import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
24
+ // Type-only: pulls the workspace plugin's Context merge (ctx.uiWorkspace), the
25
+ // multi-instance navigation face that replaced ISessions.open().
26
+ import type {} from '@deepseek-ai/dsh-client-ui-workspace/client'
27
+ import { BoardController, TASK_BOARD_PANEL_ID } from '../core/controller.ts'
28
+ import { mainViewSessionId } from './main-session.ts'
29
+ import { LocalStorageTaskStore } from '../core/store.ts'
30
+ import { claimTaskboardApply, releaseTaskboardApply } from './apply-guard.ts'
31
+ import { registerTaskBoardPanel } from './native-panel.tsx'
32
+ import { TaskBoardSettingsCard, TaskBoardSettingsCardController, type TaskBoardSettings } from './TaskBoardSettingsCard.tsx'
33
+ import { en, zh, setRuntimeTranslate, type TaskBoardKey } from './locales.ts'
34
+ import { HttpTaskBoardHostTransport } from './host-api.ts'
35
+ import { installPluginCard } from './plugin-card-seat.ts'
36
+ import { createServedEntryForm } from './settings-entry-form.ts'
37
+ import { TaskBoardClientService } from './service.ts'
38
+ import {
39
+ TASK_BOARD_SERVICE_NAME,
40
+ type TaskBoardCardDecorationProps,
41
+ type TaskBoardDetailSectionProps,
42
+ type TaskBoardHostFace,
43
+ type TaskBoardSettingsSectionProps,
44
+ } from '../core/extension.ts'
45
+
46
+ /** Locale namespace this plugin owns. */
47
+ const NS = 'task-board'
48
+
49
+ /** Settings namespace this card edits (the family identity of the plugin's own settings form). */
50
+ const TASK_BOARD_NS = 'task-board'
51
+
52
+ /**
53
+ * Profile entry id the family aggregate's generated row carries — the
54
+ * deployment shape nearly every user runs. Under 0.1.7 a settings form is
55
+ * addressed by profile entry id, so the shared-forms fallback below has to
56
+ * name it; the family binder resolves the family namespace instead.
57
+ */
58
+ const AGGREGATE_ENTRY_ID = 'web-ui-task-board'
59
+
60
+ /**
61
+ * Profile entry ids this package's two patch rows carry: the aggregate's
62
+ * generated row and the standalone bundle patch's row (`ui-task-board`), plus
63
+ * the bare namespace as the last resort for a Host whose descriptor is keyed
64
+ * by the family namespace itself.
65
+ */
66
+ const TASK_BOARD_ENTRY_IDS: readonly string[] = [AGGREGATE_ENTRY_ID, 'ui-task-board', TASK_BOARD_NS]
67
+
68
+ /** Domain-owned description of one settings namespace a family card binds. */
69
+ export interface SettingsFormSpec<T> {
70
+ /** Settings namespace the card edits. */
71
+ namespace: string
72
+ /**
73
+ * Narrow one wire section; undefined keeps the last accepted value. The
74
+ * shared form already resolves the namespace's own serialized wire schema,
75
+ * so a decoder exists only to narrow beyond that schema.
76
+ */
77
+ decode?: (section: unknown) => T | undefined
78
+ }
79
+
80
+ /**
81
+ * The family settings binder published by dsh-web-settings. Its `bind` resolves
82
+ * a family namespace to the profile entry id that owns it and hands back the
83
+ * shared configuration form, so it is the only seat that can reach this card's
84
+ * form on a Host whose row id is not the namespace.
85
+ */
86
+ export interface SettingsFormBinder {
87
+ /** Bind one family settings namespace. */
88
+ bind<T>(spec: SettingsFormSpec<T>): ConfigForm<T>
89
+ }
90
+
91
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
92
+ interface LocaleNamespaceMap {
93
+ /** Task-board surface copy. */
94
+ 'task-board': TaskBoardKey
95
+ }
96
+
97
+ interface SlotMap {
98
+ /**
99
+ * The child slot the Web UI plugin group declares; this card registers
100
+ * into the group's list seat rather than the official
101
+ * bundle-configuration seat. Spelled here with the same shape so this
102
+ * package can register without depending on the sibling UI package.
103
+ */
104
+ 'web-ui.plugin.item': { kind: 'list'; scope: 'root'; owner: SettingsPluginItemOwnerProps }
105
+
106
+ /** Provider task-detail section; the board declares and renders it. */
107
+ 'task-board.detail.section': { kind: 'list'; scope: 'root'; owner: TaskBoardDetailSectionProps }
108
+ /** Provider settings section; the board declares and renders it. */
109
+ 'task-board.settings.section': { kind: 'list'; scope: 'root'; owner: TaskBoardSettingsSectionProps }
110
+ /** Provider card decoration; the board declares and renders it. */
111
+ 'task-board.card.decoration': { kind: 'list'; scope: 'root'; owner: TaskBoardCardDecorationProps }
112
+ }
113
+ }
114
+
115
+ /** Owner share of a plugin card (the section supplies nothing). */
116
+ export interface SettingsPluginItemOwnerProps {
117
+ /** Marker field: card owner props are intentionally empty. */
118
+ children?: never
119
+ }
120
+
121
+ declare module '@deepseek-ai/cordis' {
122
+ interface Context {
123
+ /**
124
+ * Optional family settings binder provided by dsh-web-settings; absent
125
+ * when that group plugin is not installed, so callers fall back to the
126
+ * shared configuration forms service.
127
+ */
128
+ webUiSettings?: SettingsFormBinder
129
+ }
130
+ }
131
+
132
+
133
+ /**
134
+ * Required services (fiber inject waiting — the runtime must be up first).
135
+ * The generated remote namespaces are not all hard injects: `remote.session`
136
+ * is one, while `remote.agentPresets` is reached through a scoped inject at
137
+ * use time (see mountUi), because the namespace mounts with the official
138
+ * api-remotes assembly applied beside this entry rather than before it.
139
+ */
140
+ export const inject = ['slots', 'sessions', 'workspaces', 'connection', 'configForms', 'locale', 'remote', 'remote.session', 'uiWorkspace', 'layout']
141
+
142
+ /** The generated Remote namespace the mode picker reads its roster from. */
143
+ type PresetRemote = ClientRemote['agentPresets']
144
+
145
+ /** One agent-preset row the mode picker consumes. */
146
+ interface PresetRosterRow {
147
+ id: string
148
+ name?: string
149
+ description?: string
150
+ /** Why this preset cannot compose a session; absent when it can. */
151
+ broken?: string
152
+ isDefault: boolean
153
+ }
154
+
155
+ /**
156
+ * Read the agent-preset roster through the generated api-remotes face. The
157
+ * caller passes the namespace resolved inside its scoped inject, so a host
158
+ * that serves no such namespace never reaches here; a host that serves it
159
+ * answers `ok: false` instead, which leaves the picker options untouched.
160
+ * @param remote - the `remote.agentPresets` namespace.
161
+ * @returns the roster, or a failed read the caller ignores.
162
+ */
163
+ async function readPresetRoster(remote: PresetRemote): Promise<{ ok: boolean; presets: readonly PresetRosterRow[] }> {
164
+ const response = await remote.list()
165
+ if (!response.ok) return { ok: false, presets: [] }
166
+ return { ok: true, presets: response.value.presets }
167
+ }
168
+
169
+ /**
170
+ * Mount the task board.
171
+ * @param ctx - client root context (services: sessions, workspaces).
172
+ */
173
+ export function apply(ctx: ClientContext): void {
174
+
175
+ // A duplicated client injection (module factory executed twice in one page
176
+ // lifetime) would otherwise mount a second sidebar entry and board view.
177
+ // First application wins; later calls become no-ops (see apply-guard.ts).
178
+ if (!claimTaskboardApply()) return
179
+
180
+ // Release the claim when this fiber unloads (the loader supports plugin
181
+ // unloads / hot-reloads), so a rebuilt bundle can claim again in the same
182
+ // page instead of being silently dropped.
183
+ ctx.effect(() => releaseTaskboardApply, 'task-board: apply claim')
184
+
185
+ ctx.effect(() => {
186
+ try {
187
+ return ctx.locale.register(NS, { zh, en })
188
+ } catch {
189
+ return () => {}
190
+ }
191
+ }, 'task-board: dictionaries')
192
+
193
+ // Wire the SDK translate seat into the module-level t (sidebar row and
194
+ // other plain-DOM callers): reads the active locale at call time, so they
195
+ // follow the Language setting without a reload. The register effect above
196
+ // guarantees the dictionaries exist before the first read.
197
+ try { setRuntimeTranslate(ctx.locale.bind(NS)) } catch { /* locale missing: document-language fallback stays */ }
198
+
199
+ // Plugin configuration card: one staged form over the `task-board` settings
200
+ // namespace, contributed to whichever plugin-card seat this host declares
201
+ // (the family group's list seat, or the official bundle-configuration seat).
202
+ const settingsForm = bindSettingsForm(ctx)
203
+ // The board's browser-half extension service. It is provided before any
204
+ // controller exists (the UI mounts only once the settings form settles), so
205
+ // providers can subscribe and register visibility immediately.
206
+ const clientService = new TaskBoardClientService()
207
+ // A capture-only test context implements no service registry; the board's
208
+ // own surfaces still mount.
209
+ if (typeof (ctx as { provide?: unknown }).provide === 'function') {
210
+ ;(ctx.provide as unknown as (name: string, value: unknown) => void)(TASK_BOARD_SERVICE_NAME, clientService as unknown as TaskBoardHostFace)
211
+ }
212
+ ctx.effect(() => () => { clientService.detach() }, 'task-board: extension service')
213
+
214
+ const settingsCard = new TaskBoardSettingsCardController(settingsForm, request => clientService.dispatch(request))
215
+ installPluginCard(ctx, {
216
+ bundle: '@fish-under-sea/dsh-client-ui-task-board-fish',
217
+ id: 'task-board',
218
+ order: 110,
219
+ locale: NS,
220
+ // The board's own settings card declares the provider settings seat; the
221
+ // provider registers into it and this card renders it.
222
+ children: { 'task-board.settings.section': { kind: 'list', scope: 'root' } },
223
+ inject: () => settingsCard.inject(),
224
+ component: TaskBoardSettingsCard,
225
+ })
226
+ ctx.effect(() => () => { settingsCard.dispose() }, 'task-board: settings card')
227
+
228
+ // The sidebar entry and board view mount once the settings form settles;
229
+ // while the form is still loading, the composition default is unknown, so
230
+ // nothing mounts yet. Only an unavailable form (no settings surface served)
231
+ // falls back to the composition default (enabled).
232
+ let uiDisposer: (() => void) | undefined
233
+ const mountUi = (): void => {
234
+ if (uiDisposer !== undefined) return
235
+ // Host and browser SDK declarations share the Cordis Context name. Read
236
+ // the browser faces explicitly so Host-side declaration merging cannot
237
+ // narrow these two client services during a combined package build.
238
+ const sessions = ctx.get('sessions') as unknown as ISessions
239
+ const workspaces = ctx.get('workspaces') as unknown as IWorkspaces
240
+ const remote = ctx.get('remote') as unknown as ClientRemote
241
+
242
+ // Core wiring: real runtime faces into the framework-free services.
243
+ const store = new LocalStorageTaskStore()
244
+ const controller = new BoardController({
245
+ store,
246
+ transport: new HttpTaskBoardHostTransport(),
247
+ // Panel navigation belongs to the layout service: the board asks it to
248
+ // select its own panel id (or the conversation) instead of taking over
249
+ // the center column at the DOM level. The lookup stays lazy so a
250
+ // selection issued before the service settles still lands once it does,
251
+ // and the face throws by contract before the layout root entry mounts,
252
+ // which the controller tolerates.
253
+ panel: {
254
+ select: panelId => {
255
+ const layout = ctx.get('layout') as { selectPanel?: (id: string | null) => void } | undefined
256
+ layout?.selectPanel?.(panelId)
257
+ },
258
+ },
259
+ sessions: {
260
+ // The main-view Session comes from the catalog's per-source ownership
261
+ // counts; navigation belongs to the workspace UI since the
262
+ // multi-instance Client Session model.
263
+ current: () => mainViewSessionId(sessions.list.getSnapshot().byId),
264
+ open: id => ctx.uiWorkspace.openSession(id as never),
265
+ subscribe: fn => sessions.list.subscribe(fn),
266
+ },
267
+ })
268
+ controller.start()
269
+ // The extension service follows the live controller: providers observe the
270
+ // board mirror and dispatch through it while the board runs.
271
+ clientService.attach(controller)
272
+
273
+ const disposers: Array<() => void> = []
274
+
275
+ // Execution-target option feeds: the workspace list drives the workspace
276
+ // picker, and the agent-preset roster drives the mode picker. Both are
277
+ // runtime facts (not ledger state), so the wiring pushes them into the
278
+ // controller on change; the preset roster is re-read after reconnects
279
+ // because a reconnect may serve a different deployment.
280
+ const pushWorkspaceOptions = (): void => {
281
+ const snapshot = workspaces.list.getSnapshot()
282
+ controller.setExecutionOptions({
283
+ workspaces: snapshot.items.map(item => ({
284
+ workspaceId: item.workspaceId,
285
+ title: item.title !== '' ? item.title : item.path,
286
+ })),
287
+ })
288
+ }
289
+ pushWorkspaceOptions()
290
+ disposers.push(workspaces.list.subscribe(pushWorkspaceOptions))
291
+ // "New project" on the board is the GUI's own add-project call (#1536);
292
+ // the runtime emits the created Workspace through workspaces.list, which
293
+ // refreshes the filter above without a local re-read.
294
+ controller.setWorkspaceCreator(async path => {
295
+ const created = await workspaces.create({ path })
296
+ return { workspaceId: created.workspaceId }
297
+ })
298
+ const pushPresetOptions = async (presetRemote: PresetRemote): Promise<void> => {
299
+ try {
300
+ const roster = await readPresetRoster(presetRemote)
301
+ if (!roster.ok) return
302
+ controller.setExecutionOptions({
303
+ presets: roster.presets.map(preset => ({
304
+ id: preset.id,
305
+ name: preset.name,
306
+ description: preset.description,
307
+ broken: preset.broken,
308
+ isDefault: preset.isDefault,
309
+ })),
310
+ })
311
+ } catch (error) {
312
+ // A failed roster read leaves the previous options in place; the
313
+ // picker stays usable and the next reconnect retries the read.
314
+ console.error('[dsh-task-board] agent preset roster read failed', error)
315
+ }
316
+ }
317
+ // The roster namespace mounts with the official api-remotes assembly,
318
+ // which the page applies beside this entry: at mount time the namespace is
319
+ // usually still absent, and reading it through `remote.agentPresets`
320
+ // before it lands throws ("cannot get property ... without inject"), so a
321
+ // one-shot probe leaves the mode picker with nothing but "inherit" for the
322
+ // page lifetime. A hard inject is no better — it would pend the whole
323
+ // board on a deployment that never mounts the namespace. The scoped inject
324
+ // runs the feed exactly when the namespace exists and re-runs it if the
325
+ // namespace is replaced; the reconnect read inside covers a deployment
326
+ // change behind the same namespace.
327
+ const presetRosterFeed = ctx.inject(['remote.agentPresets'], (inner) => {
328
+ const presetRemote = inner.get('remote.agentPresets') as PresetRemote | undefined
329
+ if (presetRemote === undefined) return
330
+ void pushPresetOptions(presetRemote)
331
+ // Subscribed inside the injected scope, so a namespace that goes away
332
+ // takes its listener with it instead of leaving one per remount.
333
+ return inner.on('connection/reset', () => { void pushPresetOptions(presetRemote) })
334
+ })
335
+ disposers.push(() => { void presetRosterFeed.dispose() })
336
+ const pushModelOptions = async (): Promise<void> => {
337
+ try {
338
+ let models: Array<{ id: string; name?: string; provider?: string }> = []
339
+ let sessionRemote: ClientRemote['session'] | undefined
340
+ try {
341
+ sessionRemote = (remote as Partial<ClientRemote>).session
342
+ } catch {
343
+ sessionRemote = undefined
344
+ }
345
+ if (typeof sessionRemote?.modelCatalog === 'function') {
346
+ const res = await sessionRemote.modelCatalog()
347
+ if (res.ok && Array.isArray(res.value?.groups)) {
348
+ for (const g of res.value.groups) {
349
+ const provider = (g as { id?: string; provider?: string }).id ?? (g as { id?: string; provider?: string }).provider
350
+ for (const m of g.models ?? []) {
351
+ const qualifiedId = provider ? `${provider}/${m.id}` : m.id
352
+ models.push({ id: qualifiedId, name: m.name ?? m.id, provider })
353
+ }
354
+ }
355
+ }
356
+ }
357
+ if (models.length === 0) {
358
+ const conn = ctx.get('connection') as {
359
+ api?: {
360
+ llm?: { discoverModels?: () => Promise<unknown> }
361
+ sessions?: { modelCatalog?: () => Promise<unknown> }
362
+ session?: { modelCatalog?: () => Promise<unknown> }
363
+ }
364
+ } | undefined
365
+ if (conn?.api) {
366
+ if (typeof conn.api.llm?.discoverModels === 'function') {
367
+ const res = await conn.api.llm.discoverModels() as { result?: { value?: { models?: Array<{ id: string; name?: string }> } } }
368
+ const list = res?.result?.value?.models
369
+ if (Array.isArray(list)) {
370
+ models = list.map(m => ({ id: m.id, name: m.name }))
371
+ }
372
+ }
373
+ const catalogFn = typeof conn.api.session?.modelCatalog === 'function'
374
+ ? conn.api.session.modelCatalog
375
+ : typeof conn.api.sessions?.modelCatalog === 'function'
376
+ ? conn.api.sessions.modelCatalog
377
+ : undefined
378
+ if (models.length === 0 && catalogFn !== undefined) {
379
+ const res = await catalogFn() as { result?: { value?: { groups?: Array<{ id?: string; provider?: string; models?: Array<{ id: string; name?: string }> }> } } }
380
+ const groups = res?.result?.value?.groups
381
+ if (Array.isArray(groups)) {
382
+ for (const g of groups) {
383
+ const provider = g.id ?? g.provider
384
+ for (const m of g.models ?? []) {
385
+ const qualifiedId = provider ? `${provider}/${m.id}` : m.id
386
+ models.push({ id: qualifiedId, name: m.name ?? m.id, provider })
387
+ }
388
+ }
389
+ }
390
+ }
391
+ }
392
+ }
393
+ if (models.length > 0) {
394
+ controller.setExecutionOptions({ models })
395
+ }
396
+ } catch (error) {
397
+ console.error('[dsh-task-board] model options read failed', error)
398
+ }
399
+ }
400
+ void pushModelOptions()
401
+ disposers.push(ctx.on('connection/reset', () => { void pushModelOptions() }))
402
+ // Native panel surfaces: one sidebar row and one center-column page, both
403
+ // through the official slot seats the shell itself renders. The layout's
404
+ // panel selection is reconciled back into the controller so the board's own
405
+ // view state follows the user clicking another panel row.
406
+ try {
407
+ disposers.push(registerTaskBoardPanel(ctx, controller))
408
+ const layoutFace = ctx.get('layout') as { panelInfo?: { subscribe(listener: () => void): () => void; getSnapshot(): { activePanelId: unknown } } } | undefined
409
+ if (layoutFace?.panelInfo !== undefined) {
410
+ const sync = (): void => {
411
+ const active = layoutFace.panelInfo!.getSnapshot().activePanelId
412
+ controller.syncPanelSelection(active === TASK_BOARD_PANEL_ID ? TASK_BOARD_PANEL_ID : null)
413
+ }
414
+ sync()
415
+ disposers.push(layoutFace.panelInfo.subscribe(sync))
416
+ }
417
+ } catch (error) {
418
+ // A shell that cannot serve the seats degrades the board, never the GUI.
419
+ console.error('[dsh-task-board] panel registration failed:', error)
420
+ }
421
+
422
+ uiDisposer = () => {
423
+ for (const dispose of disposers.splice(0)) dispose()
424
+ clientService.detach()
425
+ controller.dispose()
426
+ uiDisposer = undefined
427
+ }
428
+ }
429
+ const syncEnabled = (): void => {
430
+ const snapshot = settingsForm.getSnapshot()
431
+ const enabled = snapshot.status === 'ready'
432
+ ? snapshot.value?.enabled ?? true
433
+ : snapshot.status === 'unavailable'
434
+ if (enabled) {
435
+ mountUi()
436
+ clientService.setEnabled(true)
437
+ } else {
438
+ clientService.setEnabled(false)
439
+ uiDisposer?.()
440
+ }
441
+ }
442
+ const unsubscribeSettings = settingsForm.subscribe(syncEnabled)
443
+ // The mounted surfaces and the settings subscription belong to this fiber.
444
+ // The loader replaces a rebuilt bundle IN PLACE (fiber teardown and re-apply
445
+ // without a page reload), and that same teardown removes the dictionaries
446
+ // this row and board render through — a row left behind would stay visible
447
+ // showing raw dictionary keys, and a surviving subscription could mount a
448
+ // second one from a dead instance.
449
+ ctx.effect(() => () => {
450
+ unsubscribeSettings()
451
+ uiDisposer?.()
452
+ }, 'task-board: DOM surfaces')
453
+ syncEnabled()
454
+ }
455
+
456
+ /**
457
+ * Bind the settings form this card stages over.
458
+ *
459
+ * The family binder (`ctx.get('webUiSettings')`, published by dsh-web-settings)
460
+ * comes first: it is what traces this package's family namespace onto the
461
+ * profile entry id the Host serves the form under, and it keeps the loopback
462
+ * bridge as its own fallback. A page without that group falls back to the
463
+ * shared configuration forms service bound directly at one of this package's
464
+ * own profile entry ids.
465
+ * @param ctx - client root context.
466
+ * @returns the form the settings card reads and writes.
467
+ */
468
+ export function bindSettingsForm(ctx: ClientContext): ConfigForm<TaskBoardSettings> {
469
+ const binder = ctx.get('webUiSettings')
470
+ if (binder !== undefined && typeof binder.bind === 'function') {
471
+ return binder.bind<TaskBoardSettings>({ namespace: TASK_BOARD_NS })
472
+ }
473
+ return createServedEntryForm<TaskBoardSettings>({
474
+ forms: ctx.configForms,
475
+ entryIds: TASK_BOARD_ENTRY_IDS,
476
+ })
477
+ }
478
+
479
+ /**
480
+ * The profile entry id this package's own row carries, for a page that serves
481
+ * no family binder.
482
+ *
483
+ * The shared describe mirror is the only local evidence of which row id this
484
+ * profile actually serves, but it answers asynchronously: at plugin activation
485
+ * it usually holds nothing yet. An unanswered mirror therefore binds the
486
+ * aggregate row id rather than guessing among the candidates, and the binding
487
+ * is re-resolved once the mirror answers — see
488
+ * {@link createServedEntryForm}, which owns that rebinding.
489
+ * @param forms - the shared configuration forms service.
490
+ * @returns the entry id to bind before the mirror answers.
491
+ */
492
+ export function servedEntryId(forms: ConfigForms): string {
493
+ let served: readonly string[] | undefined
494
+ try {
495
+ served = forms.describe().getSnapshot().view?.namespaces.map(view => view.ns)
496
+ } catch {
497
+ served = undefined
498
+ }
499
+ if (served === undefined) return AGGREGATE_ENTRY_ID
500
+ return TASK_BOARD_ENTRY_IDS.find(id => served.includes(id)) ?? TASK_BOARD_NS
501
+ }