nx-kv 0.48.2 → 0.50.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 (309) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +103 -216
  3. package/assets/groups.json +1 -1
  4. package/assets/kv-get/SKILL.md +1 -1
  5. package/assets/kv-get/references/localget.md +2 -2
  6. package/assets/kv-get/references/timegoal-workflow.md +3 -3
  7. package/assets/kv-get/references/timegoal.md +1 -1
  8. package/assets/kv-get/references/wait-workflow.md +2 -3
  9. package/assets/kv-get/references/waitloop.md +3 -3
  10. package/assets/kv-repo/SKILL.md +1 -1
  11. package/assets/kv-submit/SKILL.md +3 -3
  12. package/assets/nx-kv/SKILL.md +111 -76
  13. package/assets/nx-kv/references/agent-workflow.md +58 -47
  14. package/assets/nx-kv/references/localtask-commands.md +179 -0
  15. package/package.json +3 -4
  16. package/src/core/attachmentdb/bodies.ts +193 -0
  17. package/src/core/attachmentdb/docs.ts +158 -33
  18. package/src/core/attachmentdb/ids.ts +27 -1
  19. package/src/core/attachmentdb/mdfile.ts +249 -0
  20. package/src/core/attachmentdb/query.ts +14 -1
  21. package/src/core/attachmentdb/resources.ts +28 -2
  22. package/src/core/attachmentdb.ts +27 -0
  23. package/src/core/config.ts +13 -133
  24. package/src/core/db/bootstrap.ts +5 -5
  25. package/src/core/db/import-json/refs.ts +27 -13
  26. package/src/core/db/migrations/index.ts +9 -0
  27. package/src/core/db/migrations/v2-data.ts +4 -4
  28. package/src/core/db/migrations/v5.sql +100 -0
  29. package/src/core/db/migrations/v6-data.ts +261 -0
  30. package/src/core/db/migrations/v6.sql +67 -0
  31. package/src/core/db/migrations/v7.sql +8 -0
  32. package/src/core/db/seed-templates.ts +3 -1
  33. package/src/core/db/version.ts +12 -1
  34. package/src/core/filekind.ts +95 -0
  35. package/src/core/instruction-template.ts +6 -4
  36. package/src/core/localatt.ts +3 -6
  37. package/src/core/paths.ts +11 -1
  38. package/src/index.ts +0 -2
  39. package/src/modules/docs/actions/_manifest.generated.ts +18 -0
  40. package/src/modules/docs/actions/doc-attach.ts +2 -1
  41. package/src/modules/docs/actions/doc-link-file.ts +28 -0
  42. package/src/modules/docs/actions/doc-mdfile.ts +28 -0
  43. package/src/modules/docs/actions/doc-mdfiles.ts +29 -0
  44. package/src/modules/docs/actions/doc-ref.ts +36 -0
  45. package/src/modules/docs/actions/doc-unbind.ts +34 -0
  46. package/src/modules/docs/actions/doc-update.ts +3 -2
  47. package/src/modules/docs/actions/docs-bind.ts +1 -1
  48. package/src/modules/docs/actions/docs-bindings.ts +108 -0
  49. package/src/modules/docs/actions/docs-notebind.ts +1 -1
  50. package/src/modules/docs/attach.ts +16 -3
  51. package/src/modules/docs/bound-docs.ts +74 -0
  52. package/src/modules/docs/docref.ts +18 -3
  53. package/src/modules/docs/knowledge-md.ts +51 -0
  54. package/src/modules/docs/knowledge.ts +112 -112
  55. package/src/modules/docs/links.ts +7 -1
  56. package/src/modules/docs/mdfile.ts +24 -0
  57. package/src/modules/docs/paths.ts +6 -9
  58. package/src/modules/docs/ref-sync.ts +166 -0
  59. package/src/modules/docs/refs.ts +16 -5
  60. package/src/modules/docs/render.ts +33 -15
  61. package/src/modules/docs/seed.ts +1 -1
  62. package/src/modules/docs/service.ts +300 -30
  63. package/src/modules/docs/store.ts +147 -74
  64. package/src/modules/file/actions/_manifest.generated.ts +0 -9
  65. package/src/modules/file/actions/file-content.ts +3 -4
  66. package/src/modules/file/actions/file-get.ts +2 -3
  67. package/src/modules/file/actions/file-upload.ts +1 -4
  68. package/src/modules/file/service.ts +52 -253
  69. package/src/modules/localtask/action-render.ts +5 -5
  70. package/src/modules/localtask/actions/_manifest.generated.ts +0 -6
  71. package/src/modules/localtask/actions/localtask-attach.ts +4 -2
  72. package/src/modules/localtask/actions/localtask-cancelMany.ts +1 -1
  73. package/src/modules/localtask/actions/localtask-closeMany.ts +4 -3
  74. package/src/modules/localtask/actions/localtask-get.ts +1 -1
  75. package/src/modules/localtask/repo/tasks.ts +12 -6
  76. package/src/modules/localtask/service.ts +0 -2
  77. package/src/modules/localtask/task-ops.ts +4 -4
  78. package/src/modules/localtask/task-remove.ts +33 -16
  79. package/src/modules/localtask/task-templates.ts +2 -3
  80. package/src/modules/localtask/task-view.ts +2 -2
  81. package/src/modules/repos/actions/_manifest.generated.ts +0 -3
  82. package/src/modules/repos/actions/repo-update.ts +2 -4
  83. package/src/modules/repos/cli/render.ts +0 -15
  84. package/src/modules/repos/service/bind-topics.ts +8 -18
  85. package/src/modules/repos/service.ts +1 -1
  86. package/src/modules/repos/transfer/export.ts +4 -1
  87. package/src/modules/setting/actions/setting-set.ts +0 -2
  88. package/src/modules/setting/service.ts +6 -25
  89. package/src/modules/system/actions/bootstrap.ts +2 -31
  90. package/src/modules/system/actions/health.ts +4 -31
  91. package/src/modules/system/routes.ts +1 -1
  92. package/src/modules/tasktool/attach-resource.ts +68 -42
  93. package/src/modules/tasktool/attach-template.ts +73 -54
  94. package/src/modules/tasktool/attach.ts +98 -71
  95. package/src/modules/tasktool/delivery-template.ts +14 -4
  96. package/src/modules/tasktool/doc-inline.ts +63 -29
  97. package/src/modules/tasktool/get.ts +1 -1
  98. package/src/modules/tasktool/groupctx.ts +19 -11
  99. package/src/modules/tasktool/plugins/waitgoal-config.ts +24 -55
  100. package/src/modules/tasktool/plugins/waitgoal.ts +0 -2
  101. package/src/modules/tasktool/preview.ts +2 -3
  102. package/src/modules/tasktool/wait.ts +6 -9
  103. package/src/runtime/cli.ts +3 -15
  104. package/src/runtime/container.ts +1 -5
  105. package/src/runtime/help.ts +1 -4
  106. package/src/runtime/registry.ts +0 -6
  107. package/src/shared/prompt-blocks.ts +37 -33
  108. package/src/shared/task-status.ts +3 -3
  109. package/src/web/frontend/App.tsx +3 -3
  110. package/src/web/frontend/api/cli-tree.json +115 -608
  111. package/src/web/frontend/api/client.generated.ts +88 -401
  112. package/src/web/frontend/components/Introduction/index.tsx +26 -14
  113. package/src/web/frontend/components/Introduction/rail.tsx +28 -3
  114. package/src/web/frontend/components/Introduction/style.css +3 -33
  115. package/src/web/frontend/components/Introduction/use-intro.ts +0 -80
  116. package/src/web/frontend/components/{cloud → attach}/upload.ts +7 -20
  117. package/src/web/frontend/components/bindings/bind-tags.tsx +183 -0
  118. package/src/web/frontend/components/doc/doc-head.tsx +29 -26
  119. package/src/web/frontend/components/icons.tsx +0 -1
  120. package/src/web/frontend/components/layout/crumbs.ts +0 -2
  121. package/src/web/frontend/components/md/ack-rail.tsx +10 -142
  122. package/src/web/frontend/components/md/attach-area.tsx +64 -9
  123. package/src/web/frontend/components/md/attach-common.ts +8 -3
  124. package/src/web/frontend/components/md/attach-modal.tsx +22 -17
  125. package/src/web/frontend/components/md/attach-picker.tsx +2 -2
  126. package/src/web/frontend/components/md/attachments.ts +2 -3
  127. package/src/web/frontend/components/popup/dismiss.ts +1 -1
  128. package/src/web/frontend/components/repos/get-loop-modal.tsx +20 -207
  129. package/src/web/frontend/components/sidebar/index.tsx +32 -6
  130. package/src/web/frontend/components/sidebar/model.ts +71 -0
  131. package/src/web/frontend/components/sidebar/task-children.tsx +41 -20
  132. package/src/web/frontend/components/status-tag/model.ts +1 -1
  133. package/src/web/frontend/components/task-panel/index.tsx +4 -1
  134. package/src/web/frontend/components/task-panel/task-row.tsx +2 -2
  135. package/src/web/frontend/components/tool-acts/modules.ts +0 -3
  136. package/src/web/frontend/components/use-rail-drag.ts +177 -0
  137. package/src/web/frontend/modules/board/ack-rail-pos.ts +17 -7
  138. package/src/web/frontend/modules/board/board-view.ts +2 -2
  139. package/src/web/frontend/modules/board/task-search.ts +81 -0
  140. package/src/web/frontend/modules/md/attach-mention.ts +6 -1
  141. package/src/web/frontend/modules/md/doc-bus.ts +22 -0
  142. package/src/web/frontend/modules/md/md-render.ts +9 -2
  143. package/src/web/frontend/modules/md/styles/chrome.css +25 -0
  144. package/src/web/frontend/modules/md/styles/docs.css +32 -21
  145. package/src/web/frontend/modules/md/styles/shell.css +1 -10
  146. package/src/web/frontend/page/dir/api.ts +7 -0
  147. package/src/web/frontend/page/dir/index.tsx +24 -58
  148. package/src/web/frontend/page/dir/landing.tsx +85 -72
  149. package/src/web/frontend/page/dir/task-actions.ts +17 -5
  150. package/src/web/frontend/page/dir/task-dock-panel.tsx +87 -2
  151. package/src/web/frontend/page/dir/task-dock.ts +21 -10
  152. package/src/web/frontend/page/dir/task-goal.ts +2 -2
  153. package/src/web/frontend/page/dir/task-status-bar.tsx +14 -1
  154. package/src/web/frontend/page/dir/task.tsx +5 -3
  155. package/src/web/frontend/page/doc/api.ts +71 -5
  156. package/src/web/frontend/page/doc/bindings.tsx +240 -0
  157. package/src/web/frontend/page/doc/doc-dock.tsx +159 -0
  158. package/src/web/frontend/page/doc/index.tsx +131 -212
  159. package/src/web/frontend/page/doc/use-wiki-nav.ts +101 -0
  160. package/src/web/frontend/page/group/index.tsx +61 -87
  161. package/src/web/frontend/page/overview/index.tsx +1 -2
  162. package/src/web/frontend/page/refs/api.ts +60 -8
  163. package/src/web/frontend/page/refs/index.tsx +177 -90
  164. package/src/web/frontend/page/refs/style.css +45 -2
  165. package/src/web/frontend/page/repos/doc-search-modal.tsx +7 -0
  166. package/src/web/frontend/page/repos/index.tsx +21 -60
  167. package/src/web/frontend/page/repos/repo-table.tsx +85 -77
  168. package/src/web/frontend/page/settings/index.tsx +3 -27
  169. package/src/web/frontend/page/settings/prompt-template-params.ts +18 -28
  170. package/src/web/frontend/panels.tsx +52 -6
  171. package/src/web/frontend/registry.ts +1 -2
  172. package/src/web/frontend/routes/index.ts +1 -2
  173. package/src/web/frontend/routes/static.ts +2 -3
  174. package/src/web/frontend/store.tsx +1 -8
  175. package/src/web/frontend/style.css +1 -0
  176. package/src/web/frontend/styles/base.css +0 -17
  177. package/src/web/frontend/styles/bindings.css +75 -0
  178. package/src/web/frontend/styles/buttons-cards.css +0 -72
  179. package/src/web/frontend/styles/repos-admin.css +7 -5
  180. package/src/web/frontend/styles-v2/dir.css +1 -9
  181. package/src/web/frontend/styles-v2/shell.css +0 -2
  182. package/src/web/frontend/styles-v2/sidebar.css +12 -0
  183. package/src/web/frontend/styles-v2/views.css +22 -102
  184. package/src/web/frontend/workspace/areas.ts +0 -2
  185. package/src/web/public/assets/Introduction-CohW6Xit.js +6 -0
  186. package/src/web/public/assets/Introduction-Iuxssa-b.css +1 -0
  187. package/src/web/public/assets/app-context-BgpTewyA.js +1 -0
  188. package/src/web/public/assets/{bar-B52NTf_v.js → bar-C2mfoqmj.js} +1 -1
  189. package/src/web/public/assets/{board-view-DABoVkaA.js → board-view-aAIEbSQi.js} +1 -1
  190. package/src/web/public/assets/button-xyR2UROd.js +1 -0
  191. package/src/web/public/assets/composer-launch-eTktHT_f.js +1 -0
  192. package/src/web/public/assets/{composer-panel-DpiU2h50.js → composer-panel-C0OOIXxz.js} +1 -1
  193. package/src/web/public/assets/dag-Gm4RcvEg.js +1 -0
  194. package/src/web/public/assets/dir-PjuMRbWo.js +3 -0
  195. package/src/web/public/assets/group-D94y_Lq6.js +1 -0
  196. package/src/web/public/assets/index-CBJKsJU3.css +1 -0
  197. package/src/web/public/assets/index-Crxdmsux.js +2 -0
  198. package/src/web/public/assets/md-history-CU_1I6ht.js +39 -0
  199. package/src/web/public/assets/{md-parse-b6GY5eBl.js → md-parse-CLyUaUto.js} +1 -1
  200. package/src/web/public/assets/{member-picker-B5I7KuOR.js → member-picker-XT12VRe6.js} +1 -1
  201. package/src/web/public/assets/model-CWJ8_2dN.js +2 -0
  202. package/src/web/public/assets/{overview-B3kHI66i.js → overview-BQm8BLCG.js} +1 -1
  203. package/src/web/public/assets/{progress-CdhFz0Lz.js → progress-CNam3Wuj.js} +2 -2
  204. package/src/web/public/assets/refs-C5idWnUj.css +1 -0
  205. package/src/web/public/assets/refs-ClETk1cj.js +2 -0
  206. package/src/web/public/assets/repos-BioGejZo.js +14 -0
  207. package/src/web/public/assets/route-crumb-Fc68LcQ4.js +1 -0
  208. package/src/web/public/assets/settings-BIzumXLD.js +8 -0
  209. package/src/web/public/assets/status-tag-CBFf_-ae.js +1 -0
  210. package/src/web/public/assets/task-CGmO3I2y.js +11 -0
  211. package/src/web/public/assets/task-row-DRBa11tf.js +1 -0
  212. package/src/web/public/assets/{task-status-DSrx0i66.js → task-status-BHF-y9Aq.js} +2 -1
  213. package/src/web/public/assets/{task-utils-_JAWRAz6.js → task-utils-DjODjVdc.js} +2 -2
  214. package/src/web/public/assets/{templates-CbRyW3PJ.js → templates-j8EzXHXf.js} +1 -1
  215. package/src/web/public/assets/ui-Y0aL-bGk.js +1 -0
  216. package/src/web/public/assets/use-rail-drag-DNfz4Gcx.js +1 -0
  217. package/src/web/public/assets/{workspace-4tw7trV7.js → workspace-D_G-B3TX.js} +4 -4
  218. package/src/web/public/index.html +9 -9
  219. package/assets/nx-kv/references/todo-commands.md +0 -269
  220. package/src/core/attachstore.ts +0 -360
  221. package/src/core/fileapi.ts +0 -267
  222. package/src/core/kvapi.ts +0 -237
  223. package/src/modules/auth/actions/_manifest.generated.ts +0 -26
  224. package/src/modules/auth/actions/auth-login.ts +0 -31
  225. package/src/modules/auth/actions/auth-logout.ts +0 -33
  226. package/src/modules/auth/actions/auth-me.ts +0 -33
  227. package/src/modules/auth/actions/auth-status.ts +0 -41
  228. package/src/modules/auth/index.ts +0 -24
  229. package/src/modules/auth/support.ts +0 -28
  230. package/src/modules/file/actions/file-list.ts +0 -31
  231. package/src/modules/file/actions/file-remove.ts +0 -31
  232. package/src/modules/file/actions/file-sync.ts +0 -33
  233. package/src/modules/localtask/actions/localtask-importRemote.ts +0 -51
  234. package/src/modules/localtask/actions/task-move.ts +0 -67
  235. package/src/modules/localtask/move-prims.ts +0 -170
  236. package/src/modules/localtask/move.ts +0 -174
  237. package/src/modules/localtask/remote-import.ts +0 -159
  238. package/src/modules/repos/actions/repo-ref-backfill.ts +0 -33
  239. package/src/modules/repos/ref-backfill.ts +0 -219
  240. package/src/modules/todo/actions/_manifest.generated.ts +0 -89
  241. package/src/modules/todo/actions/group-add.ts +0 -34
  242. package/src/modules/todo/actions/group-current.ts +0 -36
  243. package/src/modules/todo/actions/group-get.ts +0 -43
  244. package/src/modules/todo/actions/group-list.ts +0 -41
  245. package/src/modules/todo/actions/group-members.ts +0 -41
  246. package/src/modules/todo/actions/group-remove.ts +0 -44
  247. package/src/modules/todo/actions/group-update.ts +0 -37
  248. package/src/modules/todo/actions/group-use.ts +0 -43
  249. package/src/modules/todo/actions/prompt-get.ts +0 -31
  250. package/src/modules/todo/actions/prompt-remove.ts +0 -31
  251. package/src/modules/todo/actions/prompt-set.ts +0 -32
  252. package/src/modules/todo/actions/todo-add.ts +0 -34
  253. package/src/modules/todo/actions/todo-archive.ts +0 -33
  254. package/src/modules/todo/actions/todo-attach.ts +0 -37
  255. package/src/modules/todo/actions/todo-attachments.ts +0 -33
  256. package/src/modules/todo/actions/todo-done.ts +0 -33
  257. package/src/modules/todo/actions/todo-freeze.ts +0 -32
  258. package/src/modules/todo/actions/todo-get.ts +0 -33
  259. package/src/modules/todo/actions/todo-list.ts +0 -32
  260. package/src/modules/todo/actions/todo-remove.ts +0 -32
  261. package/src/modules/todo/actions/todo-unfreeze.ts +0 -34
  262. package/src/modules/todo/actions/todo-update.ts +0 -42
  263. package/src/modules/todo/actions/topic-add.ts +0 -31
  264. package/src/modules/todo/actions/topic-list.ts +0 -35
  265. package/src/modules/todo/actions/topic-remove.ts +0 -36
  266. package/src/modules/todo/attachments.ts +0 -194
  267. package/src/modules/todo/group.ts +0 -207
  268. package/src/modules/todo/index.ts +0 -26
  269. package/src/modules/todo/locate.ts +0 -103
  270. package/src/modules/todo/service.ts +0 -476
  271. package/src/modules/todo/store.ts +0 -176
  272. package/src/modules/todo/support.ts +0 -93
  273. package/src/web/frontend/components/Introduction/docs-modal.tsx +0 -338
  274. package/src/web/frontend/components/cloud/editor.tsx +0 -254
  275. package/src/web/frontend/components/cloud/group-popup.tsx +0 -198
  276. package/src/web/frontend/components/cloud/markdown.tsx +0 -60
  277. package/src/web/frontend/components/migrate/dialog.tsx +0 -120
  278. package/src/web/frontend/components/migrate/undo.tsx +0 -73
  279. package/src/web/frontend/components/migrate/use-move.ts +0 -137
  280. package/src/web/frontend/page/cloud/api.ts +0 -99
  281. package/src/web/frontend/page/cloud/index.tsx +0 -516
  282. package/src/web/frontend/page/dir/deleted-panel.tsx +0 -77
  283. package/src/web/public/assets/Introduction-BcPrmROW.css +0 -1
  284. package/src/web/public/assets/Introduction-Du_dycft.js +0 -6
  285. package/src/web/public/assets/app-context-BASCGAA-.js +0 -1
  286. package/src/web/public/assets/cloud-Droja_aT.js +0 -3
  287. package/src/web/public/assets/composer-launch-mK9Nr6mZ.js +0 -1
  288. package/src/web/public/assets/dag-Ca-wjIxQ.js +0 -1
  289. package/src/web/public/assets/deleted-panel-K9GgfR8t.js +0 -1
  290. package/src/web/public/assets/dir-DacRpcBt.js +0 -5
  291. package/src/web/public/assets/frontmatter-CLLxCmTv.js +0 -2
  292. package/src/web/public/assets/group-TPuU-QVc.js +0 -2
  293. package/src/web/public/assets/index-BkLkooKe.js +0 -2
  294. package/src/web/public/assets/index-DP3qBv1o.css +0 -1
  295. package/src/web/public/assets/md-history-0GBWw4qr.js +0 -39
  296. package/src/web/public/assets/model-Bn2fG6CC.js +0 -2
  297. package/src/web/public/assets/prompt-blocks-BovFd039.js +0 -8
  298. package/src/web/public/assets/refs-BDxfuH6R.js +0 -1
  299. package/src/web/public/assets/refs-CY4i7PoC.css +0 -1
  300. package/src/web/public/assets/repos-C8jRM7wS.js +0 -15
  301. package/src/web/public/assets/repos-ZPiaK93i.css +0 -1
  302. package/src/web/public/assets/route-crumb-QvahotvN.js +0 -1
  303. package/src/web/public/assets/settings-BBcdGLTc.js +0 -1
  304. package/src/web/public/assets/status-tag-BheHByek.js +0 -1
  305. package/src/web/public/assets/task-CUkQaLBZ.js +0 -11
  306. package/src/web/public/assets/tool-bar-BAmT-BI-.js +0 -1
  307. package/src/web/public/assets/upload-BcMhRsMn.js +0 -1
  308. /package/src/web/public/assets/{prompt-blocks-DA4lNJeC.css → button-DA4lNJeC.css} +0 -0
  309. /package/src/web/public/assets/{tool-bar-1h2zairf.css → use-rail-drag-1h2zairf.css} +0 -0
@@ -1,5 +1,5 @@
1
1
  // 目录面板 —— 简介(统一 Introduction)+ 子任务表。
2
- import { useMemo, useRef, useState } from 'react';
2
+ import { useEffect, useMemo, useRef, useState } from 'react';
3
3
  import {
4
4
  addTask,
5
5
  cancelManyTasks,
@@ -10,11 +10,11 @@ import {
10
10
  removeTaskItem,
11
11
  reorderTask,
12
12
  postReopen,
13
- restoreTaskItem,
14
13
  } from './api.js';
15
14
  import { useToast } from '../../components/toast/index.jsx';
16
15
  import { useDialog, PopMenu } from '../../components/popup/index.jsx';
17
16
  import { GLOBAL_KEY, isGroupTask } from '../../modules/board/board-view.js';
17
+ import { filterTasks } from '../../modules/board/task-search.js';
18
18
  import {
19
19
  FEEDBACK_HEADING,
20
20
  PLAIN_FEEDBACK_HEADING,
@@ -24,7 +24,6 @@ import { usePager } from '../../components/pager.jsx';
24
24
  import { useApp } from '../../app-context.jsx';
25
25
  import Landing from './landing.jsx';
26
26
  import DagEditor from './dag-editor.jsx';
27
- import DeletedPanel from './deleted-panel.jsx';
28
27
  import { findOpenPanel, openPanel } from '../../workspace.js';
29
28
  import { openSettingsPanel, openTemplateEditor } from '../../panels.jsx';
30
29
  import { docIdOf, nextDraftId, saveDoc, scopeOf } from '../../modules/md/doc-store.js';
@@ -63,7 +62,6 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
63
62
 
64
63
  const isGlobal = !dirKey || dirKey === GLOBAL_KEY;
65
64
  const [tplMenu, setTplMenu] = useState<{ x?: number; y?: number } | null>(null);
66
- const [showDeleted, setShowDeleted] = useState(false); // 已删除任务面板开关
67
65
  const [dagTask, setDagTask] = useState<LocalTask | null>(null); // 正在编排依赖的任务(DAG 节点编辑器)
68
66
  const fileMdRef = useRef<HTMLInputElement | null>(null);
69
67
 
@@ -92,10 +90,19 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
92
90
  () => sortTasksForDisplay((topic?.tasks || []).filter((t) => !t.deletedAt && !isGroupTask(t))),
93
91
  [topic]
94
92
  );
95
- const pager = usePager(allTasks, PAGE_SIZE);
93
+ // #181:面板头搜索框——标题与正文都算命中目标(模糊串规则见 modules/board/task-search);
94
+ // 先过滤再分页,翻页条报的是命中数。
95
+ const [q, setQ] = useState('');
96
+ const shownTasks = useMemo(() => filterTasks(allTasks, q), [allTasks, q]);
97
+ const pager = usePager(shownTasks, PAGE_SIZE);
98
+ // 改查询串就回到第一页(否则会停在「上一结果的第 3 页」上,看起来像没命中)
99
+ useEffect(() => {
100
+ pager.setPage(0);
101
+ }, [q]);
102
+ // 待领取计数跟着**筛后**的集合走:搜索时头部「待领取 N」要与屏幕上的行对得上
96
103
  const pendingCount = useMemo(
97
- () => allTasks.filter((t) => t.status === 'pending' && !t.migratedTo).length,
98
- [allTasks]
104
+ () => shownTasks.filter((t) => t.status === 'pending' && !t.migratedTo).length,
105
+ [shownTasks]
99
106
  );
100
107
  const guard = (fn: () => Promise<unknown>) => fn().catch((e) => toast(String((e as Error).message || e)));
101
108
 
@@ -345,7 +352,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
345
352
  if (!list.length) return false;
346
353
  const ok = await dialog({
347
354
  title: `取消选中的 ${list.length} 条待领取任务`,
348
- message: '只处理待领取任务;已领取/已交付/已取消会跳过。取消为终态,原文留档。',
355
+ message: '只处理待领取任务;已领取/已完成/已取消会跳过。取消为终态,原文留档。',
349
356
  okText: '取消任务',
350
357
  });
351
358
  if (!ok) return false;
@@ -362,56 +369,24 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
362
369
  const list = (ids || []).map(Number).filter((n) => Number.isFinite(n) && n > 0);
363
370
  if (!list.length) return false;
364
371
  const ok = await dialog({
365
- title: `把选中的 ${list.length} 条待领取任务标为完成`,
366
- message: '只处理待领取任务;已领取/已交付/已取消会跳过。完成会补一条完成记录,原文留档。',
372
+ title: `把选中的 ${list.length} 条任务标为完成`,
373
+ message: '待领取与已领取(正在跑)都能收:已领取的直接收口,agent 侧回执会被忽略。已完成/已取消会跳过。完成会补一条完成记录,原文留档。',
367
374
  okText: '标为完成',
368
375
  });
369
376
  if (!ok) return false;
370
377
  return guard(async () => {
371
378
  const res = await closeManyTasks({ ...scopeBody(), ids: list, status: 'done' });
372
379
  const skipped = res?.skipped?.length || 0;
373
- toast(`已标为完成 ${res?.count ?? 0} 条任务${skipped ? `,跳过 ${skipped} 条` : ''}`);
380
+ const claimed = res?.claimedClosed?.length || 0;
381
+ toast(
382
+ `已标为完成 ${res?.count ?? 0} 条任务${claimed ? `(含 ${claimed} 条已领取)` : ''}${skipped ? `,跳过 ${skipped} 条` : ''}`,
383
+ );
374
384
  refreshLocal?.();
375
385
  return true;
376
386
  });
377
387
  };
378
388
 
379
- // ─── 已删除(软删回收站)──────────────────────────────────────────
380
- // 软删的行仍在 topic.tasks 里(带 deletedAt),看板/列表把它们过滤掉了,
381
- // 这里捞出来给「更多 → 已删除任务」面板。倒序:刚删的在上。
382
- const deletedTasks = useMemo(
383
- () => (topic?.tasks || []).filter((t) => t.deletedAt).slice().reverse(),
384
- [topic]
385
- );
386
-
387
- const restoreDeleted = (t: LocalTask | null) => {
388
- if (!t) return;
389
- guard(async () => {
390
- await restoreTaskItem(isGlobal ? { key: GLOBAL_KEY, id: t.id } : { cwd: topic?.cwd, id: t.id });
391
- toast(`已恢复 #${t.id}「${(t.text || '').split('\n').find((l) => l.trim())?.replace(/^#\s*/, '') || ''}」`);
392
- refreshLocal?.();
393
- });
394
- };
395
-
396
- const purgeDeleted = async (t: LocalTask | null) => {
397
- if (!t) return;
398
- const title = (t.text || '').split('\n').find((l) => l.trim()) || `#${t.id}`;
399
- const ok = await dialog({
400
- title: `彻底删除「${title.replace(/^#\s*/, '')}」`,
401
- message: '彻底删除后不可恢复(行从队列里真正摘除)。',
402
- danger: true,
403
- okText: '彻底删除',
404
- });
405
- if (!ok) return;
406
- guard(async () => {
407
- await removeTaskItem({ ...(isGlobal ? { key: GLOBAL_KEY } : { cwd: topic?.cwd }), id: t.id, purge: true });
408
- toast(`已彻底删除 #${t.id}`);
409
- refreshLocal?.();
410
- });
411
- };
412
-
413
- const openDeleted = () => setShowDeleted(true);
414
-
389
+ // ─── 文档列表(右侧栏)────────────────────────────────────────────
415
390
  const openRefs = () => {
416
391
  if (isGlobal || !repo) {
417
392
  toast('全局池没有项目文档列表');
@@ -473,6 +448,8 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
473
448
  model={model}
474
449
  tasks={pager.items}
475
450
  taskCount={pager.total}
451
+ q={q}
452
+ onQuery={setQ}
476
453
  pendingCount={pendingCount}
477
454
  page={pager.page}
478
455
  pageCount={pager.pageCount}
@@ -492,9 +469,7 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
492
469
  onOpenFlow={() => model && openPanel(model, { component: 'dag', name: '编排', config: { dirKey } })}
493
470
  onToggleGate={toggleGate}
494
471
  downstreamOf={downstreamOf}
495
- onDeleted={openDeleted}
496
472
  onRefs={openRefs}
497
- deletedCount={deletedTasks.length}
498
473
  />
499
474
 
500
475
  {dagTask && (
@@ -506,15 +481,6 @@ export default function DirPanel({ dirKey }: DirPanelProps) {
506
481
  />
507
482
  )}
508
483
 
509
- {showDeleted && (
510
- <DeletedPanel
511
- tasks={deletedTasks}
512
- onClose={() => setShowDeleted(false)}
513
- onRestore={restoreDeleted}
514
- onPurge={purgeDeleted}
515
- />
516
- )}
517
-
518
484
  {tplMenu && (
519
485
  <PopMenu x={tplMenu.x} y={tplMenu.y} items={tplMenuItems} onClose={() => setTplMenu(null)} />
520
486
  )}
@@ -17,7 +17,6 @@ import ToolActsBar from '../../components/tool-acts/bar.jsx';
17
17
  import TaskPanel from '../../components/task-panel/index.jsx';
18
18
  import TaskPanelLayoutRaw from '../../components/task-panel/layout.jsx';
19
19
  import TaskRow from '../../components/task-panel/task-row.jsx';
20
- import { taskLabel } from '../../components/sidebar/model.js';
21
20
  import type { LocalTask, LocalTopic, RepoRow } from '../../types.js';
22
21
 
23
22
  /** 拖动落点:行上半 = 之前,下半 = 之后。 */
@@ -90,7 +89,7 @@ interface LandingProps {
90
89
  onDeleteTasks?: (ids: number[]) => Promise<unknown>;
91
90
  /** (ids) 批量取消选中待领取任务 */
92
91
  onCancelTasks?: (ids: number[]) => Promise<unknown>;
93
- /** (ids) 批量把选中待领取任务标为完成 */
92
+ /** (ids) 批量把选中的未结束任务(待领取 / 已领取)标为完成 */
94
93
  onCompleteTasks?: (ids: number[]) => Promise<unknown>;
95
94
  onReopenTask?: (t: LocalTask) => void;
96
95
  /** 模板菜单的锚点(click 与 Enter/Space 都会调;只有鼠标事件带坐标) */
@@ -107,12 +106,12 @@ interface LandingProps {
107
106
  onToggleGate?: (t: LocalTask) => void;
108
107
  /** { [gateTaskId]: number[] } 闸门挡住的后续任务 id */
109
108
  downstreamOf?: Record<string, number[]>;
110
- /** () 打开已删除任务面板(#139 工具编排) */
111
- onDeleted?: () => void;
112
109
  /** () 打开文档列表右侧栏 */
113
110
  onRefs?: () => void;
114
- /** 已软删任务数(「更多」角标提示) */
115
- deletedCount?: number;
111
+ /** 搜索串(#181:标题 + 正文模糊匹配) */
112
+ q?: string;
113
+ /** (v) 改搜索串 */
114
+ onQuery?: (v: string) => void;
116
115
  }
117
116
 
118
117
  export default function Landing({
@@ -131,7 +130,7 @@ export default function Landing({
131
130
  onDeleteTask,
132
131
  onDeleteTasks, // (ids) 批量删除选中任务
133
132
  onCancelTasks, // (ids) 批量取消选中待领取任务
134
- onCompleteTasks, // (ids) 批量把选中待领取任务标为完成
133
+ onCompleteTasks, // (ids) 批量把选中的未结束任务(待领取 / 已领取)标为完成
135
134
  onReopenTask,
136
135
  onTplMenu,
137
136
  onImport,
@@ -141,11 +140,12 @@ export default function Landing({
141
140
  onOpenFlow, // () 打开可视化编排面板
142
141
  onToggleGate, // (t) 闸门快捷开关
143
142
  downstreamOf, // { [gateTaskId]: number[] } 闸门挡住的后续任务 id
144
- onDeleted, // () 打开已删除任务面板(#139 工具编排)
145
143
  onRefs, // () 打开文档列表右侧栏
146
- deletedCount = 0 // 已软删任务数(「更多」角标提示)
144
+ q = '', // 搜索串(标题 + 正文模糊匹配)
145
+ onQuery, // (v) 改搜索串
147
146
  }: LandingProps) {
148
147
  const name = isGlobal ? '全局池' : (topic?.name || '目录');
148
+ const searching = !!String(q).trim();
149
149
 
150
150
  // 拖动排序(HTML5 DnD):只在待领取行之间换位,落点 = 上半行之前 / 下半行之后。
151
151
  // 拖拽态走 **ref**(同步可读)——dragstart/dragover 在真实拖拽里也只隔几毫秒,
@@ -163,8 +163,13 @@ export default function Landing({
163
163
  const pageIds = tasks.map((t) => Number(t.id));
164
164
  const allPicked = pageIds.length > 0 && pageIds.every((id) => picked.has(id));
165
165
  const pickedTasks = tasks.filter((t) => picked.has(Number(t.id)));
166
- // 取消/标为完成只对待领取生效;已领取/已交付/已取消由后端跳过
167
- const closableTasks = pickedTasks.filter(
166
+ // #184:标为完成对「未结束」的任务都开放(待领取 + 已领取/正在跑);
167
+ // 取消仍只给待领取——取消是丢弃,误伤正在跑的会话代价更高,留给 agent 侧回执。
168
+ const doneTargets = pickedTasks.filter(
169
+ (t) => (t.status === 'pending' || t.status === 'claimed') && !t.migratedTo && !t.deletedAt
170
+ );
171
+ const claimedPicked = doneTargets.filter((t) => t.status === 'claimed').length;
172
+ const cancelTargets = pickedTasks.filter(
168
173
  (t) => t.status === 'pending' && !t.migratedTo && !t.deletedAt
169
174
  );
170
175
  const togglePick = (id: number | string) => {
@@ -192,7 +197,7 @@ export default function Landing({
192
197
  const ok = await fn(ids);
193
198
  if (ok) setPicked(new Set());
194
199
  };
195
- // 只有待领取行能拖动调序(已领取/已交付/已取消都是固定历史)
200
+ // 只有待领取行能拖动调序(已领取/已完成/已取消都是固定历史)
196
201
  const movable = (t: LocalTask) => t.status === 'pending' && !t.migratedTo && !t.deletedAt;
197
202
  const zoneOf = (e: ReactDragEvent<HTMLElement>, tr: HTMLElement): DropZone => {
198
203
  const r = tr.getBoundingClientRect();
@@ -238,30 +243,30 @@ export default function Landing({
238
243
  <button
239
244
  type="button"
240
245
  className="btn ghost sm"
241
- disabled={!closableTasks.length}
246
+ disabled={!doneTargets.length}
242
247
  title={
243
- closableTasks.length
244
- ? '把选中的待领取任务标为已完成(补一条完成记录,原文留档)'
245
- : '只有待领取任务可以直接标为完成'
248
+ doneTargets.length
249
+ ? `把选中的未结束任务标为已完成(补一条完成记录,原文留档)${claimedPicked ? `;其中 ${claimedPicked} 条已被领取,会直接收口,agent 侧回执忽略` : ''}`
250
+ : '选中的任务都已结束,没有可标为完成的'
246
251
  }
247
252
  onClick={() => runBatch('complete')}
248
253
  >
249
- 标为完成选中{closableTasks.length ? ` (${closableTasks.length})` : ''}
254
+ 标为完成选中{doneTargets.length ? ` (${doneTargets.length})` : ''}
250
255
  </button>
251
256
  )}
252
257
  {onCancelTasks && (
253
258
  <button
254
259
  type="button"
255
260
  className="btn ghost sm"
256
- disabled={!closableTasks.length}
261
+ disabled={!cancelTargets.length}
257
262
  title={
258
- closableTasks.length
263
+ cancelTargets.length
259
264
  ? '把选中的待领取任务标为已取消(终态,原文留档)'
260
- : '只有待领取任务可以取消'
265
+ : '只有待领取任务可以取消(已领取的交给 agent 回执)'
261
266
  }
262
267
  onClick={() => runBatch('cancel')}
263
268
  >
264
- 取消选中{closableTasks.length ? ` (${closableTasks.length})` : ''}
269
+ 取消选中{cancelTargets.length ? ` (${cancelTargets.length})` : ''}
265
270
  </button>
266
271
  )}
267
272
  {onDeleteTasks && (
@@ -279,19 +284,36 @@ export default function Landing({
279
284
  title={isGlobal ? '全局池任务' : '任务'}
280
285
  pendingCount={pendingCount}
281
286
  headerExtra={
282
- tasks.length ? (
283
- <label className="rp-proj-pickall" title="全选/取消全选当前页">
287
+ <>
288
+ {/* #181:搜索框——标题与正文一起搜(模糊串规则见 modules/board/task-search) */}
289
+ <span className="rp-tasks-tools">
284
290
  <input
285
- type="checkbox"
286
- checked={allPicked}
287
- onChange={togglePickAll}
288
- aria-label="全选当前页任务"
291
+ className="rp-task-search"
292
+ type="search"
293
+ value={q}
294
+ placeholder="搜索标题 / 内容"
295
+ aria-label="搜索任务"
296
+ onChange={(e) => onQuery && onQuery(e.target.value)}
289
297
  />
290
- 全选本页
291
- </label>
292
- ) : null
298
+ {tasks.length ? (
299
+ <label className="rp-proj-pickall" title="全选/取消全选当前页">
300
+ <input
301
+ type="checkbox"
302
+ checked={allPicked}
303
+ onChange={togglePickAll}
304
+ aria-label="全选当前页任务"
305
+ />
306
+ 全选本页
307
+ </label>
308
+ ) : null}
309
+ </span>
310
+ </>
311
+ }
312
+ emptyText={
313
+ searching
314
+ ? `没有匹配「${q.trim()}」的任务(标题与正文都搜过了)`
315
+ : `还没有页面:点「+ 新建页」写第一篇,或让 agent 往${isGlobal ? '全局池' : '这个目录'}投递任务。`
293
316
  }
294
- emptyText={`还没有页面:点「+ 新建页」写第一篇,或让 agent 往${isGlobal ? '全局池' : '这个目录'}投递任务。`}
295
317
  >
296
318
  {tasks.map((t) => {
297
319
  const movableRow = movable(t);
@@ -323,42 +345,32 @@ export default function Landing({
323
345
  downs={downs}
324
346
  onOpen={(row: LocalTask) => onOpenTask(row.id)}
325
347
  ops={
326
- <>
327
- {movableRow && (onOpenDag || onToggleGate) && (
328
- <RowMenu
329
- items={[
330
- { label: '编排依赖…', onPick: () => onOpenDag && onOpenDag(t) },
331
- {
348
+ /* 行尾操作合并进一个「⋯」菜单:编排 / 闸门 / 反馈 / 删除都从这里进,
349
+ 不再在行尾铺一排图标(反馈 + 删除原来占两个最右位,行尾过挤)。 */
350
+ <RowMenu
351
+ items={[
352
+ movableRow && onOpenDag
353
+ ? { label: '编排依赖…', onPick: () => onOpenDag(t) }
354
+ : null,
355
+ movableRow && onToggleGate
356
+ ? {
332
357
  label: t.blocksFollowing ? '取消闸门(不再挡后续)' : '设为闸门(挡住后续)',
333
- onPick: () => onToggleGate && onToggleGate(t),
334
- },
335
- ]}
336
- />
337
- )}
338
- {/* #144 反馈只在链尖:已有派生子任务(后续轮次/评论派生)的任务
339
- 不再给反馈入口——在旧轮次上反馈会把链分叉 */}
340
- {onReopenTask && t.status !== 'cancelled' && !t.childCount && (t.status === 'claimed' || t.status === 'done' || t.completedAt) && (
341
- <span
342
- className="op" role="button" tabIndex={-1}
343
- title={t.completedAt ? '反馈:新开一条任务(原任务不动)' : '反馈修改:回写本任务并记入任务链'}
344
- aria-label={`反馈 ${taskLabel(t)}`}
345
- onClick={() => onReopenTask(t)}
346
- >
347
- {/* icons.tsx 尚未类型化完(title 被推断为必填):显式传 undefined 与不传等价 */}
348
- <Icon name="refresh" size={12} title={undefined} />
349
- </span>
350
- )}
351
- {onDeleteTask && (
352
- <span
353
- className="op danger" role="button" tabIndex={-1}
354
- title="删除此任务(软删除,CLI 可恢复)"
355
- aria-label={`删除 ${taskLabel(t)}`}
356
- onClick={() => onDeleteTask(t)}
357
- >
358
- <Icon name="x" size={12} title={undefined} />
359
- </span>
360
- )}
361
- </>
358
+ onPick: () => onToggleGate(t),
359
+ }
360
+ : null,
361
+ /* #144 反馈只在链尖:已有派生子任务(后续轮次/评论派生)的任务
362
+ 不再给反馈入口——在旧轮次上反馈会把链分叉 */
363
+ onReopenTask && t.status !== 'cancelled' && !t.childCount && (t.status === 'claimed' || t.status === 'done' || t.completedAt)
364
+ ? {
365
+ label: t.completedAt ? '反馈:新开一条任务(原任务不动)' : '反馈修改:回写本任务并记入任务链',
366
+ onPick: () => onReopenTask(t),
367
+ }
368
+ : null,
369
+ onDeleteTask
370
+ ? { label: '删除此任务(软删除,CLI 可恢复)', danger: true, onPick: () => onDeleteTask(t) }
371
+ : null,
372
+ ]}
373
+ />
362
374
  }
363
375
  />
364
376
  );
@@ -383,7 +395,11 @@ export default function Landing({
383
395
  // #167 三轮:去面包屑(group 页没有,返回导航走左侧树)。
384
396
  <TaskPanelLayout
385
397
  name={name}
386
- counts={[`${taskCount} 个任务`, ...(pendingCount > 0 ? [`待领取 ${pendingCount}`] : [])]}
398
+ counts={
399
+ searching
400
+ ? [`命中 ${taskCount} 个任务`, ...(pendingCount > 0 ? [`待领取 ${pendingCount}`] : [])]
401
+ : [`${taskCount} 个任务`, ...(pendingCount > 0 ? [`待领取 ${pendingCount}`] : [])]
402
+ }
387
403
  intro={!isGlobal && repo ? <Introduction kind="repo" owner={repo} model={model} /> : null}
388
404
  batch={batchBar}
389
405
  list={listPanel}
@@ -394,15 +410,13 @@ export default function Landing({
394
410
  <ToolActsBar
395
411
  kind="dir"
396
412
  labels={{
397
- more: deletedCount > 0 ? `更多 (${deletedCount})` : '更多',
398
- deleted: deletedCount > 0 ? `已删除任务(${deletedCount})` : '已删除任务',
413
+ more: '更多',
399
414
  }}
400
415
  titles={{
401
416
  new: '按默认模板新建一页(▾ 选模板)',
402
417
  import: '把一个 .md 文件导入成任务',
403
418
  progress: '打开这个目录的进程面板',
404
- more: deletedCount > 0 ? `更多操作(含 ${deletedCount} 条已删除任务)` : '更多操作',
405
- deleted: '查看并恢复已删除任务',
419
+ more: '更多操作',
406
420
  refs: '查看文档 / reference 列表',
407
421
  }}
408
422
  renderers={{
@@ -447,7 +461,6 @@ export default function Landing({
447
461
  import: onImport,
448
462
  progress: onProg,
449
463
  orch: onOpenFlow,
450
- deleted: onDeleted,
451
464
  refs: onRefs,
452
465
  }}
453
466
  />
@@ -263,16 +263,27 @@ export function useTaskActions({
263
263
  });
264
264
  }, [doc, isDraft, task, isGlobal, topic, model, tabId, refreshLocal, guard, toast, dialog]);
265
265
 
266
- const canClosePending = !isDraft && !!taskRow && taskRow.status === 'pending';
266
+ // #184:正在跑(claimed)的任务以前在面板上是死路——工具栏连「标为完成」都不渲染,
267
+ // 只能干等 agent 自己回执。现在 claimed 也能收:用户是最终验收方,agent 稍后的 done
268
+ // 会命中服务端的幂等分支,不会报错。
269
+ // 「取消」仍只给待领取:取消是丢弃,误伤正在跑的会话代价更高,留给 agent 侧回执。
270
+ const taskStatus = String(taskRow?.status ?? '');
271
+ const canComplete = !isDraft && !!taskRow && (taskStatus === 'pending' || taskStatus === 'claimed');
272
+ const canCancel = !isDraft && !!taskRow && taskStatus === 'pending';
273
+ const canCloseTask = canComplete || canCancel;
267
274
  const closeTask = useCallback((kind: string) => {
268
- if (!canClosePending) return;
275
+ if (kind === 'done' ? !canComplete : !canCancel) return;
269
276
  guard(async () => {
270
277
  const title = doc?.title || `#${task}`;
271
278
  const scope = isGlobal ? { key: GLOBAL_KEY } : { cwd: topic?.cwd };
272
279
  if (kind === 'done') {
280
+ const claimed = taskStatus === 'claimed';
281
+ const who = String(taskRow?.claimedByName || taskRow?.claimedBy || '').trim();
273
282
  const summary = await dialog({
274
283
  title: `标为完成「${title}」`,
275
- message: '任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。',
284
+ message: claimed
285
+ ? `该任务正被${who ? ` ${who} ` : ' agent '}领取中。你是最终验收方——确认它已经做完、直接标为完成?可写一句完成总结(agent 稍后的回执会被忽略,不算冲突)。`
286
+ : '任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。',
276
287
  input: true,
277
288
  placeholder: '完成总结(可选;留空使用默认说明)',
278
289
  okText: '标为完成',
@@ -293,7 +304,7 @@ export function useTaskActions({
293
304
  }
294
305
  refreshLocal?.();
295
306
  });
296
- }, [canClosePending, doc, task, isGlobal, topic, refreshLocal, guard, toast, dialog]);
307
+ }, [canComplete, canCancel, doc, task, isGlobal, topic, taskStatus, taskRow, refreshLocal, guard, toast, dialog]);
297
308
 
298
309
  const addFiles = useCallback(async (fileList: FileList | File[], opts: { mode?: string } = {}) => {
299
310
  if (!doc) return;
@@ -424,7 +435,8 @@ export function useTaskActions({
424
435
  }, [showDockTab, attachAreaRef]);
425
436
 
426
437
  return {
427
- composeText, goalPatchOf, submit, importMd, delTask, canClosePending, closeTask,
438
+ composeText, goalPatchOf, submit, importMd, delTask,
439
+ canComplete, canCancel, canCloseTask, closeTask,
428
440
  addFiles, newTask, cloneCur, forkCur, openProgress, openAttachPanel,
429
441
  };
430
442
  }
@@ -1,4 +1,5 @@
1
- // 底部抽屉面板(#79):附件 / check / 反馈收在这里,编辑区不再被内容块挤占。
1
+ // 底部抽屉面板(#79):附件 / md / check / 反馈收在这里,编辑区不再被内容块挤占。
2
+ import { useState } from 'react';
2
3
  import type { ComponentProps, Dispatch, MouseEvent as ReactMouseEvent, ReactNode, Ref, RefObject, SetStateAction } from 'react';
3
4
  import type { Model } from 'flexlayout-react';
4
5
  import { Icon } from '../../components/icons.jsx';
@@ -8,6 +9,8 @@ import type { AttachAreaHandle } from '../../components/md/attach-area.jsx';
8
9
  import type { Attachment } from '../../components/md/attach-common.js';
9
10
  import { docIdOfLocator } from '../../components/md/attach-common.js';
10
11
  import { openPanel } from '../../workspace.js';
12
+ import { getMdfileContent } from './api.js';
13
+ import { renderMarkdownHtml } from '../../modules/md/md-render.js';
11
14
  import { GLOBAL_KEY } from '../../modules/board/board-view.js';
12
15
  import type { LocalTask, LocalTopic } from '../../types.js';
13
16
  import { fmtSec } from './task-utils.js';
@@ -60,6 +63,74 @@ interface DockPanelProps {
60
63
  latestChild: ChainApiItem | null;
61
64
  openFeedback: () => void;
62
65
  openLatestRound: () => void;
66
+ /** 任务当前挂载的附件(md 栏按 kind='mdfile' 过滤,不另建模型) */
67
+ attachments: Attachment[];
68
+ }
69
+
70
+ /** md 栏:附件里 kind='mdfile' 的那部分,按 md 渲染(底层仍是 attachments)。 */
71
+ function MdDockTab({ attachments }: { attachments: Attachment[] }) {
72
+ const list = attachments.filter((a) => a.kind === 'mdfile');
73
+ const [openId, setOpenId] = useState<string | null>(null);
74
+ const [docs, setDocs] = useState<Record<string, { html: string; path: string; stale: boolean; missing: boolean; loading?: boolean; error?: string }>>({});
75
+
76
+ const open = async (id: string) => {
77
+ setOpenId(id);
78
+ if (docs[id] && !docs[id].error) return;
79
+ setDocs((m) => ({ ...m, [id]: { html: '', path: '', stale: false, missing: false, loading: true } }));
80
+ try {
81
+ const r = await getMdfileContent(id);
82
+ setDocs((m) => ({
83
+ ...m,
84
+ [id]: {
85
+ html: renderMarkdownHtml(String(r.body || '')),
86
+ path: String(r.absPath || ''),
87
+ stale: !!r.stale,
88
+ missing: !!r.missing,
89
+ },
90
+ }));
91
+ } catch (e) {
92
+ setDocs((m) => ({ ...m, [id]: { html: '', path: '', stale: false, missing: false, error: (e as Error).message || String(e) } }));
93
+ }
94
+ };
95
+
96
+ if (!list.length) {
97
+ return <div className="mdw-dock-empty">没有 md 附件——用 `nx-kv localtask attach --mdfile &lt;本地 md 路径&gt;` 挂一个外部 md 文件。</div>;
98
+ }
99
+ const cur = openId ? docs[openId] : null;
100
+ return (
101
+ <div className="mdw-md-tab">
102
+ <div className="mdw-md-list" role="list">
103
+ {list.map((a) => (
104
+ <button
105
+ type="button"
106
+ role="listitem"
107
+ key={String(a.id)}
108
+ className={`mdw-md-item${openId === String(a.id) ? ' is-on' : ''}`}
109
+ onClick={() => open(String(a.id))}
110
+ title={a.absPath || ''}
111
+ >
112
+ <span className="mdw-md-item-name">{a.name || 'md'}</span>
113
+ <span className="mdw-md-item-path mono">{a.absPath || '(路径为空)'}{a.missing ? ' · 文件已不在' : ''}</span>
114
+ </button>
115
+ ))}
116
+ </div>
117
+ <div className="mdw-md-view">
118
+ {!openId ? <div className="mdw-dock-empty">选一条 md 看预览。</div> : null}
119
+ {cur?.loading ? <div className="mdw-dock-empty">读取中…</div> : null}
120
+ {cur?.error ? <div className="mdw-dock-empty">读取失败:{cur.error}</div> : null}
121
+ {cur && !cur.loading && !cur.error ? (
122
+ cur.missing ? (
123
+ <div className="mdw-dock-empty">源文件已不在:{cur.path || '(路径为空)'}</div>
124
+ ) : (
125
+ <div className="mdw-md-render">
126
+ {cur.stale ? <div className="att-md-warn">内容已变化(与登记指纹不一致),以下为磁盘当前内容。</div> : null}
127
+ <article dangerouslySetInnerHTML={{ __html: cur.html }} />
128
+ </div>
129
+ )
130
+ ) : null}
131
+ </div>
132
+ </div>
133
+ );
63
134
  }
64
135
 
65
136
  export function DockPanel({
@@ -70,9 +141,10 @@ export function DockPanel({
70
141
  refreshLocal, markDirty, saveDoc, persistAtt,
71
142
  attachAreaRef, reviewBarRef, reviewSumRef,
72
143
  taskRow, ackOpen, setAckOpen, ackOverflow, ackLong, ackHtml,
73
- isChainTip, latestChild, openFeedback, openLatestRound,
144
+ isChainTip, latestChild, openFeedback, openLatestRound, attachments,
74
145
  }: DockPanelProps) {
75
146
  if (!dockOpen) return null;
147
+ const mdCount = attachments.filter((a) => a.kind === 'mdfile').length;
76
148
 
77
149
  return (
78
150
  <div className="mdw-dock" ref={dockRef} style={{ height: `${dockH}px` }}>
@@ -96,6 +168,17 @@ export function DockPanel({
96
168
  >
97
169
  附件
98
170
  </button>
171
+ <button
172
+ type="button"
173
+ role="tab"
174
+ aria-selected={dockTab === 'md'}
175
+ className={`mdw-dock-tab${dockTab === 'md' ? ' is-on' : ''}`}
176
+ onClick={() => showDockTab('md')}
177
+ title="只聚合 kind='mdfile' 的附件(md 预览)"
178
+ >
179
+ md
180
+ {mdCount ? <span className="mdw-dock-tab-num">{mdCount}</span> : null}
181
+ </button>
99
182
  {canShowGoalLog ? (
100
183
  <button
101
184
  type="button"
@@ -186,6 +269,8 @@ export function DockPanel({
186
269
  )
187
270
  ) : null}
188
271
 
272
+ {dockTab === 'md' ? <MdDockTab attachments={attachments} /> : null}
273
+
189
274
  {dockTab === 'check' ? (
190
275
  <div className="mdw-dock-check">
191
276
  {goalLog.busy && !goalLog.data ? <div className="mdw-dock-empty">读取中…</div> : null}