@linxin666/dsh-client-ui-task-board 0.4.10 → 0.4.11
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 +1 -1
- package/README.zh.md +1 -1
- package/lib/client.js +542 -167
- package/lib/client.js.map +1 -1
- package/lib/types/client/PluginSettingsCard.d.ts +69 -22
- package/lib/types/client/RangeBubble.d.ts +46 -0
- package/lib/types/client/SegmentGroup.d.ts +28 -0
- package/lib/types/client/locales.d.ts +1 -4
- package/lib/types/client/plugin-card-seat.d.ts +2 -0
- package/lib/types/client/settings-form.d.ts +73 -51
- package/package.json +1 -1
- package/src/client/PluginSettingsCard.tsx +226 -93
- package/src/client/RangeBubble.tsx +164 -0
- package/src/client/SegmentGroup.tsx +93 -0
- package/src/client/TaskBoardSettingsCard.tsx +12 -5
- package/src/client/locales.ts +46 -52
- package/src/client/plugin-card-seat.ts +6 -0
- package/src/client/settings-card.module.css +341 -94
- package/src/client/settings-form.ts +102 -60
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
// Generated by scripts/sync-shared.mjs from shared/client/settings/settings-form.ts. Do not edit this copy; edit the shared source and run "node scripts/sync-shared.mjs".
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
3
|
+
* Form model behind the plugin settings card. Every control applies itself:
|
|
4
|
+
* a pick (a segment, a select option, a reset) writes the moment it is made,
|
|
5
|
+
* and typed text writes once typing pauses or the reader leaves the field.
|
|
6
|
+
* Between the edit and the write the edit is held here as a draft, so what is
|
|
7
|
+
* on screen is exactly what the write will store; a write the Host refuses
|
|
8
|
+
* puts a pick back to the stored value and keeps typed text for correcting.
|
|
9
|
+
* Family-shared slice inlined into each plugin's client bundle.
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
import type { ConfigForm, ConfigFormSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
12
13
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
13
14
|
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
14
15
|
|
|
15
|
-
/** The write one field's
|
|
16
|
+
/** The write one field's draft text performs when it is applied. */
|
|
16
17
|
export type FieldWrite =
|
|
17
18
|
| { kind: 'set'; value: unknown }
|
|
18
19
|
| { kind: 'clear' }
|
|
@@ -21,6 +22,12 @@ export type FieldWrite =
|
|
|
21
22
|
export interface FieldSpec {
|
|
22
23
|
/** Field name inside the namespace section. */
|
|
23
24
|
field: string
|
|
25
|
+
/**
|
|
26
|
+
* How the reader enters a value, which decides when it is written: a `pick`
|
|
27
|
+
* is a whole value at once and applies immediately; `type` is text arriving
|
|
28
|
+
* a keystroke at a time and applies once typing pauses or the field is left.
|
|
29
|
+
*/
|
|
30
|
+
entry: 'pick' | 'type'
|
|
24
31
|
/**
|
|
25
32
|
* Whether the Host treats this field as a secret and redacts its value from
|
|
26
33
|
* the read-back (role('secret') in the section schema). Redacted secrets are
|
|
@@ -34,8 +41,9 @@ export interface FieldSpec {
|
|
|
34
41
|
/** Render a stored value as draft text; the empty string when the section carries none. */
|
|
35
42
|
format: (value: unknown) => string
|
|
36
43
|
/**
|
|
37
|
-
* The write this draft text
|
|
38
|
-
* value this field accepts — which
|
|
44
|
+
* The write this draft text performs, or undefined when the text is not a
|
|
45
|
+
* value this field accepts — which holds the draft unwritten rather than
|
|
46
|
+
* discarding it.
|
|
39
47
|
*/
|
|
40
48
|
parse: (text: string) => FieldWrite | undefined
|
|
41
49
|
}
|
|
@@ -44,9 +52,9 @@ export interface FieldSpec {
|
|
|
44
52
|
export interface FieldState {
|
|
45
53
|
/** Draft text the control renders. */
|
|
46
54
|
text: string
|
|
47
|
-
/** Whether
|
|
55
|
+
/** Whether the field leaves (or will leave) a user-layer entry. */
|
|
48
56
|
overridden: boolean
|
|
49
|
-
/** Whether the draft is not a value this field accepts, which
|
|
57
|
+
/** Whether the draft is not a value this field accepts, which holds it unwritten. */
|
|
50
58
|
invalid: boolean
|
|
51
59
|
}
|
|
52
60
|
|
|
@@ -64,13 +72,13 @@ export interface CardShell {
|
|
|
64
72
|
exposed: boolean
|
|
65
73
|
/** Whether the Host document accepts writes. */
|
|
66
74
|
writable: boolean
|
|
67
|
-
/** Whether the form holds
|
|
75
|
+
/** Whether the form holds drafts not yet written (typed text waiting for its pause). */
|
|
68
76
|
dirty: boolean
|
|
69
|
-
/** Whether any
|
|
77
|
+
/** Whether any draft is invalid, which holds it unwritten. */
|
|
70
78
|
invalid: boolean
|
|
71
|
-
/** Whether a
|
|
79
|
+
/** Whether a write is crossing the wire. */
|
|
72
80
|
saving: boolean
|
|
73
|
-
/** Whether the last
|
|
81
|
+
/** Whether the last write did not land; cleared by the next edit or write. */
|
|
74
82
|
failed: boolean
|
|
75
83
|
/**
|
|
76
84
|
* The rejection code/message the Host returned for the last failed save,
|
|
@@ -82,16 +90,19 @@ export interface CardShell {
|
|
|
82
90
|
|
|
83
91
|
/** The write actions the card's slot entry injects. */
|
|
84
92
|
export interface CardActions {
|
|
85
|
-
/**
|
|
93
|
+
/** Take draft text for one field; a pick writes at once, typed text after a pause. */
|
|
86
94
|
edit: (field: string, text: string) => void
|
|
87
|
-
/**
|
|
95
|
+
/** Clear one field at once, so it re-inherits the composition layer. */
|
|
88
96
|
resetField: (field: string) => void
|
|
89
|
-
/** Write every
|
|
97
|
+
/** Write every pending draft now (a text field's Enter or blur), then re-seed from what the Host accepted. */
|
|
90
98
|
save: () => void
|
|
91
|
-
/** Drop every
|
|
99
|
+
/** Drop every pending draft, putting each control back to the stored value (a text field's Escape). */
|
|
92
100
|
discard: () => void
|
|
93
101
|
}
|
|
94
102
|
|
|
103
|
+
/** How long typed text rests before it is written. */
|
|
104
|
+
export const TYPE_PAUSE_MS = 600
|
|
105
|
+
|
|
95
106
|
/** One field's staged edit. */
|
|
96
107
|
interface StagedEdit {
|
|
97
108
|
/** Draft text the control renders. */
|
|
@@ -132,11 +143,12 @@ export interface NumberConstraints {
|
|
|
132
143
|
min?: number
|
|
133
144
|
}
|
|
134
145
|
|
|
135
|
-
/** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints
|
|
146
|
+
/** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints stays unwritten. */
|
|
136
147
|
export function numberField(field: string, constraints: NumberConstraints = {}): FieldSpec {
|
|
137
148
|
const { integer = false, min } = constraints
|
|
138
149
|
return {
|
|
139
150
|
field,
|
|
151
|
+
entry: 'type',
|
|
140
152
|
format: value => typeof value === 'number' ? String(value) : '',
|
|
141
153
|
parse: (text) => {
|
|
142
154
|
const trimmed = text.trim()
|
|
@@ -150,10 +162,14 @@ export function numberField(field: string, constraints: NumberConstraints = {}):
|
|
|
150
162
|
}
|
|
151
163
|
}
|
|
152
164
|
|
|
153
|
-
/**
|
|
154
|
-
|
|
165
|
+
/**
|
|
166
|
+
* A free-text field. An empty draft clears the field. `entry` is `pick` when
|
|
167
|
+
* the text arrives whole from a picker (a preset or a reasoning level).
|
|
168
|
+
*/
|
|
169
|
+
export function textField(field: string, entry: FieldSpec['entry'] = 'type'): FieldSpec {
|
|
155
170
|
return {
|
|
156
171
|
field,
|
|
172
|
+
entry,
|
|
157
173
|
format: value => typeof value === 'string' ? value : '',
|
|
158
174
|
parse: (text) => {
|
|
159
175
|
const trimmed = text.trim()
|
|
@@ -176,6 +192,7 @@ export function secretField(field: string): FieldSpec {
|
|
|
176
192
|
export function booleanField(field: string): FieldSpec {
|
|
177
193
|
return {
|
|
178
194
|
field,
|
|
195
|
+
entry: 'pick',
|
|
179
196
|
format: value => typeof value === 'boolean' ? String(value) : '',
|
|
180
197
|
parse: (text) => {
|
|
181
198
|
const trimmed = text.trim()
|
|
@@ -191,6 +208,7 @@ export function booleanField(field: string): FieldSpec {
|
|
|
191
208
|
export function choiceField(field: string, choices: readonly string[]): FieldSpec {
|
|
192
209
|
return {
|
|
193
210
|
field,
|
|
211
|
+
entry: 'pick',
|
|
194
212
|
format: value => typeof value === 'string' && choices.includes(value) ? value : '',
|
|
195
213
|
parse: (text) => {
|
|
196
214
|
if (text === '') return { kind: 'clear' }
|
|
@@ -200,12 +218,14 @@ export function choiceField(field: string, choices: readonly string[]): FieldSpe
|
|
|
200
218
|
}
|
|
201
219
|
|
|
202
220
|
/**
|
|
203
|
-
*
|
|
221
|
+
* Applies one card's edits to one settings namespace as the reader makes them.
|
|
204
222
|
*
|
|
205
223
|
* The Host is the only authority on whether a value was accepted — its
|
|
206
224
|
* validators own the constraints no schema can express — so the outcome is
|
|
207
|
-
* read back from the section rather than predicted here. A
|
|
208
|
-
* land
|
|
225
|
+
* read back from the section rather than predicted here. A write that did not
|
|
226
|
+
* land puts each pick back to the stored value, the way a switch that could not
|
|
227
|
+
* flip springs back, and keeps typed text so the reader can correct it instead
|
|
228
|
+
* of retyping.
|
|
209
229
|
*/
|
|
210
230
|
export class CardForm<T> {
|
|
211
231
|
private readonly specs: Map<string, FieldSpec>
|
|
@@ -214,6 +234,8 @@ export class CardForm<T> {
|
|
|
214
234
|
/** The form subscription installed in the constructor; released by dispose(). */
|
|
215
235
|
private readonly disposeForm: () => void
|
|
216
236
|
private disposed = false
|
|
237
|
+
/** The pending write of typed text, waiting for typing to pause. */
|
|
238
|
+
private typePause: ReturnType<typeof setTimeout> | undefined
|
|
217
239
|
private saving = false
|
|
218
240
|
/** A save asked for while one was in flight; it runs once the first settles (#1754). */
|
|
219
241
|
private saveQueued = false
|
|
@@ -236,6 +258,7 @@ export class CardForm<T> {
|
|
|
236
258
|
dispose(): void {
|
|
237
259
|
if (this.disposed) return
|
|
238
260
|
this.disposed = true
|
|
261
|
+
clearTimeout(this.typePause)
|
|
239
262
|
this.disposeForm()
|
|
240
263
|
this.listeners.clear()
|
|
241
264
|
}
|
|
@@ -247,7 +270,7 @@ export class CardForm<T> {
|
|
|
247
270
|
return store
|
|
248
271
|
}
|
|
249
272
|
|
|
250
|
-
/** Read the card-level state: what the Host serves, and what
|
|
273
|
+
/** Read the card-level state: what the Host serves, and what is still waiting to be written. */
|
|
251
274
|
shell(): CardShell {
|
|
252
275
|
const snapshot = this.scope.getSnapshot()
|
|
253
276
|
const plan = this.plan()
|
|
@@ -285,8 +308,9 @@ export class CardForm<T> {
|
|
|
285
308
|
resetField: (field) => {
|
|
286
309
|
this.stage(field, { text: this.specOf(field).format(this.baseValue(field)), clear: true })
|
|
287
310
|
},
|
|
288
|
-
save: () => {
|
|
311
|
+
save: () => { this.applyNow() },
|
|
289
312
|
discard: () => {
|
|
313
|
+
clearTimeout(this.typePause)
|
|
290
314
|
if (this.staged.size === 0 && !this.failed) return
|
|
291
315
|
this.staged.clear()
|
|
292
316
|
this.failed = false
|
|
@@ -297,32 +321,14 @@ export class CardForm<T> {
|
|
|
297
321
|
}
|
|
298
322
|
|
|
299
323
|
/**
|
|
300
|
-
*
|
|
301
|
-
* what the Host accepted.
|
|
302
|
-
*
|
|
303
|
-
* The whole batch rides one mutate, so cross-field validate hooks
|
|
304
|
-
* (baseURL+model) judge it as a unit: the Host either applies every write
|
|
305
|
-
* or refuses the batch. The form contract answers a refusal or a skipped
|
|
306
|
-
* write with `false` (it recovers with a fresh Host view instead of
|
|
307
|
-
* throwing), so the outcome is judged twice: the answer itself, and then the
|
|
308
|
-
* settled snapshot read back one planned write at a time. One missed write
|
|
309
|
-
* fails the whole save. A transport that rejects instead (the dsh-web bridge
|
|
310
|
-
* controller on a dead connection) reports through the same failure path
|
|
311
|
-
* with its rejection message. A save that did not land keeps its drafts, so
|
|
312
|
-
* the user can correct them instead of retyping.
|
|
313
|
-
* @returns settlement after the mutation and the read-back.
|
|
314
|
-
*/
|
|
315
|
-
/**
|
|
316
|
-
* Run one save, and re-run it once if another was asked for while this one
|
|
324
|
+
* Run one write, and re-run it once if another was asked for while this one
|
|
317
325
|
* was still in flight.
|
|
318
326
|
*
|
|
319
|
-
* A
|
|
320
|
-
* the Host runs
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
* another is still settling runs against the settled state - which is what
|
|
325
|
-
* the operator meant by pressing it again.
|
|
327
|
+
* A write is a Host round trip that also drives the profile reconcile, and
|
|
328
|
+
* the Host runs it inside one exclusive transaction. Answering an edit that
|
|
329
|
+
* arrives mid-flight by returning immediately dropped it with no explanation
|
|
330
|
+
* (#1754). Serializing instead means an edit made while another write is
|
|
331
|
+
* still settling is written against the settled state.
|
|
326
332
|
* @returns settlement after the mutation and the read-back.
|
|
327
333
|
*/
|
|
328
334
|
async requestSave(): Promise<void> {
|
|
@@ -336,15 +342,32 @@ export class CardForm<T> {
|
|
|
336
342
|
await this.requestSave()
|
|
337
343
|
}
|
|
338
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Write every valid draft in one atomic form mutation, then re-seed from
|
|
347
|
+
* what the Host accepted. A draft the field does not accept stays on screen,
|
|
348
|
+
* unwritten, without holding the others back.
|
|
349
|
+
*
|
|
350
|
+
* The batch rides one mutate, so cross-field validate hooks (baseURL+model)
|
|
351
|
+
* judge it as a unit: the Host either applies every write or refuses the
|
|
352
|
+
* batch. The form contract answers a refusal or a skipped write with `false`
|
|
353
|
+
* (it recovers with a fresh Host view instead of throwing), so the outcome is
|
|
354
|
+
* judged twice: the answer itself, and then the settled snapshot read back
|
|
355
|
+
* one planned write at a time. One missed write fails the whole batch. A
|
|
356
|
+
* transport that rejects instead (the dsh-web bridge controller on a dead
|
|
357
|
+
* connection) reports through the same failure path with its rejection
|
|
358
|
+
* message. A batch that did not land puts its picks and clears back to the
|
|
359
|
+
* stored value and keeps its typed text, so the reader can correct it.
|
|
360
|
+
* @returns settlement after the mutation and the read-back.
|
|
361
|
+
*/
|
|
339
362
|
async save(): Promise<void> {
|
|
340
363
|
const plan = this.plan()
|
|
341
364
|
const valid = plan.filter((item): item is PlannedWrite & { judge: () => boolean } => item.judge !== undefined)
|
|
342
|
-
if (
|
|
343
|
-
// Snapshot the staged entries this
|
|
344
|
-
// is in flight (which replaces the same key) survives: only
|
|
345
|
-
// when the entry is still the one this
|
|
365
|
+
if (valid.length === 0 || this.saving) return
|
|
366
|
+
// Snapshot the staged entries this write carries, so an edit staged while
|
|
367
|
+
// it is in flight (which replaces the same key) survives: only settle the
|
|
368
|
+
// key when the entry is still the one this write started from.
|
|
346
369
|
const pending = new Map<string, StagedEdit | undefined>()
|
|
347
|
-
for (const item of
|
|
370
|
+
for (const item of valid) pending.set(item.field, this.staged.get(item.field))
|
|
348
371
|
this.saving = true
|
|
349
372
|
this.failed = false
|
|
350
373
|
this.failedReason = undefined
|
|
@@ -369,7 +392,8 @@ export class CardForm<T> {
|
|
|
369
392
|
// whole save and keeps the drafts.
|
|
370
393
|
const landed = accepted && failedReason === undefined && valid.every(item => item.judge())
|
|
371
394
|
for (const [field, before] of pending) {
|
|
372
|
-
if (
|
|
395
|
+
if (this.staged.get(field) !== before) continue
|
|
396
|
+
if (landed || before === undefined || before.clear || this.specOf(field).entry === 'pick') this.staged.delete(field)
|
|
373
397
|
}
|
|
374
398
|
this.saving = false
|
|
375
399
|
this.failed = !landed
|
|
@@ -381,9 +405,9 @@ export class CardForm<T> {
|
|
|
381
405
|
}
|
|
382
406
|
|
|
383
407
|
/**
|
|
384
|
-
* Every staged edit a
|
|
385
|
-
* its field accepts carries no write: the form is still dirty, and the
|
|
386
|
-
*
|
|
408
|
+
* Every staged edit a write would carry. An entry whose draft is not a value
|
|
409
|
+
* its field accepts carries no write: the form is still dirty, and the draft
|
|
410
|
+
* stays on screen rather than being dropped. A staged edit that matches the
|
|
387
411
|
* effective section is not a write at all.
|
|
388
412
|
* @returns the planned writes, in the order the fields were staged.
|
|
389
413
|
*/
|
|
@@ -426,11 +450,29 @@ export class CardForm<T> {
|
|
|
426
450
|
return !this.stored(field)
|
|
427
451
|
}
|
|
428
452
|
|
|
453
|
+
/**
|
|
454
|
+
* Take one edit and schedule its write: a pick or a clear is written now,
|
|
455
|
+
* typed text once typing has rested for TYPE_PAUSE_MS.
|
|
456
|
+
*/
|
|
429
457
|
private stage(field: string, edit: StagedEdit): void {
|
|
430
458
|
this.staged.set(field, edit)
|
|
431
459
|
this.failed = false
|
|
432
460
|
this.failedReason = undefined
|
|
433
461
|
this.publish()
|
|
462
|
+
if (edit.clear || this.specOf(field).entry === 'pick') {
|
|
463
|
+
this.applyNow()
|
|
464
|
+
return
|
|
465
|
+
}
|
|
466
|
+
clearTimeout(this.typePause)
|
|
467
|
+
this.typePause = setTimeout(() => { this.applyNow() }, TYPE_PAUSE_MS)
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/** Write every pending draft now, taking the place of a waiting pause. */
|
|
471
|
+
private applyNow(): void {
|
|
472
|
+
clearTimeout(this.typePause)
|
|
473
|
+
this.typePause = undefined
|
|
474
|
+
if (this.disposed) return
|
|
475
|
+
void this.requestSave()
|
|
434
476
|
}
|
|
435
477
|
|
|
436
478
|
private specOf(field: string): FieldSpec {
|