@linxin666/dsh-client-ui-task-board 0.4.1 → 0.4.3
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.
- package/README.i18n.yaml +2 -2
- package/README.md +28 -3
- package/README.zh.md +28 -3
- package/lib/client.js +1142 -467
- package/lib/client.js.map +1 -1
- package/lib/index.js +2066 -1475
- package/lib/types/client/TaskBoardSettingsCard.d.ts +4 -0
- package/lib/types/client/board/LinkSubtaskModal.d.ts +11 -0
- package/lib/types/client/board/NewTaskModal.d.ts +7 -1
- package/lib/types/client/board/TaskCard.d.ts +11 -1
- package/lib/types/client/index.d.ts +15 -1
- package/lib/types/client/locales.d.ts +33 -0
- package/lib/types/client/native-panel.d.ts +62 -0
- package/lib/types/client/settings-entry-form.d.ts +49 -0
- package/lib/types/core/controller.d.ts +71 -3
- package/lib/types/core/subtask.d.ts +122 -0
- package/lib/types/core/tasks.d.ts +46 -3
- package/lib/types/core/use-cases/task-archive.d.ts +10 -13
- package/lib/types/core/use-cases/task-create.d.ts +13 -4
- package/lib/types/core/use-cases/task-delete.d.ts +7 -1
- package/lib/types/core/use-cases/task-parent.d.ts +21 -0
- package/lib/types/core/use-cases/task-update.d.ts +1 -1
- package/lib/types/host/agent-tools.d.ts +27 -0
- package/lib/types/host-ledger.d.ts +97 -4
- package/lib/types/host-runner.d.ts +39 -1
- package/lib/types/host-service.d.ts +98 -5
- package/lib/types/index.d.ts +93 -5
- package/lib/types/mount-once.d.ts +38 -7
- package/lib/types/protocol.d.ts +14 -0
- package/package.json +26 -21
- package/src/client/TaskBoardSettingsCard.tsx +48 -3
- package/src/client/board/LinkSubtaskModal.tsx +82 -0
- package/src/client/board/NewTaskModal.tsx +40 -6
- package/src/client/board/TaskBoard.tsx +88 -8
- package/src/client/board/TaskCard.tsx +52 -2
- package/src/client/board/TaskDetail.tsx +124 -1
- package/src/client/board.module.css +112 -131
- package/src/client/host-api.ts +14 -4
- package/src/client/index.ts +56 -18
- package/src/client/locales.ts +70 -2
- package/src/client/native-panel.tsx +124 -0
- package/src/client/settings-entry-form.ts +142 -0
- package/src/core/controller.ts +128 -10
- package/src/core/store.ts +15 -0
- package/src/core/subtask.ts +286 -0
- package/src/core/tasks.ts +50 -2
- package/src/core/use-cases/task-archive.ts +46 -12
- package/src/core/use-cases/task-create.ts +42 -7
- package/src/core/use-cases/task-delete.ts +11 -1
- package/src/core/use-cases/task-parent.ts +64 -0
- package/src/core/use-cases/task-update.ts +3 -1
- package/src/host/agent-tools.ts +643 -0
- package/src/host-ledger.ts +343 -45
- package/src/host-routes.ts +37 -1
- package/src/host-runner.ts +141 -12
- package/src/host-service.ts +265 -32
- package/src/index.ts +203 -9
- package/src/mount-once.ts +107 -13
- package/src/protocol.ts +26 -2
- package/lib/types/client/board-mount.d.ts +0 -23
- package/lib/types/client/body-mutations.d.ts +0 -45
- package/lib/types/client/panel-mount-core.d.ts +0 -56
- package/lib/types/client/sidebar-entry-core.d.ts +0 -55
- package/lib/types/client/sidebar-entry.d.ts +0 -29
- package/src/client/board-mount.tsx +0 -43
- package/src/client/body-mutations.ts +0 -133
- package/src/client/panel-mount-core.ts +0 -155
- package/src/client/sidebar-entry-core.ts +0 -237
- package/src/client/sidebar-entry.ts +0 -53
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
// Generated by scripts/sync-shared.mjs from shared/client/sidebar-entry-core.ts. Do not edit this copy; edit the shared source and run "node scripts/sync-shared.mjs".
|
|
2
|
-
/**
|
|
3
|
-
* Shared sidebar entry injection core.
|
|
4
|
-
*
|
|
5
|
-
* dsh's sidebar shell exposes no slot an external plugin can register into,
|
|
6
|
-
* so the entry row is injected between the shell's New Session button and the
|
|
7
|
-
* workspace browser. The injection self-heals: a MutationObserver watches the
|
|
8
|
-
* sidebar root and re-inserts the row whenever a React re-render displaces it
|
|
9
|
-
* (re-insertion happens in the same frame, before paint, so no flicker).
|
|
10
|
-
*
|
|
11
|
-
* The row is plain DOM (no React tree) so it can never disturb the shell's
|
|
12
|
-
* reconciliation; the view it toggles is a separate root owned by the caller.
|
|
13
|
-
*
|
|
14
|
-
* Packages receive this file as a generated copy via scripts/sync-shared.mjs;
|
|
15
|
-
* edit the shared source and re-run the sync instead of editing a copy.
|
|
16
|
-
*/
|
|
17
|
-
import { subscribeBodyInvalidations } from './body-mutations.ts'
|
|
18
|
-
|
|
19
|
-
/** Per-package configuration for one sidebar entry row. */
|
|
20
|
-
export interface SidebarEntryOptions {
|
|
21
|
-
/** Full attribute name identifying the injected row (idempotency key), e.g. 'data-dsh-ssh-entry'. */
|
|
22
|
-
rowAttribute: string
|
|
23
|
-
/** CSS selector matching the injected row, e.g. '[data-dsh-ssh-entry]'. */
|
|
24
|
-
rowSelector: string
|
|
25
|
-
/**
|
|
26
|
-
* L2 semantic-attribute plugin id (issue #506, enum table:
|
|
27
|
-
* skins/skin-center/contracts/semantic-attrs-v1.md). When set, the row also
|
|
28
|
-
* outputs data-dsh-plugin="<id>" and data-dsh-part="sidebar-entry"; unset
|
|
29
|
-
* leaves the row without semantic attributes.
|
|
30
|
-
*/
|
|
31
|
-
plugin?: string
|
|
32
|
-
/** Inline icon markup (matches the shell's 16px nav-icon look). */
|
|
33
|
-
icon: string
|
|
34
|
-
/** CSS module class names for the row and its two spans (entry / entryIcon / entryLabel). */
|
|
35
|
-
css: Record<string, string>
|
|
36
|
-
/** Localized row label (aria-label + visible text). */
|
|
37
|
-
label(): string
|
|
38
|
-
/** Optional localized tooltip (title attribute). */
|
|
39
|
-
tooltip?(): string
|
|
40
|
-
/**
|
|
41
|
-
* Optional locale-change subscription: re-applies label / aria-label /
|
|
42
|
-
* tooltip whenever the active locale changes. Plain-DOM rows would
|
|
43
|
-
* otherwise keep the label captured at mount; pass the SDK locale runtime
|
|
44
|
-
* subscription (ctx.locale.subscribe) so the row follows the language
|
|
45
|
-
* switch without a reload.
|
|
46
|
-
*/
|
|
47
|
-
refresh?: { subscribe(listener: () => void): () => void }
|
|
48
|
-
/** Click action (open/toggle the owning panel). */
|
|
49
|
-
onToggle(): void
|
|
50
|
-
/** Family-block position: 'before' inserts ahead of sibling plugin rows, 'after' behind them. */
|
|
51
|
-
position: 'before' | 'after'
|
|
52
|
-
/**
|
|
53
|
-
* Selectors of the sibling plugin entry rows this package orders against
|
|
54
|
-
* (its own row included — the placement guard excludes a row that is
|
|
55
|
-
* already inside the root). Each package passes the same list it used
|
|
56
|
-
* before the consolidation so the rendered order stays stable.
|
|
57
|
-
*/
|
|
58
|
-
familySelectors: readonly string[]
|
|
59
|
-
/** Optional active-state bridge; highlights the row while the panel is open. */
|
|
60
|
-
active?: {
|
|
61
|
-
subscribe(listener: () => void): () => void
|
|
62
|
-
isOpen(): boolean
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Find the sidebar shell root element, or undefined while not yet mounted. */
|
|
67
|
-
function sidebarRoot(): HTMLElement | undefined {
|
|
68
|
-
const column = document.querySelector<HTMLElement>('[data-pane="sidebar"], [class*="sidebarCol"]')
|
|
69
|
-
if (column === null) return undefined
|
|
70
|
-
// Current shells wrap the sidebar UI: column > wrapper > root(logoRow owner).
|
|
71
|
-
// Prefer the element that owns the logo row — the real sidebar UI root —
|
|
72
|
-
// and fall back to the column's first child for legacy shells.
|
|
73
|
-
const logoOwner = column.querySelector<HTMLElement>('[class*="logoRow"]')?.parentElement
|
|
74
|
-
return logoOwner ?? (column.firstElementChild as HTMLElement | undefined)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** The New Session button: nested in the logo row on current shells, a direct child on legacy shells. */
|
|
78
|
-
function newSessionButton(root: HTMLElement): HTMLButtonElement | undefined {
|
|
79
|
-
const nested = root.querySelector<HTMLButtonElement>('button[class*="newSession"]')
|
|
80
|
-
if (nested !== null) return nested
|
|
81
|
-
for (const child of root.children) {
|
|
82
|
-
if (child.tagName === 'BUTTON') return child as HTMLButtonElement
|
|
83
|
-
}
|
|
84
|
-
return undefined
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** Build the entry row (detached; inserted once the shell is up). */
|
|
88
|
-
function createEntry(options: SidebarEntryOptions): { entry: HTMLElement; applyLabel: () => void } {
|
|
89
|
-
const entry = document.createElement('button')
|
|
90
|
-
entry.type = 'button'
|
|
91
|
-
entry.setAttribute(options.rowAttribute, '')
|
|
92
|
-
if (options.plugin !== undefined) {
|
|
93
|
-
entry.setAttribute('data-dsh-plugin', options.plugin)
|
|
94
|
-
entry.setAttribute('data-dsh-part', 'sidebar-entry')
|
|
95
|
-
}
|
|
96
|
-
entry.className = options.css['entry'] ?? ''
|
|
97
|
-
const labelSpan = document.createElement('span')
|
|
98
|
-
labelSpan.className = options.css['entryLabel'] ?? ''
|
|
99
|
-
const iconSpan = document.createElement('span')
|
|
100
|
-
iconSpan.className = options.css['entryIcon'] ?? ''
|
|
101
|
-
iconSpan.innerHTML = options.icon
|
|
102
|
-
entry.append(iconSpan, labelSpan)
|
|
103
|
-
const applyLabel = (): void => {
|
|
104
|
-
entry.setAttribute('aria-label', options.label())
|
|
105
|
-
if (options.tooltip !== undefined) entry.setAttribute('title', options.tooltip())
|
|
106
|
-
labelSpan.textContent = options.label()
|
|
107
|
-
}
|
|
108
|
-
applyLabel()
|
|
109
|
-
entry.addEventListener('click', options.onToggle)
|
|
110
|
-
return { entry, applyLabel }
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** Re-insert the entry after the New Session row (before the browser region). */
|
|
114
|
-
function placeEntry(root: HTMLElement, entry: HTMLElement, options: SidebarEntryOptions): boolean {
|
|
115
|
-
const button = newSessionButton(root)
|
|
116
|
-
if (button === undefined) return false
|
|
117
|
-
if (entry.parentElement !== root) {
|
|
118
|
-
// Position relative to the family block (entries injected by sibling
|
|
119
|
-
// plugins), never relative to transient logoRow geometry: every family
|
|
120
|
-
// plugin that self-heals during a re-render then lands in the same
|
|
121
|
-
// relative order, so the entries cannot swap positions regardless of
|
|
122
|
-
// observer callback order or of shell wrapper changes. There is no
|
|
123
|
-
// append-to-end fallback: appending at the end would randomly reorder
|
|
124
|
-
// the block after a shell re-render.
|
|
125
|
-
const row = button.closest('[class*="logoRow"]')
|
|
126
|
-
const base = (row !== null && row.parentElement === root) ? row : button
|
|
127
|
-
const family = Array.from(root.children).filter(
|
|
128
|
-
(el): el is HTMLElement => el instanceof HTMLElement && el.matches(options.familySelectors.join(', ')),
|
|
129
|
-
)
|
|
130
|
-
const anchor = options.position === 'before'
|
|
131
|
-
? (family.length > 0 ? family[0] : base.nextElementSibling)
|
|
132
|
-
: (family.length > 0 ? family[family.length - 1]!.nextElementSibling : base.nextElementSibling)
|
|
133
|
-
root.insertBefore(entry, anchor)
|
|
134
|
-
}
|
|
135
|
-
return true
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Mount the sidebar entry, waiting for the shell to render and self-healing
|
|
140
|
-
* on later React re-renders.
|
|
141
|
-
* @param options - the row's attribute/icon/copy/action/ordering configuration.
|
|
142
|
-
* @returns disposer removing the entry and its observers.
|
|
143
|
-
*/
|
|
144
|
-
export function mountSidebarEntry(options: SidebarEntryOptions): () => void {
|
|
145
|
-
// DOM-level idempotency: whatever path mounted an entry row before this
|
|
146
|
-
// call (a duplicated apply, an HMR re-injection, a stale module still
|
|
147
|
-
// alive), never mount a second one. The existing row keeps working; a full
|
|
148
|
-
// page reload is the ultimate reset.
|
|
149
|
-
if (typeof document !== 'undefined' && document.querySelector(options.rowSelector) !== null) {
|
|
150
|
-
return () => {}
|
|
151
|
-
}
|
|
152
|
-
const { entry, applyLabel } = createEntry(options)
|
|
153
|
-
let root: HTMLElement | undefined
|
|
154
|
-
let placed = false
|
|
155
|
-
let unsubscribeRefresh: (() => void) | undefined
|
|
156
|
-
if (options.refresh !== undefined) {
|
|
157
|
-
try {
|
|
158
|
-
unsubscribeRefresh = options.refresh.subscribe(applyLabel)
|
|
159
|
-
} catch {
|
|
160
|
-
// A throwing subscription must not break the mount; the label stays at
|
|
161
|
-
// its initial value and the next reload resolves it again.
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const tryPlace = (): void => {
|
|
166
|
-
if (root !== undefined && !root.isConnected) {
|
|
167
|
-
// The shell rebuilt the sidebar pane (whole-tree teardown); the root
|
|
168
|
-
// observer is gone with the old tree, so detach it and re-query from
|
|
169
|
-
// scratch. The new pane is later noticed by the body-level watcher.
|
|
170
|
-
rootObserver.disconnect()
|
|
171
|
-
root = undefined
|
|
172
|
-
placed = false
|
|
173
|
-
}
|
|
174
|
-
if (placed) {
|
|
175
|
-
// Cheap short-circuit: entry still lives in a mountable subtree.
|
|
176
|
-
if (document.body.contains(entry)) return
|
|
177
|
-
// Entry was torn down together with the old tree; reset and re-place.
|
|
178
|
-
rootObserver.disconnect()
|
|
179
|
-
root = undefined
|
|
180
|
-
placed = false
|
|
181
|
-
}
|
|
182
|
-
root ??= sidebarRoot()
|
|
183
|
-
if (root === undefined) return
|
|
184
|
-
placed = placeEntry(root, entry, options)
|
|
185
|
-
if (placed) {
|
|
186
|
-
rootObserver.observe(root, { childList: true, subtree: true })
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Body-level watcher retained as the "whole rebuild" fallback: when the shell
|
|
191
|
-
// tears down the whole sidebar pane, the root observer is gone with it and
|
|
192
|
-
// only this body observation can notice the new pane mounting. It stays
|
|
193
|
-
// subscribed after placement; the placed-and-still-mounted case
|
|
194
|
-
// short-circuits through the cheap document.body.contains(entry) check, so
|
|
195
|
-
// unrelated app mutations (e.g. chat streaming) cost one contains check per
|
|
196
|
-
// frame instead of churning the full re-query. The body observation itself is
|
|
197
|
-
// the page-wide hub (shared/client/body-mutations.ts): every family plugin
|
|
198
|
-
// used to hold its own body subtree observer, so the per-mutation cost grew
|
|
199
|
-
// with the number of installed plugins; the hub keeps exactly one.
|
|
200
|
-
const unsubscribeBody = subscribeBodyInvalidations(() => { tryPlace() })
|
|
201
|
-
|
|
202
|
-
// Self-heal: if a React re-render displaces the row, re-insert it in the
|
|
203
|
-
// same frame (microtask before paint -> no visible flicker).
|
|
204
|
-
const rootObserver = new MutationObserver(() => {
|
|
205
|
-
if (root === undefined || !root.isConnected) {
|
|
206
|
-
placed = false
|
|
207
|
-
tryPlace()
|
|
208
|
-
return
|
|
209
|
-
}
|
|
210
|
-
if (!root.contains(entry)) {
|
|
211
|
-
placed = placeEntry(root, entry, options)
|
|
212
|
-
}
|
|
213
|
-
})
|
|
214
|
-
|
|
215
|
-
// Reflect the panel's open state on the row (active highlight). Note: assigning
|
|
216
|
-
// undefined to dataset.active materializes data-active="undefined" and keeps the
|
|
217
|
-
// row permanently highlighted — delete the attribute instead.
|
|
218
|
-
const unsubscribeActive = options.active === undefined ? undefined : (() => {
|
|
219
|
-
const syncActive = (): void => {
|
|
220
|
-
if (options.active!.isOpen()) entry.dataset.active = 'true'
|
|
221
|
-
else delete entry.dataset.active
|
|
222
|
-
}
|
|
223
|
-
const unsubscribe = options.active.subscribe(syncActive)
|
|
224
|
-
syncActive()
|
|
225
|
-
return unsubscribe
|
|
226
|
-
})()
|
|
227
|
-
|
|
228
|
-
tryPlace()
|
|
229
|
-
|
|
230
|
-
return () => {
|
|
231
|
-
unsubscribeBody()
|
|
232
|
-
rootObserver.disconnect()
|
|
233
|
-
unsubscribeRefresh?.()
|
|
234
|
-
unsubscribeActive?.()
|
|
235
|
-
entry.remove()
|
|
236
|
-
}
|
|
237
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sidebar entry injection — package-specific wiring over the shared core.
|
|
3
|
-
*
|
|
4
|
-
* dsh's sidebar shell exposes no slot an external plugin can register into
|
|
5
|
-
* (`sidebar.workspaces` / `sidebar.settings` are single-occupant and already
|
|
6
|
-
* taken), so the entry row is injected between the shell's New Session button
|
|
7
|
-
* and the workspace browser. The DOM injection / self-healing / idempotency
|
|
8
|
-
* logic lives exactly once in shared/client/sidebar-entry-core.ts (synced
|
|
9
|
-
* copy); this wrapper supplies the task-board icon, copy, CSS module, and the
|
|
10
|
-
* board toggle. The row is plain DOM (no React tree); the board view it
|
|
11
|
-
* toggles is a separate React root mounted in the center column
|
|
12
|
-
* (see board-mount.ts).
|
|
13
|
-
*/
|
|
14
|
-
import type { BoardController } from '../core/controller.ts'
|
|
15
|
-
import { t } from './locales.ts'
|
|
16
|
-
import css from './board.module.css'
|
|
17
|
-
import { mountSidebarEntry as mountSharedSidebarEntry } from './sidebar-entry-core.ts'
|
|
18
|
-
|
|
19
|
-
/** Stable data attribute identifying the injected entry row. */
|
|
20
|
-
export const ENTRY_SELECTOR = '[data-dsh-taskboard-entry]'
|
|
21
|
-
|
|
22
|
-
/** Inline icon normalized to the shell's 16px navigation glyph size. */
|
|
23
|
-
const ICON = '<svg viewBox="0 0 16 16" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="2.5" width="12" height="11" rx="1.5"/><path d="M2 6.5h12M6.5 6.5v7"/></svg>'
|
|
24
|
-
|
|
25
|
-
/** Locale-change subscription the shared core asks for (ctx.locale.subscribe shape). */
|
|
26
|
-
export interface LocaleRefreshSource { subscribe(listener: () => void): () => void }
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Mount the sidebar entry, waiting for the shell to render and self-healing
|
|
30
|
-
* on later React re-renders.
|
|
31
|
-
* @param controller - the board controller the entry toggles.
|
|
32
|
-
* @param locale - locale-change source; when given, re-applies the label on
|
|
33
|
-
* a Language switch (the plain-DOM row otherwise keeps the mount-time copy).
|
|
34
|
-
* @returns disposer removing the entry and its observers.
|
|
35
|
-
*/
|
|
36
|
-
export function mountSidebarEntry(controller: BoardController, locale?: LocaleRefreshSource): () => void {
|
|
37
|
-
return mountSharedSidebarEntry({
|
|
38
|
-
rowAttribute: 'data-dsh-taskboard-entry',
|
|
39
|
-
rowSelector: ENTRY_SELECTOR,
|
|
40
|
-
plugin: 'task-board',
|
|
41
|
-
icon: ICON,
|
|
42
|
-
css,
|
|
43
|
-
label: () => t('entry.label'),
|
|
44
|
-
refresh: locale === undefined ? undefined : { subscribe: (listener) => locale.subscribe(listener) },
|
|
45
|
-
onToggle: () => { controller.toggleBoard() },
|
|
46
|
-
position: 'before',
|
|
47
|
-
familySelectors: ['[data-dsh-taskboard-entry]', '[data-dsh-ssh-entry]'],
|
|
48
|
-
active: {
|
|
49
|
-
subscribe: (listener) => controller.subscribe(listener),
|
|
50
|
-
isOpen: () => controller.getSnapshot().boardOpen,
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
}
|