nx-kv 0.66.2 → 0.66.3
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/CHANGELOG.md +38 -0
- package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +1 -1
- package/package.json +1 -1
- package/src/core/attachmentdb/ids.ts +14 -1
- package/src/core/attachmentdb/query.ts +0 -38
- package/src/core/attachmentdb/repo.ts +98 -0
- package/src/core/attachmentdb.ts +5 -1
- package/src/core/db/migrations/index.ts +2 -0
- package/src/core/db/migrations/v15.sql +88 -0
- package/src/core/db/version.ts +4 -1
- package/src/modules/claim/assemble.ts +0 -5
- package/src/modules/claim/host.ts +1 -3
- package/src/modules/claim/preview.ts +0 -1
- package/src/modules/docs/actions/docs-detach.ts +1 -2
- package/src/modules/docs/attach.ts +3 -17
- package/src/modules/docs/render.ts +4 -13
- package/src/modules/localtask/actions/localtask-attach.ts +4 -2
- package/src/modules/localtask/actions/localtask-config.ts +2 -11
- package/src/modules/localtask/actions/localtask-detach.ts +1 -3
- package/src/modules/localtask/infra/repo/settings.ts +1 -9
- package/src/modules/localtask/lifecycle/task-templates.ts +0 -13
- package/src/modules/localtask/lifecycle/topics.ts +3 -6
- package/src/modules/localtask/ops/attach-resource.ts +46 -4
- package/src/modules/localtask/ops/attach-template.ts +73 -3
- package/src/modules/localtask/ops/attach.ts +45 -18
- package/src/modules/localtask/ui/action-render.ts +3 -12
- package/src/modules/promptplug/compose.ts +1 -3
- package/src/modules/promptplug/plugins/attachment.ts +56 -6
- package/src/modules/promptplug/plugins/context.ts +11 -2
- package/src/modules/promptplug/template-store.ts +25 -3
- package/src/shared/prompt-blocks.ts +2 -23
- package/src/web/frontend/api/cli-tree.json +4 -4
- package/src/web/frontend/api/client.generated.ts +8 -8
- package/src/web/frontend/api/tasks.ts +117 -0
- package/src/web/frontend/components/Introduction/index.tsx +50 -3
- package/src/web/frontend/components/Introduction/style.css +6 -0
- package/src/web/frontend/components/Introduction/use-intro.ts +25 -0
- package/src/web/frontend/components/md/attachments/attach-area.tsx +9 -11
- package/src/web/frontend/components/md/attachments/attach-common.ts +12 -5
- package/src/web/frontend/components/md/attachments/attach-modal.tsx +54 -9
- package/src/web/frontend/components/md/attachments/attach-repo-pick.tsx +48 -0
- package/src/web/frontend/components/sidebar/task-children.tsx +14 -11
- package/src/web/frontend/{page/dir → components/task-panel}/dag-editor.tsx +1 -1
- package/src/web/frontend/components/task-panel/task-ops.ts +299 -0
- package/src/web/frontend/components/task-panel/task-page.tsx +495 -0
- package/src/web/frontend/components/tool-acts/modules.ts +3 -0
- package/src/web/frontend/page/dir/api.ts +4 -108
- package/src/web/frontend/page/dir/index.tsx +148 -331
- package/src/web/frontend/page/dir/task-board-section.tsx +3 -0
- package/src/web/frontend/page/dir/task-dock-panel.tsx +1 -1
- package/src/web/frontend/page/dir/task.tsx +1 -1
- package/src/web/frontend/page/doc/doc-dock.tsx +1 -1
- package/src/web/frontend/page/group/api.ts +3 -21
- package/src/web/frontend/page/group/group-project-memo.ts +41 -0
- package/src/web/frontend/page/group/index.tsx +287 -426
- package/src/web/frontend/page/settings/api.ts +1 -2
- package/src/web/frontend/page/settings/prompt-templates-section.tsx +12 -44
- package/src/web/public/assets/{bar-Dy_QDX2h.js → bar-D7cWe7Kp.js} +1 -1
- package/src/web/public/assets/{composer-launch-B7DH53Yf.js → composer-launch--nJGFG35.js} +1 -1
- package/src/web/public/assets/{composer-panel-Cj1J16r-.js → composer-panel-Dhivt7UJ.js} +1 -1
- package/src/web/public/assets/{dag-DXRPHVl8.js → dag-DUhHxgTk.js} +1 -1
- package/src/web/public/assets/dir-CkYGYT9e.js +1 -0
- package/src/web/public/assets/doc-DgYKv2wo.css +1 -0
- package/src/web/public/assets/doc-QBHQi1EV.js +6 -0
- package/src/web/public/assets/group-CfJxWA7V.js +1 -0
- package/src/web/public/assets/group-project-memo-G-O6sPRw.js +1 -0
- package/src/web/public/assets/index-ByAPGidL.js +3 -0
- package/src/web/public/assets/{list-filter-CWxiOSg_.js → list-search-B2S2g8kn.js} +1 -1
- package/src/web/public/assets/md-history-DdM6P9Gq.js +47 -0
- package/src/web/public/assets/{progress-MPse2JLQ.js → progress-BVpSy-uF.js} +1 -1
- package/src/web/public/assets/refs-CCZgGPlL.js +2 -0
- package/src/web/public/assets/reopen-text-BC9a8KOp.js +13 -0
- package/src/web/public/assets/{repo-form-modal-CNLYR12c.js → repo-form-modal-D8WabN0R.js} +1 -1
- package/src/web/public/assets/{repos-BGx-yAXd.js → repos-V5xb5Kz-.js} +9 -9
- package/src/web/public/assets/settings-CAOSCF3E.js +1 -0
- package/src/web/public/assets/task-BwWlNP0i.js +13 -0
- package/src/web/public/assets/task-ops-DZgza5eZ.js +2 -0
- package/src/web/public/assets/task-utils--WIpAwUx.js +1 -0
- package/src/web/public/assets/{templates-Co1Qb1aA.js → templates-6ClSnYJN.js} +3 -3
- package/src/web/public/assets/{tool-bar-D5wLBLRl.js → tool-bar-BYdfBQeo.js} +1 -1
- package/src/web/public/assets/use-rail-drag-BMXJ48je.js +1 -0
- package/src/web/public/index.html +8 -8
- package/src/web/frontend/page/dir/landing.tsx +0 -553
- package/src/web/public/assets/dir-_M1ciSxM.js +0 -3
- package/src/web/public/assets/doc-Iuxssa-b.css +0 -1
- package/src/web/public/assets/doc-_iteSM2X.js +0 -6
- package/src/web/public/assets/get-loop-modal-DlAfqJMz.js +0 -2
- package/src/web/public/assets/group-CH8qe-eg.js +0 -1
- package/src/web/public/assets/index-Cui4IuGj.js +0 -3
- package/src/web/public/assets/md-history-Bj790fdn.js +0 -46
- package/src/web/public/assets/refs-DiIPoqnJ.js +0 -2
- package/src/web/public/assets/settings-Pt4YgGdY.js +0 -1
- package/src/web/public/assets/task-DOIIpQ4X.js +0 -13
- package/src/web/public/assets/task-utils-CJfMODCP.js +0 -13
- package/src/web/public/assets/use-rail-drag-CNOHXWng.js +0 -1
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
// 任务页模板(#251):目录任务页(page/dir)与项目组页(page/group)共用的**整页交互**。
|
|
2
|
+
//
|
|
3
|
+
// 基线是目录页:用户口径「先读 dir 的所有样式 / 交互 / 按钮,再抽成模板,两页复用」。
|
|
4
|
+
// 抽离前两页各写一遍容器与交互——组页缺多选 / 批量条 / 行尾菜单 / 导入 / 草稿态,
|
|
5
|
+
// 目录页缺组页的项目 tag 语义,改一处另一处就漂。现在两页只交数据与动作:
|
|
6
|
+
//
|
|
7
|
+
// rp-page
|
|
8
|
+
// ├ rp-group-head 标题 + 计数 chips + 工具区(ToolActsBar:新建 / 导入 / 进程 / 编排 /
|
|
9
|
+
// │ 草稿态 / 更多;两页同一套按钮与文案,差别只在 kind 的模块表)
|
|
10
|
+
// ├ intro 简介槽(目录 = 项目介绍,组 = 组介绍)
|
|
11
|
+
// ├ batch 批量条(选中后出现:标为完成 / 取消 / 删除 / 清空)
|
|
12
|
+
// ├ list TaskPanel:搜索框 + 全选本页 + 任务行(多选 / 拖把 / 行尾 ⋯)
|
|
13
|
+
// └ footer 翻页条
|
|
14
|
+
//
|
|
15
|
+
// 模板自己持有:搜索串、当前页、多选集合、拖拽视觉态、模板下拉菜单。
|
|
16
|
+
// 调用方持有:行数据(已排好显示序)、每行的 scope 语义、以及所有落盘动作。
|
|
17
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
18
|
+
import type { DragEvent as ReactDragEvent, MouseEvent as ReactMouseEvent, ReactNode } from 'react';
|
|
19
|
+
import { Icon } from '../icons.jsx';
|
|
20
|
+
import Pager, { usePager } from '../pager.jsx';
|
|
21
|
+
import { PopMenu, RowMenu } from '../popup/index.jsx';
|
|
22
|
+
import type { PopMenuItem, RowMenuItem } from '../popup/index.jsx';
|
|
23
|
+
import ToolActsBar from '../tool-acts/bar.jsx';
|
|
24
|
+
import { useToast } from '../toast/index.jsx';
|
|
25
|
+
import TaskPanel from './index.jsx';
|
|
26
|
+
import TaskPanelLayout from './layout.jsx';
|
|
27
|
+
import TaskRow from './task-row.jsx';
|
|
28
|
+
import { contextOf, hitTaskQuery } from '../../modules/board/task-search.js';
|
|
29
|
+
import type { LocalTask } from '../../types.js';
|
|
30
|
+
|
|
31
|
+
/** 列表每页条数(两页同值:20)。 */
|
|
32
|
+
const PAGE_SIZE = 20;
|
|
33
|
+
|
|
34
|
+
/** 一行任务:任务本体 + 这一页给它加的行级语义。 */
|
|
35
|
+
export interface TaskPageRow {
|
|
36
|
+
/** 行 key(组页同号任务会跨成员队列,key 必须带队列维度) */
|
|
37
|
+
key: string;
|
|
38
|
+
task: LocalTask;
|
|
39
|
+
/** 归属项目 tag(组页用;目录页不传) */
|
|
40
|
+
projectTag?: string;
|
|
41
|
+
/** 项目 tag 悬浮说明 */
|
|
42
|
+
projectTitle?: string;
|
|
43
|
+
/** 闸门挡住的下游任务 id */
|
|
44
|
+
downs?: Array<number | string>;
|
|
45
|
+
/** 行内显示 创建→领取 时间(目录页基线:传 true) */
|
|
46
|
+
showTimes?: boolean;
|
|
47
|
+
/** 可拖动排序(= 队列里的待领取任务;同时决定行尾的编排 / 闸门入口) */
|
|
48
|
+
movable?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 工具区透传面(kind 决定模块表;new / import / plan 由模板接管)。 */
|
|
52
|
+
export interface TaskPageToolActs {
|
|
53
|
+
labels?: Record<string, string | undefined>;
|
|
54
|
+
titles?: Record<string, string | undefined>;
|
|
55
|
+
disabled?: Record<string, boolean | undefined>;
|
|
56
|
+
renderers?: Record<string, ((ctx: { open: boolean }) => ReactNode) | undefined>;
|
|
57
|
+
actions?: Record<string, ((e?: ReactMouseEvent<HTMLButtonElement>) => void) | undefined>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface TaskPageProps {
|
|
61
|
+
/** 工具区模块表种类(dir / group) */
|
|
62
|
+
kind: 'dir' | 'group';
|
|
63
|
+
/** 页头主体名(目录名 / 组名) */
|
|
64
|
+
name: string;
|
|
65
|
+
/** 任务面板标题(「任务」/「本组任务」) */
|
|
66
|
+
title: string;
|
|
67
|
+
/** 全量行(已按显示序排好;搜索 / 分页由模板做) */
|
|
68
|
+
rows: TaskPageRow[];
|
|
69
|
+
/** 无搜索时的空态文案(搜索零命中的文案由模板拼) */
|
|
70
|
+
emptyText: string;
|
|
71
|
+
/** 简介槽 */
|
|
72
|
+
intro?: ReactNode;
|
|
73
|
+
/** 头部计数 chips 的**额外**项(对齐口径:任务数 / 待领取由模板出,页面只加自己的) */
|
|
74
|
+
extraCounts?: string[];
|
|
75
|
+
/** 工具区额外节点(如持续 get 的成员子菜单与配置弹窗) */
|
|
76
|
+
actionExtra?: ReactNode;
|
|
77
|
+
toolActs?: TaskPageToolActs;
|
|
78
|
+
/** 「+ 新建页」主区点击 */
|
|
79
|
+
onNew: () => void;
|
|
80
|
+
/** 新建按钮禁用(组页没有成员时不可建任务) */
|
|
81
|
+
newDisabled?: boolean;
|
|
82
|
+
/** 「+ 新建页」▾ 的模板菜单 */
|
|
83
|
+
tplMenuItems: Array<PopMenuItem | string>;
|
|
84
|
+
/** 点行 / 回车打开任务 */
|
|
85
|
+
onOpenRow: (row: TaskPageRow) => void;
|
|
86
|
+
/** 拖动排序落盘(落点只有 before / after) */
|
|
87
|
+
onMoveRow?: (src: TaskPageRow, dst: TaskPageRow, zone: 'before' | 'after') => void;
|
|
88
|
+
/** 「导入」选中 .md 后的落地 */
|
|
89
|
+
onImportFile?: (file: File) => void;
|
|
90
|
+
/** 草稿态切换(行尾单条 / 批量条都会走这里) */
|
|
91
|
+
onTogglePlan?: (rows: TaskPageRow[], to: 'plan' | 'pending') => void;
|
|
92
|
+
/** 行尾「编排依赖…」 */
|
|
93
|
+
onOpenDag?: (row: TaskPageRow) => void;
|
|
94
|
+
/** 行尾闸门开关 */
|
|
95
|
+
onToggleGate?: (row: TaskPageRow) => void;
|
|
96
|
+
/** 行尾反馈 */
|
|
97
|
+
onFeedback?: (row: TaskPageRow) => void;
|
|
98
|
+
/** 行尾单条删除 */
|
|
99
|
+
onDeleteRow?: (row: TaskPageRow) => void;
|
|
100
|
+
/** 批量:删除 / 取消 / 标为完成(返回真值则清空选择) */
|
|
101
|
+
onDeleteRows?: (rows: TaskPageRow[]) => Promise<unknown>;
|
|
102
|
+
onCancelRows?: (rows: TaskPageRow[]) => Promise<unknown>;
|
|
103
|
+
onCompleteRows?: (rows: TaskPageRow[]) => Promise<unknown>;
|
|
104
|
+
/** 页面级弹层(编排编辑器、成员选择器等) */
|
|
105
|
+
extra?: ReactNode;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** 拖动落点:行上半 = 之前,下半 = 之后。 */
|
|
109
|
+
type DropZone = 'before' | 'after';
|
|
110
|
+
|
|
111
|
+
export default function TaskPage({
|
|
112
|
+
kind,
|
|
113
|
+
name,
|
|
114
|
+
title,
|
|
115
|
+
rows,
|
|
116
|
+
emptyText,
|
|
117
|
+
intro = null,
|
|
118
|
+
extraCounts = [],
|
|
119
|
+
actionExtra = null,
|
|
120
|
+
toolActs = {},
|
|
121
|
+
onNew,
|
|
122
|
+
newDisabled = false,
|
|
123
|
+
tplMenuItems,
|
|
124
|
+
onOpenRow,
|
|
125
|
+
onMoveRow,
|
|
126
|
+
onImportFile,
|
|
127
|
+
onTogglePlan,
|
|
128
|
+
onOpenDag,
|
|
129
|
+
onToggleGate,
|
|
130
|
+
onFeedback,
|
|
131
|
+
onDeleteRow,
|
|
132
|
+
onDeleteRows,
|
|
133
|
+
onCancelRows,
|
|
134
|
+
onCompleteRows,
|
|
135
|
+
extra = null,
|
|
136
|
+
}: TaskPageProps) {
|
|
137
|
+
const toast = useToast();
|
|
138
|
+
const fileRef = useRef<HTMLInputElement | null>(null);
|
|
139
|
+
const [tplMenu, setTplMenu] = useState<{ x?: number; y?: number } | null>(null);
|
|
140
|
+
|
|
141
|
+
// ─── 搜索 + 分页(两页同一口径:标题与正文都搜,见 modules/board/task-search) ───
|
|
142
|
+
const [q, setQ] = useState('');
|
|
143
|
+
const searching = !!String(q).trim();
|
|
144
|
+
const shown = useMemo(
|
|
145
|
+
() => (searching ? rows.filter((r) => hitTaskQuery({ id: r.task.id, text: r.task.text }, q)) : rows),
|
|
146
|
+
[rows, q, searching],
|
|
147
|
+
);
|
|
148
|
+
// 待领取计数跟着**筛后**集合走:搜索时头部数字要与屏幕上的行对得上
|
|
149
|
+
const pendingCount = useMemo(
|
|
150
|
+
() => shown.filter((r) => r.task.status === 'pending' && !r.task.migratedTo).length,
|
|
151
|
+
[shown],
|
|
152
|
+
);
|
|
153
|
+
const pager = usePager(shown, PAGE_SIZE);
|
|
154
|
+
// 改查询串回第一页(否则停在「上一结果的第 3 页」,看起来像没命中)
|
|
155
|
+
useEffect(() => {
|
|
156
|
+
pager.setPage(0);
|
|
157
|
+
}, [q]);
|
|
158
|
+
|
|
159
|
+
// ─── 多选 + 批量条 ─────────────────────────────────────────────
|
|
160
|
+
const [picked, setPicked] = useState<Set<string>>(() => new Set());
|
|
161
|
+
const pageRows = pager.items;
|
|
162
|
+
const pageKeys = pageRows.map((r) => r.key);
|
|
163
|
+
const allPicked = pageKeys.length > 0 && pageKeys.every((k) => picked.has(k));
|
|
164
|
+
// 翻页后清空选择,避免批量操作跨页误伤看不到的行
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
setPicked(new Set());
|
|
167
|
+
}, [pager.page]);
|
|
168
|
+
const pickedRows = rows.filter((r) => picked.has(r.key));
|
|
169
|
+
// #184:标为完成对「未结束」任务开放(待领取 + 已领取);取消只给待领取
|
|
170
|
+
const doneTargets = pickedRows.filter(
|
|
171
|
+
(r) =>
|
|
172
|
+
(r.task.status === 'pending' || r.task.status === 'claimed') && !r.task.migratedTo && !r.task.deletedAt,
|
|
173
|
+
);
|
|
174
|
+
const cancelTargets = pickedRows.filter(
|
|
175
|
+
(r) => r.task.status === 'pending' && !r.task.migratedTo && !r.task.deletedAt,
|
|
176
|
+
);
|
|
177
|
+
const claimedPicked = doneTargets.filter((r) => r.task.status === 'claimed').length;
|
|
178
|
+
const togglePick = (key: string) => {
|
|
179
|
+
setPicked((prev) => {
|
|
180
|
+
const next = new Set(prev);
|
|
181
|
+
if (next.has(key)) next.delete(key);
|
|
182
|
+
else next.add(key);
|
|
183
|
+
return next;
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
const togglePickAll = () => {
|
|
187
|
+
setPicked((prev) => {
|
|
188
|
+
const next = new Set(prev);
|
|
189
|
+
if (allPicked) pageKeys.forEach((k) => next.delete(k));
|
|
190
|
+
else pageKeys.forEach((k) => next.add(k));
|
|
191
|
+
return next;
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
const runBatch = async (fn?: (rs: TaskPageRow[]) => Promise<unknown>) => {
|
|
195
|
+
if (!pickedRows.length || !fn) return;
|
|
196
|
+
const ok = await fn(pickedRows);
|
|
197
|
+
if (ok) setPicked(new Set());
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// ─── 草稿态(pending ↔ plan):批量条不设按钮,走工具区「草稿态」+ 行尾菜单 ───
|
|
201
|
+
const toPlan = pickedRows.filter((r) => r.task.status === 'pending');
|
|
202
|
+
const toPending = pickedRows.filter((r) => r.task.status === 'plan');
|
|
203
|
+
const planTargets = toPlan.length ? toPlan : toPending;
|
|
204
|
+
const planTo: 'plan' | 'pending' = toPlan.length ? 'plan' : 'pending';
|
|
205
|
+
const planLabel = pickedRows.length
|
|
206
|
+
? planTo === 'plan'
|
|
207
|
+
? `转草稿 (${toPlan.length})`
|
|
208
|
+
: `转回待领取 (${toPending.length})`
|
|
209
|
+
: '草稿态';
|
|
210
|
+
|
|
211
|
+
// ─── 拖动排序(HTML5 DnD,只在可移动行之间换位)────────────────────
|
|
212
|
+
// 拖拽态走 **ref**:dragstart / dragover 间隔只有几毫秒,state 那一拍会读到旧值
|
|
213
|
+
const dragRef = useRef<string | null>(null);
|
|
214
|
+
const [dragKey, setDragKey] = useState<string | null>(null);
|
|
215
|
+
const [dropAt, setDropAt] = useState<{ key: string; zone: DropZone } | null>(null);
|
|
216
|
+
const zoneOf = (e: ReactDragEvent<HTMLElement>, el: HTMLElement): DropZone => {
|
|
217
|
+
const r = el.getBoundingClientRect();
|
|
218
|
+
return e.clientY < r.top + r.height / 2 ? 'before' : 'after';
|
|
219
|
+
};
|
|
220
|
+
const onDragStart = (e: ReactDragEvent<HTMLElement>, r: TaskPageRow) => {
|
|
221
|
+
dragRef.current = r.key;
|
|
222
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
223
|
+
e.dataTransfer.setData('text/plain', 'task:' + r.task.id);
|
|
224
|
+
setDragKey(r.key);
|
|
225
|
+
};
|
|
226
|
+
const onDragOver = (e: ReactDragEvent<HTMLElement>, r: TaskPageRow) => {
|
|
227
|
+
if (!dragRef.current || !r.movable || r.key === dragRef.current) return;
|
|
228
|
+
e.preventDefault();
|
|
229
|
+
e.dataTransfer.dropEffect = 'move';
|
|
230
|
+
setDropAt({ key: r.key, zone: zoneOf(e, e.currentTarget) });
|
|
231
|
+
};
|
|
232
|
+
const onDragLeave = (e: ReactDragEvent<HTMLElement>) => {
|
|
233
|
+
// 行内子元素之间移动也会触发 dragleave:真离开整行才清指示
|
|
234
|
+
if (e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget)) return;
|
|
235
|
+
setDropAt(null);
|
|
236
|
+
};
|
|
237
|
+
const onDrop = (e: ReactDragEvent<HTMLElement>, r: TaskPageRow) => {
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
const zone = zoneOf(e, e.currentTarget);
|
|
240
|
+
const fromKey = dragRef.current;
|
|
241
|
+
dragRef.current = null;
|
|
242
|
+
setDragKey(null);
|
|
243
|
+
setDropAt(null);
|
|
244
|
+
if (!fromKey || !r.movable || r.key === fromKey) return;
|
|
245
|
+
const src = rows.find((x) => x.key === fromKey);
|
|
246
|
+
if (src && onMoveRow) onMoveRow(src, r, zone);
|
|
247
|
+
};
|
|
248
|
+
const onDragEnd = () => {
|
|
249
|
+
dragRef.current = null;
|
|
250
|
+
setDragKey(null);
|
|
251
|
+
setDropAt(null);
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// ─── 行尾 ⋯ 菜单(两页同一套条目与文案;动作由调用方给)───────────────
|
|
255
|
+
const menuOf = (r: TaskPageRow): Array<RowMenuItem | null | false> => {
|
|
256
|
+
const t = r.task;
|
|
257
|
+
return [
|
|
258
|
+
(t.status === 'pending' || t.status === 'plan') && onTogglePlan
|
|
259
|
+
? {
|
|
260
|
+
label: t.status === 'pending' ? '转为草稿(不进队列)' : '转回待领取',
|
|
261
|
+
onPick: () => onTogglePlan([r], t.status === 'pending' ? 'plan' : 'pending'),
|
|
262
|
+
}
|
|
263
|
+
: null,
|
|
264
|
+
r.movable && onOpenDag ? { label: '编排依赖…', onPick: () => onOpenDag(r) } : null,
|
|
265
|
+
r.movable && onToggleGate
|
|
266
|
+
? {
|
|
267
|
+
label: t.blocksFollowing ? '取消闸门(不再挡后续)' : '设为闸门(挡住后续)',
|
|
268
|
+
onPick: () => onToggleGate(r),
|
|
269
|
+
}
|
|
270
|
+
: null,
|
|
271
|
+
// #144 反馈只在链尖:已有派生子任务的旧轮次不再给入口(否则把链分叉)
|
|
272
|
+
onFeedback && t.status !== 'cancelled' && !t.childCount && (t.status === 'claimed' || t.status === 'done' || t.completedAt)
|
|
273
|
+
? {
|
|
274
|
+
label: t.completedAt ? '反馈:新开一条任务(原任务不动)' : '反馈修改:回写本任务并记入任务链',
|
|
275
|
+
onPick: () => onFeedback(r),
|
|
276
|
+
}
|
|
277
|
+
: null,
|
|
278
|
+
onDeleteRow ? { label: '删除此任务(软删除,CLI 可恢复)', danger: true, onPick: () => onDeleteRow(r) } : null,
|
|
279
|
+
];
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
// ─── 批量条(选中后出现;块序与样式与目录页原实现一致)───────────────
|
|
283
|
+
const batchBar = pickedRows.length > 0 ? (
|
|
284
|
+
<div className="mdw-land-batch">
|
|
285
|
+
<span className="mdw-land-batch-count">已选 {pickedRows.length} 条</span>
|
|
286
|
+
{onCompleteRows && (
|
|
287
|
+
<button
|
|
288
|
+
type="button"
|
|
289
|
+
className="btn ghost sm"
|
|
290
|
+
disabled={!doneTargets.length}
|
|
291
|
+
title={
|
|
292
|
+
doneTargets.length
|
|
293
|
+
? `把选中的未结束任务标为已完成(补一条完成记录,原文留档)${claimedPicked ? `;其中 ${claimedPicked} 条已被领取,会直接收口,agent 侧回执忽略` : ''}`
|
|
294
|
+
: '选中的任务都已结束,没有可标为完成的'
|
|
295
|
+
}
|
|
296
|
+
onClick={() => void runBatch(onCompleteRows)}
|
|
297
|
+
>
|
|
298
|
+
标为完成选中{doneTargets.length ? ` (${doneTargets.length})` : ''}
|
|
299
|
+
</button>
|
|
300
|
+
)}
|
|
301
|
+
{onCancelRows && (
|
|
302
|
+
<button
|
|
303
|
+
type="button"
|
|
304
|
+
className="btn ghost sm"
|
|
305
|
+
disabled={!cancelTargets.length}
|
|
306
|
+
title={
|
|
307
|
+
cancelTargets.length
|
|
308
|
+
? '把选中的待领取任务标为已取消(终态,原文留档)'
|
|
309
|
+
: '只有待领取任务可以取消(已领取的交给 agent 回执)'
|
|
310
|
+
}
|
|
311
|
+
onClick={() => void runBatch(onCancelRows)}
|
|
312
|
+
>
|
|
313
|
+
取消选中{cancelTargets.length ? ` (${cancelTargets.length})` : ''}
|
|
314
|
+
</button>
|
|
315
|
+
)}
|
|
316
|
+
{onDeleteRows && (
|
|
317
|
+
<button type="button" className="btn ghost sm danger" onClick={() => void runBatch(onDeleteRows)}>
|
|
318
|
+
删除选中 ({pickedRows.length})
|
|
319
|
+
</button>
|
|
320
|
+
)}
|
|
321
|
+
<button type="button" className="btn ghost sm" onClick={() => setPicked(new Set())}>
|
|
322
|
+
清空
|
|
323
|
+
</button>
|
|
324
|
+
</div>
|
|
325
|
+
) : null;
|
|
326
|
+
|
|
327
|
+
// ─── 列表 ───────────────────────────────────────────────────────
|
|
328
|
+
const listPanel = (
|
|
329
|
+
<TaskPanel
|
|
330
|
+
title={title}
|
|
331
|
+
pendingCount={pendingCount}
|
|
332
|
+
headerExtra={
|
|
333
|
+
<span className="rp-tasks-tools">
|
|
334
|
+
<input
|
|
335
|
+
className="rp-task-search"
|
|
336
|
+
type="search"
|
|
337
|
+
value={q}
|
|
338
|
+
placeholder="搜索标题 / 内容"
|
|
339
|
+
aria-label="搜索任务"
|
|
340
|
+
onChange={(e) => setQ(e.target.value)}
|
|
341
|
+
/>
|
|
342
|
+
{pageRows.length ? (
|
|
343
|
+
<label className="rp-proj-pickall" title="全选/取消全选当前页">
|
|
344
|
+
<input type="checkbox" checked={allPicked} onChange={togglePickAll} aria-label="全选当前页任务" />
|
|
345
|
+
全选本页
|
|
346
|
+
</label>
|
|
347
|
+
) : null}
|
|
348
|
+
</span>
|
|
349
|
+
}
|
|
350
|
+
emptyText={
|
|
351
|
+
searching
|
|
352
|
+
? `没有匹配「${q.trim()}」的任务(标题与正文都搜过了)`
|
|
353
|
+
: emptyText
|
|
354
|
+
}
|
|
355
|
+
>
|
|
356
|
+
{pageRows.map((r) => {
|
|
357
|
+
const handlers = r.movable
|
|
358
|
+
? {
|
|
359
|
+
onDragStart: (e: ReactDragEvent<HTMLElement>) => onDragStart(e, r),
|
|
360
|
+
onDragOver: (e: ReactDragEvent<HTMLElement>) => onDragOver(e, r),
|
|
361
|
+
onDragLeave: onDragLeave,
|
|
362
|
+
onDrop: (e: ReactDragEvent<HTMLElement>) => onDrop(e, r),
|
|
363
|
+
onDragEnd: onDragEnd,
|
|
364
|
+
}
|
|
365
|
+
: null;
|
|
366
|
+
return (
|
|
367
|
+
<TaskRow
|
|
368
|
+
key={r.key}
|
|
369
|
+
t={r.task}
|
|
370
|
+
projectTag={r.projectTag}
|
|
371
|
+
projectTitle={r.projectTitle}
|
|
372
|
+
searchCtx={searching ? contextOf(r.task, q) : null}
|
|
373
|
+
selectable
|
|
374
|
+
picked={picked.has(r.key)}
|
|
375
|
+
onTogglePick={() => togglePick(r.key)}
|
|
376
|
+
draggable={!!r.movable}
|
|
377
|
+
dragHandlers={handlers}
|
|
378
|
+
dragVisual={{ dragging: dragKey === r.key, drop: dropAt && dropAt.key === r.key ? dropAt.zone : null }}
|
|
379
|
+
showTimes={r.showTimes}
|
|
380
|
+
downs={r.downs}
|
|
381
|
+
onOpen={() => onOpenRow(r)}
|
|
382
|
+
ops={<RowMenu items={menuOf(r)} />}
|
|
383
|
+
/>
|
|
384
|
+
);
|
|
385
|
+
})}
|
|
386
|
+
</TaskPanel>
|
|
387
|
+
);
|
|
388
|
+
|
|
389
|
+
const footerBar = pager.total > 0 ? (
|
|
390
|
+
<div className="mdw-land-pager">
|
|
391
|
+
<Pager page={pager.page} pageCount={pager.pageCount} total={pager.total} onPage={pager.setPage} unit="个任务" />
|
|
392
|
+
</div>
|
|
393
|
+
) : null;
|
|
394
|
+
|
|
395
|
+
// ─── 工具区:new / import / plan 由模板接管,其余(进程 / 编排 / 更多…)由页面给 ───
|
|
396
|
+
const openTplMenu = (e: { type: string; clientX?: number; clientY?: number }) => {
|
|
397
|
+
setTplMenu({ x: e.clientX, y: e.clientY });
|
|
398
|
+
};
|
|
399
|
+
const newButton = () => (
|
|
400
|
+
<span className="rp-newtask">
|
|
401
|
+
<button
|
|
402
|
+
type="button"
|
|
403
|
+
className="btn small primary"
|
|
404
|
+
title="按默认模板新建一页(▾ 选模板)"
|
|
405
|
+
disabled={newDisabled}
|
|
406
|
+
onClick={() => onNew()}
|
|
407
|
+
>
|
|
408
|
+
+ 新建页
|
|
409
|
+
<span
|
|
410
|
+
role="button"
|
|
411
|
+
tabIndex={newDisabled ? undefined : 0}
|
|
412
|
+
aria-label="选择模板新建一页"
|
|
413
|
+
aria-haspopup="menu"
|
|
414
|
+
className="rp-newtask-caret"
|
|
415
|
+
title="选择模板新建一页"
|
|
416
|
+
onClick={(e) => {
|
|
417
|
+
e.stopPropagation();
|
|
418
|
+
openTplMenu(e);
|
|
419
|
+
}}
|
|
420
|
+
onKeyDown={(e) => {
|
|
421
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
422
|
+
e.preventDefault();
|
|
423
|
+
e.stopPropagation();
|
|
424
|
+
openTplMenu(e);
|
|
425
|
+
}
|
|
426
|
+
}}
|
|
427
|
+
>
|
|
428
|
+
<Icon name="chevron" size={11} title={undefined} />
|
|
429
|
+
</span>
|
|
430
|
+
</button>
|
|
431
|
+
</span>
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
return (
|
|
435
|
+
<>
|
|
436
|
+
<TaskPanelLayout
|
|
437
|
+
name={name}
|
|
438
|
+
counts={[
|
|
439
|
+
`${searching ? '命中 ' : ''}${pager.total} 个任务`,
|
|
440
|
+
...(pendingCount > 0 ? [`待领取 ${pendingCount}`] : []),
|
|
441
|
+
...extraCounts,
|
|
442
|
+
]}
|
|
443
|
+
intro={intro}
|
|
444
|
+
batch={batchBar}
|
|
445
|
+
list={listPanel}
|
|
446
|
+
footer={footerBar}
|
|
447
|
+
actions={
|
|
448
|
+
<>
|
|
449
|
+
<ToolActsBar
|
|
450
|
+
kind={kind}
|
|
451
|
+
labels={{ more: '更多', ...toolActs.labels, plan: planLabel }}
|
|
452
|
+
titles={{
|
|
453
|
+
new: '按默认模板新建一页(▾ 选模板)',
|
|
454
|
+
import: '把一个 .md 文件导入成任务',
|
|
455
|
+
plan: '选中任务后:待领取 ↔ 草稿(草稿不进 get/wait 队列;行尾 ⋯ 菜单也能单条切换)',
|
|
456
|
+
...toolActs.titles,
|
|
457
|
+
}}
|
|
458
|
+
disabled={toolActs.disabled}
|
|
459
|
+
renderers={{ new: newButton, ...toolActs.renderers }}
|
|
460
|
+
actions={{
|
|
461
|
+
...toolActs.actions,
|
|
462
|
+
new: () => onNew(),
|
|
463
|
+
import: () => fileRef.current?.click(),
|
|
464
|
+
plan: () => {
|
|
465
|
+
if (!planTargets.length) {
|
|
466
|
+
toast('先勾选任务:待领取可转草稿,草稿可转回待领取(行尾 ⋯ 菜单也能单条切换)');
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
onTogglePlan?.(planTargets, planTo);
|
|
470
|
+
},
|
|
471
|
+
}}
|
|
472
|
+
/>
|
|
473
|
+
{actionExtra}
|
|
474
|
+
</>
|
|
475
|
+
}
|
|
476
|
+
/>
|
|
477
|
+
|
|
478
|
+
{tplMenu && <PopMenu x={tplMenu.x} y={tplMenu.y} items={tplMenuItems} onClose={() => setTplMenu(null)} />}
|
|
479
|
+
|
|
480
|
+
<input
|
|
481
|
+
ref={fileRef}
|
|
482
|
+
type="file"
|
|
483
|
+
accept=".md,text/markdown,text/plain"
|
|
484
|
+
hidden
|
|
485
|
+
onChange={(e) => {
|
|
486
|
+
const f = e.target.files?.[0];
|
|
487
|
+
e.target.value = '';
|
|
488
|
+
if (f && onImportFile) onImportFile(f);
|
|
489
|
+
}}
|
|
490
|
+
/>
|
|
491
|
+
|
|
492
|
+
{extra}
|
|
493
|
+
</>
|
|
494
|
+
);
|
|
495
|
+
}
|
|
@@ -44,9 +44,12 @@ export const DIR_MODULES: ToolModule[] = [
|
|
|
44
44
|
|
|
45
45
|
export const GROUP_MODULES: ToolModule[] = [
|
|
46
46
|
{ id: 'new', label: '新增任务', icon: 'plus', section: 'primary', noHide: true },
|
|
47
|
+
// #251:与 dir 页对齐——导入 / 草稿态两条都补上(任务页模板统一接管 new/import/plan)
|
|
48
|
+
{ id: 'import', label: '导入', icon: 'import', section: 'bar' },
|
|
47
49
|
{ id: 'progress', label: '进程', icon: 'progress', section: 'bar' },
|
|
48
50
|
{ id: 'addMember', label: '添加成员', icon: 'users', section: 'bar' },
|
|
49
51
|
{ id: 'orch', label: '编排', icon: 'flow', section: 'bar' },
|
|
52
|
+
{ id: 'plan', label: '草稿态', icon: 'pin', section: 'bar' },
|
|
50
53
|
{ id: 'more', label: '更多', icon: 'dots', section: 'bar', noHide: true },
|
|
51
54
|
{ id: 'refs', label: '查看列表', icon: 'list', section: 'more' },
|
|
52
55
|
// #250:与 dir 页对齐——持续 get 进组页「更多」。组横跨多个成员仓库,
|
|
@@ -2,30 +2,13 @@
|
|
|
2
2
|
// 这里的函数,不直接调 api()(模板约定)。
|
|
3
3
|
//
|
|
4
4
|
// 只搬调用不改语义:路径 / 方法 / body 与收口前逐字一致。
|
|
5
|
-
//
|
|
5
|
+
// #251 起任务 CRUD / 批量那一组下沉到 api/tasks.ts(组页与任务页模板共用),
|
|
6
|
+
// 这里 re-export 保持既有 import 面不变。
|
|
6
7
|
import { api } from '../../api/client.js';
|
|
8
|
+
import type { TaskMutationResult } from '../../api/tasks.js';
|
|
7
9
|
import type { ChainApi, GoalLogData } from './task-utils.js';
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
export type TaskScope = { cwd?: string; key?: string };
|
|
11
|
-
|
|
12
|
-
/** 变更类返回的公共形状:task=落地后的任务;key/moved/name=落点与归属迁移提示。 */
|
|
13
|
-
export interface TaskMutationResult {
|
|
14
|
-
task?: { id?: number | string; text?: string };
|
|
15
|
-
id?: number | string;
|
|
16
|
-
key?: string;
|
|
17
|
-
moved?: boolean;
|
|
18
|
-
name?: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** 批量操作返回:count=处理条数;skipped/missing=跳过 / 未找到的编号。 */
|
|
22
|
-
export interface TaskBulkResult {
|
|
23
|
-
count?: number;
|
|
24
|
-
skipped?: Array<number | string>;
|
|
25
|
-
missing?: Array<number | string>;
|
|
26
|
-
/** closeMany 专用:本轮收口里「原本已被领取」的编号(#184 面板提示用)。 */
|
|
27
|
-
claimedClosed?: Array<number | string>;
|
|
28
|
-
}
|
|
11
|
+
export * from '../../api/tasks.js';
|
|
29
12
|
|
|
30
13
|
/** 任务链(GET /api/localtasks/chain?<q>)。 */
|
|
31
14
|
export function getTaskChain(query: string): Promise<ChainApi> {
|
|
@@ -37,93 +20,6 @@ export function getGoalLog(query: string): Promise<GoalLogData> {
|
|
|
37
20
|
return api(`/api/localtasks/timegoal-log?${query}`);
|
|
38
21
|
}
|
|
39
22
|
|
|
40
|
-
/** 队列内调序(PATCH /api/localtasks/reorder;beforeId / afterId 二选一)。 */
|
|
41
|
-
export function reorderTask(
|
|
42
|
-
body: TaskScope & { id: number; beforeId?: number | string; afterId?: number | string },
|
|
43
|
-
): Promise<unknown> {
|
|
44
|
-
return api('/api/localtasks/reorder', { method: 'PATCH', body });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface PatchTaskItemBody extends TaskScope {
|
|
48
|
-
id: number;
|
|
49
|
-
text?: string;
|
|
50
|
-
gate?: boolean;
|
|
51
|
-
blockBy?: string | number[];
|
|
52
|
-
duration?: string;
|
|
53
|
-
clearGoal?: boolean;
|
|
54
|
-
goalPrompt?: string;
|
|
55
|
-
summary?: string;
|
|
56
|
-
[k: string]: unknown;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** 编辑单个本地任务(PATCH /api/localtasks/item;CLI localtask update 等价)。 */
|
|
60
|
-
export function patchTaskItem(body: PatchTaskItemBody): Promise<TaskMutationResult> {
|
|
61
|
-
return api('/api/localtasks/item', { method: 'PATCH', body });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* 按查询串查单条任务(GET /api/localtasks/item?<q>)。
|
|
66
|
-
* 找不到或出错返回 null(调用方以 null 判「没有这条」)。
|
|
67
|
-
*/
|
|
68
|
-
export function findTaskItem(query: string): Promise<any> {
|
|
69
|
-
return api(`/api/localtasks/item?${query}`).catch(() => null);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface AddTaskBody extends TaskScope {
|
|
73
|
-
global?: boolean;
|
|
74
|
-
text: string;
|
|
75
|
-
forkOf?: string;
|
|
76
|
-
forkKind?: string;
|
|
77
|
-
board?: string;
|
|
78
|
-
project?: string;
|
|
79
|
-
[k: string]: unknown;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** 加任务(POST /api/localtasks;CLI localtask add 等价)。 */
|
|
83
|
-
export function addTask(body: AddTaskBody): Promise<any> {
|
|
84
|
-
return api('/api/localtasks', { method: 'POST', body });
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* #126:在 pending ↔ plan 之间切换一条任务(PATCH /api/localtasks/plan)。
|
|
89
|
-
* plan 是不进队列的临时草稿,get/wait 都领不到;转回 pending 才重新排队。
|
|
90
|
-
*/
|
|
91
|
-
export function setPlanStatus(body: TaskScope & { id: number; to: 'plan' | 'pending' }): Promise<any> {
|
|
92
|
-
return api('/api/localtasks/plan', { method: 'PATCH', body });
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/** 重开 / 追加反馈(POST /api/localtasks/reopen;kind=reopen|comment)。 */
|
|
96
|
-
export function postReopen(body: Record<string, unknown>): Promise<TaskMutationResult> {
|
|
97
|
-
return api('/api/localtasks/reopen', { method: 'POST', body });
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** 删除单个本地任务(DELETE /api/localtasks/item;purge=true 彻底删除)。 */
|
|
101
|
-
export function removeTaskItem(body: TaskScope & { id: number; purge?: boolean }): Promise<unknown> {
|
|
102
|
-
return api('/api/localtasks/item', { method: 'DELETE', body });
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/** 批量软删除(DELETE /api/localtasks/items)。 */
|
|
106
|
-
export function removeManyTasks(body: TaskScope & { ids: unknown[] }): Promise<TaskBulkResult> {
|
|
107
|
-
return api('/api/localtasks/items', { method: 'DELETE', body });
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** 批量取消(POST /api/localtasks/items/cancel)。 */
|
|
111
|
-
export function cancelManyTasks(body: TaskScope & { ids: unknown[] }): Promise<TaskBulkResult> {
|
|
112
|
-
return api('/api/localtasks/items/cancel', { method: 'POST', body });
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/** 批量收口(POST /api/localtasks/items/close;status=done|cancelled)。 */
|
|
116
|
-
export function closeManyTasks(
|
|
117
|
-
body: TaskScope & { ids: unknown[]; status: string; summary?: string },
|
|
118
|
-
): Promise<TaskBulkResult> {
|
|
119
|
-
return api('/api/localtasks/items/close', { method: 'POST', body });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** 恢复软删除的任务(POST /api/localtasks/tasks/restore)。 */
|
|
123
|
-
export function restoreTaskItem(body: TaskScope & { id: number }): Promise<unknown> {
|
|
124
|
-
return api('/api/localtasks/tasks/restore', { method: 'POST', body });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
23
|
/** 克隆任务(POST /api/localtasks/clone)。 */
|
|
128
24
|
export function cloneTask(body: { id: number; cwd?: string }): Promise<TaskMutationResult> {
|
|
129
25
|
return api('/api/localtasks/clone', { method: 'POST', body });
|