nx-kv 0.42.2 → 0.43.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 (77) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +1 -1
  3. package/assets/kv-get/SKILL.md +4 -4
  4. package/assets/kv-get/references/localget.md +2 -2
  5. package/package.json +1 -1
  6. package/src/core/attachmentdb/docs.js +12 -0
  7. package/src/core/attachmentdb/relations.js +17 -0
  8. package/src/core/attachmentdb.js +1 -0
  9. package/src/modules/docs/attach.js +46 -1
  10. package/src/modules/docs/brief.js +35 -4
  11. package/src/modules/docs/index.js +15 -1
  12. package/src/modules/docs/service.js +10 -6
  13. package/src/modules/localtask/action-attach.js +25 -0
  14. package/src/modules/localtask/action-flags.js +0 -1
  15. package/src/modules/localtask/action-lifecycle.js +6 -4
  16. package/src/modules/localtask/action-waiting.js +3 -3
  17. package/src/modules/localtask/repo/rows.js +3 -0
  18. package/src/modules/localtask/repo/tasks.js +18 -2
  19. package/src/modules/localtask/task-lifecycle.js +3 -3
  20. package/src/modules/localtask/task-view.js +14 -6
  21. package/src/modules/tasktool/attach-resource.js +3 -0
  22. package/src/modules/tasktool/attach.js +62 -0
  23. package/src/modules/tasktool/get.js +1 -2
  24. package/src/modules/tasktool/plugins/waitgoal-config.js +1 -1
  25. package/src/modules/tasktool/wait.js +2 -2
  26. package/src/shared/doc-title.js +71 -0
  27. package/src/web/frontend/components/md/attach-area.jsx +56 -6
  28. package/src/web/frontend/components/md/attach-common.js +16 -3
  29. package/src/web/frontend/components/md/attach-modal.jsx +42 -2
  30. package/src/web/frontend/components/md/md-panes-helpers.js +4 -1
  31. package/src/web/frontend/components/repos/get-loop-modal.jsx +1 -1
  32. package/src/web/frontend/components/task-panel/index.jsx +7 -25
  33. package/src/web/frontend/components/task-panel/layout.jsx +64 -0
  34. package/src/web/frontend/components/task-panel/page-shell.jsx +38 -0
  35. package/src/web/frontend/components/tool-acts/modules.js +2 -0
  36. package/src/web/frontend/modules/md/md-render.js +34 -11
  37. package/src/web/frontend/modules/md/progress-chain.js +29 -0
  38. package/src/web/frontend/modules/md/progress-search.js +14 -0
  39. package/src/web/frontend/modules/md/styles/chrome.css +9 -0
  40. package/src/web/frontend/modules/md/styles/panels.css +2 -0
  41. package/src/web/frontend/modules/md/styles/shell.css +2 -10
  42. package/src/web/frontend/page/dir/index.jsx +8 -5
  43. package/src/web/frontend/page/dir/landing.jsx +93 -100
  44. package/src/web/frontend/page/dir/task.jsx +19 -3
  45. package/src/web/frontend/page/doc/index.jsx +24 -12
  46. package/src/web/frontend/page/group/index.jsx +163 -80
  47. package/src/web/frontend/page/progress/index.jsx +67 -19
  48. package/src/web/frontend/styles-v2/views.css +5 -1
  49. package/src/web/public/assets/Introduction-DAXj7E6q.js +6 -0
  50. package/src/web/public/assets/{bar-yESbzCxC.js → bar-KTPTE33i.js} +1 -1
  51. package/src/web/public/assets/{cloud-BotRQcvf.js → cloud-CLco1knr.js} +1 -1
  52. package/src/web/public/assets/{composer-panel-Xru2qIma.js → composer-panel-D3N_wO9r.js} +1 -1
  53. package/src/web/public/assets/deleted-panel-B6sZddUs.js +1 -0
  54. package/src/web/public/assets/dir-DEbQhSfL.js +5 -0
  55. package/src/web/public/assets/group-CxqVtyyh.js +2 -0
  56. package/src/web/public/assets/index-DGvBoOdp.css +1 -0
  57. package/src/web/public/assets/{index-BrAIkzFc.js → index-DNB8tgNi.js} +2 -2
  58. package/src/web/public/assets/md-history-C9vOgGLz.js +39 -0
  59. package/src/web/public/assets/{overview-J1mQpmJt.js → overview-9nXafXeK.js} +1 -1
  60. package/src/web/public/assets/progress-Bx0reVYl.js +3 -0
  61. package/src/web/public/assets/{refs-FI1FMoGi.js → refs-B5YIZ9SG.js} +1 -1
  62. package/src/web/public/assets/{repos-Oaycnb4I.js → repos-Dbr-i-gg.js} +2 -2
  63. package/src/web/public/assets/{route-crumb-C8JzPIax.js → route-crumb-BfRi1GKw.js} +1 -1
  64. package/src/web/public/assets/{settings-D5wTGhPD.js → settings-B4FvZtu0.js} +1 -1
  65. package/src/web/public/assets/{status-tag-BoUoKYZK.js → status-tag-p3fo3Hbr.js} +1 -1
  66. package/src/web/public/assets/{task-BgubFzHT.js → task-CUb7dohw.js} +3 -3
  67. package/src/web/public/assets/{templates-6DQdUpiB.js → templates-BGhPIp0x.js} +1 -1
  68. package/src/web/public/assets/tool-bar-DpwpQ47h.js +1 -0
  69. package/src/web/public/index.html +2 -2
  70. package/src/web/public/assets/Introduction-CdC8MBfL.js +0 -1
  71. package/src/web/public/assets/dir-D4Q3L20K.js +0 -5
  72. package/src/web/public/assets/group-Csco0TYH.js +0 -1
  73. package/src/web/public/assets/index-CZzMw1zg.css +0 -1
  74. package/src/web/public/assets/md-history-DB5forf2.js +0 -39
  75. package/src/web/public/assets/progress-DHDlz9O9.js +0 -3
  76. package/src/web/public/assets/task-row-Bc6JBfrE.js +0 -1
  77. package/src/web/public/assets/tool-bar-DGCwnUcn.js +0 -1
@@ -20,6 +20,8 @@ export const GROUP_MODULES = [
20
20
  { id: 'addMember', label: '添加成员', section: 'bar' },
21
21
  { id: 'orch', label: '编排', section: 'bar' },
22
22
  { id: 'more', label: '更多', section: 'bar', noHide: true },
23
+ // #169:组页补「已删除任务」(与目录页同款入口,组任务跨多个成员队列)
24
+ { id: 'deleted', label: '已删除任务', section: 'more' },
23
25
  { id: 'refs', label: '查看列表', section: 'more' },
24
26
  ];
25
27
 
@@ -61,7 +61,19 @@ function wikiKnown(target, knownNames) {
61
61
  return knownNames.has(norm) || knownNames.has(norm.split('/').pop());
62
62
  }
63
63
 
64
- function inline(s, knownNames) {
64
+ /**
65
+ * ref 链接的显示名(#168):优先**文档标题**(refId → title 的映射,来自附件
66
+ * 清单——服务端读盘补的正文首行 # 标题),没有映射才用链接原文。
67
+ */
68
+ function refTitleOf(target, text, refTitles) {
69
+ if (!refTitles || !refTitles.size) return text;
70
+ const m = String(target || '').match(/^nxkv:\/\/ref\/([^)\s]+)$/i);
71
+ if (!m) return text;
72
+ const t = refTitles.get(m[1]);
73
+ return t ? esc(t) : text;
74
+ }
75
+
76
+ function inline(s, knownNames, refTitles) {
65
77
  const base = esc(s)
66
78
  .replace(/`([^`]+)`/g, '<code>$1</code>')
67
79
  .replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>');
@@ -83,7 +95,9 @@ function inline(s, knownNames) {
83
95
  // 不让它落到「普通 markdown 链接」而被当外链。
84
96
  const withInternal = withAtt.replace(/\[([^\]]+)\]\((nxkv:\/\/[^)\s]+)\)/g, (m, text, target) => {
85
97
  if (!/^nxkv:\/\/(?:task|ref)\//i.test(target)) return m;
86
- return `<a class="md-wl" data-nxkv="${target}" title="内部资源:${target}">${text}</a>`;
98
+ // #168:ref 引用显示**文档标题**(用户在文档里填的那行 # 标题),没有标题才用原文
99
+ const label = refTitleOf(target, text, refTitles);
100
+ return `<a class="md-wl" data-nxkv="${target}" title="内部资源:${target}">${label}</a>`;
87
101
  });
88
102
  return withInternal.replace(/\[\[([^\[\]|]+)(?:\|([^\[\]]+))?\]\]/g, (_, target, label) => {
89
103
  const t = target.trim();
@@ -100,8 +114,17 @@ function inline(s, knownNames) {
100
114
  */
101
115
  export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
102
116
  const imgMap = {};
117
+ // ref 标题映射(#168):附件清单里 kind=ref 的条目 → refId → 文档标题,
118
+ // 渲染 ref 链接时用标题当显示名(用户填了标题,编辑器里就该看到标题)。
119
+ const refTitles = new Map();
103
120
  for (const a of attachments) {
121
+ if (!a) continue;
104
122
  if (a.type === 'image' && a.url) imgMap[a.name] = a.url;
123
+ if (a.kind === 'ref') {
124
+ const id = String(a.refId || a.targetKey || a.targetRef || '');
125
+ const title = String(a.docTitle || a.title || a.name || '');
126
+ if (id && title) refTitles.set(id, title);
127
+ }
105
128
  }
106
129
  // frontmatter **不再渲染成属性卡**(#113):board/project 这些是投递元数据,
107
130
  // 摆在一堆任务正文上方纯属噪音——正文里剥掉即可(编辑态仍能点开原 YAML 看)。
@@ -183,14 +206,14 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
183
206
  }
184
207
  if (curPara.length) paras.push(curPara);
185
208
  const bodyHtml = paras
186
- .map((p) => p.map((l) => inline(l, knownNames)).join('<br>'))
209
+ .map((p) => p.map((l) => inline(l, knownNames, refTitles)).join('<br>'))
187
210
  .join('<br><br>');
188
211
  html += `<div class="md-callout md-callout-${esc(type)}">`
189
- + (title ? `<div class="md-callout-t">${inline(title, knownNames)}</div>` : '')
212
+ + (title ? `<div class="md-callout-t">${inline(title, knownNames, refTitles)}</div>` : '')
190
213
  + `<div class="md-callout-b">${bodyHtml}</div></div>`;
191
214
  continue;
192
215
  }
193
- html += `<blockquote>${q.map((l) => inline(l, knownNames)).join('<br>')}</blockquote>`;
216
+ html += `<blockquote>${q.map((l) => inline(l, knownNames, refTitles)).join('<br>')}</blockquote>`;
194
217
  continue;
195
218
  }
196
219
  if (line.startsWith('### ')) {
@@ -198,7 +221,7 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
198
221
  {
199
222
  const text = line.slice(4);
200
223
  const id = headingAnchorId(text.trim(), usedIds);
201
- html += `<h3 id="${esc(id)}">${inline(text, knownNames)}</h3>`;
224
+ html += `<h3 id="${esc(id)}">${inline(text, knownNames, refTitles)}</h3>`;
202
225
  }
203
226
  continue;
204
227
  }
@@ -207,7 +230,7 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
207
230
  {
208
231
  const text = line.slice(3);
209
232
  const id = headingAnchorId(text.trim(), usedIds);
210
- html += `<h2 id="${esc(id)}">${inline(text, knownNames)}</h2>`;
233
+ html += `<h2 id="${esc(id)}">${inline(text, knownNames, refTitles)}</h2>`;
211
234
  }
212
235
  continue;
213
236
  }
@@ -216,7 +239,7 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
216
239
  {
217
240
  const text = line.slice(2);
218
241
  const id = headingAnchorId(text.trim(), usedIds);
219
- html += `<h1 id="${esc(id)}">${inline(text, knownNames)}</h1>`;
242
+ html += `<h1 id="${esc(id)}">${inline(text, knownNames, refTitles)}</h1>`;
220
243
  }
221
244
  continue;
222
245
  }
@@ -229,15 +252,15 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
229
252
  const done = m[1] && /x/i.test(m[1]);
230
253
  if (m[1]) {
231
254
  const mark = done ? '☑' : '☐';
232
- html += `<li class="${done ? 'done' : 'todo'}"><span class="mdw-cb" aria-hidden="true">${mark}</span>${inline(m[2], knownNames)}</li>`;
255
+ html += `<li class="${done ? 'done' : 'todo'}"><span class="mdw-cb" aria-hidden="true">${mark}</span>${inline(m[2], knownNames, refTitles)}</li>`;
233
256
  } else {
234
- html += `<li>${inline(m[2], knownNames)}</li>`;
257
+ html += `<li>${inline(m[2], knownNames, refTitles)}</li>`;
235
258
  }
236
259
  continue;
237
260
  }
238
261
  flush();
239
262
  if (!line.trim()) continue;
240
- html += `<p>${inline(line, knownNames)}</p>`;
263
+ html += `<p>${inline(line, knownNames, refTitles)}</p>`;
241
264
  }
242
265
  if (inCode) html += '</code></pre>';
243
266
  flush();
@@ -0,0 +1,29 @@
1
+ // 进程面板的任务链折叠(#172):反馈任务链动辄几十轮,进程面板不再把它们**累计**
2
+ // 摊开——只留**链尖**(最新一轮),旧轮次去任务页的「更多 → 任务链」里看。
3
+ //
4
+ // 判据用后端的 childRoundCount(reopen 边数):>0 = 这件活儿已经在下一轮继续,
5
+ // 本条就是旧轮次。comment / feedback 边是**旁支新活**(评论派生 / 反馈里提的新需求),
6
+ // 不算「被取代」——父任务照旧该显示。
7
+ //
8
+ // 纯函数、无 DOM、无 IO,可单测(与 progress-search.js 同层)。
9
+
10
+ /** 这条任务是不是链尖(最新一轮,没有后续轮次)。 */
11
+ export function isChainTip(task) {
12
+ return !(Number(task && task.childRoundCount) || 0);
13
+ }
14
+
15
+ /**
16
+ * 按「链尖 / 旧轮次」切分一批任务。
17
+ * @param {Array<object>} tasks 任务列表(视图形状)
18
+ * @returns {{tips: Array<object>, folded: Array<object>}} 顺序保持原样
19
+ */
20
+ export function splitChainTips(tasks) {
21
+ const tips = [];
22
+ const folded = [];
23
+ for (const t of tasks || []) {
24
+ (isChainTip(t) ? tips : folded).push(t);
25
+ }
26
+ return { tips, folded };
27
+ }
28
+
29
+ export default isChainTip;
@@ -93,4 +93,18 @@ export function hitQuery(card, q) {
93
93
  return title.includes(body);
94
94
  }
95
95
 
96
+ /**
97
+ * 查询串是不是「精确编号」(12 / #12)且与卡片编号**等值**命中。
98
+ *
99
+ * #172:进程面板把反馈链的旧轮次折叠了(只留链尖),但「我要找 #87」这种
100
+ * 明确点名必须还能找到——所以旧轮次只按**编号等值**召回,标题模糊 / 前缀命中
101
+ * 不召回(一召回就把几十条旧轮次重新堆回屏上,等于没折叠)。
102
+ */
103
+ export function hitExactId(card, q) {
104
+ const raw = String(q ?? '').trim().toLowerCase();
105
+ const body = raw.startsWith('#') ? raw.slice(1).trim() : raw;
106
+ if (!body || !/^\d+$/.test(body)) return false;
107
+ return cardIdOf(card) === body;
108
+ }
109
+
96
110
  export default hitQuery;
@@ -226,6 +226,15 @@
226
226
  flex:none;font:400 10.5px var(--mono,ui-monospace,Consolas,monospace);color:var(--faint,#A9AEB4);
227
227
  }
228
228
  .att-pending-state{flex:none;font-size:11px;color:var(--mdw-accent,#2F6F5E)}
229
+ /* 文档条目的说明 + 进原文开关(#162:任务侧文档绑定的两个可选属性) */
230
+ .att-pending-ref-opts{flex:none;display:inline-flex;align-items:center;gap:6px;min-width:0}
231
+ .att-pending-note{
232
+ width:180px;max-width:34vw;height:22px;padding:0 6px;font:inherit;font-size:11.5px;
233
+ border:1px solid var(--line,#E4E2DC);border-radius:5px;background:var(--paper,#fff);color:inherit;
234
+ }
235
+ .att-pending-note:focus{outline:2px solid var(--mdw-accent,#2F6F5E);outline-offset:1px}
236
+ .att-pending-inline{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--ink-2,#4B515A);white-space:nowrap;cursor:pointer}
237
+ .att-pending-inline input{width:13px;height:13px;accent-color:var(--mdw-accent,#2F6F5E);cursor:pointer}
229
238
  .att-mini{height:22px;padding:0 8px;font-size:11px}
230
239
  .att-foot{display:flex;align-items:center;gap:8px;width:100%}
231
240
  .att-foot-hint{margin-right:auto;font-size:11.5px;color:var(--mid,#838A93);min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@@ -95,6 +95,8 @@
95
95
  .mdw-prog-fchip.on b{color:var(--mdw-accent)}
96
96
  /* 组模式卡片标题旁的项目 tag(复用 rp-ptag 视觉,略收间距贴标题) */
97
97
  .mdw-tcard-proj{margin-left:6px}
98
+ /* #172:被编号点名召回的旧轮次 tag(同样复用 rp-ptag 视觉) */
99
+ .mdw-tcard-old{margin-left:6px}
98
100
  /* 勾选后的操作条:已选 n 条 + 清除 + 删除所选 */
99
101
  .mdw-prog-sel{
100
102
  flex:none;display:flex;align-items:center;gap:6px;padding:7px 10px;
@@ -168,16 +168,8 @@
168
168
  /* 内容区 */
169
169
  .mdw-split{flex:1;display:flex;min-height:0;overflow:hidden}
170
170
 
171
- /* 目录落地页(#164 二轮):外壳与项目组页同构——根容器用 rp-page(同底色/同内距),
172
- 头部用 rp-group-head(h2 + 右对齐工具区);这里只留目录特有的小字 meta 行
173
- (队列 cwd + 现状)与翻页条。旧的 head/name/status-line/count 规则已随
174
- 旧头部结构删除。 */
175
- .mdw-land-meta{display:flex;align-items:baseline;gap:12px;min-width:0;margin-top:2px}
176
- .mdw-land-meta .mdw-land-path{margin-top:0;flex:none;max-width:60%}
177
- .mdw-land-status{
178
- min-width:0;font-size:11.5px;color:var(--ink-2,#4B515A);
179
- overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
180
- }
171
+ /* 目录落地页(#169):外壳与项目组页**共用组件** components/task-panel/page-shell
172
+ (结构与样式同源,这里不再各写一套容器规则);目录侧只留翻页条。 */
181
173
  /* 翻页条:队列长了翻页看,不再一次渲染全部 */
182
174
  .mdw-land-pager{display:flex;justify-content:flex-end;margin-top:10px}
183
175
  .mdw-land-table-wrap{
@@ -463,9 +463,13 @@ export default function DirPanel({ dirKey }) {
463
463
  }
464
464
 
465
465
  return (
466
- <div className="mdw">
467
- <div className="mdw-main">
468
- <Landing
466
+ // #170:落地页**不再套 .mdw 工作台外壳**——.mdw 是「MD 编辑器」的外壳
467
+ // (自带 canvas 米色底 + 一整套 .mdw 作用域的按钮/字号口径)。落地页只是
468
+ // 队列列表页,套上它会让**同款按钮在目录页与项目组页呈现两套观感**
469
+ // (.mdw .btn.ghost 透明浅边 vs .btn.ghost 灰底),页面底色也不同。
470
+ // 编辑器分支仍用 .mdw(那是编辑器,本就该有工作台外壳)。
471
+ <>
472
+ <Landing
469
473
  isGlobal={isGlobal}
470
474
  topic={topic}
471
475
  repo={repo}
@@ -495,7 +499,6 @@ export default function DirPanel({ dirKey }) {
495
499
  onRefs={openRefs}
496
500
  deletedCount={deletedTasks.length}
497
501
  />
498
- </div>
499
502
 
500
503
  {dagTask && (
501
504
  <DagEditor
@@ -532,6 +535,6 @@ export default function DirPanel({ dirKey }) {
532
535
  />
533
536
 
534
537
  {dialogNode}
535
- </div>
538
+ </>
536
539
  );
537
540
  }
@@ -5,7 +5,7 @@
5
5
  // 以组面板行结构为准)——待领取行拖动排序(拖把手)、行尾操作(编排菜单 /
6
6
  // 反馈 / 删除)、多选批量条、状态统一为 StatusTag 全称药丸(原单字徽标
7
7
  // 等/跑/完/档 收口)。分页与计数由容器(page/dir/index.jsx)算好传进来。
8
- import RouteBreadcrumb from '../../components/layout/route-crumb.jsx';
8
+ // #167 三轮:去面包屑(group 页没有,返回导航走左侧树)。
9
9
  import { useEffect, useRef, useState } from 'react';
10
10
  import { Icon } from '../../components/icons.jsx';
11
11
  import Introduction from '../../components/Introduction/index.jsx';
@@ -13,6 +13,7 @@ import Pager from '../../components/pager.jsx';
13
13
  import { RowMenu } from '../../components/popup/index.jsx';
14
14
  import ToolActsBar from '../../components/tool-acts/bar.jsx';
15
15
  import TaskPanel from '../../components/task-panel/index.jsx';
16
+ import TaskPanelLayout from '../../components/task-panel/layout.jsx';
16
17
  import TaskRow from '../../components/task-panel/task-row.jsx';
17
18
  import { taskLabel } from '../../components/sidebar/model.js';
18
19
 
@@ -47,8 +48,6 @@ export default function Landing({
47
48
  deletedCount = 0 // 已软删任务数(「更多」角标提示)
48
49
  }) {
49
50
  const name = isGlobal ? '全局池' : (topic?.name || '目录');
50
- const path = isGlobal ? '共享池(无固定目录)' : (topic?.cwd || '—');
51
- const status = String(topic?.summary || '').trim();
52
51
 
53
52
  // 拖动排序(HTML5 DnD):只在待领取行之间换位,落点 = 上半行之前 / 下半行之后。
54
53
  // 拖拽态走 **ref**(同步可读)——dragstart/dragover 在真实拖拽里也只隔几毫秒,
@@ -134,93 +133,7 @@ export default function Landing({
134
133
  setDropAt(null);
135
134
  };
136
135
 
137
- return (
138
- // 根容器与项目组页同款(rp-page:无底色差、同内距、flex gap)——#164 验收反馈
139
- // 「两种 ui 仍然不一,比如工具区、背景等」:外壳向 group 页看齐。
140
- <div className="rp-page">
141
- <RouteBreadcrumb />
142
- {/* 头部 = group 同构:h2(图标 + 名字 + 计数 chips)+ 右对齐工具区 */}
143
- <div className="rp-group-head">
144
- <h2>
145
- <Icon name="folder" size={15} /> {name}
146
- <span className="rp-chip-count">{taskCount} 个任务</span>
147
- {pendingCount > 0 ? <span className="rp-chip-count">{pendingCount} 待领取</span> : null}
148
- </h2>
149
- <div className="rp-group-acts">
150
- {/* #139:工具区可编排(顺序 / 显隐;隐藏收入「更多」) */}
151
- <ToolActsBar
152
- kind="dir"
153
- labels={{
154
- more: deletedCount > 0 ? `更多 (${deletedCount})` : '更多',
155
- deleted: deletedCount > 0 ? `已删除任务(${deletedCount})` : '已删除任务',
156
- }}
157
- titles={{
158
- new: '按默认模板新建一页(▾ 选模板)',
159
- import: '把一个 .md 文件导入成任务',
160
- progress: '打开这个目录的进程面板',
161
- more: deletedCount > 0 ? `更多操作(含 ${deletedCount} 条已删除任务)` : '更多操作',
162
- deleted: '查看并恢复已删除任务',
163
- refs: '查看文档 / reference 列表',
164
- }}
165
- renderers={{
166
- // #161 新建按钮拆两级(视觉一颗按钮、命中区两层):
167
- // 主区点击 = 按默认模板直接新建;内嵌箭头 = 模板下拉(tplMenuItems)
168
- new: () => (
169
- <span className="rp-newtask">
170
- <button
171
- type="button"
172
- className="btn small primary"
173
- title="按默认模板新建一页(▾ 选模板)"
174
- onClick={() => onNew()}
175
- >
176
- + 新建页
177
- <span
178
- role="button"
179
- tabIndex={0}
180
- aria-label="选择模板新建一页"
181
- aria-haspopup="menu"
182
- className="rp-newtask-caret"
183
- title="选择模板新建一页"
184
- onClick={(e) => {
185
- e.stopPropagation();
186
- onTplMenu?.(e);
187
- }}
188
- onKeyDown={(e) => {
189
- if (e.key === 'Enter' || e.key === ' ') {
190
- e.preventDefault();
191
- e.stopPropagation();
192
- onTplMenu?.(e);
193
- }
194
- }}
195
- >
196
- <Icon name="chevron" size={11} />
197
- </span>
198
- </button>
199
- </span>
200
- ),
201
- }}
202
- actions={{
203
- new: onNew,
204
- import: onImport,
205
- progress: onProg,
206
- orch: onOpenFlow,
207
- deleted: onDeleted,
208
- refs: onRefs,
209
- }}
210
- />
211
- </div>
212
- {/* 路径与现状:group 页没有的目录特有信息,弱化成一行小字放头部末尾 */}
213
- <div className="mdw-land-meta">
214
- <span className="mdw-land-path mono" title={path}>{path}</span>
215
- {status ? (
216
- <span className="mdw-land-status mono" title={status}>现状:{status}</span>
217
- ) : null}
218
- </div>
219
- </div>
220
-
221
- {!isGlobal && repo ? <Introduction kind="repo" owner={repo} model={model} /> : null}
222
-
223
- {pickedTasks.length > 0 && (
136
+ const batchBar = pickedTasks.length > 0 ? (
224
137
  <div className="mdw-land-batch">
225
138
  <span className="mdw-land-batch-count">已选 {pickedTasks.length} 条</span>
226
139
  {onCompleteTasks && (
@@ -262,10 +175,8 @@ export default function Landing({
262
175
  清空
263
176
  </button>
264
177
  </div>
265
- )}
266
-
267
- {/* 任务面板(#164 共享组件):行结构 / 状态药丸与项目组页一致。
268
- 当前页行不拆段(分页语义由容器负责);全选在面板头右侧。 */}
178
+ ) : null;
179
+ const listPanel = (
269
180
  <TaskPanel
270
181
  title={isGlobal ? '全局池任务' : '任务'}
271
182
  pendingCount={pendingCount}
@@ -354,10 +265,9 @@ export default function Landing({
354
265
  );
355
266
  })}
356
267
  </TaskPanel>
357
-
358
- {/* 队列长了翻页看(以前一次渲染全部,队列一长就是一堵墙) */}
359
- {taskCount > 0 && (
360
- <div className="mdw-land-pager">
268
+ );
269
+ const footerBar = taskCount > 0 ? (
270
+ <div className="mdw-land-pager">
361
271
  <Pager
362
272
  page={page}
363
273
  pageCount={pageCount}
@@ -366,7 +276,90 @@ export default function Landing({
366
276
  unit="个任务"
367
277
  />
368
278
  </div>
369
- )}
370
- </div>
279
+ ) : null;
280
+
281
+ return (
282
+ // #170:整页布局复用共享组件 TaskPanelLayout(路由与数据语义各自保留,
283
+ // 但排布骨架同源:头部 / 简介 / 批量条 / 列表 / 翻页的块序与间距由组件定)。
284
+ // #167 三轮:去面包屑(group 页没有,返回导航走左侧树)。
285
+ <TaskPanelLayout
286
+ name={name}
287
+ counts={[`${taskCount} 个任务`, ...(pendingCount > 0 ? [`待领取 ${pendingCount}`] : [])]}
288
+ intro={!isGlobal && repo ? <Introduction kind="repo" owner={repo} model={model} /> : null}
289
+ batch={batchBar}
290
+ list={listPanel}
291
+ footer={footerBar}
292
+ actions={
293
+ <>
294
+ {/* #139:工具区可编排(顺序 / 显隐;隐藏收入「更多」) */}
295
+ <ToolActsBar
296
+ kind="dir"
297
+ labels={{
298
+ more: deletedCount > 0 ? `更多 (${deletedCount})` : '更多',
299
+ deleted: deletedCount > 0 ? `已删除任务(${deletedCount})` : '已删除任务',
300
+ }}
301
+ titles={{
302
+ new: '按默认模板新建一页(▾ 选模板)',
303
+ import: '把一个 .md 文件导入成任务',
304
+ progress: '打开这个目录的进程面板',
305
+ more: deletedCount > 0 ? `更多操作(含 ${deletedCount} 条已删除任务)` : '更多操作',
306
+ deleted: '查看并恢复已删除任务',
307
+ refs: '查看文档 / reference 列表',
308
+ }}
309
+ renderers={{
310
+ // #161 新建按钮拆两级(视觉一颗按钮、命中区两层):
311
+ // 主区点击 = 按默认模板直接新建;内嵌箭头 = 模板下拉(tplMenuItems)
312
+ new: () => (
313
+ <span className="rp-newtask">
314
+ <button
315
+ type="button"
316
+ className="btn small primary"
317
+ title="按默认模板新建一页(▾ 选模板)"
318
+ onClick={() => onNew()}
319
+ >
320
+ + 新建页
321
+ <span
322
+ role="button"
323
+ tabIndex={0}
324
+ aria-label="选择模板新建一页"
325
+ aria-haspopup="menu"
326
+ className="rp-newtask-caret"
327
+ title="选择模板新建一页"
328
+ onClick={(e) => {
329
+ e.stopPropagation();
330
+ onTplMenu?.(e);
331
+ }}
332
+ onKeyDown={(e) => {
333
+ if (e.key === 'Enter' || e.key === ' ') {
334
+ e.preventDefault();
335
+ e.stopPropagation();
336
+ onTplMenu?.(e);
337
+ }
338
+ }}
339
+ >
340
+ <Icon name="chevron" size={11} />
341
+ </span>
342
+ </button>
343
+ </span>
344
+ ),
345
+ }}
346
+ actions={{
347
+ new: onNew,
348
+ import: onImport,
349
+ progress: onProg,
350
+ orch: onOpenFlow,
351
+ deleted: onDeleted,
352
+ refs: onRefs,
353
+ }}
354
+ />
355
+ </>
356
+ }
357
+ >
358
+
359
+
360
+ {/* 任务面板(#164 共享组件):行结构 / 状态药丸与项目组页一致。
361
+ 当前页行不拆段(分页语义由容器负责);全选在面板头右侧。 */}
362
+
363
+ </TaskPanelLayout>
371
364
  );
372
365
  }
@@ -132,10 +132,26 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
132
132
  const editorApiRef = useRef(null);
133
133
  const histRef = useRef(new Map());
134
134
 
135
+ // #168:ref 引用在正文里显示**文档标题**(用户在文档里填的标题)——
136
+ // 需要服务端附件清单里的 ref 条目(标题是服务端读盘补的)。
137
+ const [refAtts, setRefAtts] = useState([]);
138
+ useEffect(() => {
139
+ let alive = true;
140
+ const t = taskRow;
141
+ if (!t || !t.id) return undefined;
142
+ const q = new URLSearchParams({ id: String(t.id) });
143
+ if (topicKey) q.set('key', topicKey);
144
+ else if (t.cwd) q.set('cwd', t.cwd);
145
+ api(`/api/localtasks/attachments?${q.toString()}`)
146
+ .then((d) => { if (alive) setRefAtts((d && (d.attachments || d.data?.attachments)) || []); })
147
+ .catch(() => { if (alive) setRefAtts([]); });
148
+ return () => { alive = false; };
149
+ }, [taskRow, topicKey]);
150
+
135
151
  // 阅读视图:剥掉首个一级标题行——它就是文档标题(页头已渲染),正文再渲染一遍是重复
136
152
  const previewHtml = useMemo(
137
- () => (doc ? renderMarkdownHtml(stripTitleHeading(doc.body), doc.attachments) : ''),
138
- [doc]
153
+ () => (doc ? renderMarkdownHtml(stripTitleHeading(doc.body), refAtts.length ? refAtts : doc.attachments) : ''),
154
+ [doc, refAtts]
139
155
  );
140
156
  // 验收条 ack:agent 完成总结常带 md(加粗/列表/标题)——按正文同一套渲染,不要当纯文本。
141
157
  const ackHtml = useMemo(
@@ -405,7 +421,7 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
405
421
  previewHtml={previewHtml}
406
422
  onTitle={onTitle}
407
423
  onBody={onBody}
408
- attachments={doc.attachments}
424
+ attachments={refAtts.length ? [...doc.attachments, ...refAtts] : doc.attachments}
409
425
  docKey={id}
410
426
  editorApiRef={editorApiRef}
411
427
  onFiles={addFiles}
@@ -22,7 +22,8 @@ import DocHead, { groupOf } from '../../components/doc/doc-head.jsx';
22
22
  import RouteBreadcrumb from '../../components/layout/route-crumb.jsx';
23
23
  import { IntroRail, introDirFromRef } from '../../components/Introduction/index.jsx';
24
24
  import { uploadMany, snippetsOf } from '../../components/cloud/upload.js';
25
- import { extractMdHeadings, insertAttachmentSnippet, renderMarkdownHtml, slugName, titleFromMd } from '../../modules/md/md-parse.js';
25
+ import { extractMdHeadings, insertAttachmentSnippet, renderMarkdownHtml, slugName } from '../../modules/md/md-parse.js';
26
+ import { docTitleFromMd, setDocTitleInMd } from '../../../../shared/doc-title.js';
26
27
  import { clearHistory, pushHistory, redoHistory, undoHistory } from '../../modules/md/md-history.js';
27
28
  import { resolveWikiLink } from '../../../../shared/wikilink.js';
28
29
 
@@ -198,10 +199,21 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
198
199
  }, []);
199
200
 
200
201
  const writable = !!(doc && doc.writable);
202
+ // #168:ref 引用在预览/编辑器里显示**文档标题**——需要附件清单里的 ref 条目
203
+ // (服务端读盘补的标题),渲染时按 refId 查表替换链接文字。
204
+ const [attList, setAttList] = useState([]);
205
+ useEffect(() => {
206
+ let alive = true;
207
+ if (!docId) return undefined;
208
+ api(`/api/docs/attachments?ref=${encodeURIComponent(docId)}`)
209
+ .then((d) => { if (alive) setAttList((d && (d.attachments || d.data?.attachments)) || []); })
210
+ .catch(() => { if (alive) setAttList([]); });
211
+ return () => { alive = false; };
212
+ }, [docId]);
201
213
  const previewHtml = useMemo(
202
214
  // 外部/缺失文档不判未解析态(known=null = 全部普通样式)
203
- () => (doc ? renderMarkdownHtml(doc.body, [], writable ? known : null) : ''),
204
- [doc, known, writable]
215
+ () => (doc ? renderMarkdownHtml(doc.body, attList, writable ? known : null) : ''),
216
+ [doc, known, writable, attList]
205
217
  );
206
218
  const headings = useMemo(() => (doc ? extractMdHeadings(doc.body) : []), [doc]);
207
219
 
@@ -283,21 +295,21 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
283
295
  toast(res.summary ? '已保存,摘要已回写' : '已保存');
284
296
  });
285
297
 
286
- // ─── 编辑(文档没有独立标题:标题 = 正文首个 # 行)───
298
+ // ─── 编辑(#168:文档标题 = 正文**首行**的 `# 标题`;正文第一行不再顶替标题)───
287
299
  const onBody = (next, kind = 'op') => {
288
300
  if (!doc) return;
289
301
  pushHistory(histRef.current, docId, { body: doc.body }, kind);
290
302
  setDirty(true);
291
- setDoc((d) => ({ ...d, body: next, title: titleFromMd(next, d.title) }));
303
+ setDoc((d) => ({ ...d, body: next, title: docTitleFromMd(next) || d.title }));
292
304
  };
293
305
 
294
306
  const onTitle = (next, kind = 'typing') => {
295
307
  if (!doc) return;
296
308
  pushHistory(histRef.current, docId, { body: doc.body }, kind);
297
309
  setDirty(true);
298
- const b = /^#\s+/m.test(doc.body)
299
- ? doc.body.replace(/^#\s+.+$/m, `# ${next || '未命名文档'}`)
300
- : `# ${next || '未命名文档'}\n\n${doc.body}`;
310
+ // 改写**首行**的标题行(首行不是 # 就补到文首)——标题行永远在首行,
311
+ // 不会被正文其它 # 行带偏。
312
+ const b = setDocTitleInMd(doc.body, next);
301
313
  setDoc((d) => ({ ...d, body: b, title: next }));
302
314
  };
303
315
 
@@ -305,7 +317,7 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
305
317
  if (!doc) return;
306
318
  const snap = undoHistory(histRef.current, docId, { body: doc.body });
307
319
  if (!snap) return;
308
- setDoc((d) => ({ ...d, body: snap.body, title: titleFromMd(snap.body, d.title) }));
320
+ setDoc((d) => ({ ...d, body: snap.body, title: docTitleFromMd(snap.body) || d.title }));
309
321
  setDirty(true);
310
322
  requestAnimationFrame(() => editorApiRef.current?.caretFromDiff?.(doc.body, snap.body));
311
323
  };
@@ -314,7 +326,7 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
314
326
  if (!doc) return;
315
327
  const snap = redoHistory(histRef.current, docId, { body: doc.body });
316
328
  if (!snap) return;
317
- setDoc((d) => ({ ...d, body: snap.body, title: titleFromMd(snap.body, d.title) }));
329
+ setDoc((d) => ({ ...d, body: snap.body, title: docTitleFromMd(snap.body) || d.title }));
318
330
  setDirty(true);
319
331
  requestAnimationFrame(() => editorApiRef.current?.caretFromDiff?.(doc.body, snap.body));
320
332
  };
@@ -338,7 +350,7 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
338
350
  const placed = insertAttachmentSnippet(cur.body, snippet, opts);
339
351
  pushHistory(histRef.current, docId, { body: cur.body });
340
352
  setDirty(true);
341
- setDoc((d) => (d ? { ...d, body: placed.body, title: titleFromMd(placed.body, d.title) } : d));
353
+ setDoc((d) => (d ? { ...d, body: placed.body, title: docTitleFromMd(placed.body) || d.title } : d));
342
354
  toast(`已插入 ${results.length} 个附件`);
343
355
  } catch (e) {
344
356
  toast(`附件上传失败:${String(e.message || e)}`);
@@ -506,7 +518,7 @@ export default function DocPanel({ docId, repoKey, boardKey, boardName, model, t
506
518
  onTitle={writable ? onTitle : null}
507
519
  onBody={writable ? onBody : null}
508
520
  onFiles={writable ? addFiles : null}
509
- attachments={[]}
521
+ attachments={attList}
510
522
  docKey={docId}
511
523
  editorApiRef={editorApiRef}
512
524
  onSave={writable ? save : null}