@fish-under-sea/dsh-client-ui-task-board-fish 1.0.2 → 2.0.0
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/NOTICE +1 -1
- package/README.en.md +6 -4
- package/README.md +6 -4
- package/README.zh.md +6 -4
- package/icon.png +0 -0
- package/lib/client.js +4428 -1508
- package/lib/client.js.map +1 -1
- package/lib/index.js +2670 -496
- package/lib/types/client/CardDefaultPresetField.d.ts +35 -0
- package/lib/types/client/PluginSettingsCard.d.ts +130 -19
- package/lib/types/client/RangeBubble.d.ts +46 -0
- package/lib/types/client/SegmentGroup.d.ts +28 -0
- package/lib/types/client/TaskBoardSettingsCard.d.ts +63 -0
- package/lib/types/client/board/AttachmentField.d.ts +70 -0
- package/lib/types/client/board/ExecutionLog.d.ts +24 -0
- package/lib/types/client/board/ReasoningEffortField.d.ts +25 -0
- package/lib/types/client/board/TaskForm.d.ts +4 -0
- package/lib/types/client/board/VerificationReport.d.ts +2 -15
- package/lib/types/client/board/model-options.d.ts +87 -0
- package/lib/types/client/board/preset-label.d.ts +21 -0
- package/lib/types/client/board/preset-roster.d.ts +45 -0
- package/lib/types/client/board/source-group.d.ts +27 -0
- package/lib/types/client/body-mutations.d.ts +45 -0
- package/lib/types/client/host-api.d.ts +25 -0
- package/lib/types/client/locales.d.ts +87 -9
- package/lib/types/client/pending-verify.d.ts +47 -0
- package/lib/types/client/plugin-card-seat.d.ts +3 -1
- package/lib/types/client/service.d.ts +4 -1
- package/lib/types/client/settings-form.d.ts +73 -51
- package/lib/types/core/attachment.d.ts +132 -0
- package/lib/types/core/card-defaults.d.ts +78 -0
- package/lib/types/core/controller.d.ts +57 -8
- package/lib/types/core/execution-summary.d.ts +52 -0
- package/lib/types/core/extension.d.ts +116 -0
- package/lib/types/core/launch-width.d.ts +31 -0
- package/lib/types/core/reasoning-effort.d.ts +57 -0
- package/lib/types/core/session-reuse.d.ts +7 -1
- package/lib/types/core/spend-budget.d.ts +28 -0
- package/lib/types/core/subtask.d.ts +100 -37
- package/lib/types/core/tasks.d.ts +94 -10
- package/lib/types/core/use-cases/task-create.d.ts +10 -5
- package/lib/types/core/use-cases/task-tag.d.ts +36 -0
- package/lib/types/core/use-cases/task-update.d.ts +22 -1
- package/lib/types/core/wire-projection.d.ts +35 -0
- package/lib/types/core/workspace-target.d.ts +23 -3
- package/lib/types/host/attachments.d.ts +250 -0
- package/lib/types/host/extension-registry.d.ts +40 -0
- package/lib/types/host/launch-admission.d.ts +71 -0
- package/lib/types/host-ledger.d.ts +114 -47
- package/lib/types/host-routes.d.ts +63 -0
- package/lib/types/host-runner.d.ts +164 -18
- package/lib/types/host-service.d.ts +182 -46
- package/lib/types/host-spend.d.ts +52 -0
- package/lib/types/index.d.ts +173 -54
- package/lib/types/loopback.d.ts +41 -1
- package/lib/types/protocol.d.ts +52 -11
- package/lib/types/tool-surface.d.ts +1 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +36 -29
- package/src/client/CardDefaultPresetField.tsx +101 -0
- package/src/client/PluginSettingsCard.tsx +385 -111
- package/src/client/RangeBubble.tsx +164 -0
- package/src/client/SegmentGroup.tsx +93 -0
- package/src/client/TaskBoardSettingsCard.tsx +332 -37
- package/src/client/board/AttachmentField.tsx +383 -0
- package/src/client/board/EditTaskModal.tsx +63 -0
- package/src/client/board/ExecutionLog.tsx +154 -0
- package/src/client/board/LinkSubtaskModal.tsx +1 -1
- package/src/client/board/NewTaskModal.tsx +154 -45
- package/src/client/board/ReasoningEffortField.tsx +50 -0
- package/src/client/board/TagManagerModal.tsx +151 -2
- package/src/client/board/TaskBoard.tsx +47 -10
- package/src/client/board/TaskCard.tsx +45 -23
- package/src/client/board/TaskDetail.tsx +468 -258
- package/src/client/board/TaskForm.tsx +19 -4
- package/src/client/board/VerificationReport.tsx +143 -104
- package/src/client/board/model-options.ts +208 -0
- package/src/client/board/preset-label.ts +32 -0
- package/src/client/board/preset-roster.ts +58 -0
- package/src/client/board/source-group.ts +94 -0
- package/src/client/board/task-markdown.module.css +11 -8
- package/src/client/board-settings.module.css +35 -7
- package/src/client/board.module.css +1044 -105
- package/src/client/body-mutations.ts +133 -0
- package/src/client/host-api.ts +70 -0
- package/src/client/index.ts +109 -95
- package/src/client/locales.ts +205 -48
- package/src/client/pending-verify.ts +90 -0
- package/src/client/plugin-card-seat.ts +8 -2
- package/src/client/service.ts +24 -0
- package/src/client/settings-card.module.css +466 -89
- package/src/client/settings-entry-form.ts +0 -1
- package/src/client/settings-form.ts +102 -60
- package/src/core/attachment.ts +287 -0
- package/src/core/card-defaults.ts +132 -0
- package/src/core/controller.ts +90 -11
- package/src/core/execution-summary.ts +96 -0
- package/src/core/extension.ts +120 -0
- package/src/core/launch-width.ts +38 -0
- package/src/core/reasoning-effort.ts +92 -0
- package/src/core/session-reuse.ts +7 -1
- package/src/core/spend-budget.ts +35 -0
- package/src/core/store.ts +19 -1
- package/src/core/subtask.ts +144 -68
- package/src/core/tasks.ts +117 -10
- package/src/core/use-cases/task-create.ts +27 -16
- package/src/core/use-cases/task-tag.ts +56 -0
- package/src/core/use-cases/task-update.ts +33 -5
- package/src/core/wire-projection.ts +81 -0
- package/src/core/workspace-target.ts +27 -3
- package/src/host/agent-tools.ts +33 -21
- package/src/host/attachments.ts +650 -0
- package/src/host/extension-registry.ts +150 -5
- package/src/host/launch-admission.ts +139 -0
- package/src/host-ledger.ts +248 -117
- package/src/host-routes.ts +233 -15
- package/src/host-runner.ts +395 -61
- package/src/host-service.ts +512 -139
- package/src/host-spend.ts +105 -0
- package/src/index.ts +312 -92
- package/src/loopback.ts +57 -1
- package/src/protocol.ts +83 -18
- package/src/tool-surface.ts +1 -0
- package/icon.svg +0 -3
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { useEffect, useRef, useState } from 'react'
|
|
6
6
|
import type { BoardController } from '../../core/controller.ts'
|
|
7
|
+
import { resolveCardTargets, type CardTargetSource } from '../../core/card-defaults.ts'
|
|
7
8
|
import { isValidCron, nextRunAtMs } from '../../core/schedule.ts'
|
|
8
9
|
import { parseFreezeRequest } from '../../core/freeze-snapshot.ts'
|
|
9
10
|
import { effectiveTaskPermission } from '../../core/subtask.ts'
|
|
@@ -12,10 +13,14 @@ import { t, type TaskBoardKey } from '../locales.ts'
|
|
|
12
13
|
import { SCHEDULE_PRESETS } from '../schedule-presets.ts'
|
|
13
14
|
import { defaultZonedInputValue, nextRunLabel, parseZonedInput, runCapOption, zonedInputValue, zoneChoices } from '../schedule-zone.ts'
|
|
14
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'
|
|
15
18
|
import type { OverlayPhase } from './overlay.tsx'
|
|
16
19
|
import { formatHostTimestamp } from './TaskCard.tsx'
|
|
17
20
|
import { readParseModelPreference, writeParseModelPreference } from './parse-model-pref.ts'
|
|
18
|
-
import { inheritPresetLabel,
|
|
21
|
+
import { inheritPresetLabel, presetChoiceRows, presetLabel } from './preset-label.ts'
|
|
22
|
+
import { ReasoningEffortField } from './ReasoningEffortField.tsx'
|
|
23
|
+
import { modelDisplayLabel, reconcileReasoningEffort } from './model-options.ts'
|
|
19
24
|
import css from '../board.module.css'
|
|
20
25
|
|
|
21
26
|
export interface NewTaskModalProps {
|
|
@@ -40,21 +45,52 @@ export interface NewTaskModalProps {
|
|
|
40
45
|
phase?: OverlayPhase
|
|
41
46
|
}
|
|
42
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
|
+
|
|
43
62
|
/** New-task form overlay. */
|
|
44
63
|
export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspaceId, onDuplicateSuccess, parentTask, phase }: NewTaskModalProps) {
|
|
45
64
|
const isDuplicate = initialTask !== undefined
|
|
46
65
|
const [title, setTitle] = useState(initialTask?.title ?? '')
|
|
47
66
|
const [description, setDescription] = useState(initialTask?.description ?? '')
|
|
48
67
|
const [prompt, setPrompt] = useState(initialTask?.prompt ?? '')
|
|
68
|
+
// The four execution targets this dialog opens on, resolved by the one rule
|
|
69
|
+
// the Host create path also uses (core/card-defaults.ts): what the card is
|
|
70
|
+
// created from (a duplicate's source, a subtask's parent) first, the board's
|
|
71
|
+
// new-card defaults second, blank when neither supplies a value. Resolving it
|
|
72
|
+
// from the SAME function the ledger uses is what keeps the dialog from
|
|
73
|
+
// drifting from what a create without an explicit choice stores.
|
|
74
|
+
const [seed] = useState(() => {
|
|
75
|
+
const source: CardTargetSource | undefined = parentTask !== undefined
|
|
76
|
+
? { kind: 'parent', task: parentTask }
|
|
77
|
+
: initialTask !== undefined ? { kind: 'duplicate', task: initialTask } : undefined
|
|
78
|
+
return resolveCardTargets(controller.getSnapshot().host?.cardDefaults, source)
|
|
79
|
+
})
|
|
49
80
|
// A subtask starts from its parent's execution contract (issue: subtask
|
|
50
81
|
// inheritance); each picker below still overrides it for this card. The
|
|
51
|
-
// permission stays UNSET
|
|
52
|
-
// inherit the parent's binding together with its human
|
|
53
|
-
// picking a value pins this card's own binding and
|
|
82
|
+
// permission stays UNSET unless a default supplies one: leaving it empty is
|
|
83
|
+
// what makes the Host inherit the parent's binding together with its human
|
|
84
|
+
// confirmation, while picking a value pins this card's own binding and
|
|
85
|
+
// re-arms the gate. A parent's permission never travels here at all.
|
|
54
86
|
const [workspaceId, setWorkspaceId] = useState(initialTask?.workspaceId ?? parentTask?.workspaceId ?? defaultWorkspaceId ?? '')
|
|
55
|
-
const [mode, setMode] = useState(
|
|
56
|
-
const [permission, setPermission] = useState(
|
|
57
|
-
const [model, setModel] = useState(
|
|
87
|
+
const [mode, setMode] = useState(seed.mode)
|
|
88
|
+
const [permission, setPermission] = useState(seed.permission)
|
|
89
|
+
const [model, setModel] = useState(seed.model)
|
|
90
|
+
// The effort belongs to the model pin: the resolved seed carries the source
|
|
91
|
+
// card's pair and applies the configured default level only while the final
|
|
92
|
+
// model IS the configured default model; '' follows the model/Host default.
|
|
93
|
+
const [reasoningEffort, setReasoningEffort] = useState(seed.reasoningEffort)
|
|
58
94
|
const inheritedPermission = parentTask === undefined ? undefined : effectiveTaskPermission(parentTask)
|
|
59
95
|
const [reuseSession, setReuseSession] = useState(initialTask?.reuseSession ?? false)
|
|
60
96
|
// Unchecked by default: a new task runs one plain turn unless the user opts
|
|
@@ -81,6 +117,14 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
81
117
|
initialTask?.handover?.references !== undefined ? initialTask.handover.references.join('\n') : '',
|
|
82
118
|
)
|
|
83
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)
|
|
84
128
|
const [archiveOriginal, setArchiveOriginal] = useState(true)
|
|
85
129
|
const [error, setError] = useState<string | undefined>(undefined)
|
|
86
130
|
const [pending, setPending] = useState(false)
|
|
@@ -100,14 +144,14 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
100
144
|
const [parsePending, setParsePending] = useState(false)
|
|
101
145
|
const [parseError, setParseError] = useState<string | undefined>(undefined)
|
|
102
146
|
const parseAbort = useRef<AbortController | undefined>(undefined)
|
|
103
|
-
const
|
|
147
|
+
const models = options.models ?? []
|
|
104
148
|
// A pinned target may have disappeared from the runtime (workspace deleted,
|
|
105
149
|
// preset removed) — especially when the form starts from a subtask's parent.
|
|
106
150
|
// Keep it selectable as a stale row, so the field shows what the create
|
|
107
151
|
// action will actually send instead of silently displaying the default.
|
|
108
152
|
const workspaceKnown = workspaceId === '' || options.workspaces.some(item => item.workspaceId === workspaceId)
|
|
109
153
|
const modeKnown = mode === '' || options.presets.some(item => item.id === mode)
|
|
110
|
-
const modelKnown = model === '' ||
|
|
154
|
+
const modelKnown = model === '' || models.some(item => item.id === model)
|
|
111
155
|
|
|
112
156
|
// The workspace list and preset roster arrive from the runtime after mount;
|
|
113
157
|
// follow them so the pickers never freeze on an empty snapshot.
|
|
@@ -124,8 +168,8 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
124
168
|
// no longer offers falls back to the Host default; an empty value is the
|
|
125
169
|
// Host-default choice and is never overwritten by the roster (issue #1621).
|
|
126
170
|
useEffect(() => {
|
|
127
|
-
if (parseModel === '' ||
|
|
128
|
-
if (
|
|
171
|
+
if (parseModel === '' || models.length === 0) return
|
|
172
|
+
if (models.some(option => option.id === parseModel)) return
|
|
129
173
|
setParseModel('')
|
|
130
174
|
writeParseModelPreference('')
|
|
131
175
|
}, [parseModel, options.models])
|
|
@@ -208,6 +252,24 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
208
252
|
// empty name, and an empty list is expressed by omitting the field.
|
|
209
253
|
const tagList = cleanTags(tags)
|
|
210
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
|
+
}
|
|
211
273
|
const task = await controller.createTaskConfirmed({
|
|
212
274
|
title,
|
|
213
275
|
description,
|
|
@@ -215,14 +277,24 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
215
277
|
...(parentTask === undefined ? {} : { parentId: parentTask.id }),
|
|
216
278
|
freeze,
|
|
217
279
|
handover,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
280
|
+
// A cleared picker is OMITTED, never sent as an empty value: absence is
|
|
281
|
+
// how "no pin, resolved at run time" is stored, so blanking a field the
|
|
282
|
+
// dialog opened prefilled really unpins it. This dialog never sends
|
|
283
|
+
// `applyCardDefaults` — the prefill above is the whole feature here.
|
|
284
|
+
...(workspaceId === '' ? {} : { workspaceId }),
|
|
285
|
+
...(mode === '' ? {} : { mode }),
|
|
286
|
+
...(permission === '' ? {} : { permission: permission as TaskPermission }),
|
|
287
|
+
...(model === '' ? {} : { model }),
|
|
288
|
+
...(reasoningEffort === '' ? {} : { reasoningEffort }),
|
|
222
289
|
...(reuseSession ? { reuseSession: true } : {}),
|
|
223
290
|
...(goalRun ? { goalRun: true } : {}),
|
|
224
291
|
...(skipVerification ? { skipVerification: true } : {}),
|
|
225
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
|
+
: {}),
|
|
226
298
|
schedule: scheduleEnabled
|
|
227
299
|
? scheduleMode === 'once'
|
|
228
300
|
? {
|
|
@@ -283,10 +355,11 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
283
355
|
: isDuplicate ? t('new.duplicateTitle') : t('board.new')
|
|
284
356
|
|
|
285
357
|
// Agent-preset picker rows: the four built-in presets first, then every other
|
|
286
|
-
// roster row (user presets)
|
|
287
|
-
//
|
|
288
|
-
|
|
289
|
-
|
|
358
|
+
// roster row (user presets), each labelled with its default/unavailable
|
|
359
|
+
// suffixes by the one row builder the settings card's default-preset field
|
|
360
|
+
// also renders through. The inherit option names the preset a run actually
|
|
361
|
+
// lands on when the card pins nothing.
|
|
362
|
+
const presetRows = presetChoiceRows(options.presets)
|
|
290
363
|
const inheritLabel = inheritPresetLabel(options.presets)
|
|
291
364
|
const selectedPreset = options.presets.find(preset => preset.id === mode)
|
|
292
365
|
const modeLabel = mode === '' ? inheritLabel : selectedPreset === undefined ? mode : presetLabel(selectedPreset)
|
|
@@ -298,9 +371,16 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
298
371
|
? t('exec.permission.default')
|
|
299
372
|
: t('exec.permission.inheritParent', { permission: t(`exec.permission.${inheritedPermission}` as TaskBoardKey) })
|
|
300
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.
|
|
301
378
|
const modelLabel = model === ''
|
|
302
379
|
? t('exec.model.default')
|
|
303
|
-
: (
|
|
380
|
+
: modelDisplayLabel(models.find(item => item.id === model) ?? { id: model })
|
|
381
|
+
// The effort is part of the model pin, so a pinned one rides the model's own
|
|
382
|
+
// summary entry instead of standing as a region-level value of its own.
|
|
383
|
+
const modelSummary = reasoningEffort === '' ? modelLabel : `${modelLabel} · ${reasoningEffort}`
|
|
304
384
|
// Collapsed-region summaries: what each closed region currently holds, so a
|
|
305
385
|
// collapse never hides the configuration without a trace.
|
|
306
386
|
// A host-default model adds only the long parenthetical name to the
|
|
@@ -309,8 +389,14 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
309
389
|
workspaceLabel,
|
|
310
390
|
modeLabel,
|
|
311
391
|
permissionLabel,
|
|
312
|
-
...(model === '' ? [] : [
|
|
392
|
+
...(model === '' ? [] : [modelSummary]),
|
|
313
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) })
|
|
314
400
|
const tagCount = cleanTags(tags).length
|
|
315
401
|
const labelsSummary = tagCount === 0 ? t('new.summary.none') : t('new.summary.labelCount', { count: String(tagCount) })
|
|
316
402
|
const runSummary = [
|
|
@@ -378,8 +464,8 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
378
464
|
}}
|
|
379
465
|
>
|
|
380
466
|
<option value="">{t('exec.model.default')}</option>
|
|
381
|
-
{
|
|
382
|
-
<option key={option.id} value={option.id}>{option
|
|
467
|
+
{models.map(option => (
|
|
468
|
+
<option key={option.id} value={option.id}>{modelDisplayLabel(option)}</option>
|
|
383
469
|
))}
|
|
384
470
|
</select>
|
|
385
471
|
{parsePending
|
|
@@ -391,7 +477,7 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
391
477
|
: (
|
|
392
478
|
<button
|
|
393
479
|
type="button"
|
|
394
|
-
className={css.
|
|
480
|
+
className={css.ghostButton}
|
|
395
481
|
disabled={parseText.trim() === ''}
|
|
396
482
|
onClick={() => { void runParse() }}
|
|
397
483
|
>
|
|
@@ -405,9 +491,11 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
405
491
|
)}
|
|
406
492
|
|
|
407
493
|
{parentTask !== undefined && (
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
494
|
+
<>
|
|
495
|
+
<p className={css.detailText} data-dsh-part="subtask-inherit">
|
|
496
|
+
{t('detail.parent')}: {parentTask.title} · {t('new.subtaskInherit')}
|
|
497
|
+
</p>
|
|
498
|
+
</>
|
|
411
499
|
)}
|
|
412
500
|
|
|
413
501
|
<CollapsibleSection title={t('new.section.content')} defaultOpen>
|
|
@@ -420,7 +508,7 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
420
508
|
onPromptChange={setPrompt}
|
|
421
509
|
/>
|
|
422
510
|
{isDuplicate && (
|
|
423
|
-
<label className={css.
|
|
511
|
+
<label className={css.scheduleToggle}>
|
|
424
512
|
<input
|
|
425
513
|
type="checkbox"
|
|
426
514
|
checked={archiveOriginal}
|
|
@@ -435,6 +523,21 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
435
523
|
<TaskTagFields tags={tags} knownTags={collectKnownTags(controller.getSnapshot().tasks)} onChange={setTags} />
|
|
436
524
|
</CollapsibleSection>
|
|
437
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
|
+
|
|
438
541
|
<CollapsibleSection title={t('new.section.execution')} summary={executionSummary}>
|
|
439
542
|
<label className={css.field}>
|
|
440
543
|
<span className={css.fieldLabel}>{t('new.workspace')}</span>
|
|
@@ -460,25 +563,17 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
460
563
|
>
|
|
461
564
|
<option value="">{inheritLabel}</option>
|
|
462
565
|
{!modeKnown && <option value={mode}>{mode}{t('exec.mode.removed')}</option>}
|
|
463
|
-
{
|
|
566
|
+
{presetRows.builtin.length > 0 && (
|
|
464
567
|
<optgroup label={t('exec.mode.builtinGroup')}>
|
|
465
|
-
{
|
|
466
|
-
<option key={
|
|
467
|
-
{presetLabel(preset)}
|
|
468
|
-
{preset.isDefault ? t('exec.mode.defaultSuffix') : ''}
|
|
469
|
-
{preset.broken !== undefined ? t('exec.mode.brokenSuffix') : ''}
|
|
470
|
-
</option>
|
|
568
|
+
{presetRows.builtin.map(row => (
|
|
569
|
+
<option key={row.id} value={row.id} disabled={row.disabled}>{row.label}</option>
|
|
471
570
|
))}
|
|
472
571
|
</optgroup>
|
|
473
572
|
)}
|
|
474
|
-
{
|
|
573
|
+
{presetRows.custom.length > 0 && (
|
|
475
574
|
<optgroup label={t('exec.mode.customGroup')}>
|
|
476
|
-
{
|
|
477
|
-
<option key={
|
|
478
|
-
{presetLabel(preset)}
|
|
479
|
-
{preset.isDefault ? t('exec.mode.defaultSuffix') : ''}
|
|
480
|
-
{preset.broken !== undefined ? t('exec.mode.brokenSuffix') : ''}
|
|
481
|
-
</option>
|
|
575
|
+
{presetRows.custom.map(row => (
|
|
576
|
+
<option key={row.id} value={row.id} disabled={row.disabled}>{row.label}</option>
|
|
482
577
|
))}
|
|
483
578
|
</optgroup>
|
|
484
579
|
)}
|
|
@@ -506,15 +601,29 @@ export function NewTaskModal({ controller, onClose, initialTask, defaultWorkspac
|
|
|
506
601
|
<select
|
|
507
602
|
className={css.select}
|
|
508
603
|
value={model}
|
|
509
|
-
onChange={event => {
|
|
604
|
+
onChange={event => {
|
|
605
|
+
// The effort belongs to the model: switching to a model that
|
|
606
|
+
// cannot honor the picked level drops it instead of carrying it.
|
|
607
|
+
const next = event.target.value
|
|
608
|
+
setModel(next)
|
|
609
|
+
setReasoningEffort(current => reconcileReasoningEffort(models, next, current))
|
|
610
|
+
}}
|
|
510
611
|
>
|
|
511
612
|
<option value="">{t('exec.model.default')}</option>
|
|
512
613
|
{!modelKnown && <option value={model}>{model}{t('exec.model.unknown')}</option>}
|
|
513
|
-
{
|
|
514
|
-
<option key={item.id} value={item.id}>{item
|
|
614
|
+
{models.map(item => (
|
|
615
|
+
<option key={item.id} value={item.id}>{modelDisplayLabel(item)}</option>
|
|
515
616
|
))}
|
|
516
617
|
</select>
|
|
517
618
|
</label>
|
|
619
|
+
|
|
620
|
+
<ReasoningEffortField
|
|
621
|
+
models={models}
|
|
622
|
+
modelId={model}
|
|
623
|
+
value={reasoningEffort}
|
|
624
|
+
pending={pending}
|
|
625
|
+
onChange={setReasoningEffort}
|
|
626
|
+
/>
|
|
518
627
|
</CollapsibleSection>
|
|
519
628
|
|
|
520
629
|
<CollapsibleSection title={t('new.section.run')} summary={runSummary}>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reasoning-effort field: one picker shared by both execution-target editors
|
|
3
|
+
* (the create dialog and the detail page), so the two never describe the same
|
|
4
|
+
* capability differently. The levels are the ones the picked model's catalog
|
|
5
|
+
* entry declares; an empty value is a real choice — "follow the model or Host
|
|
6
|
+
* default" — and is the default state.
|
|
7
|
+
*
|
|
8
|
+
* A stored level the roster no longer lists (the model left the roster, or its
|
|
9
|
+
* adapter changed) stays shown and labelled, but is not offered again, so the
|
|
10
|
+
* field never silently shows a different value than the one the card will ask
|
|
11
|
+
* for while the choosable set stays exactly the levels the model declares.
|
|
12
|
+
*/
|
|
13
|
+
import type { ExecutionModelOption } from '../../core/controller.ts'
|
|
14
|
+
import { t } from '../locales.ts'
|
|
15
|
+
import css from '../board.module.css'
|
|
16
|
+
import { reasoningEffortsFor, reasoningHintKey, reasoningPickerEnabled } from './model-options.ts'
|
|
17
|
+
|
|
18
|
+
/** The controlled reasoning-effort picker. */
|
|
19
|
+
export function ReasoningEffortField({ models, modelId, value, pending, onChange }: {
|
|
20
|
+
/** The roster the picked model is looked up in. */
|
|
21
|
+
models: readonly ExecutionModelOption[]
|
|
22
|
+
/** The model this card pins; '' means "no pin". */
|
|
23
|
+
modelId: string
|
|
24
|
+
/** The selected effort; '' means "follow the model or Host default". */
|
|
25
|
+
value: string
|
|
26
|
+
/** Whether a mutation is in flight (the field locks with the rest of the form). */
|
|
27
|
+
pending: boolean
|
|
28
|
+
onChange: (next: string) => void
|
|
29
|
+
}) {
|
|
30
|
+
const efforts = reasoningEffortsFor(models, modelId)
|
|
31
|
+
const unlisted = value !== '' && !efforts.includes(value)
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
<label className={css.field}>
|
|
35
|
+
<span className={css.fieldLabel}>{t('exec.reasoning')}</span>
|
|
36
|
+
<select
|
|
37
|
+
className={css.select}
|
|
38
|
+
value={value}
|
|
39
|
+
disabled={pending || !reasoningPickerEnabled(models, modelId)}
|
|
40
|
+
onChange={event => { onChange(event.target.value) }}
|
|
41
|
+
>
|
|
42
|
+
<option value="">{t('exec.reasoning.inherit')}</option>
|
|
43
|
+
{unlisted && <option value={value} disabled>{value}{t('exec.reasoning.unknown')}</option>}
|
|
44
|
+
{efforts.map(effort => <option key={effort} value={effort}>{effort}</option>)}
|
|
45
|
+
</select>
|
|
46
|
+
</label>
|
|
47
|
+
<p className={css.detailText}>{t(reasoningHintKey(models, modelId))}</p>
|
|
48
|
+
</>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
@@ -12,16 +12,30 @@
|
|
|
12
12
|
* Renaming onto a name already in use merges the two labels; the dialog says so
|
|
13
13
|
* before the edit is submitted. Deleting is confirmed first, and the
|
|
14
14
|
* confirmation names how many tasks the label is removed from.
|
|
15
|
+
*
|
|
16
|
+
* Clearing is that same delete applied to a judged set instead of one row: the
|
|
17
|
+
* dialog offers a usage threshold, cleanupCandidates names the labels that are
|
|
18
|
+
* both below it and carried only by finished tasks, and the confirmation lists
|
|
19
|
+
* what would go before anything is written. The Host ledger stays the authority
|
|
20
|
+
* either way — this surface only decides what to ask for.
|
|
15
21
|
*/
|
|
16
|
-
import { useMemo, useState } from 'react'
|
|
22
|
+
import { useId, useMemo, useState } from 'react'
|
|
17
23
|
import type { BoardController } from '../../core/controller.ts'
|
|
18
24
|
import { TAG_NAME_MAX_LENGTH, collectKnownTags, type TaskRecord } from '../../core/tasks.ts'
|
|
25
|
+
import { cleanupCandidates, type TagCleanupCandidate } from '../../core/use-cases/task-tag.ts'
|
|
19
26
|
import { t } from '../locales.ts'
|
|
20
27
|
import css from '../board.module.css'
|
|
21
28
|
import { ConfirmDialog } from './ConfirmDialog.tsx'
|
|
22
29
|
import { IconClose } from './icons.tsx'
|
|
23
30
|
import { useDialog, usePresence, type OverlayPhase } from './overlay.tsx'
|
|
24
31
|
|
|
32
|
+
/** Usage the clear control starts on: labels carried by fewer tasks than this. */
|
|
33
|
+
const CLEANUP_THRESHOLD_DEFAULT = 5
|
|
34
|
+
/** Floor of the threshold field: a label in use always sits on at least one task. */
|
|
35
|
+
const CLEANUP_THRESHOLD_MIN = 1
|
|
36
|
+
/** Ceiling of the threshold field, which keeps the field a two-digit control. */
|
|
37
|
+
const CLEANUP_THRESHOLD_MAX = 99
|
|
38
|
+
|
|
25
39
|
/** One label as the manager lists it: its definition plus how many tasks carry it. */
|
|
26
40
|
export interface TagUsage {
|
|
27
41
|
name: string
|
|
@@ -48,6 +62,36 @@ export function tagUsage(tasks: readonly TaskRecord[]): TagUsage[] {
|
|
|
48
62
|
}))
|
|
49
63
|
}
|
|
50
64
|
|
|
65
|
+
/**
|
|
66
|
+
* The threshold a typed value actually stands for. A number field only marks an
|
|
67
|
+
* out-of-range value invalid; it still hands the value back, so the range the
|
|
68
|
+
* field declares is folded in here before anything is judged: below the floor
|
|
69
|
+
* becomes the floor, above the ceiling becomes the ceiling, and a value that is
|
|
70
|
+
* not a number at all selects nothing (the manager then answers "no label
|
|
71
|
+
* matches" instead of guessing a bound).
|
|
72
|
+
* @param typed - the raw field value.
|
|
73
|
+
* @returns a threshold inside the field's range, or NaN for "select nothing".
|
|
74
|
+
*/
|
|
75
|
+
function cleanupThreshold(typed: string): number {
|
|
76
|
+
const value = Number(typed)
|
|
77
|
+
if (!Number.isFinite(value)) return Number.NaN
|
|
78
|
+
return Math.min(CLEANUP_THRESHOLD_MAX, Math.max(CLEANUP_THRESHOLD_MIN, value))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The confirmation body for a cleanup: every label that would go, each with the
|
|
83
|
+
* number of tasks it would be removed from, so the decision is made against
|
|
84
|
+
* names and sizes rather than against a bare count.
|
|
85
|
+
* @param candidates - what the threshold judged, in listing order.
|
|
86
|
+
* @returns the sentence the confirmation shows.
|
|
87
|
+
*/
|
|
88
|
+
function cleanupMessage(candidates: readonly TagCleanupCandidate[]): string {
|
|
89
|
+
return t('tags.cleanupConfirm', {
|
|
90
|
+
count: String(candidates.length),
|
|
91
|
+
names: candidates.map(candidate => candidate.name + ' (' + candidate.count + ')').join(', '),
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
51
95
|
/** Label-manager overlay props. */
|
|
52
96
|
export interface TagManagerModalProps {
|
|
53
97
|
controller: BoardController
|
|
@@ -64,7 +108,22 @@ export function TagManagerModal({ controller, onClose, phase = 'open' }: TagMana
|
|
|
64
108
|
const [busy, setBusy] = useState(false)
|
|
65
109
|
const [error, setError] = useState<string | undefined>(undefined)
|
|
66
110
|
const [confirmDelete, setConfirmDelete] = useState<string | undefined>(undefined)
|
|
111
|
+
/** What the clear control judged, kept as the draft the confirmation lists. */
|
|
112
|
+
const [confirmCleanup, setConfirmCleanup] = useState<TagCleanupCandidate[] | undefined>(undefined)
|
|
113
|
+
/** The threshold as typed, so an emptied field stays empty instead of snapping back. */
|
|
114
|
+
const [threshold, setThreshold] = useState(String(CLEANUP_THRESHOLD_DEFAULT))
|
|
115
|
+
/** Supporting answer to a clear press (nothing matched), never an error. */
|
|
116
|
+
const [notice, setNotice] = useState<string | undefined>(undefined)
|
|
117
|
+
/** Description target of the corner `?`: the same text as its hover text. */
|
|
118
|
+
const ruleId = useId()
|
|
119
|
+
/**
|
|
120
|
+
* Everything this dialog explains, in reading order: what labels are and what
|
|
121
|
+
* renaming or deleting does to the cards, then the clear rule. The body keeps
|
|
122
|
+
* the list alone; the corner `?` carries the prose.
|
|
123
|
+
*/
|
|
124
|
+
const ruleText = `${t('tags.hint')}\n\n${t('tags.cleanupHint')}`
|
|
67
125
|
const confirmPresence = usePresence(confirmDelete !== undefined)
|
|
126
|
+
const cleanupPresence = usePresence(confirmCleanup !== undefined)
|
|
68
127
|
// Escape and a backdrop press peel one layer at a time: an open row editor
|
|
69
128
|
// first, then the dialog — so a half-typed rename is never lost to the same
|
|
70
129
|
// key that closes the surface under it.
|
|
@@ -114,6 +173,40 @@ export function TagManagerModal({ controller, onClose, phase = 'open' }: TagMana
|
|
|
114
173
|
if (!accepted) setError(controller.getSnapshot().transportError ?? t('tags.deleteFailed'))
|
|
115
174
|
}
|
|
116
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Judge the ledger against the typed threshold. Nothing is written here: an
|
|
178
|
+
* empty verdict is answered in place, so a threshold nobody agrees with can
|
|
179
|
+
* never delete anything by itself.
|
|
180
|
+
*/
|
|
181
|
+
const startCleanup = (): void => {
|
|
182
|
+
setError(undefined)
|
|
183
|
+
setNotice(undefined)
|
|
184
|
+
const candidates = cleanupCandidates(controller.getSnapshot().tasks, cleanupThreshold(threshold))
|
|
185
|
+
if (candidates.length === 0) {
|
|
186
|
+
setNotice(t('tags.cleanupEmpty'))
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
setConfirmCleanup(candidates)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Remove the judged labels one ledger edit at a time, in the order they were
|
|
194
|
+
* listed: each delete is its own Host-confirmed transition, so a refused one
|
|
195
|
+
* leaves the rest of the ledger untouched and only counts as a failure.
|
|
196
|
+
*/
|
|
197
|
+
const clearLabels = async (candidates: readonly TagCleanupCandidate[]): Promise<void> => {
|
|
198
|
+
setBusy(true)
|
|
199
|
+
setError(undefined)
|
|
200
|
+
setNotice(undefined)
|
|
201
|
+
let failed = 0
|
|
202
|
+
for (const candidate of candidates) {
|
|
203
|
+
const accepted = await controller.deleteTag(candidate.name)
|
|
204
|
+
if (!accepted) failed += 1
|
|
205
|
+
}
|
|
206
|
+
setBusy(false)
|
|
207
|
+
if (failed > 0) setError(t('tags.cleanupFailed', { count: String(failed) }))
|
|
208
|
+
}
|
|
209
|
+
|
|
117
210
|
return (
|
|
118
211
|
<>
|
|
119
212
|
<div className={css.modalBackdrop} data-state={phase} onMouseDown={dialog.onMouseDown}>
|
|
@@ -127,6 +220,46 @@ export function TagManagerModal({ controller, onClose, phase = 'open' }: TagMana
|
|
|
127
220
|
>
|
|
128
221
|
<header className={css.modalHeader}>
|
|
129
222
|
<h2 className={css.modalTitle}>{t('tags.title')}</h2>
|
|
223
|
+
{/* The clear control belongs to the whole ledger, not to the row above
|
|
224
|
+
it, so it lives in the card's corner instead of after the list. Its
|
|
225
|
+
rule rides on the `?` as a real bubble rather than a native title:
|
|
226
|
+
Electron did not paint the title here, the bubble also answers
|
|
227
|
+
keyboard focus, and it is the element aria-describedby names. */}
|
|
228
|
+
<div className={css.tagCleanup}>
|
|
229
|
+
<div className={css.helpTipWrap}>
|
|
230
|
+
<button
|
|
231
|
+
type="button"
|
|
232
|
+
className={css.helpButton}
|
|
233
|
+
aria-label={t('tags.help')}
|
|
234
|
+
aria-describedby={ruleId}
|
|
235
|
+
>
|
|
236
|
+
?
|
|
237
|
+
</button>
|
|
238
|
+
<span id={ruleId} className={css.helpTip} role="tooltip">{ruleText}</span>
|
|
239
|
+
</div>
|
|
240
|
+
<label className={css.scheduleZone}>
|
|
241
|
+
<span>{t('tags.cleanupThreshold')}</span>
|
|
242
|
+
<input
|
|
243
|
+
className={css.input + ' ' + css.tagCleanupInput}
|
|
244
|
+
type="number"
|
|
245
|
+
min={CLEANUP_THRESHOLD_MIN}
|
|
246
|
+
max={CLEANUP_THRESHOLD_MAX}
|
|
247
|
+
step={1}
|
|
248
|
+
inputMode="numeric"
|
|
249
|
+
value={threshold}
|
|
250
|
+
disabled={busy}
|
|
251
|
+
aria-label={t('tags.cleanupThreshold')}
|
|
252
|
+
onChange={event => {
|
|
253
|
+
setThreshold(event.target.value)
|
|
254
|
+
setNotice(undefined)
|
|
255
|
+
setError(undefined)
|
|
256
|
+
}}
|
|
257
|
+
/>
|
|
258
|
+
</label>
|
|
259
|
+
<button type="button" className={css.ghostButton} disabled={busy} onClick={startCleanup}>
|
|
260
|
+
{t('tags.cleanup')}
|
|
261
|
+
</button>
|
|
262
|
+
</div>
|
|
130
263
|
<button
|
|
131
264
|
type="button"
|
|
132
265
|
className={css.iconButton}
|
|
@@ -139,7 +272,7 @@ export function TagManagerModal({ controller, onClose, phase = 'open' }: TagMana
|
|
|
139
272
|
</header>
|
|
140
273
|
|
|
141
274
|
<div className={css.modalBody}>
|
|
142
|
-
<p className={css.
|
|
275
|
+
{notice !== undefined && <p className={css.tagCleanupNotice} role="status">{notice}</p>}
|
|
143
276
|
{rows.length === 0
|
|
144
277
|
? <p className={css.detailText}>{t('tags.empty')}</p>
|
|
145
278
|
: (
|
|
@@ -230,6 +363,22 @@ export function TagManagerModal({ controller, onClose, phase = 'open' }: TagMana
|
|
|
230
363
|
}}
|
|
231
364
|
/>
|
|
232
365
|
)}
|
|
366
|
+
|
|
367
|
+
{cleanupPresence.mounted && confirmCleanup !== undefined && (
|
|
368
|
+
<ConfirmDialog
|
|
369
|
+
title={t('tags.cleanupTitle')}
|
|
370
|
+
message={cleanupMessage(confirmCleanup)}
|
|
371
|
+
confirmLabel={t('tags.cleanupOk')}
|
|
372
|
+
danger
|
|
373
|
+
phase={cleanupPresence.phase}
|
|
374
|
+
onCancel={() => { setConfirmCleanup(undefined) }}
|
|
375
|
+
onConfirm={() => {
|
|
376
|
+
const judged = confirmCleanup
|
|
377
|
+
setConfirmCleanup(undefined)
|
|
378
|
+
void clearLabels(judged)
|
|
379
|
+
}}
|
|
380
|
+
/>
|
|
381
|
+
)}
|
|
233
382
|
</>
|
|
234
383
|
)
|
|
235
384
|
}
|