@linxin666/dsh-client-ui-task-board 0.4.13 → 0.4.15
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 +4 -4
- package/README.zh.md +4 -4
- package/lib/client.js +244 -264
- package/lib/client.js.map +1 -1
- package/lib/index.js +36 -11
- package/lib/types/client/board/source-group.d.ts +27 -0
- package/lib/types/client/locales.d.ts +1 -0
- package/lib/types/client/pending-verify.d.ts +47 -0
- package/lib/types/client/plugin-card-seat.d.ts +1 -1
- package/lib/types/client/service.d.ts +4 -1
- package/lib/types/core/controller.d.ts +7 -1
- package/lib/types/core/extension.d.ts +14 -0
- package/lib/types/host-routes.d.ts +6 -0
- package/lib/types/index.d.ts +1 -1
- package/package.json +28 -28
- package/src/client/board/TaskBoard.tsx +47 -10
- package/src/client/board/source-group.ts +94 -0
- package/src/client/board.module.css +17 -0
- package/src/client/host-api.ts +7 -0
- package/src/client/index.ts +11 -10
- package/src/client/locales.ts +2 -0
- package/src/client/pending-verify.ts +90 -0
- package/src/client/plugin-card-seat.ts +2 -2
- package/src/client/service.ts +24 -0
- package/src/core/controller.ts +18 -0
- package/src/core/extension.ts +16 -0
- package/src/host-routes.ts +46 -11
- package/src/index.ts +1 -1
- package/lib/types/client/suppress-schedule-row.d.ts +0 -86
- package/src/client/suppress-schedule-row.ts +0 -198
package/src/client/index.ts
CHANGED
|
@@ -29,12 +29,13 @@ 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
|
-
import { createScheduleRowGuard } from './suppress-schedule-row.ts'
|
|
35
35
|
import { TaskBoardSettingsCard, TaskBoardSettingsCardController, type TaskBoardSettings } from './TaskBoardSettingsCard.tsx'
|
|
36
36
|
import { en, zh, setRuntimeTranslate, type TaskBoardKey } from './locales.ts'
|
|
37
37
|
import { HttpTaskBoardHostTransport } from './host-api.ts'
|
|
38
|
+
import { startPendingVerification } from './pending-verify.ts'
|
|
38
39
|
import { reportDailyHeartbeat } from './telemetry.ts'
|
|
39
40
|
import { installPluginCard } from './plugin-card-seat.ts'
|
|
40
41
|
import { createServedEntryForm } from './settings-entry-form.ts'
|
|
@@ -297,6 +298,15 @@ export function apply(ctx: ClientContext): void {
|
|
|
297
298
|
// which serves the settings card whether or not the view is mounted.
|
|
298
299
|
liveController = controller
|
|
299
300
|
if (presetRoster !== undefined) controller.setExecutionOptions({ presets: presetRoster })
|
|
301
|
+
// While the mirror shows work in flight it verifies that state itself: the
|
|
302
|
+
// pushed frame is unverifiable from the browser (a stream can stay open and
|
|
303
|
+
// silent), and a settled card would otherwise keep rendering as running for
|
|
304
|
+
// as long as the tab stays open. Nothing is read once nothing is in flight.
|
|
305
|
+
disposers.push(startPendingVerification({
|
|
306
|
+
pending: () => controller.getSnapshot().tasks.some(hasOpenExecution),
|
|
307
|
+
refresh: () => { controller.refreshHostState() },
|
|
308
|
+
subscribe: listener => controller.subscribe(listener),
|
|
309
|
+
}))
|
|
300
310
|
|
|
301
311
|
// The new-card defaults are written through the very settings form this
|
|
302
312
|
// plugin binds (that is the card's save), and the Host republishes its
|
|
@@ -414,12 +424,6 @@ export function apply(ctx: ClientContext): void {
|
|
|
414
424
|
uiDisposer = undefined
|
|
415
425
|
}
|
|
416
426
|
}
|
|
417
|
-
// The board's master switch owns the official automation-tasks entry as
|
|
418
|
-
// well: while the board is on, the shell's duplicate "Automation tasks" row
|
|
419
|
-
// is hidden, and with the board off the official row comes back. The same
|
|
420
|
-
// switch already governs the board's own row, so both scheduling entries
|
|
421
|
-
// appear and disappear together.
|
|
422
|
-
const scheduleRowGuard = createScheduleRowGuard(ctx)
|
|
423
427
|
const syncEnabled = (): void => {
|
|
424
428
|
const snapshot = settingsForm.getSnapshot()
|
|
425
429
|
const enabled = snapshot.status === 'ready'
|
|
@@ -428,10 +432,8 @@ export function apply(ctx: ClientContext): void {
|
|
|
428
432
|
if (enabled) {
|
|
429
433
|
mountUi()
|
|
430
434
|
clientService.setEnabled(true)
|
|
431
|
-
scheduleRowGuard.hide()
|
|
432
435
|
} else {
|
|
433
436
|
clientService.setEnabled(false)
|
|
434
|
-
scheduleRowGuard.show()
|
|
435
437
|
uiDisposer?.()
|
|
436
438
|
}
|
|
437
439
|
}
|
|
@@ -445,7 +447,6 @@ export function apply(ctx: ClientContext): void {
|
|
|
445
447
|
ctx.effect(() => () => {
|
|
446
448
|
unsubscribeSettings()
|
|
447
449
|
uiDisposer?.()
|
|
448
|
-
scheduleRowGuard.dispose()
|
|
449
450
|
}, 'task-board: DOM surfaces')
|
|
450
451
|
syncEnabled()
|
|
451
452
|
}
|
package/src/client/locales.ts
CHANGED
|
@@ -500,6 +500,7 @@ export const zh = {
|
|
|
500
500
|
'card.time.updated': '更新于 {time}',
|
|
501
501
|
'board.density.compact': '切换为紧凑卡片',
|
|
502
502
|
'board.density.comfortable': '切换为完整卡片',
|
|
503
|
+
'board.source.local': '本地任务',
|
|
503
504
|
'board.group.today': '今天',
|
|
504
505
|
'board.group.week': '近 7 天',
|
|
505
506
|
'board.group.earlier': '更早',
|
|
@@ -1006,6 +1007,7 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
1006
1007
|
'card.time.updated': 'Updated {time}',
|
|
1007
1008
|
'board.density.compact': 'Switch to compact cards',
|
|
1008
1009
|
'board.density.comfortable': 'Switch to full cards',
|
|
1010
|
+
'board.source.local': 'Local tasks',
|
|
1009
1011
|
'board.group.today': 'Today',
|
|
1010
1012
|
'board.group.week': 'Last 7 days',
|
|
1011
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
|
+
}
|
|
@@ -62,7 +62,7 @@ export interface PluginCardContext {
|
|
|
62
62
|
/** Service lookup; absent on a context double that only models the slots. */
|
|
63
63
|
get?(name: string): unknown
|
|
64
64
|
/** Event subscription seat; absent on an event-less test double. */
|
|
65
|
-
on?(event:
|
|
65
|
+
on?(event: never, listener: never): unknown
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
/** Owner share of a family list-seat card (that seat supplies nothing). */
|
|
@@ -193,7 +193,7 @@ export function installPluginCard(ctx: PluginCardContext, seat: PluginCardSeat):
|
|
|
193
193
|
|
|
194
194
|
if (typeof ctx.on === 'function') {
|
|
195
195
|
try {
|
|
196
|
-
ctx.on('slots/changed', () => { reconcile() })
|
|
196
|
+
ctx.on('slots/changed' as never, (() => { reconcile() }) as never)
|
|
197
197
|
} catch {
|
|
198
198
|
// An event seat that refuses the subscription leaves the initial
|
|
199
199
|
// decision in place; the card still renders in the seat chosen below.
|
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) }
|
package/src/core/controller.ts
CHANGED
|
@@ -32,6 +32,7 @@ import type {
|
|
|
32
32
|
} from '../protocol.ts'
|
|
33
33
|
import type {
|
|
34
34
|
TaskBoardExtensionActionRequest,
|
|
35
|
+
TaskBoardGroupingSelector,
|
|
35
36
|
TaskBoardVisibilityPredicate,
|
|
36
37
|
} from './extension.ts'
|
|
37
38
|
|
|
@@ -184,6 +185,8 @@ export interface ControllerSnapshot {
|
|
|
184
185
|
* hand-built snapshot (tests, a shell-less composition) defaults to visible.
|
|
185
186
|
*/
|
|
186
187
|
visibility?: readonly TaskBoardVisibilityPredicate[]
|
|
188
|
+
/** Provider source-group selectors, in registration order; browser-only functions. */
|
|
189
|
+
grouping?: readonly TaskBoardGroupingSelector[]
|
|
187
190
|
/** Read-only summaries published by running extensions, keyed by extension id. */
|
|
188
191
|
extensions?: Readonly<Record<string, unknown>>
|
|
189
192
|
}
|
|
@@ -235,6 +238,8 @@ export class BoardController {
|
|
|
235
238
|
private hostState: HostMirror | undefined
|
|
236
239
|
/** Provider visibility predicates (immutable array; replaced on change). */
|
|
237
240
|
private visibility: readonly TaskBoardVisibilityPredicate[] = []
|
|
241
|
+
/** Provider source-group selectors (immutable array; replaced on change). */
|
|
242
|
+
private grouping: readonly TaskBoardGroupingSelector[] = []
|
|
238
243
|
private remoteSubscribed = false
|
|
239
244
|
private remoteInitialization: Promise<boolean> | undefined
|
|
240
245
|
|
|
@@ -286,6 +291,7 @@ export class BoardController {
|
|
|
286
291
|
...(this.transportError === undefined ? {} : { transportError: this.transportError }),
|
|
287
292
|
...(this.hostState === undefined ? {} : { host: this.hostState }),
|
|
288
293
|
visibility: this.visibility,
|
|
294
|
+
grouping: this.grouping,
|
|
289
295
|
...(this.hostState?.extensions === undefined ? {} : { extensions: this.hostState.extensions }),
|
|
290
296
|
}
|
|
291
297
|
}
|
|
@@ -305,6 +311,18 @@ export class BoardController {
|
|
|
305
311
|
}
|
|
306
312
|
}
|
|
307
313
|
|
|
314
|
+
/** Register one source-group selector; registration order breaks ownership ties. */
|
|
315
|
+
registerGrouping(selector: TaskBoardGroupingSelector): () => void {
|
|
316
|
+
this.grouping = [...this.grouping, selector]
|
|
317
|
+
this.notify()
|
|
318
|
+
return () => {
|
|
319
|
+
const next = this.grouping.filter(candidate => candidate !== selector)
|
|
320
|
+
if (next.length === this.grouping.length) return
|
|
321
|
+
this.grouping = next
|
|
322
|
+
this.notify()
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
308
326
|
/**
|
|
309
327
|
* Deliver one provider action through the board's same-origin channel. A
|
|
310
328
|
* board without a Host transport (the legacy in-memory path) refuses it.
|
package/src/core/extension.ts
CHANGED
|
@@ -364,6 +364,17 @@ export interface TaskBoardClientMirror {
|
|
|
364
364
|
/** Whether a task should be shown on the board; false hides it. */
|
|
365
365
|
export type TaskBoardVisibilityPredicate = (task: TaskRecord) => boolean
|
|
366
366
|
|
|
367
|
+
/** Generic source bucket a provider assigns to one card. */
|
|
368
|
+
export interface TaskBoardSourceGroup {
|
|
369
|
+
/** Stable, provider-namespaced identity used for ordering and fold persistence. */
|
|
370
|
+
id: string
|
|
371
|
+
/** Full human-readable source label, such as an owner/repository pair. */
|
|
372
|
+
label: string
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** Return a card's source group, or undefined when this provider does not own it. */
|
|
376
|
+
export type TaskBoardGroupingSelector = (task: TaskRecord) => TaskBoardSourceGroup | undefined
|
|
377
|
+
|
|
367
378
|
/**
|
|
368
379
|
* Client capability face the board's browser half provides. A provider's
|
|
369
380
|
* browser half resolves it from the shared cordis service name; it never
|
|
@@ -374,6 +385,11 @@ export interface TaskBoardClientFace {
|
|
|
374
385
|
dispatch(request: TaskBoardExtensionActionRequest): Promise<boolean>
|
|
375
386
|
/** Register one card visibility predicate; the returned disposer removes it. */
|
|
376
387
|
registerVisibility(predicate: TaskBoardVisibilityPredicate): () => void
|
|
388
|
+
/**
|
|
389
|
+
* Register one source-group selector; the first selector returning a group
|
|
390
|
+
* wins. Optional so an older board can serve the same API version.
|
|
391
|
+
*/
|
|
392
|
+
registerGrouping?(selector: TaskBoardGroupingSelector): () => void
|
|
377
393
|
/** Subscribe to the board mirror. */
|
|
378
394
|
subscribe(callback: (mirror: TaskBoardClientMirror) => void): () => void
|
|
379
395
|
/** Read the current board mirror. */
|
package/src/host-routes.ts
CHANGED
|
@@ -27,7 +27,12 @@ import {
|
|
|
27
27
|
|
|
28
28
|
const ACTION_LIMIT = 64 * 1024
|
|
29
29
|
const IMPORT_LIMIT = 2 * 1024 * 1024
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Comment-frame cadence on the event stream. It keeps the connection alive
|
|
32
|
+
* through intermediaries that would close an idle one; it is not a frame the
|
|
33
|
+
* browser reports to the panel (an SSE comment is invisible to EventSource).
|
|
34
|
+
*/
|
|
35
|
+
export const HEARTBEAT_MS = 15_000
|
|
31
36
|
|
|
32
37
|
/** Header replaced by an authenticated same-host reverse proxy. */
|
|
33
38
|
export const TASK_BOARD_PROXY_TOKEN_HEADER = 'x-dsh-task-board-proxy-token'
|
|
@@ -334,18 +339,48 @@ export function makeTaskBoardRoutes(
|
|
|
334
339
|
'cache-control': 'no-cache',
|
|
335
340
|
connection: 'keep-alive',
|
|
336
341
|
})
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
// The stream is the board's only live signal, so it also has to be able to
|
|
343
|
+
// STOP being one. A connection can stop accepting bytes while neither end
|
|
344
|
+
// has closed it (a half-open socket, an intermediary that stopped
|
|
345
|
+
// reading); from then on every frame is written into nothing, the browser's
|
|
346
|
+
// EventSource sees an open stream that never speaks, and the panel keeps
|
|
347
|
+
// the snapshot it last applied with no error to react to. A failed write is
|
|
348
|
+
// the one report of that state, so it ends the connection here: the browser
|
|
349
|
+
// then reports the closed stream, and a closed stream makes the panel read
|
|
350
|
+
// the state again.
|
|
351
|
+
let heartbeat: ReturnType<typeof setInterval> | undefined
|
|
352
|
+
let release: (() => void) | undefined
|
|
353
|
+
const stop = (): void => {
|
|
354
|
+
if (heartbeat !== undefined) {
|
|
355
|
+
clearInterval(heartbeat)
|
|
356
|
+
heartbeat = undefined
|
|
357
|
+
}
|
|
358
|
+
const unsubscribe = release
|
|
359
|
+
release = undefined
|
|
360
|
+
unsubscribe?.()
|
|
340
361
|
}
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
362
|
+
const drop = (): void => {
|
|
363
|
+
if (release === undefined) return
|
|
364
|
+
stop()
|
|
365
|
+
res.destroy()
|
|
366
|
+
}
|
|
367
|
+
const write = (chunk: string): void => {
|
|
368
|
+
if (release === undefined || res.writableEnded || res.destroyed) return
|
|
369
|
+
// The callback is the only place Node reports a write that never landed;
|
|
370
|
+
// its result (backpressure) is not an error and is ignored.
|
|
371
|
+
res.write(chunk, (error) => { if (error !== null && error !== undefined) drop() })
|
|
372
|
+
}
|
|
373
|
+
const push = (): void => {
|
|
374
|
+
write(`data: ${JSON.stringify(service.eventPayload())}\n\n`)
|
|
346
375
|
}
|
|
347
|
-
|
|
348
|
-
|
|
376
|
+
release = service.subscribe(push)
|
|
377
|
+
heartbeat = setInterval(() => { write(': ping\n\n') }, HEARTBEAT_MS)
|
|
378
|
+
req.once('close', stop)
|
|
379
|
+
res.once('close', stop)
|
|
380
|
+
// A reset socket reports the same fact as a failed write. Without this
|
|
381
|
+
// listener Node treats a response error as unhandled, so the connection is
|
|
382
|
+
// released here instead of being left behind.
|
|
383
|
+
res.on('error', () => { drop() })
|
|
349
384
|
push()
|
|
350
385
|
},
|
|
351
386
|
}
|
package/src/index.ts
CHANGED
|
@@ -237,7 +237,7 @@ export interface Config {
|
|
|
237
237
|
* config against, before the schema turns volatile fields into live references
|
|
238
238
|
* and applies defaults. Declared separately because the two sides no longer
|
|
239
239
|
* share one shape, so the schema is annotated `z<ConfigInput, Config>` — the
|
|
240
|
-
* same split
|
|
240
|
+
* same split the git-family packages use. The annotation is also what keeps the
|
|
241
241
|
* emitted declaration portable: an unannotated schema holding a nested object
|
|
242
242
|
* array infers a type that cannot be named without reaching into a transitive
|
|
243
243
|
* dependency's own types.
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hide the official automation-tasks entry while the board is on.
|
|
3
|
-
*
|
|
4
|
-
* The shell mounts two scheduling surfaces side by side in the sidebar: the
|
|
5
|
-
* official `ui-schedule` client half ("Automation tasks" — the Host Schedule
|
|
6
|
-
* service's own page) and this package's board ("Task board" — a Host ledger
|
|
7
|
-
* that runs real DSH sessions). The board is the family's complete surface, so
|
|
8
|
-
* while it is enabled the official row is hidden and the sidebar offers one
|
|
9
|
-
* scheduling entry instead of two.
|
|
10
|
-
*
|
|
11
|
-
* The shell owns that row: it renders the button, the label, the tooltip, the
|
|
12
|
-
* active highlight and the collapsed rail, and the host's own end-to-end suite
|
|
13
|
-
* addresses the row by its accessible name. The row is therefore located the
|
|
14
|
-
* same way — the shell's global panel list seat (`sidebar.panellist`), whose
|
|
15
|
-
* per-row anchor the slot renderer stamps — and it is identified by the label
|
|
16
|
-
* the shell itself resolves for that entry (`resolveSlotLabel`, exactly the
|
|
17
|
-
* call the shell's panel projection makes), so the match follows the active
|
|
18
|
-
* language instead of a hard-coded translation.
|
|
19
|
-
*
|
|
20
|
-
* The write is one inline `display: none` on the shell's own button: the row
|
|
21
|
-
* stays mounted (React keeps owning it) and the official panel keeps working
|
|
22
|
-
* everywhere else it is reachable — only the duplicate sidebar entry goes
|
|
23
|
-
* away. The board's master switch owns the state, exactly as it owns the
|
|
24
|
-
* board's own row: with the board off, the official row comes back.
|
|
25
|
-
*/
|
|
26
|
-
import { type StoredEntry } from '@deepseek-ai/dsh-client-ui-slots';
|
|
27
|
-
/**
|
|
28
|
-
* The official automation-tasks panel id.
|
|
29
|
-
*
|
|
30
|
-
* The host `ui-schedule` client half registers its sidebar row and its
|
|
31
|
-
* center-column page under this id; the shell's panel projection addresses
|
|
32
|
-
* both by it.
|
|
33
|
-
*/
|
|
34
|
-
export declare const OFFICIAL_SCHEDULE_PANEL_ID = "schedules";
|
|
35
|
-
/** The slot-service slice the guard reads. */
|
|
36
|
-
export interface PanelSlotReader {
|
|
37
|
-
entriesOfSlot?(key: string): readonly StoredEntry[];
|
|
38
|
-
}
|
|
39
|
-
/** The context slice the guard needs. */
|
|
40
|
-
export interface ScheduleRowGuardContext {
|
|
41
|
-
slots?: PanelSlotReader;
|
|
42
|
-
}
|
|
43
|
-
/** The guard's controls. */
|
|
44
|
-
export interface ScheduleRowGuard {
|
|
45
|
-
/** Hide the official row, and keep it hidden while the board is on. */
|
|
46
|
-
hide(): void;
|
|
47
|
-
/** Restore the official row: the board's master switch is off. */
|
|
48
|
-
show(): void;
|
|
49
|
-
/** Release the listeners and restore the row. */
|
|
50
|
-
dispose(): void;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* The accessible name the shell renders on the official automation-tasks row.
|
|
54
|
-
*
|
|
55
|
-
* The shell projects its panel list with `resolveSlotLabel(options.label) ??
|
|
56
|
-
* id`, and that value becomes the row's accessible name. Reading the same
|
|
57
|
-
* value out of the same ledger is what keeps the DOM match correct in every
|
|
58
|
-
* language.
|
|
59
|
-
* @param entries - the live panel-list ledger.
|
|
60
|
-
* @returns the row's accessible name, or undefined when the official panel is not mounted.
|
|
61
|
-
*/
|
|
62
|
-
export declare function officialScheduleRowLabel(entries: readonly StoredEntry[]): string | undefined;
|
|
63
|
-
/**
|
|
64
|
-
* The shell's button for the panel row carrying this accessible name.
|
|
65
|
-
*
|
|
66
|
-
* Every global panel row renders one slot anchor inside the shell's own
|
|
67
|
-
* button, so the anchor is the row's handle and the button is what the user
|
|
68
|
-
* sees. Rows a plugin owns (they carry the family's own entry hook) are
|
|
69
|
-
* skipped.
|
|
70
|
-
* @param root - the document (or a subtree) to search.
|
|
71
|
-
* @param label - the accessible name to match.
|
|
72
|
-
* @returns the row button, or undefined when no row carries that name.
|
|
73
|
-
*/
|
|
74
|
-
export declare function findPanelRow(root: ParentNode, label: string): HTMLElement | undefined;
|
|
75
|
-
/**
|
|
76
|
-
* Guard the official automation-tasks row against the board's presence.
|
|
77
|
-
*
|
|
78
|
-
* The guard hides the row while the board is enabled and restores it when the
|
|
79
|
-
* board is switched off. It re-applies its write after every DOM change,
|
|
80
|
-
* because the shell owns the row and may mount or replace it at any time (a
|
|
81
|
-
* re-render, a panel-list change, the official plugin arriving late).
|
|
82
|
-
* @param ctx - client context carrying the slot registry.
|
|
83
|
-
* @param root - the document to search; defaults to the ambient one.
|
|
84
|
-
* @returns the guard's controls.
|
|
85
|
-
*/
|
|
86
|
-
export declare function createScheduleRowGuard(ctx: ScheduleRowGuardContext, root?: ParentNode): ScheduleRowGuard;
|