@linxin666/dsh-client-ui-task-board 0.4.21 → 0.4.22
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 +2 -1
- package/README.zh.md +2 -1
- package/lib/client.js +44 -60
- package/lib/client.js.map +1 -1
- package/lib/index.js +39 -20
- package/lib/types/client/board/AttachmentField.d.ts +3 -1
- package/lib/types/client/locales.d.ts +1 -0
- package/lib/types/core/tasks.d.ts +9 -0
- package/lib/types/core/use-cases/task-update.d.ts +25 -17
- package/package.json +28 -28
- package/src/client/board/AttachmentField.tsx +6 -1
- package/src/client/board/EditTaskModal.tsx +4 -1
- package/src/client/board/TaskDetail.tsx +16 -11
- package/src/client/locales.ts +2 -0
- package/src/core/store.ts +2 -0
- package/src/core/tasks.ts +13 -0
- package/src/core/use-cases/task-update.ts +29 -19
- package/src/host-ledger.ts +11 -5
- package/src/protocol.ts +4 -0
package/lib/index.js
CHANGED
|
@@ -1200,7 +1200,9 @@ function startExecution(task, now, executionId, initiatedBy, runGroupId, rework)
|
|
|
1200
1200
|
...task.freeze === void 0 ? {} : {
|
|
1201
1201
|
frozenAt: task.freeze.frozenAt,
|
|
1202
1202
|
...task.freeze.frozenBy === void 0 ? {} : { frozenBy: task.freeze.frozenBy }
|
|
1203
|
-
}
|
|
1203
|
+
},
|
|
1204
|
+
promptSnapshot: task.prompt,
|
|
1205
|
+
titleSnapshot: task.title
|
|
1204
1206
|
};
|
|
1205
1207
|
return {
|
|
1206
1208
|
task: {
|
|
@@ -1855,6 +1857,8 @@ function isTaskRecordShape(value) {
|
|
|
1855
1857
|
if (entry.initiatedBy !== void 0 && typeof entry.initiatedBy !== "string") return false;
|
|
1856
1858
|
if (entry.frozenBy !== void 0 && typeof entry.frozenBy !== "string") return false;
|
|
1857
1859
|
if (entry.frozenAt !== void 0 && typeof entry.frozenAt !== "number") return false;
|
|
1860
|
+
if (entry.promptSnapshot !== void 0 && typeof entry.promptSnapshot !== "string") return false;
|
|
1861
|
+
if (entry.titleSnapshot !== void 0 && typeof entry.titleSnapshot !== "string") return false;
|
|
1858
1862
|
if (entry.external !== void 0 && typeof entry.external !== "boolean") return false;
|
|
1859
1863
|
}
|
|
1860
1864
|
return true;
|
|
@@ -2727,26 +2731,23 @@ function applyDeleteTag(tasks, name, now) {
|
|
|
2727
2731
|
* back to the runtime default); an unknown permission string is ignored so
|
|
2728
2732
|
* stale UI can never persist a value the execution service rejects.
|
|
2729
2733
|
*/
|
|
2730
|
-
/**
|
|
2731
|
-
*
|
|
2732
|
-
*
|
|
2733
|
-
*
|
|
2734
|
+
/**
|
|
2735
|
+
* The fields that freeze with the first run. Split by what keeps them honest:
|
|
2736
|
+
*
|
|
2737
|
+
* - The CONTENT fields stay editable between runs because every execution
|
|
2738
|
+
* record captures the prompt/title snapshot it was opened with (see
|
|
2739
|
+
* `startExecution`), so a post-run edit changes only the next run, never
|
|
2740
|
+
* the audit trail.
|
|
2741
|
+
* - The ATTACHMENTS freeze at the first run and stay frozen: they are binary
|
|
2742
|
+
* references the record does not snapshot, and a card whose first run
|
|
2743
|
+
* already consumed an image keeps that image — the record of what ran
|
|
2744
|
+
* stays what it was. `canEditTaskAttachments` owns that boundary.
|
|
2734
2745
|
*/
|
|
2735
2746
|
const TASK_CONTENT_FIELDS = [
|
|
2736
2747
|
"title",
|
|
2737
2748
|
"description",
|
|
2738
2749
|
"prompt"
|
|
2739
2750
|
];
|
|
2740
|
-
/**
|
|
2741
|
-
* The fields that freeze with the card content: the text the card says AND
|
|
2742
|
-
* the attachments it carries.
|
|
2743
|
-
*
|
|
2744
|
-
* The attachments freeze with the content because they ARE part of what the
|
|
2745
|
-
* card hands to its execution: a card whose first run already consumed an
|
|
2746
|
-
* image keeps that image, and the record of what ran stays what it was. An
|
|
2747
|
-
* executed or archived card therefore refuses an attachment change exactly
|
|
2748
|
-
* as it refuses a prompt change.
|
|
2749
|
-
*/
|
|
2750
2751
|
const TASK_FROZEN_FIELDS = [...TASK_CONTENT_FIELDS, "attachments"];
|
|
2751
2752
|
/** Whether an update patch touches any task-content field. */
|
|
2752
2753
|
function hasContentPatch(patch) {
|
|
@@ -2754,12 +2755,25 @@ function hasContentPatch(patch) {
|
|
|
2754
2755
|
}
|
|
2755
2756
|
/**
|
|
2756
2757
|
* Whether a task's content may still be edited: the task must be on-board
|
|
2757
|
-
* (not archived) and must
|
|
2758
|
-
*
|
|
2759
|
-
*
|
|
2760
|
-
*
|
|
2758
|
+
* (not archived) and must not have an open execution. Settled history does
|
|
2759
|
+
* NOT lock the card: new execution records carry the prompt/title snapshot
|
|
2760
|
+
* they were opened with (`promptSnapshot`/`titleSnapshot`), so a
|
|
2761
|
+
* post-run edit changes only the next run, never the audit trail. The run,
|
|
2762
|
+
* not the column, stays the trigger: a card parked in 'running' by hand has
|
|
2763
|
+
* nothing recorded yet and stays editable, and a card mid-run is locked
|
|
2764
|
+
* until its execution settles.
|
|
2761
2765
|
*/
|
|
2762
2766
|
function canEditTaskContent(task) {
|
|
2767
|
+
return task.archivedAt === void 0 && !hasOpenExecution(task);
|
|
2768
|
+
}
|
|
2769
|
+
/**
|
|
2770
|
+
* Whether a task's attachments may still be edited: unlike the content
|
|
2771
|
+
* fields, attachments are NOT captured on the execution record, so they keep
|
|
2772
|
+
* the historical boundary — editable until the first run opens, frozen for
|
|
2773
|
+
* every executed or archived card afterwards. The record of what ran keeps
|
|
2774
|
+
* referencing exactly what ran.
|
|
2775
|
+
*/
|
|
2776
|
+
function canEditTaskAttachments(task) {
|
|
2763
2777
|
return task.archivedAt === void 0 && task.executions.length === 0;
|
|
2764
2778
|
}
|
|
2765
2779
|
/** Keep an unknown permission string from entering the ledger. */
|
|
@@ -2915,6 +2929,8 @@ function validImportedKnownFields(value) {
|
|
|
2915
2929
|
if (execution.external !== void 0 && typeof execution.external !== "boolean") return false;
|
|
2916
2930
|
if (execution.frozenBy !== void 0 && typeof execution.frozenBy !== "string") return false;
|
|
2917
2931
|
if (execution.frozenAt !== void 0 && typeof execution.frozenAt !== "number") return false;
|
|
2932
|
+
if (execution.promptSnapshot !== void 0 && typeof execution.promptSnapshot !== "string") return false;
|
|
2933
|
+
if (execution.titleSnapshot !== void 0 && typeof execution.titleSnapshot !== "string") return false;
|
|
2918
2934
|
}
|
|
2919
2935
|
}
|
|
2920
2936
|
return true;
|
|
@@ -2942,7 +2958,9 @@ function importedTask(value) {
|
|
|
2942
2958
|
...execution.initiatedBy === void 0 ? {} : { initiatedBy: execution.initiatedBy },
|
|
2943
2959
|
...execution.external === true ? { external: true } : {},
|
|
2944
2960
|
...execution.frozenAt === void 0 ? {} : { frozenAt: execution.frozenAt },
|
|
2945
|
-
...execution.frozenBy === void 0 ? {} : { frozenBy: execution.frozenBy }
|
|
2961
|
+
...execution.frozenBy === void 0 ? {} : { frozenBy: execution.frozenBy },
|
|
2962
|
+
...execution.promptSnapshot === void 0 ? {} : { promptSnapshot: execution.promptSnapshot },
|
|
2963
|
+
...execution.titleSnapshot === void 0 ? {} : { titleSnapshot: execution.titleSnapshot }
|
|
2946
2964
|
})),
|
|
2947
2965
|
...task.schedule === void 0 ? {} : { schedule: { ...task.schedule } },
|
|
2948
2966
|
...task.parentId === void 0 ? {} : { parentId: task.parentId },
|
|
@@ -4318,6 +4336,7 @@ var HostTaskLedger = class {
|
|
|
4318
4336
|
const task = this.document.tasks.find((task) => task.id === action.taskId);
|
|
4319
4337
|
if (task === void 0) throw new Error("task not found");
|
|
4320
4338
|
if (task.archivedAt !== void 0) throw new Error("archived task is read-only");
|
|
4339
|
+
if ("attachments" in action.patch && !canEditTaskAttachments(task)) throw new Error("task has already been executed");
|
|
4321
4340
|
if (hasContentPatch(action.patch) && !canEditTaskContent(task)) throw new Error("task has already been executed");
|
|
4322
4341
|
if ("title" in action.patch && action.patch.title?.trim() === "") throw new Error("title is required");
|
|
4323
4342
|
const patch = action.patch.freeze === null || action.patch.freeze === void 0 || initiator === void 0 || initiator === "" ? action.patch : {
|
|
@@ -56,7 +56,7 @@ export declare function attachmentKindOf(file: File): TaskAttachmentKind;
|
|
|
56
56
|
* The component owns the local staging only: the selection it reports is what
|
|
57
57
|
* the card will carry, and the parent uploads the staged files on save.
|
|
58
58
|
*/
|
|
59
|
-
export declare function AttachmentField({ selection, onChange, limits, disabled, onError, }: {
|
|
59
|
+
export declare function AttachmentField({ selection, onChange, limits, disabled, lockedHint, onError, }: {
|
|
60
60
|
/** What the card currently carries and what is staged on top of it. */
|
|
61
61
|
selection: AttachmentSelection;
|
|
62
62
|
/** Receives the new selection after every change. */
|
|
@@ -65,6 +65,8 @@ export declare function AttachmentField({ selection, onChange, limits, disabled,
|
|
|
65
65
|
limits?: AttachmentLimits;
|
|
66
66
|
/** Whether the field refuses new input. */
|
|
67
67
|
disabled?: boolean;
|
|
68
|
+
/** Replaces the inviting upload hint when the caller locks the field. */
|
|
69
|
+
lockedHint?: string;
|
|
68
70
|
/** Receives the reason a selection was refused. */
|
|
69
71
|
onError?: (message: string) => void;
|
|
70
72
|
}): import("react").JSX.Element;
|
|
@@ -107,6 +107,15 @@ export interface ExecutionRecord {
|
|
|
107
107
|
frozenAt?: number;
|
|
108
108
|
/** Freeze source session captured from the card snapshot when the run opened. */
|
|
109
109
|
frozenBy?: string;
|
|
110
|
+
/**
|
|
111
|
+
* The prompt this execution was opened with, captured at run start. The
|
|
112
|
+
* card's prompt stays editable between runs; this snapshot — not the live
|
|
113
|
+
* field — is the record of what actually ran. Absent on executions recorded
|
|
114
|
+
* before snapshots were introduced.
|
|
115
|
+
*/
|
|
116
|
+
promptSnapshot?: string;
|
|
117
|
+
/** Title captured alongside {@link promptSnapshot} when the run opened. */
|
|
118
|
+
titleSnapshot?: string;
|
|
110
119
|
/**
|
|
111
120
|
* Cascade run group shared by the parent execution and every descendant
|
|
112
121
|
* execution one run request opened. Absent on a plain single-task run.
|
|
@@ -39,33 +39,41 @@ export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' |
|
|
|
39
39
|
*/
|
|
40
40
|
attachments?: TaskAttachment[] | null;
|
|
41
41
|
};
|
|
42
|
-
/** The fields that edit the task's content (what the user reads and what the
|
|
43
|
-
* next execution sends). Unlike the execution targets they stay editable only
|
|
44
|
-
* while the task has never started executing — after the first run the
|
|
45
|
-
* recorded prompt is the record of what actually ran, so it becomes read-only.
|
|
46
|
-
*/
|
|
47
|
-
export declare const TASK_CONTENT_FIELDS: readonly ["title", "description", "prompt"];
|
|
48
42
|
/**
|
|
49
|
-
* The fields that freeze with the
|
|
50
|
-
* the attachments it carries.
|
|
43
|
+
* The fields that freeze with the first run. Split by what keeps them honest:
|
|
51
44
|
*
|
|
52
|
-
* The
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
45
|
+
* - The CONTENT fields stay editable between runs because every execution
|
|
46
|
+
* record captures the prompt/title snapshot it was opened with (see
|
|
47
|
+
* `startExecution`), so a post-run edit changes only the next run, never
|
|
48
|
+
* the audit trail.
|
|
49
|
+
* - The ATTACHMENTS freeze at the first run and stay frozen: they are binary
|
|
50
|
+
* references the record does not snapshot, and a card whose first run
|
|
51
|
+
* already consumed an image keeps that image — the record of what ran
|
|
52
|
+
* stays what it was. `canEditTaskAttachments` owns that boundary.
|
|
57
53
|
*/
|
|
54
|
+
export declare const TASK_CONTENT_FIELDS: readonly ["title", "description", "prompt"];
|
|
58
55
|
export declare const TASK_FROZEN_FIELDS: readonly ["title", "description", "prompt", "attachments"];
|
|
59
56
|
/** Whether an update patch touches any task-content field. */
|
|
60
57
|
export declare function hasContentPatch(patch: TaskUpdatePatch): boolean;
|
|
61
58
|
/**
|
|
62
59
|
* Whether a task's content may still be edited: the task must be on-board
|
|
63
|
-
* (not archived) and must
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
60
|
+
* (not archived) and must not have an open execution. Settled history does
|
|
61
|
+
* NOT lock the card: new execution records carry the prompt/title snapshot
|
|
62
|
+
* they were opened with (`promptSnapshot`/`titleSnapshot`), so a
|
|
63
|
+
* post-run edit changes only the next run, never the audit trail. The run,
|
|
64
|
+
* not the column, stays the trigger: a card parked in 'running' by hand has
|
|
65
|
+
* nothing recorded yet and stays editable, and a card mid-run is locked
|
|
66
|
+
* until its execution settles.
|
|
67
67
|
*/
|
|
68
68
|
export declare function canEditTaskContent(task: TaskRecord): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Whether a task's attachments may still be edited: unlike the content
|
|
71
|
+
* fields, attachments are NOT captured on the execution record, so they keep
|
|
72
|
+
* the historical boundary — editable until the first run opens, frozen for
|
|
73
|
+
* every executed or archived card afterwards. The record of what ran keeps
|
|
74
|
+
* referencing exactly what ran.
|
|
75
|
+
*/
|
|
76
|
+
export declare function canEditTaskAttachments(task: TaskRecord): boolean;
|
|
69
77
|
/**
|
|
70
78
|
* Apply an update across the ledger. Tasks that do not match the id are left
|
|
71
79
|
* untouched; the matched task receives the patch plus a fresh updatedAt.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-client-ui-task-board",
|
|
3
3
|
"description": "Host-authoritative task board for the DSH Web GUI with real session execution, Host cron scheduling, and optional cross-platform idle-sleep protection; mounted without DSH source changes.",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.22",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dsh": {
|
|
24
24
|
"engines": {
|
|
25
|
-
"dsh": ">=0.2.
|
|
25
|
+
"dsh": ">=0.2.3-alpha.2"
|
|
26
26
|
},
|
|
27
27
|
"bundle": {
|
|
28
28
|
"patch": "./cordis.patch.yml"
|
|
@@ -42,38 +42,38 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@deepseek-ai/dsh": ">=0.2.
|
|
45
|
+
"@deepseek-ai/dsh": ">=0.2.3-alpha.2",
|
|
46
46
|
"react": "^18.2.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@deepseek-ai/schemastery": "
|
|
49
|
+
"@deepseek-ai/schemastery": "~3.20.0-alpha.1",
|
|
50
50
|
"marked": "^18.0.14"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@deepseek-ai/cordis": "
|
|
54
|
-
"@deepseek-ai/dsh-agent": "^0.2.
|
|
55
|
-
"@deepseek-ai/dsh-agent-preset-registry": "^0.2.
|
|
56
|
-
"@deepseek-ai/dsh-attachment": "^0.2.
|
|
57
|
-
"@deepseek-ai/dsh-api-gateway": "^0.2.
|
|
58
|
-
"@deepseek-ai/dsh-api-remotes": "^0.2.
|
|
59
|
-
"@deepseek-ai/dsh-api-session-controller": "^0.2.
|
|
60
|
-
"@deepseek-ai/dsh-api-workspace-controller": "^0.2.
|
|
61
|
-
"@deepseek-ai/dsh-client-connection": "^0.2.
|
|
62
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.
|
|
63
|
-
"@deepseek-ai/dsh-client-store": "^0.2.
|
|
64
|
-
"@deepseek-ai/dsh-client-ui-layout": "^0.2.
|
|
65
|
-
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.
|
|
66
|
-
"@deepseek-ai/dsh-client-ui-settings": "^0.2.
|
|
67
|
-
"@deepseek-ai/dsh-client-ui-sidebar": "^0.2.
|
|
68
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.2.
|
|
69
|
-
"@deepseek-ai/dsh-client-ui-workspace": "^0.2.
|
|
70
|
-
"@deepseek-ai/dsh-commands": "^0.2.
|
|
71
|
-
"@deepseek-ai/dsh-host-webserver": "^0.2.
|
|
72
|
-
"@deepseek-ai/dsh-llm": "^0.2.
|
|
73
|
-
"@deepseek-ai/dsh-settings": "^0.2.
|
|
74
|
-
"@deepseek-ai/dsh-system-prompt": "^0.2.
|
|
75
|
-
"@deepseek-ai/dsh-tools": "^0.2.
|
|
76
|
-
"@deepseek-ai/dsh-workspace": "^0.2.
|
|
53
|
+
"@deepseek-ai/cordis": "~4.2.0-alpha.1",
|
|
54
|
+
"@deepseek-ai/dsh-agent": "^0.2.3-alpha.2",
|
|
55
|
+
"@deepseek-ai/dsh-agent-preset-registry": "^0.2.3-alpha.2",
|
|
56
|
+
"@deepseek-ai/dsh-attachment": "^0.2.3-alpha.2",
|
|
57
|
+
"@deepseek-ai/dsh-api-gateway": "^0.2.3-alpha.2",
|
|
58
|
+
"@deepseek-ai/dsh-api-remotes": "^0.2.3-alpha.2",
|
|
59
|
+
"@deepseek-ai/dsh-api-session-controller": "^0.2.3-alpha.2",
|
|
60
|
+
"@deepseek-ai/dsh-api-workspace-controller": "^0.2.3-alpha.2",
|
|
61
|
+
"@deepseek-ai/dsh-client-connection": "^0.2.3-alpha.2",
|
|
62
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.3-alpha.2",
|
|
63
|
+
"@deepseek-ai/dsh-client-store": "^0.2.3-alpha.2",
|
|
64
|
+
"@deepseek-ai/dsh-client-ui-layout": "^0.2.3-alpha.2",
|
|
65
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.3-alpha.2",
|
|
66
|
+
"@deepseek-ai/dsh-client-ui-settings": "^0.2.3-alpha.2",
|
|
67
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "^0.2.3-alpha.2",
|
|
68
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.2.3-alpha.2",
|
|
69
|
+
"@deepseek-ai/dsh-client-ui-workspace": "^0.2.3-alpha.2",
|
|
70
|
+
"@deepseek-ai/dsh-commands": "^0.2.3-alpha.2",
|
|
71
|
+
"@deepseek-ai/dsh-host-webserver": "^0.2.3-alpha.2",
|
|
72
|
+
"@deepseek-ai/dsh-llm": "^0.2.3-alpha.2",
|
|
73
|
+
"@deepseek-ai/dsh-settings": "^0.2.3-alpha.2",
|
|
74
|
+
"@deepseek-ai/dsh-system-prompt": "^0.2.3-alpha.2",
|
|
75
|
+
"@deepseek-ai/dsh-tools": "^0.2.3-alpha.2",
|
|
76
|
+
"@deepseek-ai/dsh-workspace": "^0.2.3-alpha.2",
|
|
77
77
|
"@types/node": "^22.20.0",
|
|
78
78
|
"@types/react": "~18.3.1",
|
|
79
79
|
"@types/react-dom": "^18.3.5",
|
|
@@ -156,6 +156,7 @@ export function AttachmentField({
|
|
|
156
156
|
onChange,
|
|
157
157
|
limits,
|
|
158
158
|
disabled = false,
|
|
159
|
+
lockedHint,
|
|
159
160
|
onError,
|
|
160
161
|
}: {
|
|
161
162
|
/** What the card currently carries and what is staged on top of it. */
|
|
@@ -166,6 +167,8 @@ export function AttachmentField({
|
|
|
166
167
|
limits?: AttachmentLimits
|
|
167
168
|
/** Whether the field refuses new input. */
|
|
168
169
|
disabled?: boolean
|
|
170
|
+
/** Replaces the inviting upload hint when the caller locks the field. */
|
|
171
|
+
lockedHint?: string
|
|
169
172
|
/** Receives the reason a selection was refused. */
|
|
170
173
|
onError?: (message: string) => void
|
|
171
174
|
}) {
|
|
@@ -275,7 +278,9 @@ export function AttachmentField({
|
|
|
275
278
|
return (
|
|
276
279
|
<div className={css.field} data-dsh-part="form-section">
|
|
277
280
|
<span className={css.fieldLabel}>{t('new.attachments')}</span>
|
|
278
|
-
|
|
281
|
+
{/* When the caller locks the field (an executed card), the inviting
|
|
282
|
+
upload hint is replaced by why the field refuses input. */}
|
|
283
|
+
<span className={css.fieldHint}>{lockedHint ?? t('new.attachmentsHint')}</span>
|
|
279
284
|
<div
|
|
280
285
|
className={css.attachmentDrop}
|
|
281
286
|
// A disabled field is not styled as a drop target: the drag state is
|
|
@@ -113,7 +113,10 @@ export function EditTaskModal({ controller, task, onClose, phase }: { controller
|
|
|
113
113
|
selection={attachments}
|
|
114
114
|
onChange={setAttachments}
|
|
115
115
|
limits={controller.getSnapshot().host?.attachmentLimits}
|
|
116
|
-
|
|
116
|
+
// Attachments freeze at the first run (they are not snapshotted on
|
|
117
|
+
// the execution record); an executed card edits its content only.
|
|
118
|
+
disabled={pending || task.executions.length > 0}
|
|
119
|
+
lockedHint={task.executions.length > 0 ? t('edit.attachmentsLocked') : undefined}
|
|
117
120
|
onError={message => { setAttachmentError(message) }}
|
|
118
121
|
/>
|
|
119
122
|
{attachmentError !== undefined && <p className={css.formError}>{attachmentError}</p>}
|
|
@@ -842,10 +842,25 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
|
|
|
842
842
|
if (!archived) {
|
|
843
843
|
headerActions.push({
|
|
844
844
|
key: 'duplicate',
|
|
845
|
-
|
|
845
|
+
// Label keys on execution history, not editability: an executed card
|
|
846
|
+
// keeps the「duplicate-and-edit」wording even though its content is now
|
|
847
|
+
// directly editable between runs.
|
|
848
|
+
label: current.executions.length === 0 ? t('detail.duplicate') : t('detail.duplicateAndEdit'),
|
|
846
849
|
disabled: pending,
|
|
847
850
|
onSelect: () => { setShowDuplicate(true) },
|
|
848
851
|
})
|
|
852
|
+
// Tags stay directly editable on executed cards (they shape the next
|
|
853
|
+
// run, not the record of what ran); the full edit modal covers them too,
|
|
854
|
+
// this header entry is the shortcut. Keys on execution history so it
|
|
855
|
+
// survives content-edit unlocking instead of turning into dead code.
|
|
856
|
+
if (current.executions.length > 0 && !busy) {
|
|
857
|
+
headerActions.push({
|
|
858
|
+
key: 'editTags',
|
|
859
|
+
label: t('detail.editTags'),
|
|
860
|
+
disabled: pending,
|
|
861
|
+
onSelect: () => { setShowEditTags(true) },
|
|
862
|
+
})
|
|
863
|
+
}
|
|
849
864
|
if (current.status === 'done' || current.status === 'failed') {
|
|
850
865
|
headerActions.push({
|
|
851
866
|
key: 'archive',
|
|
@@ -1073,16 +1088,6 @@ export function TaskDetail({ controller, task, phase = 'open' }: { controller: B
|
|
|
1073
1088
|
{t('detail.edit')}
|
|
1074
1089
|
</button>
|
|
1075
1090
|
)}
|
|
1076
|
-
{!archived && !canEditTaskContent(current) && !busy && (
|
|
1077
|
-
<button
|
|
1078
|
-
type="button"
|
|
1079
|
-
className={css.ghostButton}
|
|
1080
|
-
disabled={pending}
|
|
1081
|
-
onClick={() => { setShowEditTags(true) }}
|
|
1082
|
-
>
|
|
1083
|
-
{t('detail.editTags')}
|
|
1084
|
-
</button>
|
|
1085
|
-
)}
|
|
1086
1091
|
{!archived && (
|
|
1087
1092
|
<button
|
|
1088
1093
|
type="button"
|
package/src/client/locales.ts
CHANGED
|
@@ -159,6 +159,7 @@ export const zh = {
|
|
|
159
159
|
'detail.close': '关闭',
|
|
160
160
|
'edit.title': '编辑任务',
|
|
161
161
|
'edit.save': '保存',
|
|
162
|
+
'edit.attachmentsLocked': '附件已随首次执行固定:执行记录不快照附件,修改请用「复制为新任务」。',
|
|
162
163
|
'new.duplicateTitle': '新建任务(副本)',
|
|
163
164
|
'new.archiveOriginal': '创建后归档原任务',
|
|
164
165
|
'detail.prompt': '执行 Prompt',
|
|
@@ -558,6 +559,7 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
558
559
|
'detail.close': 'Close',
|
|
559
560
|
'edit.title': 'Edit Task',
|
|
560
561
|
'edit.save': 'Save',
|
|
562
|
+
'edit.attachmentsLocked': 'Attachments froze with the first run: execution records do not snapshot attachments; use Duplicate as new copy to change them.',
|
|
561
563
|
'new.duplicateTitle': 'New Task (Copy)',
|
|
562
564
|
'new.archiveOriginal': 'Archive original task upon creation',
|
|
563
565
|
'detail.prompt': 'Run Prompt',
|
package/src/core/store.ts
CHANGED
|
@@ -88,6 +88,8 @@ function isTaskRecordShape(value: unknown): value is Omit<TaskRecord, 'status'>
|
|
|
88
88
|
if (entry.initiatedBy !== undefined && typeof entry.initiatedBy !== 'string') return false
|
|
89
89
|
if (entry.frozenBy !== undefined && typeof entry.frozenBy !== 'string') return false
|
|
90
90
|
if (entry.frozenAt !== undefined && typeof entry.frozenAt !== 'number') return false
|
|
91
|
+
if (entry.promptSnapshot !== undefined && typeof entry.promptSnapshot !== 'string') return false
|
|
92
|
+
if (entry.titleSnapshot !== undefined && typeof entry.titleSnapshot !== 'string') return false
|
|
91
93
|
// An external-outcome marker is optional in BOTH directions: a ledger
|
|
92
94
|
// written before the field existed carries none, and a non-boolean value
|
|
93
95
|
// is dropped by the repair below rather than trusted as provenance.
|
package/src/core/tasks.ts
CHANGED
|
@@ -120,6 +120,15 @@ export interface ExecutionRecord {
|
|
|
120
120
|
frozenAt?: number
|
|
121
121
|
/** Freeze source session captured from the card snapshot when the run opened. */
|
|
122
122
|
frozenBy?: string
|
|
123
|
+
/**
|
|
124
|
+
* The prompt this execution was opened with, captured at run start. The
|
|
125
|
+
* card's prompt stays editable between runs; this snapshot — not the live
|
|
126
|
+
* field — is the record of what actually ran. Absent on executions recorded
|
|
127
|
+
* before snapshots were introduced.
|
|
128
|
+
*/
|
|
129
|
+
promptSnapshot?: string
|
|
130
|
+
/** Title captured alongside {@link promptSnapshot} when the run opened. */
|
|
131
|
+
titleSnapshot?: string
|
|
123
132
|
/**
|
|
124
133
|
* Cascade run group shared by the parent execution and every descendant
|
|
125
134
|
* execution one run request opened. Absent on a plain single-task run.
|
|
@@ -841,6 +850,10 @@ export function startExecution(
|
|
|
841
850
|
frozenAt: task.freeze.frozenAt,
|
|
842
851
|
...(task.freeze.frozenBy === undefined ? {} : { frozenBy: task.freeze.frozenBy }),
|
|
843
852
|
}),
|
|
853
|
+
// Freeze the content this run was opened with; the card may be edited
|
|
854
|
+
// between runs, but history answers from these snapshots, not the card.
|
|
855
|
+
promptSnapshot: task.prompt,
|
|
856
|
+
titleSnapshot: task.title,
|
|
844
857
|
}
|
|
845
858
|
return {
|
|
846
859
|
task: {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* back to the runtime default); an unknown permission string is ignored so
|
|
9
9
|
* stale UI can never persist a value the execution service rejects.
|
|
10
10
|
*/
|
|
11
|
-
import { freezeOf, isTaskPermission, normalizeTags, normalizeTargetId, type TaskRecord, type TaskPermission, type TaskTag } from '../tasks.ts'
|
|
11
|
+
import { freezeOf, hasOpenExecution, isTaskPermission, normalizeTags, normalizeTargetId, type TaskRecord, type TaskPermission, type TaskTag } from '../tasks.ts'
|
|
12
12
|
import { normalizeAttachments, type TaskAttachment } from '../attachment.ts'
|
|
13
13
|
import type { FreezeSnapshot } from '../freeze-snapshot.ts'
|
|
14
14
|
import type { TaskHandoverInput } from '../handover.ts'
|
|
@@ -39,23 +39,19 @@ export type TaskUpdatePatch = Partial<Pick<TaskRecord, 'title' | 'description' |
|
|
|
39
39
|
attachments?: TaskAttachment[] | null
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/** The fields that edit the task's content (what the user reads and what the
|
|
43
|
-
* next execution sends). Unlike the execution targets they stay editable only
|
|
44
|
-
* while the task has never started executing — after the first run the
|
|
45
|
-
* recorded prompt is the record of what actually ran, so it becomes read-only.
|
|
46
|
-
*/
|
|
47
|
-
export const TASK_CONTENT_FIELDS = ['title', 'description', 'prompt'] as const
|
|
48
|
-
|
|
49
42
|
/**
|
|
50
|
-
* The fields that freeze with the
|
|
51
|
-
* the attachments it carries.
|
|
43
|
+
* The fields that freeze with the first run. Split by what keeps them honest:
|
|
52
44
|
*
|
|
53
|
-
* The
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
45
|
+
* - The CONTENT fields stay editable between runs because every execution
|
|
46
|
+
* record captures the prompt/title snapshot it was opened with (see
|
|
47
|
+
* `startExecution`), so a post-run edit changes only the next run, never
|
|
48
|
+
* the audit trail.
|
|
49
|
+
* - The ATTACHMENTS freeze at the first run and stay frozen: they are binary
|
|
50
|
+
* references the record does not snapshot, and a card whose first run
|
|
51
|
+
* already consumed an image keeps that image — the record of what ran
|
|
52
|
+
* stays what it was. `canEditTaskAttachments` owns that boundary.
|
|
58
53
|
*/
|
|
54
|
+
export const TASK_CONTENT_FIELDS = ['title', 'description', 'prompt'] as const
|
|
59
55
|
export const TASK_FROZEN_FIELDS = [...TASK_CONTENT_FIELDS, 'attachments'] as const
|
|
60
56
|
|
|
61
57
|
/** Whether an update patch touches any task-content field. */
|
|
@@ -65,12 +61,26 @@ export function hasContentPatch(patch: TaskUpdatePatch): boolean {
|
|
|
65
61
|
|
|
66
62
|
/**
|
|
67
63
|
* Whether a task's content may still be edited: the task must be on-board
|
|
68
|
-
* (not archived) and must
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
64
|
+
* (not archived) and must not have an open execution. Settled history does
|
|
65
|
+
* NOT lock the card: new execution records carry the prompt/title snapshot
|
|
66
|
+
* they were opened with (`promptSnapshot`/`titleSnapshot`), so a
|
|
67
|
+
* post-run edit changes only the next run, never the audit trail. The run,
|
|
68
|
+
* not the column, stays the trigger: a card parked in 'running' by hand has
|
|
69
|
+
* nothing recorded yet and stays editable, and a card mid-run is locked
|
|
70
|
+
* until its execution settles.
|
|
72
71
|
*/
|
|
73
72
|
export function canEditTaskContent(task: TaskRecord): boolean {
|
|
73
|
+
return task.archivedAt === undefined && !hasOpenExecution(task)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Whether a task's attachments may still be edited: unlike the content
|
|
78
|
+
* fields, attachments are NOT captured on the execution record, so they keep
|
|
79
|
+
* the historical boundary — editable until the first run opens, frozen for
|
|
80
|
+
* every executed or archived card afterwards. The record of what ran keeps
|
|
81
|
+
* referencing exactly what ran.
|
|
82
|
+
*/
|
|
83
|
+
export function canEditTaskAttachments(task: TaskRecord): boolean {
|
|
74
84
|
return task.archivedAt === undefined && task.executions.length === 0
|
|
75
85
|
}
|
|
76
86
|
|
package/src/host-ledger.ts
CHANGED
|
@@ -28,7 +28,7 @@ import { applyDeleteTask } from './core/use-cases/task-delete.ts'
|
|
|
28
28
|
import { applySetSchedule, applyScheduleProgress, applyScheduleRefund, type ScheduleProgress } from './core/use-cases/task-schedule.ts'
|
|
29
29
|
import { applySetParent } from './core/use-cases/task-parent.ts'
|
|
30
30
|
import { applyDeleteTag, applyRenameTag } from './core/use-cases/task-tag.ts'
|
|
31
|
-
import { applyUpdateTask, canEditTaskContent, hasContentPatch } from './core/use-cases/task-update.ts'
|
|
31
|
+
import { applyUpdateTask, canEditTaskAttachments, canEditTaskContent, hasContentPatch } from './core/use-cases/task-update.ts'
|
|
32
32
|
import { TASK_BOARD_MIGRATABLE_SCHEMA_VERSIONS, TASK_BOARD_SCHEMA_VERSION, TASK_BOARD_ZONE_STAMP_SCHEMA_VERSION, type TaskBoardAction, type TaskBoardSchedulerSnapshot } from './protocol.ts'
|
|
33
33
|
import { DEFAULT_SESSION_PERMISSION, requiresPermissionConfirmation, type TaskPermission } from './core/handover.ts'
|
|
34
34
|
import type { TaskBoardLaunchDecision, TaskBoardLaunchHandler, TaskBoardLaunchTrigger } from './core/extension.ts'
|
|
@@ -1244,10 +1244,16 @@ export class HostTaskLedger {
|
|
|
1244
1244
|
const task = this.document.tasks.find(task => task.id === action.taskId)
|
|
1245
1245
|
if (task === undefined) throw new Error('task not found')
|
|
1246
1246
|
if (task.archivedAt !== undefined) throw new Error('archived task is read-only')
|
|
1247
|
-
//
|
|
1248
|
-
//
|
|
1249
|
-
//
|
|
1250
|
-
|
|
1247
|
+
// Attachments keep the historical boundary: they are not captured on
|
|
1248
|
+
// the execution record, so they freeze at the first run and stay
|
|
1249
|
+
// frozen for every executed or archived card afterwards.
|
|
1250
|
+
if ('attachments' in action.patch && !canEditTaskAttachments(task)) {
|
|
1251
|
+
throw new Error('task has already been executed')
|
|
1252
|
+
}
|
|
1253
|
+
// The content fields (title/description/prompt) may change between
|
|
1254
|
+
// runs — each execution record carries the snapshot it was opened
|
|
1255
|
+
// with — but never under an open execution. Execution targets stay
|
|
1256
|
+
// editable throughout (they only affect future runs).
|
|
1251
1257
|
if (hasContentPatch(action.patch) && !canEditTaskContent(task)) {
|
|
1252
1258
|
throw new Error('task has already been executed')
|
|
1253
1259
|
}
|
package/src/protocol.ts
CHANGED
|
@@ -329,6 +329,8 @@ function validImportedKnownFields(value: Record<string, unknown>): boolean {
|
|
|
329
329
|
if (execution.external !== undefined && typeof execution.external !== 'boolean') return false
|
|
330
330
|
if (execution.frozenBy !== undefined && typeof execution.frozenBy !== 'string') return false
|
|
331
331
|
if (execution.frozenAt !== undefined && typeof execution.frozenAt !== 'number') return false
|
|
332
|
+
if (execution.promptSnapshot !== undefined && typeof execution.promptSnapshot !== 'string') return false
|
|
333
|
+
if (execution.titleSnapshot !== undefined && typeof execution.titleSnapshot !== 'string') return false
|
|
332
334
|
}
|
|
333
335
|
}
|
|
334
336
|
return true
|
|
@@ -358,6 +360,8 @@ function importedTask(value: unknown): TaskRecord | undefined {
|
|
|
358
360
|
...(execution.external === true ? { external: true } : {}),
|
|
359
361
|
...(execution.frozenAt === undefined ? {} : { frozenAt: execution.frozenAt }),
|
|
360
362
|
...(execution.frozenBy === undefined ? {} : { frozenBy: execution.frozenBy }),
|
|
363
|
+
...(execution.promptSnapshot === undefined ? {} : { promptSnapshot: execution.promptSnapshot }),
|
|
364
|
+
...(execution.titleSnapshot === undefined ? {} : { titleSnapshot: execution.titleSnapshot }),
|
|
361
365
|
})),
|
|
362
366
|
// The rule was already reconstructed field by field by parseLedger (which
|
|
363
367
|
// is what drops an unknown or malformed field), so the import keeps that
|