@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
|
@@ -10,7 +10,10 @@ import type { BoardController } from '../../core/controller.ts'
|
|
|
10
10
|
import { collectKnownTags, type TaskRecord, type TaskTag } from '../../core/tasks.ts'
|
|
11
11
|
import { t } from '../locales.ts'
|
|
12
12
|
import { ModalShell, TaskContentFields, TaskTagFields, cleanTags } from './TaskForm.tsx'
|
|
13
|
+
import { AttachmentField, type AttachmentSelection } from './AttachmentField.tsx'
|
|
14
|
+
import { dedupeAttachments, type TaskAttachment } from '../../core/attachment.ts'
|
|
13
15
|
import type { OverlayPhase } from './overlay.tsx'
|
|
16
|
+
import css from '../board.module.css'
|
|
14
17
|
|
|
15
18
|
/** Edit-task form overlay. */
|
|
16
19
|
export function EditTaskModal({ controller, task, onClose, phase }: { controller: BoardController; task: TaskRecord; onClose: () => void; phase?: OverlayPhase }) {
|
|
@@ -18,6 +21,13 @@ export function EditTaskModal({ controller, task, onClose, phase }: { controller
|
|
|
18
21
|
const [description, setDescription] = useState(task.description)
|
|
19
22
|
const [prompt, setPrompt] = useState(task.prompt)
|
|
20
23
|
const [tags, setTags] = useState<TaskTag[]>(task.tags ?? [])
|
|
24
|
+
// The card's attachments: the stored ones the user kept, plus the files
|
|
25
|
+
// staged locally. A staged file is uploaded when the card is SAVED.
|
|
26
|
+
const [attachments, setAttachments] = useState<AttachmentSelection>({
|
|
27
|
+
persisted: task.attachments ?? [],
|
|
28
|
+
staged: [],
|
|
29
|
+
})
|
|
30
|
+
const [attachmentError, setAttachmentError] = useState<string | undefined>(undefined)
|
|
21
31
|
const [error, setError] = useState<string | undefined>(undefined)
|
|
22
32
|
const [pending, setPending] = useState(false)
|
|
23
33
|
|
|
@@ -33,11 +43,41 @@ export function EditTaskModal({ controller, task, onClose, phase }: { controller
|
|
|
33
43
|
// carried one is not sent a clearing null: the wire stays minimal, and the
|
|
34
44
|
// no-tags path keeps producing exactly the patch it produced before.
|
|
35
45
|
const tagList = cleanTags(tags)
|
|
46
|
+
// The staged files are uploaded when the card is saved, never when they
|
|
47
|
+
// are picked: an abandoned edit leaves no stored object behind.
|
|
48
|
+
const uploaded: TaskAttachment[] = []
|
|
49
|
+
for (const staged of attachments.staged) {
|
|
50
|
+
setAttachments(current => markStaged(current, staged.id, { pending: true, error: undefined }))
|
|
51
|
+
try {
|
|
52
|
+
const attachment = await controller.uploadAttachment(staged.file, staged.kind)
|
|
53
|
+
if (attachment === undefined) throw new Error(t('new.attachments.unavailable'))
|
|
54
|
+
uploaded.push(attachment)
|
|
55
|
+
} catch (uploadError) {
|
|
56
|
+
const message = uploadError instanceof Error ? uploadError.message : String(uploadError)
|
|
57
|
+
setAttachments(current => markStaged(current, staged.id, { pending: false, error: message }))
|
|
58
|
+
setPending(false)
|
|
59
|
+
setError(message)
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const carried = dedupeAttachments([...attachments.persisted, ...uploaded])
|
|
64
|
+
// The attachments ride the patch ONLY when the resulting ordered set
|
|
65
|
+
// differs from the card's current one: a title-only edit must not make
|
|
66
|
+
// the Host re-read and re-verify the stored objects, and it must still
|
|
67
|
+
// work in a deployment whose attachment storage is unavailable.
|
|
68
|
+
const current = task.attachments ?? []
|
|
69
|
+
const unchanged = current.length === carried.length
|
|
70
|
+
&& current.every((attachment, index) => attachment.attachmentId === carried[index]?.attachmentId)
|
|
36
71
|
const patch = {
|
|
37
72
|
title,
|
|
38
73
|
description,
|
|
39
74
|
prompt,
|
|
40
75
|
...(tagList.length > 0 ? { tags: tagList } : (task.tags === undefined ? {} : { tags: null })),
|
|
76
|
+
// An array REPLACES the stored set; an explicit null clears it. A card
|
|
77
|
+
// whose set did not change sends nothing at all.
|
|
78
|
+
...(unchanged
|
|
79
|
+
? {}
|
|
80
|
+
: (carried.length > 0 ? { attachments: carried } : { attachments: null })),
|
|
41
81
|
}
|
|
42
82
|
if (await controller.updateTask(task.id, patch)) {
|
|
43
83
|
onClose()
|
|
@@ -68,10 +108,33 @@ export function EditTaskModal({ controller, task, onClose, phase }: { controller
|
|
|
68
108
|
/>
|
|
69
109
|
|
|
70
110
|
<TaskTagFields tags={tags} knownTags={collectKnownTags(controller.getSnapshot().tasks)} onChange={setTags} />
|
|
111
|
+
|
|
112
|
+
<AttachmentField
|
|
113
|
+
selection={attachments}
|
|
114
|
+
onChange={setAttachments}
|
|
115
|
+
limits={controller.getSnapshot().host?.attachmentLimits}
|
|
116
|
+
disabled={pending}
|
|
117
|
+
onError={message => { setAttachmentError(message) }}
|
|
118
|
+
/>
|
|
119
|
+
{attachmentError !== undefined && <p className={css.formError}>{attachmentError}</p>}
|
|
71
120
|
</ModalShell>
|
|
72
121
|
)
|
|
73
122
|
}
|
|
74
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Mark one staged attachment row: the upload state and the failure reason.
|
|
126
|
+
*/
|
|
127
|
+
function markStaged(
|
|
128
|
+
selection: AttachmentSelection,
|
|
129
|
+
id: string,
|
|
130
|
+
patch: { pending?: boolean; error?: string },
|
|
131
|
+
): AttachmentSelection {
|
|
132
|
+
return {
|
|
133
|
+
...selection,
|
|
134
|
+
staged: selection.staged.map(staged => staged.id === id ? { ...staged, ...patch } : staged),
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
75
138
|
/** Edit-tags modal: edit labels only, shown for tasks after first execution. */
|
|
76
139
|
export function EditTagsModal({ controller, task, onClose, phase }: { controller: BoardController; task: TaskRecord; onClose: () => void; phase?: OverlayPhase }) {
|
|
77
140
|
const [tags, setTags] = useState<TaskTag[]>(task.tags ?? [])
|
|
@@ -13,12 +13,14 @@ import { t, type TaskBoardKey } from '../locales.ts'
|
|
|
13
13
|
import { SCHEDULE_PRESETS } from '../schedule-presets.ts'
|
|
14
14
|
import { defaultZonedInputValue, nextRunLabel, parseZonedInput, runCapOption, zonedInputValue, zoneChoices } from '../schedule-zone.ts'
|
|
15
15
|
import { CollapsibleSection, ModalShell, TaskContentFields, TaskTagFields, cleanTags } from './TaskForm.tsx'
|
|
16
|
+
import { AttachmentField, type AttachmentSelection } from './AttachmentField.tsx'
|
|
17
|
+
import { dedupeAttachments, type TaskAttachment } from '../../core/attachment.ts'
|
|
16
18
|
import type { OverlayPhase } from './overlay.tsx'
|
|
17
19
|
import { formatHostTimestamp } from './TaskCard.tsx'
|
|
18
20
|
import { readParseModelPreference, writeParseModelPreference } from './parse-model-pref.ts'
|
|
19
21
|
import { inheritPresetLabel, presetChoiceRows, presetLabel } from './preset-label.ts'
|
|
20
22
|
import { ReasoningEffortField } from './ReasoningEffortField.tsx'
|
|
21
|
-
import { reconcileReasoningEffort } from './model-options.ts'
|
|
23
|
+
import { modelDisplayLabel, reconcileReasoningEffort } from './model-options.ts'
|
|
22
24
|
import css from '../board.module.css'
|
|
23
25
|
|
|
24
26
|
export interface NewTaskModalProps {
|
|
@@ -43,6 +45,20 @@ export interface NewTaskModalProps {
|
|
|
43
45
|
phase?: OverlayPhase
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Mark one staged attachment row: the upload state and the failure reason.
|
|
50
|
+
*/
|
|
51
|
+
function markStaged(
|
|
52
|
+
selection: AttachmentSelection,
|
|
53
|
+
id: string,
|
|
54
|
+
patch: { pending?: boolean; error?: string },
|
|
55
|
+
): AttachmentSelection {
|
|
56
|
+
return {
|
|
57
|
+
...selection,
|
|
58
|
+
staged: selection.staged.map(staged => staged.id === id ? { ...staged, ...patch } : staged),
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
46
62
|
/** New-task form overlay. */
|
|
47
63
|
export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspaceId, onDuplicateSuccess, parentTask, phase }: NewTaskModalProps) {
|
|
48
64
|
const isDuplicate = initialTask !== undefined
|
|
@@ -101,6 +117,14 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
101
117
|
initialTask?.handover?.references !== undefined ? initialTask.handover.references.join('\n') : '',
|
|
102
118
|
)
|
|
103
119
|
const [tags, setTags] = useState<TaskTag[]>(initialTask?.tags ?? [])
|
|
120
|
+
// The card's attachments: what a duplicated card already carries, plus the
|
|
121
|
+
// files staged locally. A staged file is a local preview until the card is
|
|
122
|
+
// SAVED: the upload happens on save, never on selection.
|
|
123
|
+
const [attachments, setAttachments] = useState<AttachmentSelection>({
|
|
124
|
+
persisted: initialTask?.attachments ?? [],
|
|
125
|
+
staged: [],
|
|
126
|
+
})
|
|
127
|
+
const [attachmentError, setAttachmentError] = useState<string | undefined>(undefined)
|
|
104
128
|
const [archiveOriginal, setArchiveOriginal] = useState(true)
|
|
105
129
|
const [error, setError] = useState<string | undefined>(undefined)
|
|
106
130
|
const [pending, setPending] = useState(false)
|
|
@@ -228,6 +252,24 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
228
252
|
// empty name, and an empty list is expressed by omitting the field.
|
|
229
253
|
const tagList = cleanTags(tags)
|
|
230
254
|
setPending(true)
|
|
255
|
+
// The staged files are uploaded NOW, because the card is being saved: the
|
|
256
|
+
// upload is what turns a local file into a stored object the card can
|
|
257
|
+
// reference. A card the user abandons never uploads anything.
|
|
258
|
+
const uploaded: TaskAttachment[] = []
|
|
259
|
+
for (const staged of attachments.staged) {
|
|
260
|
+
setAttachments(current => markStaged(current, staged.id, { pending: true, error: undefined }))
|
|
261
|
+
try {
|
|
262
|
+
const attachment = await controller.uploadAttachment(staged.file, staged.kind)
|
|
263
|
+
if (attachment === undefined) throw new Error(t('new.attachments.unavailable'))
|
|
264
|
+
uploaded.push(attachment)
|
|
265
|
+
} catch (uploadError) {
|
|
266
|
+
const message = uploadError instanceof Error ? uploadError.message : String(uploadError)
|
|
267
|
+
setAttachments(current => markStaged(current, staged.id, { pending: false, error: message }))
|
|
268
|
+
setPending(false)
|
|
269
|
+
setError(message)
|
|
270
|
+
return
|
|
271
|
+
}
|
|
272
|
+
}
|
|
231
273
|
const task = await controller.createTaskConfirmed({
|
|
232
274
|
title,
|
|
233
275
|
description,
|
|
@@ -248,6 +290,11 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
248
290
|
...(goalRun ? { goalRun: true } : {}),
|
|
249
291
|
...(skipVerification ? { skipVerification: true } : {}),
|
|
250
292
|
...(tagList.length > 0 ? { tags: tagList } : {}),
|
|
293
|
+
...(attachments.persisted.length + uploaded.length > 0
|
|
294
|
+
// The storage is content-addressed: the same content uploaded twice
|
|
295
|
+
// answers with one identifier, and the card may claim it once.
|
|
296
|
+
? { attachments: dedupeAttachments([...attachments.persisted, ...uploaded]) }
|
|
297
|
+
: {}),
|
|
251
298
|
schedule: scheduleEnabled
|
|
252
299
|
? scheduleMode === 'once'
|
|
253
300
|
? {
|
|
@@ -324,9 +371,13 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
324
371
|
? t('exec.permission.default')
|
|
325
372
|
: t('exec.permission.inheritParent', { permission: t(`exec.permission.${inheritedPermission}` as TaskBoardKey) })
|
|
326
373
|
: t(`exec.permission.${permission}` as TaskBoardKey)
|
|
374
|
+
// The pinned model is shown in the shared display form, so a model two
|
|
375
|
+
// providers publish stays tellable apart in the collapsed line too. A
|
|
376
|
+
// route the roster does not describe keeps its own id: the display never
|
|
377
|
+
// invents a provider for a route it cannot resolve.
|
|
327
378
|
const modelLabel = model === ''
|
|
328
379
|
? t('exec.model.default')
|
|
329
|
-
: (
|
|
380
|
+
: modelDisplayLabel(models.find(item => item.id === model) ?? { id: model })
|
|
330
381
|
// The effort is part of the model pin, so a pinned one rides the model's own
|
|
331
382
|
// summary entry instead of standing as a region-level value of its own.
|
|
332
383
|
const modelSummary = reasoningEffort === '' ? modelLabel : `${modelLabel} · ${reasoningEffort}`
|
|
@@ -340,6 +391,12 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
340
391
|
permissionLabel,
|
|
341
392
|
...(model === '' ? [] : [modelSummary]),
|
|
342
393
|
].join(' · ')
|
|
394
|
+
// The collapsed line of the attachment region: how many objects the card
|
|
395
|
+
// will carry once it is saved.
|
|
396
|
+
const attachmentCount = attachments.persisted.length + attachments.staged.length
|
|
397
|
+
const attachmentSummary = attachmentCount === 0
|
|
398
|
+
? t('new.summary.none')
|
|
399
|
+
: t('new.summary.attachmentCount', { count: String(attachmentCount) })
|
|
343
400
|
const tagCount = cleanTags(tags).length
|
|
344
401
|
const labelsSummary = tagCount === 0 ? t('new.summary.none') : t('new.summary.labelCount', { count: String(tagCount) })
|
|
345
402
|
const runSummary = [
|
|
@@ -408,7 +465,7 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
408
465
|
>
|
|
409
466
|
<option value="">{t('exec.model.default')}</option>
|
|
410
467
|
{models.map(option => (
|
|
411
|
-
<option key={option.id} value={option.id}>{option
|
|
468
|
+
<option key={option.id} value={option.id}>{modelDisplayLabel(option)}</option>
|
|
412
469
|
))}
|
|
413
470
|
</select>
|
|
414
471
|
{parsePending
|
|
@@ -466,6 +523,21 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
466
523
|
<TaskTagFields tags={tags} knownTags={collectKnownTags(controller.getSnapshot().tasks)} onChange={setTags} />
|
|
467
524
|
</CollapsibleSection>
|
|
468
525
|
|
|
526
|
+
<CollapsibleSection
|
|
527
|
+
title={t('new.section.attachments')}
|
|
528
|
+
summary={attachmentSummary}
|
|
529
|
+
forceOpen={attachmentError !== undefined}
|
|
530
|
+
>
|
|
531
|
+
<AttachmentField
|
|
532
|
+
selection={attachments}
|
|
533
|
+
onChange={setAttachments}
|
|
534
|
+
limits={controller.getSnapshot().host?.attachmentLimits}
|
|
535
|
+
disabled={pending}
|
|
536
|
+
onError={message => { setAttachmentError(message) }}
|
|
537
|
+
/>
|
|
538
|
+
{attachmentError !== undefined && <p className={css.formError}>{attachmentError}</p>}
|
|
539
|
+
</CollapsibleSection>
|
|
540
|
+
|
|
469
541
|
<CollapsibleSection title={t('new.section.execution')} summary={executionSummary}>
|
|
470
542
|
<label className={css.field}>
|
|
471
543
|
<span className={css.fieldLabel}>{t('new.workspace')}</span>
|
|
@@ -540,7 +612,7 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
540
612
|
<option value="">{t('exec.model.default')}</option>
|
|
541
613
|
{!modelKnown && <option value={model}>{model}{t('exec.model.unknown')}</option>}
|
|
542
614
|
{models.map(item => (
|
|
543
|
-
<option key={item.id} value={item.id}>{item
|
|
615
|
+
<option key={item.id} value={item.id}>{modelDisplayLabel(item)}</option>
|
|
544
616
|
))}
|
|
545
617
|
</select>
|
|
546
618
|
</label>
|
|
@@ -16,6 +16,7 @@ import { TagManagerModal } from './TagManagerModal.tsx'
|
|
|
16
16
|
import { cardTimeline, groupByRecency, readCompactColumns, RECENCY_KEY, writeCompactColumns, type RecencyGroup } from './card-view.ts'
|
|
17
17
|
import { TaskCard } from './TaskCard.tsx'
|
|
18
18
|
import { TaskDetail } from './TaskDetail.tsx'
|
|
19
|
+
import { groupTasksBySource, isSourceGroupFolded, readSourceGroupFolds, sourceGroupFoldKey, writeSourceGroupFolds, type SourceGroupView } from './source-group.ts'
|
|
19
20
|
|
|
20
21
|
/** Sentinel option value of the project row's "register a new project" entry. */
|
|
21
22
|
export const NEW_PROJECT_VALUE = '__dsh_new_project__'
|
|
@@ -140,6 +141,8 @@ export function TaskBoard({ controller }: { controller: BoardController }) {
|
|
|
140
141
|
// Density is a per-column browser preference: the long settled column starts
|
|
141
142
|
// compact, and each column header toggles its own density.
|
|
142
143
|
const [compactColumns, setCompactColumns] = useState<TaskStatus[]>(() => readCompactColumns(globalThis.localStorage))
|
|
144
|
+
// Source-group fold overrides persist per browser; done starts folded.
|
|
145
|
+
const [sourceFolds, setSourceFolds] = useState(() => readSourceGroupFolds(globalThis.localStorage))
|
|
143
146
|
// Grouped columns whose folded "earlier" group the user expanded this visit.
|
|
144
147
|
const [unfolded, setUnfolded] = useState<string[]>([])
|
|
145
148
|
const [showNew, setShowNew] = useState(false)
|
|
@@ -250,15 +253,13 @@ export function TaskBoard({ controller }: { controller: BoardController }) {
|
|
|
250
253
|
/>
|
|
251
254
|
)
|
|
252
255
|
/**
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* a hundred finished issues opens on what happened lately; a text or label
|
|
256
|
-
* search never folds, because a match hidden behind a fold reads as no match.
|
|
256
|
+
* Recency groups nested inside one source group. The fold key includes the
|
|
257
|
+
* source, so expanding one repository's earlier cards opens no other group's.
|
|
257
258
|
*/
|
|
258
|
-
const
|
|
259
|
+
const renderRecencyGroups = (foldScope: string, tasks: TaskRecord[], compact: boolean, archived: boolean) => {
|
|
259
260
|
const buckets = groupByRecency(tasks, task => cardTimeline(task, archived).at, now, timeZone)
|
|
260
261
|
const foldable = !searchActive && tasks.length > COLUMN_FOLD_THRESHOLD && buckets.length > 1
|
|
261
|
-
const open = unfolded.includes(
|
|
262
|
+
const open = unfolded.includes(foldScope)
|
|
262
263
|
return buckets.map(bucket => {
|
|
263
264
|
const folded = foldable && bucket.group === buckets[buckets.length - 1]!.group && !open
|
|
264
265
|
return (
|
|
@@ -273,7 +274,7 @@ export function TaskBoard({ controller }: { controller: BoardController }) {
|
|
|
273
274
|
data-dsh-part="card-group-toggle"
|
|
274
275
|
aria-expanded={!folded}
|
|
275
276
|
onClick={() => {
|
|
276
|
-
setUnfolded(current => current.includes(
|
|
277
|
+
setUnfolded(current => current.includes(foldScope) ? current.filter(entry => entry !== foldScope) : [...current, foldScope])
|
|
277
278
|
}}
|
|
278
279
|
>
|
|
279
280
|
{folded ? t('board.group.expand', { count: String(bucket.items.length) }) : t('board.group.collapse')}
|
|
@@ -286,6 +287,43 @@ export function TaskBoard({ controller }: { controller: BoardController }) {
|
|
|
286
287
|
})
|
|
287
288
|
}
|
|
288
289
|
|
|
290
|
+
/** Every column and the archive first split by provider-owned source. */
|
|
291
|
+
const renderSourceGroups = (view: SourceGroupView, tasks: TaskRecord[], compact: boolean, archived: boolean) => {
|
|
292
|
+
const recency = archived || GROUPED_COLUMNS.includes(view as TaskStatus)
|
|
293
|
+
return groupTasksBySource(tasks, snapshot.grouping ?? []).map(bucket => {
|
|
294
|
+
const foldKey = sourceGroupFoldKey(view, bucket.id)
|
|
295
|
+
const folded = isSourceGroupFolded(sourceFolds, view, bucket.id, searchActive)
|
|
296
|
+
const label = bucket.local ? t('board.source.local') : bucket.label
|
|
297
|
+
return (
|
|
298
|
+
<div key={bucket.id} className={`${css.cardGroup} ${css.sourceGroup}`} data-dsh-part="card-group">
|
|
299
|
+
<div className={`${css.cardGroupHeader} ${css.sourceGroupHeader}`}>
|
|
300
|
+
<span className={css.sourceGroupLabel}>{label}</span>
|
|
301
|
+
<span className={css.cardGroupCount}>{bucket.items.length}</span>
|
|
302
|
+
<button
|
|
303
|
+
type="button"
|
|
304
|
+
className={css.linkButton}
|
|
305
|
+
data-dsh-part="card-group-toggle"
|
|
306
|
+
aria-expanded={!folded}
|
|
307
|
+
disabled={searchActive}
|
|
308
|
+
onClick={() => {
|
|
309
|
+
setSourceFolds(current => {
|
|
310
|
+
const next = { ...current, [foldKey]: !isSourceGroupFolded(current, view, bucket.id, false) }
|
|
311
|
+
writeSourceGroupFolds(globalThis.localStorage, next)
|
|
312
|
+
return next
|
|
313
|
+
})
|
|
314
|
+
}}
|
|
315
|
+
>
|
|
316
|
+
{folded ? t('board.group.expand', { count: String(bucket.items.length) }) : t('board.group.collapse')}
|
|
317
|
+
</button>
|
|
318
|
+
</div>
|
|
319
|
+
{!folded && (recency
|
|
320
|
+
? renderRecencyGroups(foldKey, bucket.items, compact, archived)
|
|
321
|
+
: bucket.items.map(task => renderCard(task, compact)))}
|
|
322
|
+
</div>
|
|
323
|
+
)
|
|
324
|
+
})
|
|
325
|
+
}
|
|
326
|
+
|
|
289
327
|
return (
|
|
290
328
|
<div className={css.board} data-dsh-taskboard-board="" data-dsh-plugin="task-board">
|
|
291
329
|
<header className={css.boardHeader}>
|
|
@@ -472,7 +510,7 @@ export function TaskBoard({ controller }: { controller: BoardController }) {
|
|
|
472
510
|
<span className={css.columnCount}>{visible.length}</span>
|
|
473
511
|
</header>
|
|
474
512
|
<div className={css.cards}>
|
|
475
|
-
{
|
|
513
|
+
{renderSourceGroups(ARCHIVE_COLUMN, visible, false, true)}
|
|
476
514
|
{visible.length === 0 && (
|
|
477
515
|
<div className={css.columnEmpty}>{tagFilter.length > 0 ? t('board.tagEmpty') : t('archive.empty')}</div>
|
|
478
516
|
)}
|
|
@@ -485,7 +523,6 @@ export function TaskBoard({ controller }: { controller: BoardController }) {
|
|
|
485
523
|
// never does, because only the runner opens an execution.
|
|
486
524
|
const isManualDropTarget = MANUAL_STATUSES.includes(column.status)
|
|
487
525
|
const compact = compactColumns.includes(column.status)
|
|
488
|
-
const grouped = GROUPED_COLUMNS.includes(column.status)
|
|
489
526
|
return (
|
|
490
527
|
<section
|
|
491
528
|
key={column.status}
|
|
@@ -524,7 +561,7 @@ export function TaskBoard({ controller }: { controller: BoardController }) {
|
|
|
524
561
|
</button>
|
|
525
562
|
</header>
|
|
526
563
|
<div className={css.cards}>
|
|
527
|
-
{
|
|
564
|
+
{renderSourceGroups(column.status, tasks, compact, false)}
|
|
528
565
|
{tasks.length === 0 && (
|
|
529
566
|
<div className={css.columnEmpty}>{tagFilter.length > 0 ? t('board.tagEmpty') : t('board.empty')}</div>
|
|
530
567
|
)}
|
|
@@ -14,6 +14,8 @@ import { canEditTaskContent } from '../../core/use-cases/task-update.ts'
|
|
|
14
14
|
import { requiresPermissionConfirmation } from '../../core/handover.ts'
|
|
15
15
|
import { DEFAULT_SUBTASK_DEPTH, descendantTasks, directSubtasks, joinsCascadeRun, taskDepth } from '../../core/subtask.ts'
|
|
16
16
|
import { t, type TaskBoardKey } from '../locales.ts'
|
|
17
|
+
import { attachmentImageUrl } from '../host-api.ts'
|
|
18
|
+
import { formatAttachmentBytes } from './AttachmentField.tsx'
|
|
17
19
|
import { SCHEDULE_PRESETS } from '../schedule-presets.ts'
|
|
18
20
|
import { budgetLabel, defaultZonedInputValue, endedLabel, nextRunLabel, parseZonedInput, runCapOption, skippedLabel, zonedInputValue, zoneChoices } from '../schedule-zone.ts'
|
|
19
21
|
import css from '../board.module.css'
|
|
@@ -25,7 +27,7 @@ import { NewTaskModal } from './NewTaskModal.tsx'
|
|
|
25
27
|
import { useDialog, usePresence, type OverlayPhase } from './overlay.tsx'
|
|
26
28
|
import { inheritPresetLabel, presetLabel } from './preset-label.ts'
|
|
27
29
|
import { ReasoningEffortField } from './ReasoningEffortField.tsx'
|
|
28
|
-
import { reconcileReasoningEffort } from './model-options.ts'
|
|
30
|
+
import { modelDisplayLabel, reconcileReasoningEffort } from './model-options.ts'
|
|
29
31
|
import { formatHostTimestamp, formatTime } from './TaskCard.tsx'
|
|
30
32
|
import { STATUS_KEY } from './status-key.ts'
|
|
31
33
|
import { ClampedMarkdown } from './ClampedMarkdown.tsx'
|
|
@@ -300,7 +302,7 @@ function ExecutionSettingsSection({ controller, task, pending, executionOptions,
|
|
|
300
302
|
<option value="">{t('exec.model.default')}</option>
|
|
301
303
|
{!modelKnown && <option value={model}>{model}{t('exec.model.unknown')}</option>}
|
|
302
304
|
{models.map(item => (
|
|
303
|
-
<option key={item.id} value={item.id}>{item
|
|
305
|
+
<option key={item.id} value={item.id}>{modelDisplayLabel(item)}</option>
|
|
304
306
|
))}
|
|
305
307
|
</select>
|
|
306
308
|
</label>
|
|
@@ -956,6 +958,32 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
|
|
|
956
958
|
</section>
|
|
957
959
|
)}
|
|
958
960
|
|
|
961
|
+
{current.attachments !== undefined && current.attachments.length > 0 && (
|
|
962
|
+
<section className={css.detailSection}>
|
|
963
|
+
<h4>{t('detail.attachments')}</h4>
|
|
964
|
+
<ul className={css.attachmentList}>
|
|
965
|
+
{current.attachments.map(attachment => (
|
|
966
|
+
<li className={css.attachmentRow} key={attachment.attachmentId}>
|
|
967
|
+
{attachment.kind === 'image'
|
|
968
|
+
? <img className={css.attachmentThumb} src={attachmentImageUrl(attachment.attachmentId)} alt={attachment.name} />
|
|
969
|
+
: null}
|
|
970
|
+
<span className={css.attachmentName}>
|
|
971
|
+
{attachment.name}
|
|
972
|
+
<span className={css.attachmentMeta}>
|
|
973
|
+
{' '}
|
|
974
|
+
{formatAttachmentBytes(attachment.bytes)}
|
|
975
|
+
{attachment.kind === 'image' && attachment.width !== undefined && attachment.height !== undefined
|
|
976
|
+
? ` · ${attachment.width}×${attachment.height}`
|
|
977
|
+
: ''}
|
|
978
|
+
</span>
|
|
979
|
+
</span>
|
|
980
|
+
</li>
|
|
981
|
+
))}
|
|
982
|
+
</ul>
|
|
983
|
+
<p className={css.detailMeta}>{t('detail.attachments.removeHint')}</p>
|
|
984
|
+
</section>
|
|
985
|
+
)}
|
|
986
|
+
|
|
959
987
|
<SubtaskSection controller={controller} task={current} pending={pending} archived={archived} snapshot={snapshot} />
|
|
960
988
|
|
|
961
989
|
{current.freeze !== undefined && (
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
* picker re-reading the wire shape. The fallback discovery path carries no
|
|
10
10
|
* capability metadata at all; its rows stay silent about reasoning rather than
|
|
11
11
|
* claiming a model supports none.
|
|
12
|
+
*
|
|
13
|
+
* This module also owns the one display form a model row is shown in: the
|
|
14
|
+
* model name, then the provider that publishes it. Two providers may publish
|
|
15
|
+
* one model name, and they are two different routes, so a picker that shows
|
|
16
|
+
* only the name offers two identical rows. Every picker and every collapsed
|
|
17
|
+
* summary reads the label from here, so they cannot drift apart.
|
|
12
18
|
*/
|
|
13
19
|
import type { ExecutionModelOption } from '../../core/controller.ts'
|
|
14
20
|
import type { TaskBoardKey } from '../locales.ts'
|
|
@@ -106,9 +112,33 @@ export function modelOptionsFromDiscoveredModels(value: unknown): ExecutionModel
|
|
|
106
112
|
return options
|
|
107
113
|
}
|
|
108
114
|
|
|
115
|
+
/**
|
|
116
|
+
* The display form of one model row: the model name first, then the provider
|
|
117
|
+
* that publishes it, joined by " · ".
|
|
118
|
+
*
|
|
119
|
+
* Two providers publishing one model name are two different routes, so the
|
|
120
|
+
* provider belongs in the label — otherwise the picker offers two identical
|
|
121
|
+
* rows and the operator cannot tell which route a card would pin. A row
|
|
122
|
+
* without a provider (the flat discovery fallback names models only) keeps
|
|
123
|
+
* its bare name, and a row that carries no name of its own shows the model
|
|
124
|
+
* part of its own qualified route, so the provider is never printed twice.
|
|
125
|
+
* @param model - the roster row.
|
|
126
|
+
* @returns the label every model picker row and every collapsed summary shows.
|
|
127
|
+
*/
|
|
128
|
+
export function modelDisplayLabel(model: ExecutionModelOption): string {
|
|
129
|
+
const provider = model.provider === undefined || model.provider === '' ? undefined : model.provider
|
|
130
|
+
const name = model.name !== undefined && model.name !== ''
|
|
131
|
+
? model.name
|
|
132
|
+
: provider !== undefined && model.id.startsWith(provider + '/')
|
|
133
|
+
? model.id.slice(provider.length + 1)
|
|
134
|
+
: model.id
|
|
135
|
+
if (provider === undefined) return name
|
|
136
|
+
return name + ' · ' + provider
|
|
137
|
+
}
|
|
138
|
+
|
|
109
139
|
/**
|
|
110
140
|
* The picker rows of a model roster: the qualified `provider/model` route as
|
|
111
|
-
* the value a pin stores, and the
|
|
141
|
+
* the value a pin stores, and the shared display form as the label, so two
|
|
112
142
|
* providers offering one model name stay distinguishable.
|
|
113
143
|
* @param models - the roster rows.
|
|
114
144
|
* @returns the choice rows, in roster order.
|
|
@@ -116,7 +146,7 @@ export function modelOptionsFromDiscoveredModels(value: unknown): ExecutionModel
|
|
|
116
146
|
export function modelChoiceRows(models: readonly ExecutionModelOption[]): Array<{ value: string; label: string }> {
|
|
117
147
|
return models.map(model => ({
|
|
118
148
|
value: model.id,
|
|
119
|
-
label: (model
|
|
149
|
+
label: modelDisplayLabel(model),
|
|
120
150
|
}))
|
|
121
151
|
}
|
|
122
152
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source grouping and fold preferences for the board view. Providers contribute
|
|
3
|
+
* opaque groups through the client contract; this module owns only ordering,
|
|
4
|
+
* local fallback, and browser persistence, never provider metadata semantics.
|
|
5
|
+
*/
|
|
6
|
+
import type { TaskBoardGroupingSelector, TaskBoardSourceGroup } from '../../core/extension.ts'
|
|
7
|
+
import type { TaskRecord, TaskStatus } from '../../core/tasks.ts'
|
|
8
|
+
|
|
9
|
+
/** Reserved group for cards no provider claimed. */
|
|
10
|
+
export const LOCAL_SOURCE_GROUP_ID = 'local'
|
|
11
|
+
/** Browser storage key for explicit source-fold overrides. */
|
|
12
|
+
export const SOURCE_GROUP_FOLDS_KEY = 'dsh.taskBoard.sourceGroupFolds.v1'
|
|
13
|
+
|
|
14
|
+
export type SourceGroupView = TaskStatus | 'archived'
|
|
15
|
+
export type SourceGroupFolds = Readonly<Record<string, boolean>>
|
|
16
|
+
|
|
17
|
+
export interface SourceGroupBucket extends TaskBoardSourceGroup {
|
|
18
|
+
items: TaskRecord[]
|
|
19
|
+
local: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function compareText(left: string, right: string): number {
|
|
23
|
+
const a = left.toLowerCase()
|
|
24
|
+
const b = right.toLowerCase()
|
|
25
|
+
if (a < b) return -1
|
|
26
|
+
if (a > b) return 1
|
|
27
|
+
return left < right ? -1 : left > right ? 1 : 0
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Group cards in their incoming order, then sort provider groups by full label. */
|
|
31
|
+
export function groupTasksBySource(tasks: readonly TaskRecord[], selectors: readonly TaskBoardGroupingSelector[]): SourceGroupBucket[] {
|
|
32
|
+
const groups = new Map<string, SourceGroupBucket>()
|
|
33
|
+
for (const task of tasks) {
|
|
34
|
+
let source: TaskBoardSourceGroup | undefined
|
|
35
|
+
for (const selector of selectors) {
|
|
36
|
+
try {
|
|
37
|
+
const candidate = selector(task)
|
|
38
|
+
if (candidate === undefined) continue
|
|
39
|
+
const id = candidate.id.trim()
|
|
40
|
+
const label = candidate.label.trim()
|
|
41
|
+
if (id === '' || label === '') continue
|
|
42
|
+
source = { id, label }
|
|
43
|
+
break
|
|
44
|
+
} catch {
|
|
45
|
+
// A faulty provider loses its grouping contribution, not the board.
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const group = source ?? { id: LOCAL_SOURCE_GROUP_ID, label: '' }
|
|
49
|
+
const bucket = groups.get(group.id) ?? { ...group, items: [], local: source === undefined }
|
|
50
|
+
bucket.items.push(task)
|
|
51
|
+
groups.set(group.id, bucket)
|
|
52
|
+
}
|
|
53
|
+
return [...groups.values()].sort((left, right) => {
|
|
54
|
+
if (left.local !== right.local) return left.local ? 1 : -1
|
|
55
|
+
return compareText(left.label, right.label) || compareText(left.id, right.id)
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Compound key keeps a fold choice scoped to one column/view and one source. */
|
|
60
|
+
export function sourceGroupFoldKey(view: SourceGroupView, sourceId: string): string {
|
|
61
|
+
return `${view}:${sourceId}`
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Read explicit overrides; malformed or unavailable storage falls back to defaults. */
|
|
65
|
+
export function readSourceGroupFolds(storage: Pick<Storage, 'getItem'> | undefined): SourceGroupFolds {
|
|
66
|
+
try {
|
|
67
|
+
const raw = storage?.getItem(SOURCE_GROUP_FOLDS_KEY)
|
|
68
|
+
if (raw === null || raw === undefined) return {}
|
|
69
|
+
const parsed: unknown = JSON.parse(raw)
|
|
70
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return {}
|
|
71
|
+
const result: Record<string, boolean> = Object.create(null) as Record<string, boolean>
|
|
72
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
73
|
+
if (key !== '' && typeof value === 'boolean') result[key] = value
|
|
74
|
+
}
|
|
75
|
+
return result
|
|
76
|
+
} catch {
|
|
77
|
+
return {}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Persist overrides; a storage failure only loses the preference. */
|
|
82
|
+
export function writeSourceGroupFolds(storage: Pick<Storage, 'setItem'> | undefined, folds: SourceGroupFolds): void {
|
|
83
|
+
try {
|
|
84
|
+
storage?.setItem(SOURCE_GROUP_FOLDS_KEY, JSON.stringify(folds))
|
|
85
|
+
} catch {
|
|
86
|
+
// Preference only: the in-memory choice still works.
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Search always reveals matches; otherwise an override beats the column default. */
|
|
91
|
+
export function isSourceGroupFolded(folds: SourceGroupFolds, view: SourceGroupView, sourceId: string, searchActive: boolean): boolean {
|
|
92
|
+
if (searchActive) return false
|
|
93
|
+
return folds[sourceGroupFoldKey(view, sourceId)] ?? view === 'done'
|
|
94
|
+
}
|