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.
Files changed (95) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +1 -1
  3. package/package.json +1 -1
  4. package/src/core/attachmentdb/ids.ts +14 -1
  5. package/src/core/attachmentdb/query.ts +0 -38
  6. package/src/core/attachmentdb/repo.ts +98 -0
  7. package/src/core/attachmentdb.ts +5 -1
  8. package/src/core/db/migrations/index.ts +2 -0
  9. package/src/core/db/migrations/v15.sql +88 -0
  10. package/src/core/db/version.ts +4 -1
  11. package/src/modules/claim/assemble.ts +0 -5
  12. package/src/modules/claim/host.ts +1 -3
  13. package/src/modules/claim/preview.ts +0 -1
  14. package/src/modules/docs/actions/docs-detach.ts +1 -2
  15. package/src/modules/docs/attach.ts +3 -17
  16. package/src/modules/docs/render.ts +4 -13
  17. package/src/modules/localtask/actions/localtask-attach.ts +4 -2
  18. package/src/modules/localtask/actions/localtask-config.ts +2 -11
  19. package/src/modules/localtask/actions/localtask-detach.ts +1 -3
  20. package/src/modules/localtask/infra/repo/settings.ts +1 -9
  21. package/src/modules/localtask/lifecycle/task-templates.ts +0 -13
  22. package/src/modules/localtask/lifecycle/topics.ts +3 -6
  23. package/src/modules/localtask/ops/attach-resource.ts +46 -4
  24. package/src/modules/localtask/ops/attach-template.ts +73 -3
  25. package/src/modules/localtask/ops/attach.ts +45 -18
  26. package/src/modules/localtask/ui/action-render.ts +3 -12
  27. package/src/modules/promptplug/compose.ts +1 -3
  28. package/src/modules/promptplug/plugins/attachment.ts +56 -6
  29. package/src/modules/promptplug/plugins/context.ts +11 -2
  30. package/src/modules/promptplug/template-store.ts +25 -3
  31. package/src/shared/prompt-blocks.ts +2 -23
  32. package/src/web/frontend/api/cli-tree.json +4 -4
  33. package/src/web/frontend/api/client.generated.ts +8 -8
  34. package/src/web/frontend/api/tasks.ts +117 -0
  35. package/src/web/frontend/components/Introduction/index.tsx +50 -3
  36. package/src/web/frontend/components/Introduction/style.css +6 -0
  37. package/src/web/frontend/components/Introduction/use-intro.ts +25 -0
  38. package/src/web/frontend/components/md/attachments/attach-area.tsx +9 -11
  39. package/src/web/frontend/components/md/attachments/attach-common.ts +12 -5
  40. package/src/web/frontend/components/md/attachments/attach-modal.tsx +54 -9
  41. package/src/web/frontend/components/md/attachments/attach-repo-pick.tsx +48 -0
  42. package/src/web/frontend/components/sidebar/task-children.tsx +14 -11
  43. package/src/web/frontend/{page/dir → components/task-panel}/dag-editor.tsx +1 -1
  44. package/src/web/frontend/components/task-panel/task-ops.ts +299 -0
  45. package/src/web/frontend/components/task-panel/task-page.tsx +495 -0
  46. package/src/web/frontend/components/tool-acts/modules.ts +3 -0
  47. package/src/web/frontend/page/dir/api.ts +4 -108
  48. package/src/web/frontend/page/dir/index.tsx +148 -331
  49. package/src/web/frontend/page/dir/task-board-section.tsx +3 -0
  50. package/src/web/frontend/page/dir/task-dock-panel.tsx +1 -1
  51. package/src/web/frontend/page/dir/task.tsx +1 -1
  52. package/src/web/frontend/page/doc/doc-dock.tsx +1 -1
  53. package/src/web/frontend/page/group/api.ts +3 -21
  54. package/src/web/frontend/page/group/group-project-memo.ts +41 -0
  55. package/src/web/frontend/page/group/index.tsx +287 -426
  56. package/src/web/frontend/page/settings/api.ts +1 -2
  57. package/src/web/frontend/page/settings/prompt-templates-section.tsx +12 -44
  58. package/src/web/public/assets/{bar-Dy_QDX2h.js → bar-D7cWe7Kp.js} +1 -1
  59. package/src/web/public/assets/{composer-launch-B7DH53Yf.js → composer-launch--nJGFG35.js} +1 -1
  60. package/src/web/public/assets/{composer-panel-Cj1J16r-.js → composer-panel-Dhivt7UJ.js} +1 -1
  61. package/src/web/public/assets/{dag-DXRPHVl8.js → dag-DUhHxgTk.js} +1 -1
  62. package/src/web/public/assets/dir-CkYGYT9e.js +1 -0
  63. package/src/web/public/assets/doc-DgYKv2wo.css +1 -0
  64. package/src/web/public/assets/doc-QBHQi1EV.js +6 -0
  65. package/src/web/public/assets/group-CfJxWA7V.js +1 -0
  66. package/src/web/public/assets/group-project-memo-G-O6sPRw.js +1 -0
  67. package/src/web/public/assets/index-ByAPGidL.js +3 -0
  68. package/src/web/public/assets/{list-filter-CWxiOSg_.js → list-search-B2S2g8kn.js} +1 -1
  69. package/src/web/public/assets/md-history-DdM6P9Gq.js +47 -0
  70. package/src/web/public/assets/{progress-MPse2JLQ.js → progress-BVpSy-uF.js} +1 -1
  71. package/src/web/public/assets/refs-CCZgGPlL.js +2 -0
  72. package/src/web/public/assets/reopen-text-BC9a8KOp.js +13 -0
  73. package/src/web/public/assets/{repo-form-modal-CNLYR12c.js → repo-form-modal-D8WabN0R.js} +1 -1
  74. package/src/web/public/assets/{repos-BGx-yAXd.js → repos-V5xb5Kz-.js} +9 -9
  75. package/src/web/public/assets/settings-CAOSCF3E.js +1 -0
  76. package/src/web/public/assets/task-BwWlNP0i.js +13 -0
  77. package/src/web/public/assets/task-ops-DZgza5eZ.js +2 -0
  78. package/src/web/public/assets/task-utils--WIpAwUx.js +1 -0
  79. package/src/web/public/assets/{templates-Co1Qb1aA.js → templates-6ClSnYJN.js} +3 -3
  80. package/src/web/public/assets/{tool-bar-D5wLBLRl.js → tool-bar-BYdfBQeo.js} +1 -1
  81. package/src/web/public/assets/use-rail-drag-BMXJ48je.js +1 -0
  82. package/src/web/public/index.html +8 -8
  83. package/src/web/frontend/page/dir/landing.tsx +0 -553
  84. package/src/web/public/assets/dir-_M1ciSxM.js +0 -3
  85. package/src/web/public/assets/doc-Iuxssa-b.css +0 -1
  86. package/src/web/public/assets/doc-_iteSM2X.js +0 -6
  87. package/src/web/public/assets/get-loop-modal-DlAfqJMz.js +0 -2
  88. package/src/web/public/assets/group-CH8qe-eg.js +0 -1
  89. package/src/web/public/assets/index-Cui4IuGj.js +0 -3
  90. package/src/web/public/assets/md-history-Bj790fdn.js +0 -46
  91. package/src/web/public/assets/refs-DiIPoqnJ.js +0 -2
  92. package/src/web/public/assets/settings-Pt4YgGdY.js +0 -1
  93. package/src/web/public/assets/task-DOIIpQ4X.js +0 -13
  94. package/src/web/public/assets/task-utils-CJfMODCP.js +0 -13
  95. package/src/web/public/assets/use-rail-drag-CNOHXWng.js +0 -1
@@ -1,49 +1,38 @@
1
- // 目录面板 —— 简介(统一 Introduction)+ 子任务表。
2
- import { useEffect, useMemo, useRef, useState } from 'react';
3
- import {
4
- addTask,
5
- cancelManyTasks,
6
- closeManyTasks,
7
- findTaskItem,
8
- patchTaskItem,
9
- removeManyTasks,
10
- removeTaskItem,
11
- reorderTask,
12
- postReopen,
13
- } from './api.js';
1
+ // 目录面板 —— 简介(统一 Introduction)+ 任务页模板(#251)。
2
+ //
3
+ // 本页只负责「目录这条主题」的数据与接线:主题定位、显示序、模板可见域、草稿落点。
4
+ // 列表的**整页交互**(工具区 / 搜索 / 全选 / 多选批量条 / 行尾菜单 / 翻页 / 拖动排序)
5
+ // 全在 components/task-panel/task-page(与项目组页同一份),行尾与批量动作的流程在
6
+ // components/task-panel/task-ops(同一份)——两页不再各写一遍。
7
+ import { useMemo, useState } from 'react';
8
+ import { addTask, reorderTask } from './api.js';
14
9
  import { useToast } from '../../components/toast/index.jsx';
15
- import { useDialog, PopMenu } from '../../components/popup/index.jsx';
10
+ import { useDialog } from '../../components/popup/index.jsx';
16
11
  import { GLOBAL_KEY, isGroupTask } from '../../modules/board/board-view.js';
17
- import { filterTasks } from '../../modules/board/task-search.js';
18
- import {
19
- FEEDBACK_HEADING,
20
- PLAIN_FEEDBACK_HEADING,
21
- buildReopenText,
22
- } from '../../modules/board/reopen-text.js';
23
- import { usePager } from '../../components/pager.jsx';
24
12
  import { useApp } from '../../app-context.jsx';
25
- import Landing from './landing.jsx';
26
- import DagEditor from './dag-editor.jsx';
13
+ import Introduction from '../../components/Introduction/index.jsx';
14
+ import GetLoopModal from '../../components/repos/get-loop-modal.js';
15
+ import DagEditor from '../../components/task-panel/dag-editor.jsx';
27
16
  import { findOpenPanel, openPanel } from '../../workspace.js';
28
17
  import { openTemplateEditor } from '../../panels.jsx';
29
18
  import { docIdOf, nextDraftId, saveDoc, scopeOf } from '../../modules/md/doc-store.js';
30
19
  import { putManageSession } from '../../modules/md/manage-session.js';
31
20
  import { useTemplatesFor } from '../../modules/md/use-templates.js';
32
- import type { LocalTask, PromptTemplate, RepoRow } from '../../types.js';
21
+ import TaskPage from '../../components/task-panel/task-page.jsx';
22
+ import type { TaskPageRow } from '../../components/task-panel/task-page.jsx';
23
+ import {
24
+ runBatchCancel,
25
+ runBatchComplete,
26
+ runBatchDelete,
27
+ runDeleteTask,
28
+ runFeedbackTask,
29
+ runPlanSwitch,
30
+ runToggleGate,
31
+ saveDagPatches,
32
+ } from '../../components/task-panel/task-ops.js';
33
+ import type { DagPatchInput, TaskOpsDeps } from '../../components/task-panel/task-ops.js';
33
34
  import { sortTasksForDisplay } from './task-utils.js';
34
-
35
- // 目录任务表每页条数(队列一长就翻页,不再一次渲染全部)
36
- const PAGE_SIZE = 20;
37
-
38
- /** 拖动落点(与 landing 的约定一致)。 */
39
- type DropZone = 'before' | 'after';
40
-
41
- /** DagEditor 回传的逐条 patch(结构与其内部 DagPatch 一致)。 */
42
- interface DagPatchInput {
43
- id: number;
44
- gate?: boolean;
45
- blockBy?: number[];
46
- }
35
+ import type { LocalTask, PromptTemplate, RepoRow } from '../../types.js';
47
36
 
48
37
  interface DirPanelProps {
49
38
  dirKey?: string;
@@ -60,9 +49,9 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
60
49
  const repos = (app.repoData && app.repoData.repos) || [];
61
50
 
62
51
  const isGlobal = !dirKey || dirKey === GLOBAL_KEY;
63
- const [tplMenu, setTplMenu] = useState<{ x?: number; y?: number } | null>(null);
64
52
  const [dagTask, setDagTask] = useState<LocalTask | null>(null); // 正在编排依赖的任务(DAG 节点编辑器)
65
- const fileMdRef = useRef<HTMLInputElement | null>(null);
53
+ // #165:持续 get(waitgoal)配置——按主题(仓库)粒度控制,收在工具区直读状态
54
+ const [glOpen, setGlOpen] = useState(false);
66
55
 
67
56
  const topic = useMemo(() => {
68
57
  if (isGlobal) return rows.find((r) => r.isGlobal) || null;
@@ -82,63 +71,12 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
82
71
  }, [topic, repos, isGlobal]);
83
72
 
84
73
  // 显示序:未完成(待领取)优先,追加的新任务不会被历史埋在下面;
85
- // 软删除的行不进表。分页:队列一长就翻页,不一次渲染全部。
86
- // #85 两种走向:目录页是**项目走向**的视图——组任务(frontmatter.board)
87
- // 物理上在这条队列里,但归组页管,列表与下面的计数/编排一并排除。
74
+ // 软删除的行不进表。#85 两种走向:目录页是**项目走向**的视图——组任务
75
+ // (frontmatter.board)物理上在这条队列里,但归组页管,列表与计数一并排除。
88
76
  const allTasks = useMemo<LocalTask[]>(
89
77
  () => sortTasksForDisplay((topic?.tasks || []).filter((t) => !t.deletedAt && !isGroupTask(t))),
90
78
  [topic]
91
79
  );
92
- // #181:面板头搜索框——标题与正文都算命中目标(模糊串规则见 modules/board/task-search);
93
- // 先过滤再分页,翻页条报的是命中数。
94
- const [q, setQ] = useState('');
95
- const shownTasks = useMemo(() => filterTasks(allTasks, q), [allTasks, q]);
96
- const pager = usePager(shownTasks, PAGE_SIZE);
97
- // 改查询串就回到第一页(否则会停在「上一结果的第 3 页」上,看起来像没命中)
98
- useEffect(() => {
99
- pager.setPage(0);
100
- }, [q]);
101
- // 待领取计数跟着**筛后**的集合走:搜索时头部「待领取 N」要与屏幕上的行对得上
102
- const pendingCount = useMemo(
103
- () => shownTasks.filter((t) => t.status === 'pending' && !t.migratedTo).length,
104
- [shownTasks]
105
- );
106
- const guard = (fn: () => Promise<unknown>) => fn().catch((e) => toast(String((e as Error).message || e)));
107
-
108
- // ─── 编排(DAG):拖动排序 / 闸门 / 上下游依赖 ───
109
- // 定位 body:全局池用 key,目录用 cwd(与 reopen / delete 同一套)
110
- const scopeBody = () => (isGlobal ? { key: GLOBAL_KEY } : { cwd: topic?.cwd });
111
-
112
- // 拖动排序:服务端只许 pending ↔ pending 换位(已领取是固定历史),UI 侧已同口径过滤
113
- const moveTask = (t: { id: number }, targetId: number | string, zone: DropZone) => {
114
- guard(async () => {
115
- await reorderTask({ ...scopeBody(), id: t.id, ...(zone === 'before' ? { beforeId: targetId } : { afterId: targetId }) });
116
- refreshLocal?.();
117
- });
118
- };
119
-
120
- const toggleGate = (t: LocalTask) => {
121
- guard(async () => {
122
- await patchTaskItem({ ...scopeBody(), id: t.id, gate: !t.blocksFollowing });
123
- toast(!t.blocksFollowing ? `#${t.id} 已设为闸门——挡住所有后续待领取任务` : `#${t.id} 闸门已取消`);
124
- refreshLocal?.();
125
- });
126
- };
127
-
128
- // 编排编辑器保存:patches 是逐条任务级 PATCH(本任务的 gate/blockBy + 下游各方 blockBy)。
129
- // 失败时 toast 并**向上抛**——编辑器据此保持打开。
130
- const saveDag = async (patches: DagPatchInput[]) => {
131
- try {
132
- for (const p of patches) {
133
- await patchTaskItem({ ...scopeBody(), ...p });
134
- }
135
- toast('编排已保存');
136
- refreshLocal?.();
137
- } catch (e) {
138
- toast(String((e as Error).message || e));
139
- throw e;
140
- }
141
- };
142
80
 
143
81
  // 闸门 → 被它挡住的后续任务(队列序:pending 子序即领取序)。
144
82
  // 领取闸判定只看「排在我前面的 alive 闸门」(core/workflow/readiness),同一口径。
@@ -155,6 +93,46 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
155
93
  [allTasks]
156
94
  );
157
95
 
96
+ // #181 搜索 / 分页 / 多选 / 拖动 / 行尾菜单都由 TaskPage 持有;这里只给行数据。
97
+ const pageRows = useMemo<TaskPageRow[]>(
98
+ () =>
99
+ allTasks.map((t) => ({
100
+ key: String(t.id),
101
+ task: t,
102
+ showTimes: true, // 目录页基线:行内显示 创建 → 领取 时间
103
+ movable: t.status === 'pending' && !t.migratedTo && !t.deletedAt,
104
+ downs: downstreamOf[t.id] || [],
105
+ })),
106
+ [allTasks, downstreamOf]
107
+ );
108
+
109
+ const guard = (fn: () => Promise<unknown>) => fn().catch((e) => toast(String((e as Error).message || e)));
110
+
111
+ // 主题定位二选一:全局池用 key,目录用 cwd(行尾 / 批量 / 编排同一套)
112
+ const scopeBody = () => (isGlobal ? { key: GLOBAL_KEY } : { cwd: topic?.cwd });
113
+ const topicKeyHere = isGlobal ? GLOBAL_KEY : dirKey || GLOBAL_KEY;
114
+ // 持续 get 的展示态(配置本身在 GetLoopModal 里改)
115
+ const glOn = !!(repo && repo.getLoop && repo.getLoop.enabled);
116
+ const glMinutes = repo && repo.getLoop && repo.getLoop.waitMinutes !== undefined && repo.getLoop.waitMinutes !== null
117
+ ? Number(repo.getLoop.waitMinutes)
118
+ : null;
119
+
120
+ // 动作层的依赖:弹窗 / 提示 / 刷新 / 文档落点都来自本页
121
+ const ops: TaskOpsDeps = {
122
+ dialog,
123
+ toast,
124
+ refresh: () => {
125
+ refreshLocal?.();
126
+ },
127
+ docKey: dirKey || GLOBAL_KEY,
128
+ onDeleted: (t) => {
129
+ if (!model) return;
130
+ // workspace.findOpenPanel 的返回类型尚未收口(被推断成 null),按实际契约窄化
131
+ const page = findOpenPanel(model, 'page', { dirKey, task: String(t.id) }) as { getId: () => string } | null;
132
+ if (page && app.closePanel) app.closePanel(page.getId());
133
+ },
134
+ };
135
+
158
136
  const openTask = (id: number | string) => {
159
137
  if (app.openPage) app.openPage({ dirKey, task: String(id), name: `#${id}` });
160
138
  };
@@ -189,7 +167,6 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
189
167
 
190
168
  // #128 模板可见域:「模板 ▾」只列**本主题可用**的模板(服务端按 scope 过滤)。
191
169
  // 三档退化都回落全量(scoped 未加载/旧 serve/失败时 templates=null),菜单不变空。
192
- const topicKeyHere = isGlobal ? GLOBAL_KEY : dirKey || GLOBAL_KEY;
193
170
  const scopedTpl = useTemplatesFor(topicKeyHere);
194
171
  const menuTemplates: PromptTemplate[] = scopedTpl.templates || (tpl && tpl.templates) || [];
195
172
 
@@ -227,176 +204,6 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
227
204
  { label: '管理模板…', icon: 'gear', onClick: openTplList },
228
205
  ];
229
206
 
230
- // #79:反馈的 base 以**服务端当前正文**为准——列表行的 t.text 是 rows 快照,
231
- // 可能落后于盘上(别的会话改过 / 上一轮重开追加过),拿旧正文拼回去就是丢数据。
232
- const fetchServerTask = async (t: LocalTask | null) => {
233
- if (t == null) return null;
234
- const q = isGlobal
235
- ? `key=${encodeURIComponent(GLOBAL_KEY)}&id=${Number(t.id)}`
236
- : `cwd=${encodeURIComponent(topic?.cwd || '')}&id=${Number(t.id)}`;
237
- return findTaskItem(q);
238
- };
239
-
240
- const reopenTask = (t: LocalTask | null) => {
241
- if (!t) return;
242
- const title = (t.text || '').split('\n').find((l) => l.trim()) || `#${t.id}`;
243
- guard(async () => {
244
- const acked = !!t.completedAt;
245
- const body = await dialog({
246
- title: acked ? `反馈 · #${t.id}` : `反馈修改 · #${t.id}`,
247
- input: true,
248
- placeholder: acked
249
- ? '写下反馈(将新开一条任务,原任务不动)'
250
- : '写下要改的地方(留空 = 只重开,不改正文)',
251
- });
252
- if (body === null || body === undefined) return;
253
- const fb = String(body).trim();
254
- // #79:base 取服务端当前正文(取不到才退回 rows 快照);两头的都没有就中止。
255
- const fresh = await fetchServerTask(t);
256
- const baseText = String(fresh?.text ?? '').trim() || String(t.text || '').trim();
257
- const ackSummary = acked ? (fresh?.roundSummary || t.roundSummary || '') : '';
258
- if (!fb && !acked && !baseText) {
259
- // 只重开(不改正文)不需要 base;带反馈但拿不到正文时不能瞎拼
260
- toast('拿不到任务当前正文,已取消(防止丢内容)');
261
- return;
262
- }
263
-
264
- // #75:已完成 → 反馈 = **新开任务**(forkOf 指回本条),原任务留档不动。
265
- // 新任务的正文 = 完整之前的任务 + 上轮总结 + 本轮反馈(面板拼装——新任务
266
- // 的落点内容只能整篇给)。
267
- if (acked) {
268
- // 拼装参数先收进变量:reopen-text 的入参形状仍在迁移(字面量直接传会被多余属性检查拦下)
269
- const reopenArgs = {
270
- base: baseText,
271
- feedback: fb,
272
- ackSummary,
273
- feedbackHeading: FEEDBACK_HEADING,
274
- bold: true,
275
- };
276
- const text = fb ? buildReopenText(reopenArgs) : '';
277
- if (!text) {
278
- toast('写一下反馈');
279
- return;
280
- }
281
- const res = await addTask(
282
- isGlobal
283
- ? { global: true, text, forkOf: String(t.id), forkKind: 'reopen' }
284
- : { cwd: topic?.cwd, text, forkOf: String(t.id), forkKind: 'reopen' },
285
- );
286
- const newId = String(res?.task?.id ?? res?.id ?? '');
287
- const landedKey = res?.key || dirKey;
288
- if (newId) saveDoc(docIdOf(scopeOf(landedKey), newId), { body: text });
289
- toast(`已反馈「${title.replace(/^#\s*/, '')}」→ 新任务 #${newId || '?'}`);
290
- refreshLocal?.();
291
- return;
292
- }
293
-
294
- // 未完成:就地回写(#74 reopen)。#79:纯反馈不传 text——服务端把反馈段
295
- // 原子追加到盘上当前正文;「只重开不改正文」(无反馈)维持只翻状态。
296
- const res = await postReopen({
297
- ...scopeBody(),
298
- id: t.id,
299
- kind: 'reopen',
300
- ...(fb
301
- ? {
302
- feedback: fb,
303
- feedbackHeading: PLAIN_FEEDBACK_HEADING,
304
- feedbackBold: false,
305
- }
306
- : {}),
307
- });
308
- const landedKey = res?.key || dirKey;
309
- const sameId = String(res?.task?.id ?? t.id);
310
- const finalText = String(res?.task?.text ?? '');
311
- if (finalText) saveDoc(docIdOf(scopeOf(landedKey), sameId), { body: finalText });
312
- toast(
313
- `已回写「${title.replace(/^#\s*/, '')}」#${sameId}` +
314
- (res?.moved && res.name ? `;归属迁到「${res.name}」` : ''),
315
- );
316
- refreshLocal?.();
317
- });
318
- };
319
-
320
- const delTask = async (t: LocalTask | null) => {
321
- if (!t) return;
322
- const title = (t.text || '').split('\n').find((l) => l.trim()) || `#${t.id}`;
323
- const ok = await dialog({
324
- title: `删除任务「${title.replace(/^#\s*/, '')}」`,
325
- message: '软删除:CLI localtask task restore 可恢复。',
326
- danger: true,
327
- okText: '删除',
328
- });
329
- if (!ok) return;
330
- guard(async () => {
331
- await removeTaskItem(isGlobal ? { key: GLOBAL_KEY, id: t.id } : { cwd: topic?.cwd, id: t.id });
332
- toast(`已删除「${title.replace(/^#\s*/, '')}」`);
333
- if (model) {
334
- // workspace.findOpenPanel 的返回类型尚未收口(被推断成 null),按实际契约窄化
335
- const page = findOpenPanel(model, 'page', { dirKey, task: String(t.id) }) as { getId: () => string } | null;
336
- if (page && app.closePanel) app.closePanel(page.getId());
337
- }
338
- refreshLocal?.();
339
- });
340
- };
341
-
342
- // ─── 批量操作(多选删除 / 取消)────────────────────────────────────
343
- const batchDeleteTasks = async (ids: number[]): Promise<unknown> => {
344
- const list = (ids || []).map(Number).filter((n) => Number.isFinite(n) && n > 0);
345
- if (!list.length) return false;
346
- const ok = await dialog({
347
- title: `删除选中的 ${list.length} 条任务`,
348
- message: '软删除:CLI localtask task restore 可恢复。',
349
- danger: true,
350
- okText: '删除',
351
- });
352
- if (!ok) return false;
353
- return guard(async () => {
354
- const res = await removeManyTasks({ ...scopeBody(), ids: list });
355
- toast(`已删除 ${res?.count ?? list.length} 条任务`);
356
- refreshLocal?.();
357
- return true;
358
- });
359
- };
360
-
361
- const batchCancelTasks = async (ids: number[]): Promise<unknown> => {
362
- const list = (ids || []).map(Number).filter((n) => Number.isFinite(n) && n > 0);
363
- if (!list.length) return false;
364
- const ok = await dialog({
365
- title: `取消选中的 ${list.length} 条待领取任务`,
366
- message: '只处理待领取任务;已领取/已完成/已取消会跳过。取消为终态,原文留档。',
367
- okText: '取消任务',
368
- });
369
- if (!ok) return false;
370
- return guard(async () => {
371
- const res = await cancelManyTasks({ ...scopeBody(), ids: list });
372
- const skipped = res?.skipped?.length || 0;
373
- toast(`已取消 ${res?.count ?? 0} 条任务${skipped ? `,跳过 ${skipped} 条` : ''}`);
374
- refreshLocal?.();
375
- return true;
376
- });
377
- };
378
-
379
- const batchCompleteTasks = async (ids: number[]): Promise<unknown> => {
380
- const list = (ids || []).map(Number).filter((n) => Number.isFinite(n) && n > 0);
381
- if (!list.length) return false;
382
- const ok = await dialog({
383
- title: `把选中的 ${list.length} 条任务标为完成`,
384
- message: '待领取与已领取(正在跑)都能收:已领取的直接收口,agent 侧回执会被忽略。已完成/已取消会跳过。完成会补一条完成记录,原文留档。',
385
- okText: '标为完成',
386
- });
387
- if (!ok) return false;
388
- return guard(async () => {
389
- const res = await closeManyTasks({ ...scopeBody(), ids: list, status: 'done' });
390
- const skipped = res?.skipped?.length || 0;
391
- const claimed = res?.claimedClosed?.length || 0;
392
- toast(
393
- `已标为完成 ${res?.count ?? 0} 条任务${claimed ? `(含 ${claimed} 条已领取)` : ''}${skipped ? `,跳过 ${skipped} 条` : ''}`,
394
- );
395
- refreshLocal?.();
396
- return true;
397
- });
398
- };
399
-
400
207
  // ─── 文档列表(右侧栏)────────────────────────────────────────────
401
208
  const openRefs = () => {
402
209
  if (isGlobal || !repo) {
@@ -431,16 +238,10 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
431
238
  };
432
239
 
433
240
  if (!topic && !isGlobal) {
241
+ // 空态与组页同骨架(#170:落地页不套 .mdw 编辑器外壳;#251:两页空态都走 rp-page)
434
242
  return (
435
- <div className="mdw">
436
- <div className="mdw-main">
437
- <div className="mdw-top">
438
- <div className="mdw-head">
439
- <div className="mdw-title">目录不存在</div>
440
- <div className="mdw-path">—</div>
441
- </div>
442
- </div>
443
- </div>
243
+ <div className="rp-page">
244
+ <div className="rp-empty">目录不存在(主题可能被删了)</div>
444
245
  </div>
445
246
  );
446
247
  }
@@ -450,68 +251,84 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
450
251
  // (自带 canvas 米色底 + 一整套 .mdw 作用域的按钮/字号口径)。落地页只是
451
252
  // 队列列表页,套上它会让**同款按钮在目录页与项目组页呈现两套观感**
452
253
  // (.mdw .btn.ghost 透明浅边 vs .btn.ghost 灰底),页面底色也不同。
453
- // 编辑器分支仍用 .mdw(那是编辑器,本就该有工作台外壳)。
454
254
  <>
455
- <Landing
456
- isGlobal={isGlobal}
457
- topic={topic}
458
- repo={repo}
459
- model={model}
460
- tasks={pager.items}
461
- taskCount={pager.total}
462
- q={q}
463
- onQuery={setQ}
464
- pendingCount={pendingCount}
465
- page={pager.page}
466
- pageCount={pager.pageCount}
467
- onPage={pager.setPage}
468
- onNew={() => {
469
- const p = tpl ? tpl.defaultPick() : null;
470
- newDraft(p ? p.body : '');
471
- }}
472
- onOpenTask={openTask}
473
- onDeleteTask={delTask}
474
- onDeleteTasks={batchDeleteTasks}
475
- onCancelTasks={batchCancelTasks}
476
- onCompleteTasks={batchCompleteTasks}
477
- onReopenTask={reopenTask}
478
- onTplMenu={(e) => setTplMenu({ x: e.clientX, y: e.clientY })}
479
- onImport={() => fileMdRef.current?.click()}
480
- onProg={openProgress}
481
- onMoveTask={moveTask}
482
- onOpenDag={setDagTask}
483
- onOpenFlow={() => model && openPanel(model, { component: 'dag', name: '编排', config: { dirKey } })}
484
- onToggleGate={toggleGate}
485
- downstreamOf={downstreamOf}
486
- onRefs={openRefs}
487
- />
488
-
489
- {dagTask && (
490
- <DagEditor
491
- task={dagTask}
492
- tasks={dagCandidates}
493
- onClose={() => setDagTask(null)}
494
- onSave={saveDag}
495
- />
496
- )}
497
-
498
- {tplMenu && (
499
- <PopMenu x={tplMenu.x} y={tplMenu.y} items={tplMenuItems} onClose={() => setTplMenu(null)} />
500
- )}
501
-
502
- <input
503
- ref={fileMdRef}
504
- type="file"
505
- accept=".md,text/markdown,text/plain"
506
- hidden
507
- onChange={(e) => {
508
- const f = e.target.files?.[0];
509
- e.target.value = '';
510
- if (f) importMd(f);
255
+ <TaskPage
256
+ kind="dir"
257
+ name={isGlobal ? '全局池' : (topic?.name || '目录')}
258
+ title={isGlobal ? '全局池任务' : '任务'}
259
+ intro={!isGlobal && repo ? <Introduction kind="repo" owner={repo} model={model} /> : null}
260
+ rows={pageRows}
261
+ emptyText={`还没有页面:点「+ 新建页」写第一篇,或让 agent 往${isGlobal ? '全局池' : '这个目录'}投递任务。`}
262
+ tplMenuItems={tplMenuItems}
263
+ onNew={() => {
264
+ const p = tpl ? tpl.defaultPick() : null;
265
+ newDraft(p ? p.body : '');
511
266
  }}
267
+ onOpenRow={(r) => openTask(r.task.id)}
268
+ onImportFile={(f) => void importMd(f)}
269
+ onMoveRow={(src, dst, zone) => guard(async () => {
270
+ // 服务端只许 pending ↔ pending 换位(已领取是固定历史),UI 侧已同口径过滤
271
+ await reorderTask({
272
+ ...scopeBody(),
273
+ id: src.task.id,
274
+ ...(zone === 'before' ? { beforeId: dst.task.id } : { afterId: dst.task.id }),
275
+ });
276
+ refreshLocal?.();
277
+ })}
278
+ onTogglePlan={(rs, to) =>
279
+ void runPlanSwitch(ops, [{ scope: { key: topicKeyHere }, ids: rs.map((r) => r.task.id) }], to)
280
+ }
281
+ onOpenDag={(r) => setDagTask(r.task)}
282
+ onToggleGate={(r) => void runToggleGate(ops, scopeBody(), r.task)}
283
+ onFeedback={(r) => void runFeedbackTask(ops, scopeBody(), r.task)}
284
+ onDeleteRow={(r) => void runDeleteTask(ops, scopeBody(), r.task)}
285
+ onDeleteRows={(rs) =>
286
+ runBatchDelete(ops, [{ scope: scopeBody(), ids: rs.map((r) => Number(r.task.id)) }])
287
+ }
288
+ onCancelRows={(rs) =>
289
+ runBatchCancel(ops, [{ scope: scopeBody(), ids: rs.map((r) => Number(r.task.id)) }])
290
+ }
291
+ onCompleteRows={(rs) =>
292
+ runBatchComplete(ops, [{ scope: scopeBody(), ids: rs.map((r) => Number(r.task.id)) }])
293
+ }
294
+ toolActs={{
295
+ // #165:持续 get 开/关状态直读(配置弹窗点开改)
296
+ renderers: {
297
+ getloop: () => (
298
+ <button
299
+ type="button"
300
+ className="btn small ghost"
301
+ title={glOn
302
+ ? `持续 get 已开启:agent 领完任务没活时会阻塞等待(每轮 ${glMinutes ?? 10} 分钟)——点这里去配置/关闭`
303
+ : '持续 get 未开启:开启后 agent 领完任务没活会自动唤起阻塞等待——点这里配置'}
304
+ onClick={() => setGlOpen(true)}
305
+ >
306
+ {glOn ? `持续 get:开(${glMinutes ?? 10} 分钟)` : '持续 get:关'}
307
+ </button>
308
+ ),
309
+ },
310
+ actions: {
311
+ progress: openProgress,
312
+ orch: () => model && openPanel(model, { component: 'dag', name: '编排', config: { dirKey } }),
313
+ refs: openRefs,
314
+ getloop: () => setGlOpen(true),
315
+ },
316
+ }}
317
+ actionExtra={glOpen && repo ? <GetLoopModal repo={repo} onClose={() => setGlOpen(false)} onSaved={() => app.refreshRepos?.()} /> : null}
318
+ extra={
319
+ <>
320
+ {dagTask && (
321
+ <DagEditor
322
+ task={dagTask}
323
+ tasks={dagCandidates}
324
+ onClose={() => setDagTask(null)}
325
+ onSave={(patches: DagPatchInput[]) => saveDagPatches(ops, scopeBody(), patches)}
326
+ />
327
+ )}
328
+ {dialogNode}
329
+ </>
330
+ }
512
331
  />
513
-
514
- {dialogNode}
515
332
  </>
516
333
  );
517
334
  }
@@ -2,6 +2,7 @@
2
2
  import { saveDoc } from '../../modules/md/doc-store.js';
3
3
  import { withFrontmatter } from '../../modules/md/md-parse.js';
4
4
  import type { BoardCtx, DocFm, DocState } from './task-utils.js';
5
+ import { rememberGroupProject } from '../group/group-project-memo.js';
5
6
 
6
7
  interface BoardSectionProps {
7
8
  boardCtx: BoardCtx | null;
@@ -29,6 +30,8 @@ export function BoardSection({ boardCtx, docFm, goalEditable, doc, id, markDirty
29
30
  className="mdw-proj-pick"
30
31
  value={docFm.project || ''}
31
32
  onChange={(e) => {
33
+ // #187:记住这次选择——下次在这个组里新建任务直接用它当默认归属
34
+ rememberGroupProject(boardCtx.board.id, e.target.value);
32
35
  saveDoc(id, {
33
36
  body: withFrontmatter(doc.body, { ...docFm, board: boardCtx.board.id, project: e.target.value }),
34
37
  });
@@ -242,7 +242,7 @@ export function DockPanel({
242
242
  hostId={Number(task)}
243
243
  hostKey={isGlobal ? GLOBAL_KEY : undefined}
244
244
  hostCwd={isGlobal ? undefined : topic.cwd}
245
- allow={{ file: true, url: true, folder: true, task: true, ref: true }}
245
+ allow={{ file: true, url: true, folder: true, task: true, ref: true, repo: true }}
246
246
  taskOptions={(topic.tasks || []).map((t: LocalTask) => ({ id: t.id, text: t.text, status: t.status }))}
247
247
  onChanged={refreshLocal}
248
248
  onOpenTask={(hit: { key?: string; seq?: number | null }) => {
@@ -479,7 +479,7 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
479
479
  hostId: Number(task),
480
480
  hostKey: isGlobal ? GLOBAL_KEY : undefined,
481
481
  hostCwd: isGlobal ? undefined : topic?.cwd,
482
- allow: { file: true, url: true, folder: true, task: true, ref: true },
482
+ allow: { file: true, url: true, folder: true, task: true, ref: true, repo: true },
483
483
  taskOptions: (topic?.tasks || []).map((t: LocalTask) => ({ id: t.id, text: t.text, status: t.status })),
484
484
  }}
485
485
  />
@@ -27,7 +27,7 @@ export function DocAttachBody({ refId, writable, onChanged, onOpenDoc }: {
27
27
  <AttachArea
28
28
  host="doc"
29
29
  refId={refId}
30
- allow={{ file: true, url: true, folder: true, task: false, ref: true }}
30
+ allow={{ file: true, url: true, folder: true, task: false, ref: true, repo: false }}
31
31
  disabled={!writable}
32
32
  disabledText="只读文档不能添加附件。"
33
33
  onChanged={onChanged}
@@ -1,24 +1,6 @@
1
1
  // group 页的 API 收口:页面组件只消费这里的函数,不直接调 api()(模板约定)。
2
2
  //
3
3
  // 只搬调用不改语义:路径 / 方法 / body 与收口前逐字一致。
4
- import { api } from '../../api/client.js';
5
-
6
- /** 恢复软删除的任务(POST /api/localtasks/tasks/restore;CLI localtask task-restore 等价)。 */
7
- export function restoreTask(body: { cwd?: string; id?: number | string }): Promise<any> {
8
- return api('/api/localtasks/tasks/restore', { method: 'POST', body });
9
- }
10
-
11
- /** 删除单个本地任务(DELETE /api/localtasks/item;purge=true 彻底删除不可恢复)。 */
12
- export function removeTask(body: { cwd?: string; id?: number | string; purge?: boolean }): Promise<any> {
13
- return api('/api/localtasks/item', { method: 'DELETE', body });
14
- }
15
-
16
- /** 队列内调序(PATCH /api/localtasks/reorder;beforeId / afterId 二选一)。 */
17
- export function reorderTask(body: {
18
- cwd?: string;
19
- id?: number | string;
20
- beforeId?: number | string;
21
- afterId?: number | string;
22
- }): Promise<any> {
23
- return api('/api/localtasks/reorder', { method: 'PATCH', body });
24
- }
4
+ // #251:任务 CRUD / 批量 / 调序与目录页合成同一份实现(api/tasks.ts)——
5
+ // 两页共用任务页模板,接口面不再各写一套。
6
+ export * from '../../api/tasks.js';
@@ -0,0 +1,41 @@
1
+ // 「组的归属项目」记忆(#187):每个组记住上次选的成员项目,下次进去直接用。
2
+ //
3
+ // 为什么是 localStorage 而不是 settings 表:这是**本机界面习惯**(跟侧栏折叠态同类),
4
+ // 不是任务数据;换机器重选一次无成本,也不该占 settings 的全局键。
5
+ const KEY = 'nx-kv-group-project-v1';
6
+
7
+ function readAll(): Record<string, string> {
8
+ try {
9
+ const raw = localStorage.getItem(KEY);
10
+ if (!raw) return {};
11
+ const v = JSON.parse(raw);
12
+ return v && typeof v === 'object' ? (v as Record<string, string>) : {};
13
+ } catch {
14
+ return {};
15
+ }
16
+ }
17
+
18
+ /** 某组上次选的归属项目 key(没记过 → 空串)。 */
19
+ export function readGroupProject(boardId: unknown): string {
20
+ const id = String(boardId || '');
21
+ if (!id) return '';
22
+ return String(readAll()[id] || '');
23
+ }
24
+
25
+ /** 记住某组的归属项目(下拉切换时调用)。 */
26
+ export function rememberGroupProject(boardId: unknown, projectKey: unknown): void {
27
+ const id = String(boardId || '');
28
+ const k = String(projectKey || '');
29
+ if (!id || !k) return;
30
+ try {
31
+ const all = readAll();
32
+ if (all[id] === k) return;
33
+ all[id] = k;
34
+ // 只保留最近 200 个组,避免 localStorage 无限长
35
+ const keys = Object.keys(all);
36
+ if (keys.length > 200) for (const old of keys.slice(0, keys.length - 200)) delete all[old];
37
+ localStorage.setItem(KEY, JSON.stringify(all));
38
+ } catch {
39
+ /* 存不进去不影响本次选择 */
40
+ }
41
+ }