@linxin666/dsh-client-ui-task-board 0.4.12 → 0.4.14
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 +9 -3
- package/README.zh.md +9 -3
- package/lib/client.js +1476 -478
- package/lib/client.js.map +1 -1
- package/lib/index.js +1280 -65
- package/lib/types/client/board/AttachmentField.d.ts +70 -0
- package/lib/types/client/board/model-options.d.ts +21 -1
- package/lib/types/client/board/source-group.d.ts +27 -0
- package/lib/types/client/host-api.d.ts +25 -0
- package/lib/types/client/locales.d.ts +17 -0
- package/lib/types/client/pending-verify.d.ts +47 -0
- package/lib/types/client/service.d.ts +4 -1
- package/lib/types/core/attachment.d.ts +132 -0
- package/lib/types/core/controller.d.ts +26 -2
- package/lib/types/core/extension.d.ts +82 -0
- package/lib/types/core/session-reuse.d.ts +7 -1
- package/lib/types/core/tasks.d.ts +38 -1
- package/lib/types/core/use-cases/task-update.d.ts +21 -0
- package/lib/types/core/wire-projection.d.ts +35 -0
- package/lib/types/host/attachments.d.ts +250 -0
- package/lib/types/host/extension-registry.d.ts +40 -0
- package/lib/types/host-ledger.d.ts +16 -0
- package/lib/types/host-routes.d.ts +14 -0
- package/lib/types/host-runner.d.ts +53 -1
- package/lib/types/host-service.d.ts +59 -0
- package/lib/types/index.d.ts +23 -0
- package/lib/types/protocol.d.ts +39 -6
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +6 -2
- package/src/client/TaskBoardSettingsCard.tsx +11 -1
- package/src/client/board/AttachmentField.tsx +383 -0
- package/src/client/board/EditTaskModal.tsx +63 -0
- package/src/client/board/NewTaskModal.tsx +76 -4
- package/src/client/board/TaskBoard.tsx +47 -10
- package/src/client/board/TaskDetail.tsx +30 -2
- package/src/client/board/model-options.ts +32 -2
- package/src/client/board/source-group.ts +94 -0
- package/src/client/board.module.css +83 -0
- package/src/client/host-api.ts +70 -0
- package/src/client/index.ts +11 -0
- package/src/client/locales.ts +34 -0
- package/src/client/pending-verify.ts +90 -0
- package/src/client/service.ts +24 -0
- package/src/core/attachment.ts +287 -0
- package/src/core/controller.ts +47 -1
- package/src/core/extension.ts +86 -0
- package/src/core/session-reuse.ts +7 -1
- package/src/core/store.ts +10 -1
- package/src/core/tasks.ts +49 -0
- package/src/core/use-cases/task-update.ts +27 -2
- package/src/core/wire-projection.ts +81 -0
- package/src/host/attachments.ts +650 -0
- package/src/host/extension-registry.ts +150 -5
- package/src/host-ledger.ts +32 -4
- package/src/host-routes.ts +168 -13
- package/src/host-runner.ts +124 -4
- package/src/host-service.ts +165 -12
- package/src/index.ts +47 -0
- package/src/protocol.ts +57 -9
|
@@ -564,6 +564,23 @@
|
|
|
564
564
|
font-size: 12px;
|
|
565
565
|
}
|
|
566
566
|
|
|
567
|
+
/* Provider-owned source groups wrap recency groups without adding a new
|
|
568
|
+
semantic part. Long owner/repository labels wrap instead of pushing the
|
|
569
|
+
count and disclosure beyond a narrow column. */
|
|
570
|
+
.sourceGroup {
|
|
571
|
+
gap: 8px;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.sourceGroupHeader {
|
|
575
|
+
color: var(--dsw-alias-label-secondary);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
.sourceGroupLabel {
|
|
579
|
+
flex: 1 1 auto;
|
|
580
|
+
min-width: 0;
|
|
581
|
+
overflow-wrap: anywhere;
|
|
582
|
+
}
|
|
583
|
+
|
|
567
584
|
/* Per-column density switch in the column header: one row slot, 44px pointer
|
|
568
585
|
target from the same expansion the card's quick action uses. */
|
|
569
586
|
.densityToggle {
|
|
@@ -2533,6 +2550,72 @@
|
|
|
2533
2550
|
align-self: flex-start;
|
|
2534
2551
|
}
|
|
2535
2552
|
|
|
2553
|
+
/* --- card attachments (#1979) ------------------------------------------------- */
|
|
2554
|
+
|
|
2555
|
+
.attachmentDrop {
|
|
2556
|
+
display: flex;
|
|
2557
|
+
align-items: center;
|
|
2558
|
+
gap: 8px;
|
|
2559
|
+
flex-wrap: wrap;
|
|
2560
|
+
margin-top: 6px;
|
|
2561
|
+
padding: 10px 12px;
|
|
2562
|
+
border: 1px dashed var(--dsw-alias-border-secondary);
|
|
2563
|
+
border-radius: 8px;
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
.attachmentDrop[data-state='active'] {
|
|
2567
|
+
border-color: var(--dsw-alias-border-focus);
|
|
2568
|
+
background: var(--dsw-alias-surface-raised);
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
.attachmentDropHint {
|
|
2572
|
+
flex: 1 1 12em;
|
|
2573
|
+
min-width: 0;
|
|
2574
|
+
color: var(--dsw-alias-label-tertiary);
|
|
2575
|
+
font-size: 12px;
|
|
2576
|
+
line-height: 1.4;
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
.attachmentList {
|
|
2580
|
+
display: flex;
|
|
2581
|
+
flex-direction: column;
|
|
2582
|
+
gap: 6px;
|
|
2583
|
+
margin: 8px 0 0;
|
|
2584
|
+
padding: 0;
|
|
2585
|
+
list-style: none;
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
.attachmentRow {
|
|
2589
|
+
display: flex;
|
|
2590
|
+
align-items: center;
|
|
2591
|
+
gap: 8px;
|
|
2592
|
+
padding: 4px 6px;
|
|
2593
|
+
border: 1px solid var(--dsw-alias-border-subtle);
|
|
2594
|
+
border-radius: 6px;
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
.attachmentThumb {
|
|
2598
|
+
flex: none;
|
|
2599
|
+
width: 40px;
|
|
2600
|
+
height: 40px;
|
|
2601
|
+
object-fit: cover;
|
|
2602
|
+
border-radius: 4px;
|
|
2603
|
+
background: var(--dsw-alias-surface-raised);
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
.attachmentName {
|
|
2607
|
+
flex: 1 1 0;
|
|
2608
|
+
min-width: 0;
|
|
2609
|
+
overflow-wrap: anywhere;
|
|
2610
|
+
font-size: 13px;
|
|
2611
|
+
line-height: 1.4;
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
.attachmentMeta {
|
|
2615
|
+
color: var(--dsw-alias-label-tertiary);
|
|
2616
|
+
font-size: 12px;
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2536
2619
|
/* --- project partition (#1536) ------------------------------------------------ */
|
|
2537
2620
|
|
|
2538
2621
|
.projectFilter {
|
package/src/client/host-api.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { degradedRowOf, ledgerOwnerPid } from '../core/degraded-reason.ts'
|
|
2
|
+
import { isTaskAttachment, type TaskAttachment, type TaskAttachmentKind } from '../core/attachment.ts'
|
|
2
3
|
import { TASK_BOARD_PACKAGE } from '../core/package-name.ts'
|
|
3
4
|
import type { TaskRecord } from '../core/tasks.ts'
|
|
4
5
|
import { t } from './locales.ts'
|
|
@@ -27,6 +28,8 @@ const IMPORT_MARKER = 'dsh.taskBoard.v2.hostImported'
|
|
|
27
28
|
const SOURCE_KEY = 'dsh.taskBoard.v2.sourceId'
|
|
28
29
|
const IMPORT_REQUEST_KEY = 'dsh.taskBoard.v2.importRequestId'
|
|
29
30
|
const REQUEST_TIMEOUT_MS = 15_000
|
|
31
|
+
/** An upload moves real bytes, so it gets a wider budget than a JSON call. */
|
|
32
|
+
const UPLOAD_TIMEOUT_MS = 120_000
|
|
30
33
|
/** Re-notify the panel at most this often while the event stream stays broken. */
|
|
31
34
|
const STREAM_ERROR_NOTIFY_MS = 15_000
|
|
32
35
|
/** Mirrors the Host's own parse budget; only used to phrase the timeout. */
|
|
@@ -196,6 +199,22 @@ export interface TaskBoardHostTransport {
|
|
|
196
199
|
subscribe(listener: (event?: TaskBoardEventPayload) => void): () => void
|
|
197
200
|
/** One-shot model parse of pasted text (issue #1540). */
|
|
198
201
|
parseDraft(request: TaskBoardParseRequest, signal?: AbortSignal): Promise<TaskBoardParseDraft>
|
|
202
|
+
/**
|
|
203
|
+
* Upload one file or image into the Host's attachment storage. Optional: a
|
|
204
|
+
* deployment that serves no attachment storage omits it, and the form then
|
|
205
|
+
* refuses to stage an attachment at all.
|
|
206
|
+
*/
|
|
207
|
+
uploadAttachment?(file: File, kind: TaskAttachmentKind): Promise<TaskAttachment>
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The URL of one stored image. The board serves it only for an id a card of
|
|
212
|
+
* this board references, so the URL is useless on its own.
|
|
213
|
+
* @param attachmentId - the stored object's identifier.
|
|
214
|
+
* @returns the document-relative URL of the image.
|
|
215
|
+
*/
|
|
216
|
+
export function attachmentImageUrl(attachmentId: string): string {
|
|
217
|
+
return `${CLIENT_API_PREFIX}/attachments/image?id=${encodeURIComponent(attachmentId)}`
|
|
199
218
|
}
|
|
200
219
|
|
|
201
220
|
export class HttpTaskBoardHostTransport implements TaskBoardHostTransport {
|
|
@@ -305,6 +324,50 @@ export class HttpTaskBoardHostTransport implements TaskBoardHostTransport {
|
|
|
305
324
|
throw new HostApiError('rejected', t('new.aiParseFailed', { error: detail }), response.status)
|
|
306
325
|
}
|
|
307
326
|
|
|
327
|
+
/**
|
|
328
|
+
* Upload one attachment into the Host's attachment storage.
|
|
329
|
+
*
|
|
330
|
+
* The bytes travel as the raw request body: the Host measures the ACTUAL
|
|
331
|
+
* stream, publishes the object and answers with the host-computed metadata
|
|
332
|
+
* (size, type and digest) that the card will record.
|
|
333
|
+
* @param file - the picked file.
|
|
334
|
+
* @param kind - whether the file is stored as an image or verbatim.
|
|
335
|
+
* @returns the metadata the Host computed for the stored object.
|
|
336
|
+
*/
|
|
337
|
+
async uploadAttachment(file: File, kind: TaskAttachmentKind): Promise<TaskAttachment> {
|
|
338
|
+
const controller = new AbortController()
|
|
339
|
+
const timer = globalThis.setTimeout(() => { controller.abort() }, UPLOAD_TIMEOUT_MS)
|
|
340
|
+
try {
|
|
341
|
+
const query = new URLSearchParams({ kind, name: file.name, mediaType: file.type })
|
|
342
|
+
const response = await fetch(`${CLIENT_API_PREFIX}/attachments/upload?${query.toString()}`, {
|
|
343
|
+
method: 'POST',
|
|
344
|
+
headers: { 'content-type': 'application/octet-stream' },
|
|
345
|
+
body: file,
|
|
346
|
+
signal: controller.signal,
|
|
347
|
+
})
|
|
348
|
+
const text = await response.text()
|
|
349
|
+
let parsed: unknown
|
|
350
|
+
try {
|
|
351
|
+
parsed = JSON.parse(text)
|
|
352
|
+
} catch {
|
|
353
|
+
parsed = undefined
|
|
354
|
+
}
|
|
355
|
+
const record = parsed as { ok?: unknown; attachment?: unknown; error?: unknown } | undefined
|
|
356
|
+
if (response.ok) {
|
|
357
|
+
if (record !== undefined && isTaskAttachment(record.attachment)) return record.attachment
|
|
358
|
+
throw new HostApiError('unexpected', t('board.hostError.unexpected', { status: String(response.status) }), response.status)
|
|
359
|
+
}
|
|
360
|
+
const detail = typeof record?.error === 'string' && record.error !== '' ? record.error : String(response.status)
|
|
361
|
+
throw new HostApiError('rejected', detail, response.status)
|
|
362
|
+
} catch (error) {
|
|
363
|
+
if (error instanceof HostApiError) throw error
|
|
364
|
+
if (controller.signal.aborted) throw new HostApiError('timeout', t('board.hostError.timeout', { seconds: String(UPLOAD_TIMEOUT_MS / 1000) }))
|
|
365
|
+
throw new HostApiError('unreachable', t('board.hostError.unreachable'))
|
|
366
|
+
} finally {
|
|
367
|
+
globalThis.clearTimeout(timer)
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
308
371
|
subscribe(listener: (event?: TaskBoardEventPayload) => void): () => void {
|
|
309
372
|
const events = new EventSource(`${CLIENT_API_PREFIX}/events`)
|
|
310
373
|
let lastStreamErrorNotify = 0
|
|
@@ -317,6 +380,13 @@ export class HttpTaskBoardHostTransport implements TaskBoardHostTransport {
|
|
|
317
380
|
listener()
|
|
318
381
|
}
|
|
319
382
|
}
|
|
383
|
+
// Every connect and every reconnect is a resynchronization point: the route
|
|
384
|
+
// pushes one frame when it accepts a stream, but a frame whose revision
|
|
385
|
+
// already matches the mirrored one is what the panel applies without a
|
|
386
|
+
// read, so the connection itself asks for the snapshot. Without this, a
|
|
387
|
+
// stream that came back after an outage would only catch up if some later
|
|
388
|
+
// Host write happened to move the revision past the mirror.
|
|
389
|
+
events.onopen = (): void => { listener() }
|
|
320
390
|
// A stream that cannot connect at all (unmounted route, refused socket) is
|
|
321
391
|
// how a Host half that never mounted looks from the browser; nudge the
|
|
322
392
|
// panel into one state read so the failure becomes visible (#1528).
|
package/src/client/index.ts
CHANGED
|
@@ -29,12 +29,14 @@ import { modelOptionsFromCatalog, modelOptionsFromDiscoveredModels } from './boa
|
|
|
29
29
|
import { presetOptionsFromRoster, readPresetRoster, type PresetRemote } from './board/preset-roster.ts'
|
|
30
30
|
import { mainViewSessionId } from './main-session.ts'
|
|
31
31
|
import { LocalStorageTaskStore } from '../core/store.ts'
|
|
32
|
+
import { hasOpenExecution } from '../core/tasks.ts'
|
|
32
33
|
import { claimTaskboardApply, releaseTaskboardApply } from './apply-guard.ts'
|
|
33
34
|
import { registerTaskBoardPanel } from './native-panel.tsx'
|
|
34
35
|
import { createScheduleRowGuard } from './suppress-schedule-row.ts'
|
|
35
36
|
import { TaskBoardSettingsCard, TaskBoardSettingsCardController, type TaskBoardSettings } from './TaskBoardSettingsCard.tsx'
|
|
36
37
|
import { en, zh, setRuntimeTranslate, type TaskBoardKey } from './locales.ts'
|
|
37
38
|
import { HttpTaskBoardHostTransport } from './host-api.ts'
|
|
39
|
+
import { startPendingVerification } from './pending-verify.ts'
|
|
38
40
|
import { reportDailyHeartbeat } from './telemetry.ts'
|
|
39
41
|
import { installPluginCard } from './plugin-card-seat.ts'
|
|
40
42
|
import { createServedEntryForm } from './settings-entry-form.ts'
|
|
@@ -297,6 +299,15 @@ export function apply(ctx: ClientContext): void {
|
|
|
297
299
|
// which serves the settings card whether or not the view is mounted.
|
|
298
300
|
liveController = controller
|
|
299
301
|
if (presetRoster !== undefined) controller.setExecutionOptions({ presets: presetRoster })
|
|
302
|
+
// While the mirror shows work in flight it verifies that state itself: the
|
|
303
|
+
// pushed frame is unverifiable from the browser (a stream can stay open and
|
|
304
|
+
// silent), and a settled card would otherwise keep rendering as running for
|
|
305
|
+
// as long as the tab stays open. Nothing is read once nothing is in flight.
|
|
306
|
+
disposers.push(startPendingVerification({
|
|
307
|
+
pending: () => controller.getSnapshot().tasks.some(hasOpenExecution),
|
|
308
|
+
refresh: () => { controller.refreshHostState() },
|
|
309
|
+
subscribe: listener => controller.subscribe(listener),
|
|
310
|
+
}))
|
|
300
311
|
|
|
301
312
|
// The new-card defaults are written through the very settings form this
|
|
302
313
|
// plugin binds (that is the card's save), and the Host republishes its
|
package/src/client/locales.ts
CHANGED
|
@@ -61,12 +61,14 @@ export const zh = {
|
|
|
61
61
|
'new.section.parse': 'AI 解析',
|
|
62
62
|
'new.section.content': '任务内容',
|
|
63
63
|
'new.section.labels': '标签',
|
|
64
|
+
'new.section.attachments': '附件',
|
|
64
65
|
'new.section.execution': '执行设置',
|
|
65
66
|
'new.section.run': '运行方式',
|
|
66
67
|
'new.section.handover': '交接与续跑',
|
|
67
68
|
'new.section.schedule': '定时运行',
|
|
68
69
|
'new.summary.none': '未设置',
|
|
69
70
|
'new.summary.labelCount': '{count} 个标签',
|
|
71
|
+
'new.summary.attachmentCount': '{count} 个附件',
|
|
70
72
|
'new.summary.filled': '已填写',
|
|
71
73
|
'new.summary.scheduleOff': '未启用',
|
|
72
74
|
'new.summary.multiRound': '多轮 /goal',
|
|
@@ -104,6 +106,20 @@ export const zh = {
|
|
|
104
106
|
'new.tagPromptPlaceholder': '例如:产物归档到 02-工作/',
|
|
105
107
|
'new.tagAdd': '添加标签',
|
|
106
108
|
'new.tagRemove': '移除标签 {name}',
|
|
109
|
+
'new.attachments': '附件',
|
|
110
|
+
'new.attachmentsHint': '拖放、粘贴或选择文件;文件在保存卡片时才上传。图片会随执行一起送给模型,普通文件以只读路径交给执行会话。',
|
|
111
|
+
'new.attachments.drop': '把文件拖到这里,或直接粘贴',
|
|
112
|
+
'new.attachments.pick': '选择文件',
|
|
113
|
+
'new.attachments.remove': '移除附件 {name}',
|
|
114
|
+
'new.attachments.limitCount': '每张卡片最多 {count} 个附件',
|
|
115
|
+
'new.attachments.limitImages': '这个部署每条消息最多接收 {count} 张图片',
|
|
116
|
+
'new.attachments.limitImageBytes': '图片总大小超过部署上限 {size}',
|
|
117
|
+
'new.attachments.limitSize': '{name} 超过单个附件上限 {size}',
|
|
118
|
+
'new.attachments.limitTotal': '附件总大小超过上限 {size}',
|
|
119
|
+
'new.attachments.unavailable': '这个部署没有提供附件存储,无法上传附件',
|
|
120
|
+
'new.attachments.uploading': '上传中',
|
|
121
|
+
'detail.attachments': '附件',
|
|
122
|
+
'detail.attachments.removeHint': '移除附件只会删掉卡片上的引用;Host 存储里的文件不会被物理删除。',
|
|
107
123
|
'board.tagFilter': '按标签筛选',
|
|
108
124
|
'board.tagFilterClear': '清除标签筛选',
|
|
109
125
|
'board.tagEmpty': '没有同时带这些标签的任务',
|
|
@@ -484,6 +500,7 @@ export const zh = {
|
|
|
484
500
|
'card.time.updated': '更新于 {time}',
|
|
485
501
|
'board.density.compact': '切换为紧凑卡片',
|
|
486
502
|
'board.density.comfortable': '切换为完整卡片',
|
|
503
|
+
'board.source.local': '本地任务',
|
|
487
504
|
'board.group.today': '今天',
|
|
488
505
|
'board.group.week': '近 7 天',
|
|
489
506
|
'board.group.earlier': '更早',
|
|
@@ -551,12 +568,14 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
551
568
|
'new.section.parse': 'AI Parse',
|
|
552
569
|
'new.section.content': 'Task Content',
|
|
553
570
|
'new.section.labels': 'Tags',
|
|
571
|
+
'new.section.attachments': 'Attachments',
|
|
554
572
|
'new.section.execution': 'Execution Settings',
|
|
555
573
|
'new.section.run': 'Run Mode',
|
|
556
574
|
'new.section.handover': 'Handover',
|
|
557
575
|
'new.section.schedule': 'Scheduled Runs',
|
|
558
576
|
'new.summary.none': 'Not set',
|
|
559
577
|
'new.summary.labelCount': '{count} tags',
|
|
578
|
+
'new.summary.attachmentCount': '{count} attachments',
|
|
560
579
|
'new.summary.filled': 'Filled',
|
|
561
580
|
'new.summary.scheduleOff': 'Off',
|
|
562
581
|
'new.summary.multiRound': 'multi-round /goal',
|
|
@@ -594,6 +613,20 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
594
613
|
'new.tagPromptPlaceholder': 'e.g. Archive artefacts under 02-work/',
|
|
595
614
|
'new.tagAdd': 'Add tag',
|
|
596
615
|
'new.tagRemove': 'Remove tag {name}',
|
|
616
|
+
'new.attachments': 'Attachments',
|
|
617
|
+
'new.attachmentsHint': 'Drag, paste, or pick files; they are uploaded when the card is saved. Images travel with the execution, plain files reach the session as read-only paths.',
|
|
618
|
+
'new.attachments.drop': 'Drop files here, or paste them',
|
|
619
|
+
'new.attachments.pick': 'Choose files',
|
|
620
|
+
'new.attachments.remove': 'Remove attachment {name}',
|
|
621
|
+
'new.attachments.limitCount': 'A card carries at most {count} attachments',
|
|
622
|
+
'new.attachments.limitImages': 'This deployment admits at most {count} images per message',
|
|
623
|
+
'new.attachments.limitImageBytes': 'The images exceed the deployment limit of {size}',
|
|
624
|
+
'new.attachments.limitSize': '{name} exceeds the per-attachment limit of {size}',
|
|
625
|
+
'new.attachments.limitTotal': 'The attachments exceed the total limit of {size}',
|
|
626
|
+
'new.attachments.unavailable': 'This deployment serves no attachment storage, so nothing can be uploaded',
|
|
627
|
+
'new.attachments.uploading': 'uploading',
|
|
628
|
+
'detail.attachments': 'Attachments',
|
|
629
|
+
'detail.attachments.removeHint': 'Removing an attachment drops the reference on the card; the stored file itself is not physically deleted.',
|
|
597
630
|
'board.tagFilter': 'Filter by tag',
|
|
598
631
|
'board.tagFilterClear': 'Clear tag filter',
|
|
599
632
|
'board.tagEmpty': 'No task carries all of these tags',
|
|
@@ -974,6 +1007,7 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
974
1007
|
'card.time.updated': 'Updated {time}',
|
|
975
1008
|
'board.density.compact': 'Switch to compact cards',
|
|
976
1009
|
'board.density.comfortable': 'Switch to full cards',
|
|
1010
|
+
'board.source.local': 'Local tasks',
|
|
977
1011
|
'board.group.today': 'Today',
|
|
978
1012
|
'board.group.week': 'Last 7 days',
|
|
979
1013
|
'board.group.earlier': 'Earlier',
|
|
@@ -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
|
+
}
|
package/src/client/service.ts
CHANGED
|
@@ -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) }
|