nx-kv 0.66.2 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/assets/nx-kv/references/A02-/346/217/220/344/272/244/344/273/273/345/212/241.md +6 -7
  3. package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +1 -1
  4. package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +2 -2
  5. package/package.json +1 -1
  6. package/src/core/attachmentdb/ids.ts +14 -1
  7. package/src/core/attachmentdb/query.ts +0 -38
  8. package/src/core/attachmentdb/repo.ts +98 -0
  9. package/src/core/attachmentdb.ts +5 -1
  10. package/src/core/db/import-json/tasks.ts +10 -9
  11. package/src/core/db/import-json.ts +16 -6
  12. package/src/core/db/index.ts +1 -1
  13. package/src/core/db/migrations/index.ts +2 -0
  14. package/src/core/db/migrations/v15.sql +88 -0
  15. package/src/core/db/verify.ts +7 -3
  16. package/src/core/db/version.ts +4 -1
  17. package/src/core/topic-key.ts +5 -8
  18. package/src/core/workflow/readiness.ts +1 -1
  19. package/src/core/workflow/types.ts +1 -1
  20. package/src/modules/claim/assemble.ts +0 -5
  21. package/src/modules/claim/host.ts +2 -4
  22. package/src/modules/claim/preview.ts +0 -1
  23. package/src/modules/claim/wait.ts +9 -49
  24. package/src/modules/docs/actions/docs-detach.ts +1 -2
  25. package/src/modules/docs/attach.ts +3 -17
  26. package/src/modules/docs/render.ts +4 -13
  27. package/src/modules/localtask/actions/localtask-add.ts +1 -3
  28. package/src/modules/localtask/actions/localtask-attach.ts +4 -2
  29. package/src/modules/localtask/actions/localtask-boardtasks.ts +0 -1
  30. package/src/modules/localtask/actions/localtask-clone.ts +1 -1
  31. package/src/modules/localtask/actions/localtask-config.ts +2 -11
  32. package/src/modules/localtask/actions/localtask-detach.ts +1 -3
  33. package/src/modules/localtask/infra/events.ts +5 -5
  34. package/src/modules/localtask/infra/repo/rows.ts +0 -1
  35. package/src/modules/localtask/infra/repo/settings.ts +1 -9
  36. package/src/modules/localtask/infra/repo/topics.ts +0 -4
  37. package/src/modules/localtask/lifecycle/add.ts +2 -9
  38. package/src/modules/localtask/lifecycle/deletion.ts +7 -15
  39. package/src/modules/localtask/lifecycle/task-lifecycle.ts +2 -2
  40. package/src/modules/localtask/lifecycle/task-ops.ts +14 -56
  41. package/src/modules/localtask/lifecycle/task-templates.ts +0 -13
  42. package/src/modules/localtask/lifecycle/task-view.ts +2 -3
  43. package/src/modules/localtask/lifecycle/topics.ts +3 -8
  44. package/src/modules/localtask/ops/attach-resource.ts +46 -4
  45. package/src/modules/localtask/ops/attach-template.ts +73 -3
  46. package/src/modules/localtask/ops/attach.ts +45 -18
  47. package/src/modules/localtask/paths.ts +7 -17
  48. package/src/modules/localtask/service.ts +3 -7
  49. package/src/modules/localtask/ui/action-flags.ts +2 -2
  50. package/src/modules/localtask/ui/action-render.ts +7 -19
  51. package/src/modules/localtask/waiting.ts +1 -8
  52. package/src/modules/promptplug/compose.ts +1 -3
  53. package/src/modules/promptplug/plugins/attachment.ts +56 -6
  54. package/src/modules/promptplug/plugins/context.ts +11 -2
  55. package/src/modules/promptplug/template-store.ts +25 -3
  56. package/src/modules/templates/scope.ts +1 -1
  57. package/src/shared/prompt-blocks.ts +2 -23
  58. package/src/web/frontend/App.tsx +4 -9
  59. package/src/web/frontend/api/cli-tree.json +6 -6
  60. package/src/web/frontend/api/client.generated.ts +11 -11
  61. package/src/web/frontend/api/tasks.ts +117 -0
  62. package/src/web/frontend/components/Introduction/index.tsx +50 -3
  63. package/src/web/frontend/components/Introduction/style.css +6 -0
  64. package/src/web/frontend/components/Introduction/use-intro.ts +25 -0
  65. package/src/web/frontend/components/md/attachments/attach-area.tsx +9 -11
  66. package/src/web/frontend/components/md/attachments/attach-common.ts +12 -5
  67. package/src/web/frontend/components/md/attachments/attach-modal.tsx +54 -9
  68. package/src/web/frontend/components/md/attachments/attach-repo-pick.tsx +48 -0
  69. package/src/web/frontend/components/sidebar/index.tsx +52 -48
  70. package/src/web/frontend/components/sidebar/model.ts +16 -32
  71. package/src/web/frontend/components/sidebar/queue-nav.ts +3 -4
  72. package/src/web/frontend/components/sidebar/row-menu.tsx +1 -1
  73. package/src/web/frontend/components/sidebar/task-children.tsx +53 -32
  74. package/src/web/frontend/{page/dir → components/task-panel}/dag-editor.tsx +1 -1
  75. package/src/web/frontend/components/task-panel/task-ops.ts +299 -0
  76. package/src/web/frontend/components/task-panel/task-page.tsx +495 -0
  77. package/src/web/frontend/components/tool-acts/modules.ts +3 -0
  78. package/src/web/frontend/modules/board/board-view.ts +2 -56
  79. package/src/web/frontend/modules/md/doc-store.ts +2 -3
  80. package/src/web/frontend/page/dag/head-bar.tsx +0 -1
  81. package/src/web/frontend/page/dag/index.tsx +1 -4
  82. package/src/web/frontend/page/dag/model.ts +0 -1
  83. package/src/web/frontend/page/dir/api.ts +4 -108
  84. package/src/web/frontend/page/dir/index.tsx +161 -348
  85. package/src/web/frontend/page/dir/task-actions.ts +20 -32
  86. package/src/web/frontend/page/dir/task-board-section.tsx +3 -0
  87. package/src/web/frontend/page/dir/task-chain.ts +6 -10
  88. package/src/web/frontend/page/dir/task-dock-panel.tsx +3 -6
  89. package/src/web/frontend/page/dir/task-feedback.ts +9 -17
  90. package/src/web/frontend/page/dir/task-not-found.tsx +2 -3
  91. package/src/web/frontend/page/dir/task-utils.ts +0 -1
  92. package/src/web/frontend/page/dir/task.tsx +14 -18
  93. package/src/web/frontend/page/doc/doc-dock.tsx +1 -1
  94. package/src/web/frontend/page/group/api.ts +3 -21
  95. package/src/web/frontend/page/group/group-project-memo.ts +41 -0
  96. package/src/web/frontend/page/group/index.tsx +289 -429
  97. package/src/web/frontend/page/progress/index.tsx +7 -12
  98. package/src/web/frontend/page/settings/api.ts +1 -2
  99. package/src/web/frontend/page/settings/prompt-templates-section.tsx +12 -44
  100. package/src/web/frontend/panels.tsx +1 -1
  101. package/src/web/frontend/registry.ts +1 -2
  102. package/src/web/frontend/route-map.ts +0 -1
  103. package/src/web/frontend/routes/dir.ts +1 -4
  104. package/src/web/frontend/routes/keys.ts +5 -3
  105. package/src/web/frontend/svghub/catalog-nav.ts +8 -11
  106. package/src/web/public/assets/app-context-CngKv8Tc.js +1 -0
  107. package/src/web/public/assets/{bar-Dy_QDX2h.js → bar-C0Q_Qe4z.js} +1 -1
  108. package/src/web/public/assets/board-view-C8OQhkyi.js +1 -0
  109. package/src/web/public/assets/{button-3JlUeln_.js → button-Cs6w2CDi.js} +1 -1
  110. package/src/web/public/assets/{composer-launch-B7DH53Yf.js → composer-launch-BF3_hyn5.js} +1 -1
  111. package/src/web/public/assets/{composer-panel-Cj1J16r-.js → composer-panel-D6vBrzCs.js} +1 -1
  112. package/src/web/public/assets/{dag-DXRPHVl8.js → dag-CZF6sV2_.js} +1 -1
  113. package/src/web/public/assets/dir-6RhnWw1E.js +1 -0
  114. package/src/web/public/assets/doc-CVIVBV6n.js +6 -0
  115. package/src/web/public/assets/doc-DgYKv2wo.css +1 -0
  116. package/src/web/public/assets/group-AF62Z-_G.js +1 -0
  117. package/src/web/public/assets/group-project-memo-G-O6sPRw.js +1 -0
  118. package/src/web/public/assets/index-Bposj22Z.js +3 -0
  119. package/src/web/public/assets/{list-filter-CWxiOSg_.js → list-search-DFvFY408.js} +1 -1
  120. package/src/web/public/assets/md-history-COQu16vy.js +47 -0
  121. package/src/web/public/assets/{member-picker-BZgE3HGb.js → member-picker-CHX0nS0O.js} +1 -1
  122. package/src/web/public/assets/popup-dBtYqEM1.js +1 -0
  123. package/src/web/public/assets/progress-CDh6DY7g.js +3 -0
  124. package/src/web/public/assets/refs-t79ynSY8.js +2 -0
  125. package/src/web/public/assets/reopen-text-B2d9SZi0.js +13 -0
  126. package/src/web/public/assets/{repo-form-modal-CNLYR12c.js → repo-form-modal-dZqpHyUj.js} +1 -1
  127. package/src/web/public/assets/{repos-BGx-yAXd.js → repos-DdhOQJqF.js} +9 -9
  128. package/src/web/public/assets/{route-crumb-DX9C4jmQ.js → route-crumb-BKq2jry0.js} +1 -1
  129. package/src/web/public/assets/settings-Bk3clN2f.js +1 -0
  130. package/src/web/public/assets/task-C8nax2rT.js +13 -0
  131. package/src/web/public/assets/task-ops-D6E_TgEC.js +2 -0
  132. package/src/web/public/assets/task-utils-Dh33OFKe.js +1 -0
  133. package/src/web/public/assets/{templates-Co1Qb1aA.js → templates-Dusbff7Z.js} +3 -3
  134. package/src/web/public/assets/{tool-bar-D5wLBLRl.js → tool-bar-DPXnjdQF.js} +2 -2
  135. package/src/web/public/assets/use-rail-drag-B6J0iqFK.js +1 -0
  136. package/src/web/public/index.html +13 -13
  137. package/src/web/frontend/page/dir/landing.tsx +0 -553
  138. package/src/web/public/assets/app-context-BqCBcDsx.js +0 -1
  139. package/src/web/public/assets/board-view-Cm8189wG.js +0 -1
  140. package/src/web/public/assets/dir-_M1ciSxM.js +0 -3
  141. package/src/web/public/assets/doc-Iuxssa-b.css +0 -1
  142. package/src/web/public/assets/doc-_iteSM2X.js +0 -6
  143. package/src/web/public/assets/get-loop-modal-DlAfqJMz.js +0 -2
  144. package/src/web/public/assets/group-CH8qe-eg.js +0 -1
  145. package/src/web/public/assets/index-Cui4IuGj.js +0 -3
  146. package/src/web/public/assets/md-history-Bj790fdn.js +0 -46
  147. package/src/web/public/assets/popup-DZ2Khv2c.js +0 -1
  148. package/src/web/public/assets/progress-MPse2JLQ.js +0 -3
  149. package/src/web/public/assets/refs-DiIPoqnJ.js +0 -2
  150. package/src/web/public/assets/settings-Pt4YgGdY.js +0 -1
  151. package/src/web/public/assets/task-DOIIpQ4X.js +0 -13
  152. package/src/web/public/assets/task-utils-CJfMODCP.js +0 -13
  153. 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';
16
- 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';
10
+ import { useDialog } from '../../components/popup/index.jsx';
11
+ import { isGroupTask } from '../../modules/board/board-view.js';
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;
@@ -59,18 +48,14 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
59
48
  const model = app.model;
60
49
  const repos = (app.repoData && app.repoData.repos) || [];
61
50
 
62
- const isGlobal = !dirKey || dirKey === GLOBAL_KEY;
63
- const [tplMenu, setTplMenu] = useState<{ x?: number; y?: number } | null>(null);
64
51
  const [dagTask, setDagTask] = useState<LocalTask | null>(null); // 正在编排依赖的任务(DAG 节点编辑器)
65
- const fileMdRef = useRef<HTMLInputElement | null>(null);
52
+ // #165:持续 get(waitgoal)配置——按主题(仓库)粒度控制,收在工具区直读状态
53
+ const [glOpen, setGlOpen] = useState(false);
66
54
 
67
- const topic = useMemo(() => {
68
- if (isGlobal) return rows.find((r) => r.isGlobal) || null;
69
- return rows.find((r) => r.key === dirKey) || null;
70
- }, [rows, dirKey, isGlobal]);
55
+ const topic = useMemo(() => rows.find((r) => r.key === dirKey) || null, [rows, dirKey]);
71
56
 
72
57
  const repo = useMemo<RepoRow | null>(() => {
73
- if (!topic || isGlobal) return null;
58
+ if (!topic) return null;
74
59
  const rk = topic.repo && topic.repo.key;
75
60
  if (rk) {
76
61
  const byKey = repos.find((r) => r.key === rk);
@@ -79,66 +64,15 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
79
64
  const cwd = String(topic.cwd || '').replace(/\\/g, '/').toLowerCase();
80
65
  if (!cwd) return null;
81
66
  return repos.find((r) => String(r.path || '').replace(/\\/g, '/').toLowerCase() === cwd) || null;
82
- }, [topic, repos, isGlobal]);
67
+ }, [topic, repos]);
83
68
 
84
69
  // 显示序:未完成(待领取)优先,追加的新任务不会被历史埋在下面;
85
- // 软删除的行不进表。分页:队列一长就翻页,不一次渲染全部。
86
- // #85 两种走向:目录页是**项目走向**的视图——组任务(frontmatter.board)
87
- // 物理上在这条队列里,但归组页管,列表与下面的计数/编排一并排除。
70
+ // 软删除的行不进表。#85 两种走向:目录页是**项目走向**的视图——组任务
71
+ // (frontmatter.board)物理上在这条队列里,但归组页管,列表与计数一并排除。
88
72
  const allTasks = useMemo<LocalTask[]>(
89
73
  () => sortTasksForDisplay((topic?.tasks || []).filter((t) => !t.deletedAt && !isGroupTask(t))),
90
74
  [topic]
91
75
  );
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
76
 
143
77
  // 闸门 → 被它挡住的后续任务(队列序:pending 子序即领取序)。
144
78
  // 领取闸判定只看「排在我前面的 alive 闸门」(core/workflow/readiness),同一口径。
@@ -155,6 +89,46 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
155
89
  [allTasks]
156
90
  );
157
91
 
92
+ // #181 搜索 / 分页 / 多选 / 拖动 / 行尾菜单都由 TaskPage 持有;这里只给行数据。
93
+ const pageRows = useMemo<TaskPageRow[]>(
94
+ () =>
95
+ allTasks.map((t) => ({
96
+ key: String(t.id),
97
+ task: t,
98
+ showTimes: true, // 目录页基线:行内显示 创建 → 领取 时间
99
+ movable: t.status === 'pending' && !t.migratedTo && !t.deletedAt,
100
+ downs: downstreamOf[t.id] || [],
101
+ })),
102
+ [allTasks, downstreamOf]
103
+ );
104
+
105
+ const guard = (fn: () => Promise<unknown>) => fn().catch((e) => toast(String((e as Error).message || e)));
106
+
107
+ // 主题定位:按目录 cwd(行尾 / 批量 / 编排同一套;#190 全局池已删除)
108
+ const scopeBody = () => ({ cwd: topic?.cwd });
109
+ const topicKeyHere = dirKey || '';
110
+ // 持续 get 的展示态(配置本身在 GetLoopModal 里改)
111
+ const glOn = !!(repo && repo.getLoop && repo.getLoop.enabled);
112
+ const glMinutes = repo && repo.getLoop && repo.getLoop.waitMinutes !== undefined && repo.getLoop.waitMinutes !== null
113
+ ? Number(repo.getLoop.waitMinutes)
114
+ : null;
115
+
116
+ // 动作层的依赖:弹窗 / 提示 / 刷新 / 文档落点都来自本页
117
+ const ops: TaskOpsDeps = {
118
+ dialog,
119
+ toast,
120
+ refresh: () => {
121
+ refreshLocal?.();
122
+ },
123
+ docKey: dirKey || 'local',
124
+ onDeleted: (t) => {
125
+ if (!model) return;
126
+ // workspace.findOpenPanel 的返回类型尚未收口(被推断成 null),按实际契约窄化
127
+ const page = findOpenPanel(model, 'page', { dirKey, task: String(t.id) }) as { getId: () => string } | null;
128
+ if (page && app.closePanel) app.closePanel(page.getId());
129
+ },
130
+ };
131
+
158
132
  const openTask = (id: number | string) => {
159
133
  if (app.openPage) app.openPage({ dirKey, task: String(id), name: `#${id}` });
160
134
  };
@@ -171,8 +145,8 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
171
145
  const openTplList = () => {
172
146
  const id = putManageSession({
173
147
  topic: topicKeyHere,
174
- repo: isGlobal ? '' : (repo?.key || ''),
175
- label: isGlobal ? '全局池' : (topic?.name || dirKey || '本目录'),
148
+ repo: repo?.key || '',
149
+ label: topic?.name || dirKey || '本目录',
176
150
  });
177
151
  app.onNavigate?.(`#/templates/manage/${id}`);
178
152
  };
@@ -182,14 +156,13 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
182
156
  openPanel(model, {
183
157
  component: 'progress',
184
158
  name: '进程',
185
- config: { dirKey: dirKey || GLOBAL_KEY },
159
+ config: { dirKey: dirKey || '' },
186
160
  location: 'right',
187
161
  });
188
162
  };
189
163
 
190
164
  // #128 模板可见域:「模板 ▾」只列**本主题可用**的模板(服务端按 scope 过滤)。
191
165
  // 三档退化都回落全量(scoped 未加载/旧 serve/失败时 templates=null),菜单不变空。
192
- const topicKeyHere = isGlobal ? GLOBAL_KEY : dirKey || GLOBAL_KEY;
193
166
  const scopedTpl = useTemplatesFor(topicKeyHere);
194
167
  const menuTemplates: PromptTemplate[] = scopedTpl.templates || (tpl && tpl.templates) || [];
195
168
 
@@ -202,7 +175,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
202
175
  openTemplateEditor(model, {
203
176
  mode: 'new',
204
177
  topic: topicKeyHere,
205
- scope: isGlobal ? [] : [`topic:${topicKeyHere}`],
178
+ scope: [`topic:${topicKeyHere}`],
206
179
  name: '',
207
180
  });
208
181
  };
@@ -223,184 +196,14 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
223
196
  },
224
197
  }]),
225
198
  'sep',
226
- { label: `为本${isGlobal ? '全局池' : '目录'}新建模板…`, icon: 'plus', onClick: newTemplateForHere },
199
+ { label: '为本目录新建模板…', icon: 'plus', onClick: newTemplateForHere },
227
200
  { label: '管理模板…', icon: 'gear', onClick: openTplList },
228
201
  ];
229
202
 
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
203
  // ─── 文档列表(右侧栏)────────────────────────────────────────────
401
204
  const openRefs = () => {
402
- if (isGlobal || !repo) {
403
- toast('全局池没有项目文档列表');
205
+ if (!repo) {
206
+ toast('这个目录还没有登记为仓库,没有项目文档列表');
404
207
  return;
405
208
  }
406
209
  if (!model) return;
@@ -422,7 +225,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
422
225
  const name = file.name.replace(/\.md$/i, '');
423
226
  await guard(async () => {
424
227
  const bodyText = text.startsWith('#') ? text : `# ${name}\n\n${text}`;
425
- const res = await addTask(isGlobal ? { global: true, text: bodyText } : { cwd: topic?.cwd, text: bodyText });
228
+ const res = await addTask({ cwd: topic?.cwd, text: bodyText });
426
229
  toast(`已导入:${file.name}`);
427
230
  refreshLocal?.();
428
231
  const newId = res?.task?.id ?? res?.id;
@@ -430,17 +233,11 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
430
233
  });
431
234
  };
432
235
 
433
- if (!topic && !isGlobal) {
236
+ if (!topic) {
237
+ // 空态与组页同骨架(#170:落地页不套 .mdw 编辑器外壳;#251:两页空态都走 rp-page)
434
238
  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>
239
+ <div className="rp-page">
240
+ <div className="rp-empty">目录不存在(主题可能被删了)</div>
444
241
  </div>
445
242
  );
446
243
  }
@@ -450,68 +247,84 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
450
247
  // (自带 canvas 米色底 + 一整套 .mdw 作用域的按钮/字号口径)。落地页只是
451
248
  // 队列列表页,套上它会让**同款按钮在目录页与项目组页呈现两套观感**
452
249
  // (.mdw .btn.ghost 透明浅边 vs .btn.ghost 灰底),页面底色也不同。
453
- // 编辑器分支仍用 .mdw(那是编辑器,本就该有工作台外壳)。
454
250
  <>
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);
251
+ <TaskPage
252
+ kind="dir"
253
+ name={topic?.name || '目录'}
254
+ title='任务'
255
+ intro={repo ? <Introduction kind="repo" owner={repo} model={model} /> : null}
256
+ rows={pageRows}
257
+ emptyText='还没有页面:点「+ 新建页」写第一篇,或让 agent 往这个目录投递任务。'
258
+ tplMenuItems={tplMenuItems}
259
+ onNew={() => {
260
+ const p = tpl ? tpl.defaultPick() : null;
261
+ newDraft(p ? p.body : '');
511
262
  }}
263
+ onOpenRow={(r) => openTask(r.task.id)}
264
+ onImportFile={(f) => void importMd(f)}
265
+ onMoveRow={(src, dst, zone) => guard(async () => {
266
+ // 服务端只许 pending ↔ pending 换位(已领取是固定历史),UI 侧已同口径过滤
267
+ await reorderTask({
268
+ ...scopeBody(),
269
+ id: src.task.id,
270
+ ...(zone === 'before' ? { beforeId: dst.task.id } : { afterId: dst.task.id }),
271
+ });
272
+ refreshLocal?.();
273
+ })}
274
+ onTogglePlan={(rs, to) =>
275
+ void runPlanSwitch(ops, [{ scope: { key: topicKeyHere }, ids: rs.map((r) => r.task.id) }], to)
276
+ }
277
+ onOpenDag={(r) => setDagTask(r.task)}
278
+ onToggleGate={(r) => void runToggleGate(ops, scopeBody(), r.task)}
279
+ onFeedback={(r) => void runFeedbackTask(ops, scopeBody(), r.task)}
280
+ onDeleteRow={(r) => void runDeleteTask(ops, scopeBody(), r.task)}
281
+ onDeleteRows={(rs) =>
282
+ runBatchDelete(ops, [{ scope: scopeBody(), ids: rs.map((r) => Number(r.task.id)) }])
283
+ }
284
+ onCancelRows={(rs) =>
285
+ runBatchCancel(ops, [{ scope: scopeBody(), ids: rs.map((r) => Number(r.task.id)) }])
286
+ }
287
+ onCompleteRows={(rs) =>
288
+ runBatchComplete(ops, [{ scope: scopeBody(), ids: rs.map((r) => Number(r.task.id)) }])
289
+ }
290
+ toolActs={{
291
+ // #165:持续 get 开/关状态直读(配置弹窗点开改)
292
+ renderers: {
293
+ getloop: () => (
294
+ <button
295
+ type="button"
296
+ className="btn small ghost"
297
+ title={glOn
298
+ ? `持续 get 已开启:agent 领完任务没活时会阻塞等待(每轮 ${glMinutes ?? 10} 分钟)——点这里去配置/关闭`
299
+ : '持续 get 未开启:开启后 agent 领完任务没活会自动唤起阻塞等待——点这里配置'}
300
+ onClick={() => setGlOpen(true)}
301
+ >
302
+ {glOn ? `持续 get:开(${glMinutes ?? 10} 分钟)` : '持续 get:关'}
303
+ </button>
304
+ ),
305
+ },
306
+ actions: {
307
+ progress: openProgress,
308
+ orch: () => model && openPanel(model, { component: 'dag', name: '编排', config: { dirKey } }),
309
+ refs: openRefs,
310
+ getloop: () => setGlOpen(true),
311
+ },
312
+ }}
313
+ actionExtra={glOpen && repo ? <GetLoopModal repo={repo} onClose={() => setGlOpen(false)} onSaved={() => app.refreshRepos?.()} /> : null}
314
+ extra={
315
+ <>
316
+ {dagTask && (
317
+ <DagEditor
318
+ task={dagTask}
319
+ tasks={dagCandidates}
320
+ onClose={() => setDagTask(null)}
321
+ onSave={(patches: DagPatchInput[]) => saveDagPatches(ops, scopeBody(), patches)}
322
+ />
323
+ )}
324
+ {dialogNode}
325
+ </>
326
+ }
512
327
  />
513
-
514
- {dialogNode}
515
328
  </>
516
329
  );
517
330
  }