nx-kv 0.34.0 → 0.36.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 (58) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/package.json +1 -1
  3. package/src/modules/localtask/repo/rows.js +2 -0
  4. package/src/modules/localtask/repo/tasks.js +4 -2
  5. package/src/modules/localtask/task-lifecycle.js +21 -8
  6. package/src/modules/localtask/task-view.js +2 -0
  7. package/src/shared/feedback-text.js +118 -0
  8. package/src/web/frontend/components/md/ack-rail.jsx +14 -4
  9. package/src/web/frontend/components/md/md-panes.jsx +10 -3
  10. package/src/web/frontend/components/repos/get-loop-modal.jsx +181 -0
  11. package/src/web/frontend/components/tool-acts/layout-panel.jsx +1 -1
  12. package/src/web/frontend/components/tool-acts/modules.js +25 -0
  13. package/src/web/frontend/modules/board/ack-nodes.js +49 -1
  14. package/src/web/frontend/modules/board/reopen-text.js +32 -19
  15. package/src/web/frontend/modules/md/md-parse.js +41 -3
  16. package/src/web/frontend/modules/md/style.css +29 -8
  17. package/src/web/frontend/page/dag/index.jsx +104 -17
  18. package/src/web/frontend/page/dir/landing.jsx +3 -1
  19. package/src/web/frontend/page/dir/task.jsx +40 -3
  20. package/src/web/frontend/page/repos/index.jsx +90 -25
  21. package/src/web/frontend/page/settings/index.jsx +5 -368
  22. package/src/web/frontend/page/settings/style.css +4 -147
  23. package/src/web/frontend/style-v2.css +65 -0
  24. package/src/web/public/assets/{Introduction-DU27b_b_.js → Introduction-EDM3eqXe.js} +1 -1
  25. package/src/web/public/assets/{bar-CNuQf706.js → bar-P_ky_qA9.js} +1 -1
  26. package/src/web/public/assets/button-M9TUn-AR.js +1 -0
  27. package/src/web/public/assets/{cloud-DgNCxJsL.js → cloud-Bl7EJoQ_.js} +1 -1
  28. package/src/web/public/assets/{composer-launch-BKeKTPp4.js → composer-launch-DOB0Hm0B.js} +1 -1
  29. package/src/web/public/assets/{composer-panel-DP322mVs.js → composer-panel-DCV7JGNt.js} +1 -1
  30. package/src/web/public/assets/dag-NSMkkWrt.js +1 -0
  31. package/src/web/public/assets/{dir-Cipgyv3a.js → dir-ClkYDLql.js} +1 -1
  32. package/src/web/public/assets/{group-m61-WL4C.js → group-DqBGGAEA.js} +1 -1
  33. package/src/web/public/assets/{index-CeIJd4ee.js → index-CLsU9Lad.js} +3 -3
  34. package/src/web/public/assets/{index-BEkITE6q.css → index-CZBR0CbL.css} +1 -1
  35. package/src/web/public/assets/{md-panes-PS7K93Lg.js → md-panes-DMs3KANu.js} +2 -2
  36. package/src/web/public/assets/{md-parse-DN9INgZn.js → md-parse-C2bDc3IZ.js} +1 -1
  37. package/src/web/public/assets/{overview-BmoTQJuu.js → overview-CFGcpG_m.js} +1 -1
  38. package/src/web/public/assets/{progress-CWy9bYKr.js → progress-B0fipz7a.js} +1 -1
  39. package/src/web/public/assets/{refs-DAy1kYGf.js → refs-DLThlN46.js} +1 -1
  40. package/src/web/public/assets/reopen-text-BylkngqC.js +12 -0
  41. package/src/web/public/assets/repos-BygXrPSp.js +10 -0
  42. package/src/web/public/assets/repos-ZPiaK93i.css +1 -0
  43. package/src/web/public/assets/{route-crumb-lOriqwxP.js → route-crumb-Cyesq6KK.js} +1 -1
  44. package/src/web/public/assets/settings-BBKNCMHm.css +1 -0
  45. package/src/web/public/assets/settings-KHM4F3Sy.js +6 -0
  46. package/src/web/public/assets/{status-tag-DGlwjAg2.js → status-tag-Bts7p2cp.js} +1 -1
  47. package/src/web/public/assets/task-BoJGRYpA.js +11 -0
  48. package/src/web/public/assets/{templates-D900RS5b.js → templates-CdPNcDxd.js} +1 -1
  49. package/src/web/public/assets/tool-bar-Bh3XH8MU.js +1 -0
  50. package/src/web/public/index.html +3 -3
  51. package/src/web/public/assets/button-BPYMY-zh.js +0 -1
  52. package/src/web/public/assets/dag-C4702bOt.js +0 -1
  53. package/src/web/public/assets/reopen-text-DIFfS71D.js +0 -6
  54. package/src/web/public/assets/repos-D_NT51Dq.js +0 -9
  55. package/src/web/public/assets/settings-CBrQ3Iz5.css +0 -1
  56. package/src/web/public/assets/settings-Vp3ZMC1M.js +0 -7
  57. package/src/web/public/assets/task-CRpctHxx.js +0 -9
  58. package/src/web/public/assets/tool-bar-C-rnP0vv.js +0 -1
@@ -19,14 +19,38 @@
19
19
 
20
20
  import { liveBodyBlocks } from '../md/md-parse.js';
21
21
 
22
- /** ack 段标题(与 reopen-text.js 同口径) */
22
+ /** ack 段标题(与 reopen-text.js 同口径;#144 起新正文改写轮次 callout,旧正文仍认) */
23
23
  export const ACK_NODE_HEADING = '## 上一轮完成总结';
24
24
  /** 反馈段标题 */
25
25
  export const ACK_NODE_FEEDBACK_HEADING = '## 验收反馈';
26
26
 
27
+ // callout 形态(#144):`> [!NOTE] 第 1 轮 · 完成总结` / `> [!WARNING] 第 1 轮 · 验收反馈`
28
+ const CALLOUT_TITLE_RE = /^>\s*\[![A-Za-z][\w-]*\][ \t]*(.*)$/;
29
+ const ACK_TITLE_RE = /完成总结/;
30
+ const FB_TITLE_RE = /反馈/;
31
+ const ROUND_NUM_RE = /第\s*(\d+)\s*轮/;
32
+
33
+ /** callout 块 → { title, body }(body 为剥掉 `> ` 的正文行);不是 callout 返回 null */
34
+ function calloutOf(block) {
35
+ const lines = String(block ?? '').split('\n');
36
+ const m = lines.length && String(lines[0]).match(CALLOUT_TITLE_RE);
37
+ if (!m) return null;
38
+ const body = lines
39
+ .slice(1)
40
+ .map((l) => l.replace(/^>[ \t]?/, ''))
41
+ .filter((l) => l.trim() !== '')
42
+ .join('\n');
43
+ return { title: String(m[1] ?? '').trim(), body };
44
+ }
45
+
27
46
  /**
28
47
  * 从任务正文里抽出每一轮 ack 节点。
29
48
  *
49
+ * 两种形态都认(#144):
50
+ * - 旧段名:`## 上一轮完成总结` + `## 验收反馈`(历史正文)
51
+ * - 轮次 callout:`> [!NOTE] 第 N 轮 · 完成总结` + `> [!WARNING] 第 N 轮 · 验收反馈`
52
+ * (轮次号取标题里的数字;没有数字就按出现顺序排)
53
+ *
30
54
  * @param {string} body 任务正文(Markdown)
31
55
  * @returns {{ round:number, blockIndex:number, feedbackBlockIndex:number,
32
56
  * ackText:string, feedbackText:string }[]}
@@ -44,6 +68,21 @@ export function extractAckNodes(body) {
44
68
 
45
69
  blocks.forEach((raw, i) => {
46
70
  const b = String(raw || '').trim();
71
+ const co = calloutOf(b);
72
+ if (co && ACK_TITLE_RE.test(co.title)) {
73
+ // callout 完成总结块:轮次号优先取标题里的「第 N 轮」
74
+ const rNum = Number((co.title.match(ROUND_NUM_RE) || [])[1]);
75
+ cur = {
76
+ round: Number.isFinite(rNum) && rNum > 0 ? rNum : out.length + 1,
77
+ blockIndex: i,
78
+ feedbackBlockIndex: -1,
79
+ ackText: co.body,
80
+ feedbackText: '',
81
+ };
82
+ out.push(cur);
83
+ phase = 'ack';
84
+ return;
85
+ }
47
86
  if (b === ACK_NODE_HEADING) {
48
87
  cur = {
49
88
  round: out.length + 1,
@@ -56,6 +95,15 @@ export function extractAckNodes(body) {
56
95
  phase = 'ack';
57
96
  return;
58
97
  }
98
+ if (co && FB_TITLE_RE.test(co.title)) {
99
+ // callout 反馈块归属**当前正在填的 ack 段**(孤儿反馈块不算节点)
100
+ if (cur && phase === 'ack') {
101
+ cur.feedbackBlockIndex = i;
102
+ cur.feedbackText = co.body;
103
+ phase = 'feedback';
104
+ }
105
+ return;
106
+ }
59
107
  if (b === ACK_NODE_FEEDBACK_HEADING) {
60
108
  // 反馈段归属**当前正在填的 ack 段**(没有则忽略——孤儿反馈段不算节点)
61
109
  if (cur && phase === 'ack') {
@@ -16,6 +16,16 @@ export {
16
16
  ACK_SUMMARY_HEADING,
17
17
  FEEDBACK_HEADING,
18
18
  PLAIN_FEEDBACK_HEADING,
19
+ ACK_CALLOUT_TYPE,
20
+ FEEDBACK_CALLOUT_TYPE,
21
+ ackCalloutSection,
22
+ feedbackCalloutSection,
23
+ ackCalloutTitle,
24
+ feedbackCalloutTitle,
25
+ countAckRounds,
26
+ nextRoundOf,
27
+ bodyHasAck,
28
+ appendAckFeedback,
19
29
  boldFeedback,
20
30
  quoteBlock,
21
31
  feedbackSection,
@@ -23,19 +33,28 @@ export {
23
33
  } from '../../../../shared/feedback-text.js';
24
34
 
25
35
  import {
26
- ACK_SUMMARY_HEADING,
27
36
  FEEDBACK_HEADING,
37
+ PLAIN_FEEDBACK_HEADING,
28
38
  boldFeedback,
39
+ appendAckFeedback,
29
40
  } from '../../../../shared/feedback-text.js';
30
41
 
31
42
  /**
32
43
  * 拼重开后的任务正文。
33
44
  *
45
+ * 验收反馈(ack 场景,#144 起默认):正文 = 原正文 + 「第 N 轮 · 完成总结」callout
46
+ * + 「第 N 轮 · 验收反馈」callout——轮次号按正文已有轮数 + 1(也可显式传 round),
47
+ * 同一份总结不重复追加(连点两次重做)。旧的 `## 上一轮完成总结` 段名从此不再新写。
48
+ *
49
+ * 普通评论 / 「反馈修改」(feedbackHeading = PLAIN_FEEDBACK_HEADING):无轮次语义,
50
+ * 沿用旧段名拼装(不加粗由调用方控制)。
51
+ *
34
52
  * @param {string} base 原正文(可空)
35
53
  * @param {string} feedback 用户反馈(可空)
36
54
  * @param {string} ackSummary 上一轮 agent 的完成总结(可空——没完成过就没有)
37
- * @param {string} feedbackHeading 反馈段标题
55
+ * @param {string} feedbackHeading 反馈段标题(PLAIN_FEEDBACK_HEADING 走旧段名分支)
38
56
  * @param {boolean} bold 反馈是否逐行加粗(ack 场景 true;普通「反馈修改」沿用旧口径 false)
57
+ * @param {number} [round] 显式轮次号(缺省 = 正文已有轮数 + 1)
39
58
  * @returns {string} 新正文;无任何内容时返回空串(调用方据此**不带 text 字段**,
40
59
  * 服务端就只翻状态、不动正文)
41
60
  */
@@ -45,23 +64,17 @@ export function buildReopenText({
45
64
  ackSummary,
46
65
  feedbackHeading = FEEDBACK_HEADING,
47
66
  bold = true,
67
+ round,
48
68
  } = {}) {
49
- const parts = [];
50
- const b = String(base ?? '').trim();
51
- if (b) parts.push(b);
52
-
53
- // 同一份总结不追加两遍:连着点两次「重做」而 agent 还没交活时 roundSummary 没变,
54
- // 再追加一遍只是噪音。
55
- const ack = String(ackSummary ?? '').trim();
56
- if (ack && !b.includes(`${ACK_SUMMARY_HEADING}\n\n${ack}`)) {
57
- parts.push(`${ACK_SUMMARY_HEADING}\n\n${ack}`);
58
- }
59
-
60
- const fb = String(feedback ?? '').trim();
61
- if (fb) {
62
- const body = bold ? boldFeedback(fb) : fb;
63
- parts.push(`${feedbackHeading}\n\n${body}`);
69
+ // 划选评论 / 「反馈修改」:没有轮次语义,保持旧段名(## 反馈修改)不动。
70
+ if (String(feedbackHeading ?? '') === PLAIN_FEEDBACK_HEADING) {
71
+ const parts = [];
72
+ const b = String(base ?? '').trim();
73
+ if (b) parts.push(b);
74
+ const fb = String(feedback ?? '').trim();
75
+ if (fb) parts.push(`${feedbackHeading}\n\n${bold ? boldFeedback(fb) : fb}`);
76
+ return parts.length ? `${parts.join('\n\n')}\n` : '';
64
77
  }
65
-
66
- return parts.length ? `${parts.join('\n\n')}\n` : '';
78
+ // 验收反馈:轮次 callout(第 N 轮 · 完成总结 / 验收反馈)
79
+ return appendAckFeedback({ base, ack: ackSummary, feedback, bold, round });
67
80
  }
@@ -134,7 +134,8 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
134
134
  inUl = false;
135
135
  }
136
136
  };
137
- for (const line of lines) {
137
+ for (let i = 0; i < lines.length; i++) {
138
+ const line = lines[i];
138
139
  // fenced code:整块原样输出(不跑 inline/双链——代码里的 [[示例]] 不是链接)
139
140
  if (line.startsWith('```')) {
140
141
  if (inCode) {
@@ -168,9 +169,46 @@ export function renderMarkdownHtml(src, attachments = [], knownNames = null) {
168
169
  : `<p><code>![${esc(img[1])}](${esc(img[2])})</code></p>`;
169
170
  continue;
170
171
  }
171
- if (line.startsWith('> ')) {
172
+ // 引用 / callout(#144):连续的 `>` 行合成**一个块**——callout 块必须整体渲染。
173
+ // 首行带 `[!TYPE] 标题` 标记(GFM/Obsidian 口径)→ 渲染成醒目色块;
174
+ // 无标记 → 普通 blockquote(多行合并,锚定引用不再拆成 N 个散框)。
175
+ if (line.startsWith('>')) {
172
176
  flush();
173
- html += `<blockquote>${inline(line.slice(2), knownNames)}</blockquote>`;
177
+ const q = [];
178
+ let j = i;
179
+ while (j < lines.length && lines[j].startsWith('>')) {
180
+ q.push(lines[j].replace(/^>[ \t]?/, ''));
181
+ j += 1;
182
+ }
183
+ i = j - 1; // 外层循环再 ++,回到最后一条被消费的引用行
184
+ const cm = q.length && q[0] ? q[0].match(/^\[!([A-Za-z][\w-]*)\][ \t]*(.*)$/) : null;
185
+ if (cm) {
186
+ // callout:正文按空行分段(段间 <br><br> 有段落间隔)、段内 <br> 连行
187
+ // (反馈以短行为主,够用且轻)
188
+ const type = String(cm[1] || '').toLowerCase();
189
+ const title = String(cm[2] || '').trim();
190
+ const paras = [];
191
+ let curPara = [];
192
+ for (const l of q.slice(1)) {
193
+ if (!l.trim()) {
194
+ if (curPara.length) {
195
+ paras.push(curPara);
196
+ curPara = [];
197
+ }
198
+ continue;
199
+ }
200
+ curPara.push(l);
201
+ }
202
+ if (curPara.length) paras.push(curPara);
203
+ const bodyHtml = paras
204
+ .map((p) => p.map((l) => inline(l, knownNames)).join('<br>'))
205
+ .join('<br><br>');
206
+ html += `<div class="md-callout md-callout-${esc(type)}">`
207
+ + (title ? `<div class="md-callout-t">${inline(title, knownNames)}</div>` : '')
208
+ + `<div class="md-callout-b">${bodyHtml}</div></div>`;
209
+ continue;
210
+ }
211
+ html += `<blockquote>${q.map((l) => inline(l, knownNames)).join('<br>')}</blockquote>`;
174
212
  continue;
175
213
  }
176
214
  if (line.startsWith('### ')) {
@@ -501,16 +501,11 @@
501
501
  transition:none!important;
502
502
  }
503
503
  /* 占位提示:聚焦即隐(原先要打字才消失,提示文字压在光标底下)。
504
- !important:全局 input/textarea 的 placeholder 规则更晚加载,不加赢不了它。
505
- 指引文案改挂在**视图态的空块**上(见下方 .mdw-lp-gap::after)——
506
- 聚焦编辑时干净,失焦时仍有提示,不至于把指引整个弄丢。 */
504
+ !important:全局 input/textarea 的 placeholder 规则更晚加载,不加赢不了它。 */
507
505
  .mdw-lp-src::placeholder{color:var(--faint,#A9AEB4)}
508
506
  .mdw-lp textarea.mdw-lp-src:focus::placeholder{color:transparent!important}
509
- /* 空块(视图态)的操作指引:点进编辑态就换textarea,不再需要占位文字 */
510
- .mdw-lp-blocks:not(.is-empty-doc) .mdw-lp-block.is-empty .mdw-lp-gap::after{
511
- content:"输入… Enter 新块 · 行首 / 命令";
512
- color:var(--faint,#A9AEB4);font-size:var(--mdw-lp-body-size,13.5px);
513
- }
507
+ /* 空块(视图态)不再渲染「输入…」提示语(#151:正文里的空行挂着一句常驻
508
+ 提示太吵——空块保留 1.6em 最小高度可点击,编辑态 textarea 的 placeholder 仍在) */
514
509
  /* 划选:不改文字色、不抬行高;淡绿底仅标范围,光标仍是强调色 */
515
510
  .mdw-lp ::selection,
516
511
  .mdw-lp textarea.mdw-lp-src::selection{
@@ -641,6 +636,30 @@
641
636
  margin:8px 0;padding:2px 0 2px 12px;border-left:2px solid var(--line,#E4E2DC);
642
637
  background:transparent;font-size:13px;color:var(--ink-2,#4B515A);border-radius:0;
643
638
  }
639
+ /* 轮次 callout(#144):`> [!NOTE]` / `> [!WARNING]` 渲染成醒目色块——
640
+ 完成总结 = 绿(accent),验收反馈 = 琥珀;标题行 + 正文两段式。 */
641
+ .md-callout{
642
+ margin:10px 0;padding:9px 12px 10px;border-radius:8px;
643
+ border:1px solid var(--mdw-accent-line,#B7D4C8);
644
+ border-left:3px solid var(--mdw-accent,#2F6F5E);
645
+ background:var(--mdw-accent-soft,#E8F2EE);
646
+ }
647
+ .md-callout .md-callout-t{
648
+ font-weight:650;font-size:12.5px;color:var(--mdw-accent,#2F6F5E);margin-bottom:4px;
649
+ }
650
+ .md-callout .md-callout-b{font-size:13px;line-height:1.55;color:var(--ink-2,#4B515A)}
651
+ .md-callout .md-callout-b>:first-child{margin-top:0}
652
+ .md-callout .md-callout-b>:last-child{margin-bottom:0}
653
+ .md-callout-warning{
654
+ border-color:#E8D9B5;border-left-color:#C08A2D;background:#FBF3E1;
655
+ }
656
+ .md-callout-warning .md-callout-t{color:#8A6508}
657
+ .md-callout-tip{border-color:#CFE3DA;border-left-color:#3D8F79;background:#EDF6F2}
658
+ .md-callout-tip .md-callout-t{color:#2F6F5E}
659
+ .md-callout-important{border-color:#DCCFE8;border-left-color:#8A5FB0;background:#F5EFFA}
660
+ .md-callout-important .md-callout-t{color:#6B4590}
661
+ .md-callout-caution{border-color:#EBCCCB;border-left-color:#C0504A;background:#FAEDEC}
662
+ .md-callout-caution .md-callout-t{color:#A03934}
644
663
  .mdw-preview .mdw-empty,.mdw-lp-view .mdw-empty{
645
664
  color:var(--faint,#A9AEB4);padding:40px 0;text-align:center;
646
665
  }
@@ -922,6 +941,8 @@ button.cmp-quote:focus-visible{outline:2px solid var(--mdw-accent-line,#B7D4C8);
922
941
  letter-spacing:.02em;white-space:nowrap;
923
942
  }
924
943
  .mdw-review-at{font-size:10.5px;color:var(--faint,#A9AEB4)}
944
+ /* 已进入后续轮次的提示(#144):非链尖任务收起反馈入口,指到最新一轮 */
945
+ .mdw-review-later{font-size:11.5px;color:var(--ink-2,#4B515A);white-space:nowrap}
925
946
  /* 默认夹 4 行;过长出「展开全文」。ack 是 Markdown(加粗/列表/标题),按 HTML 渲染 */
926
947
  .mdw-review-sum{
927
948
  font-size:12px;line-height:1.55;color:var(--ink-2,#4B515A);
@@ -19,6 +19,7 @@ import { reaches } from '../../../../shared/graph.js';
19
19
 
20
20
  const NODE_W = 280;
21
21
  const NODE_GAP_Y = 22;
22
+ const ROW_H = 72 + NODE_GAP_Y; // 一行节点占位高(节点 72 + 行距)
22
23
  const PAD_X = 56;
23
24
  const PAD_Y = 28;
24
25
  const COL_GAP = 320;
@@ -63,7 +64,18 @@ function formatDepForTarget(sourceNode, targetTopicKey) {
63
64
  return nodeKeyOf(sourceNode.topicKey, sourceNode.id);
64
65
  }
65
66
 
66
- function defaultLayout(nodes) {
67
+ /**
68
+ * 默认布局:**按 topic 分块 + 块内分栏换行**(#153)。
69
+ *
70
+ * 旧版是「一列到底」的竖排(列 = topic,列内纵排)——单目录时只有一列,
71
+ * 任务一多就出纵向滚动条,而右边大片空着。现在每块按可视高度算容量,
72
+ * 装不下就换到右边一列,横向铺开把中右区用满。
73
+ *
74
+ * @param {Array<object>} nodes
75
+ * @param {{perCol?:number}} [opts] perCol = 每列最多几个节点
76
+ */
77
+ function defaultLayout(nodes, opts = {}) {
78
+ const perCol = Math.max(3, Number(opts.perCol) || 8);
67
79
  // 按 topic 分列,列内按原序纵向
68
80
  const byTopic = new Map();
69
81
  for (const n of nodes) {
@@ -74,16 +86,49 @@ function defaultLayout(nodes) {
74
86
  let col = 0;
75
87
  for (const [, list] of byTopic) {
76
88
  list.forEach((n, i) => {
89
+ const c = col + Math.floor(i / perCol);
90
+ const r = i % perCol;
77
91
  pos.set(n.nodeKey, {
78
- x: PAD_X + col * COL_GAP,
79
- y: PAD_Y + i * (72 + NODE_GAP_Y),
92
+ x: PAD_X + c * COL_GAP,
93
+ y: PAD_Y + r * ROW_H,
80
94
  });
81
95
  });
82
- col += 1;
96
+ col += Math.ceil(list.length / perCol);
83
97
  }
84
98
  return pos;
85
99
  }
86
100
 
101
+ /** 节点位置持久化(#153):拖过的位置记住,重开还原——连线也跟着节点走。 */
102
+ const POS_KEY = (scope) => `nx-kv-dag-pos:${scope}`;
103
+
104
+ /** 读已存位置:{ "topicKey:id": [x, y] } → Map<nodeKey, {x,y}> */
105
+ function loadPos(scope) {
106
+ try {
107
+ const raw = JSON.parse(localStorage.getItem(POS_KEY(scope)) || '{}');
108
+ const out = new Map();
109
+ for (const [k, v] of Object.entries(raw || {})) {
110
+ if (Array.isArray(v) && Number.isFinite(v[0]) && Number.isFinite(v[1])) out.set(k, { x: v[0], y: v[1] });
111
+ }
112
+ return out;
113
+ } catch {
114
+ return new Map();
115
+ }
116
+ }
117
+
118
+ /** 写回已存位置(只写有值的节点,键值对 [x,y]) */
119
+ function savePos(scope, pos) {
120
+ try {
121
+ const out = {};
122
+ for (const [k, p] of pos) {
123
+ if (p && Number.isFinite(p.x) && Number.isFinite(p.y)) out[k] = [Math.round(p.x), Math.round(p.y)];
124
+ }
125
+ localStorage.setItem(POS_KEY(scope), JSON.stringify(out));
126
+ return true;
127
+ } catch {
128
+ return false;
129
+ }
130
+ }
131
+
87
132
  function cubic(x1, y1, x2, y2) {
88
133
  const dx = Math.max(48, Math.abs(x2 - x1) * 0.5);
89
134
  return `M ${x1} ${y1} C ${x1 + dx} ${y1}, ${x2 - dx} ${y2}, ${x2} ${y2}`;
@@ -195,25 +240,49 @@ export default function DagPanel({ dirKey, groupId }) {
195
240
  const [pos, setPos] = useState(() => new Map());
196
241
  const posRef = useRef(pos);
197
242
  posRef.current = pos;
198
- const layoutSigRef = useRef('');
243
+ // 画布可视高度 → 每列容量(#153:布局分栏换行,别再一列到底竖着排)
244
+ const [canvasH, setCanvasH] = useState(0);
245
+ useEffect(() => {
246
+ const el = canvasRef.current;
247
+ if (!el) return undefined;
248
+ const read = () => setCanvasH(el.clientHeight || 0);
249
+ read();
250
+ const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(read) : null;
251
+ ro?.observe(el);
252
+ window.addEventListener('resize', read);
253
+ return () => {
254
+ ro?.disconnect();
255
+ window.removeEventListener('resize', read);
256
+ };
257
+ }, []);
258
+ const perCol = Math.max(3, Math.floor(((canvasH || 720) - PAD_Y * 2) / ROW_H) || 8);
259
+
260
+ // 位置持久化(#153):scope = 组 id 或目录 key;拖过的位置记在 localStorage
261
+ const scopeKey = groupMode ? `g:${board?.id || groupId || ''}` : `d:${dirKey || ''}`;
262
+ const scopeKeyRef = useRef(scopeKey);
263
+ scopeKeyRef.current = scopeKey; // 拖动写盘用(全局监听是空依赖闭包,得读最新)
264
+ const storedPos = useMemo(() => loadPos(scopeKey), [scopeKey]);
265
+ const scopeRef = useRef(scopeKey);
266
+ const userMovedRef = useRef(new Set());
199
267
 
200
268
  useEffect(() => {
201
- const sig = nodes.map((n) => n.nodeKey).join('|') + '#' + (groupMode ? filterKey || 'ALL' : dirKey || '');
202
- const switched = layoutSigRef.current.split('#')[0] !== sig.split('#')[0]
203
- || layoutSigRef.current.split('#')[1] !== sig.split('#')[1];
204
- layoutSigRef.current = sig;
269
+ const scopeChanged = scopeRef.current !== scopeKey;
270
+ scopeRef.current = scopeKey;
205
271
  setPos((prev) => {
206
272
  const next = new Map();
207
- const fresh = defaultLayout(nodes);
273
+ const fresh = defaultLayout(nodes, { perCol });
208
274
  for (const n of nodes) {
209
- next.set(
210
- n.nodeKey,
211
- !switched && prev.has(n.nodeKey) ? prev.get(n.nodeKey) : (fresh.get(n.nodeKey) || { x: PAD_X, y: PAD_Y }),
212
- );
275
+ // 优先级:已存位置(用户拖过)> 本会话拖过的位置 > 默认布局
276
+ const saved = storedPos.get(n.nodeKey);
277
+ const kept = saved
278
+ || (!scopeChanged && userMovedRef.current.has(n.nodeKey) ? prev.get(n.nodeKey) : null)
279
+ || fresh.get(n.nodeKey)
280
+ || { x: PAD_X, y: PAD_Y };
281
+ next.set(n.nodeKey, kept);
213
282
  }
214
283
  return next;
215
284
  });
216
- }, [nodes, groupMode, filterKey, dirKey]);
285
+ }, [nodes, perCol, storedPos, scopeKey]);
217
286
 
218
287
  const modeRef = useRef(null);
219
288
  const [dragId, setDragId] = useState(null);
@@ -376,6 +445,9 @@ export default function DagPanel({ dirKey, groupId }) {
376
445
  const m = modeRef.current;
377
446
  if (!m) return;
378
447
  if (m.kind === 'drag') {
448
+ // 位置记住(#153):拖完写盘——重开还原,连线跟着节点走
449
+ userMovedRef.current.add(m.id);
450
+ savePos(scopeKeyRef.current, posRef.current);
379
451
  clearMode();
380
452
  return;
381
453
  }
@@ -533,12 +605,15 @@ export default function DagPanel({ dirKey, groupId }) {
533
605
  if (!a) continue;
534
606
  const elFrom = canvasRef.current?.querySelector(`[data-node-id="${CSS.escape(fromKey)}"]`);
535
607
  const hFrom = elFrom ? elFrom.offsetHeight : 64;
608
+ // 方向自适应(#153):目标在源右侧 → 源右缘出、目标左缘入;否则反向
609
+ // (同列纵向依赖、用户把节点拖到左边时,线不再绕回去打结)
610
+ const toRight = b.x > a.x + NODE_W - 8;
536
611
  out.push({
537
612
  from: fromKey,
538
613
  to: n.nodeKey,
539
- x1: a.x + NODE_W,
614
+ x1: toRight ? a.x + NODE_W : a.x,
540
615
  y1: a.y + hFrom / 2,
541
- x2: b.x,
616
+ x2: toRight ? b.x : b.x + NODE_W,
542
617
  y2: b.y + hTo / 2,
543
618
  });
544
619
  }
@@ -566,6 +641,14 @@ export default function DagPanel({ dirKey, groupId }) {
566
641
  ? (board?.name || '组编排')
567
642
  : (dirTopic?.name || dirKey || '编排');
568
643
 
644
+ /** 恢复默认布局(#153):清掉记住的摆位,按当前分栏规则重排 */
645
+ const resetLayout = () => {
646
+ try { localStorage.removeItem(POS_KEY(scopeKeyRef.current)); } catch { /* 隐私模式 */ }
647
+ userMovedRef.current.clear();
648
+ setPos(defaultLayout(nodes, { perCol }));
649
+ toast('已恢复默认布局');
650
+ };
651
+
569
652
  const linkArmed = !!linking;
570
653
  const srcLabel = linking
571
654
  ? (byNodeKey.get(linking.sourceId)?.id ?? linking.sourceId)
@@ -607,6 +690,10 @@ export default function DagPanel({ dirKey, groupId }) {
607
690
  ))}
608
691
  </span>
609
692
  )}
693
+ {/* #153:摆位记住了(拖动即存),给一条「恢复默认布局」的退路 */}
694
+ <button type="button" className="dagp-reset" onClick={resetLayout} title="清掉记住的摆位,按默认分栏重排">
695
+ 恢复默认布局
696
+ </button>
610
697
  </div>
611
698
 
612
699
  <div className="dagp-canvas" ref={canvasRef} onPointerDown={onCanvasPointerDown}>
@@ -369,7 +369,9 @@ export default function Landing({
369
369
  />
370
370
  </span>
371
371
  )}
372
- {onReopenTask && t.status !== 'cancelled' && (t.status === 'claimed' || t.status === 'done' || t.completedAt) && (
372
+ {/* #144 反馈只在链尖:已有派生子任务(后续轮次/评论派生)的任务
373
+ 不再给反馈入口——在旧轮次上反馈会把链分叉 */}
374
+ {onReopenTask && t.status !== 'cancelled' && !t.childCount && (t.status === 'claimed' || t.status === 'done' || t.completedAt) && (
373
375
  <span
374
376
  className="op" role="button" tabIndex={-1}
375
377
  title={t.completedAt ? '反馈:新开一条任务(原任务不动)' : '反馈修改:回写本任务并记入任务链'}
@@ -698,6 +698,22 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
698
698
  return (taskRow.history || []).find((h) => Number(h.id) === want) || null;
699
699
  }, [historyId, taskRow]);
700
700
 
701
+ // #144 反馈只在链尖:已有任何派生子任务(后续轮次 / 评论派生)就不再是最新一轮,
702
+ // 反馈入口收起并指到最新一轮——在过去的轮次上反馈会把链分叉。
703
+ const chainChildren = Array.isArray(chainApi?.children) ? chainApi.children : [];
704
+ const isChainTip = chainChildren.length === 0;
705
+ const latestChild = chainChildren.length ? chainChildren[chainChildren.length - 1] : null;
706
+ const openLatestRound = useCallback(() => {
707
+ if (!latestChild || !app.openPage) return;
708
+ // 组锚定页保持组锚(任务还在本组,只是看最新一轮)
709
+ if (groupAnchored) app.openPage({ groupId, task: String(latestChild.id), name: `#${latestChild.id}` });
710
+ else app.openPage({
711
+ dirKey: String(latestChild.key || topicKey || GLOBAL_KEY),
712
+ task: String(latestChild.id),
713
+ name: `#${latestChild.id}`,
714
+ });
715
+ }, [latestChild, app.openPage, groupAnchored, groupId, topicKey]);
716
+
701
717
  const markDirty = useCallback(() => setDirty(true), []);
702
718
 
703
719
  /** 标题 + frontmatter 拼装(提交/贴图同步共用)——标题行永远在 FM 之后。 */
@@ -1661,9 +1677,30 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
1661
1677
  ) : null}
1662
1678
  </div>
1663
1679
  <div className="mdw-review-acts">
1664
- <button type="button" className="ghost" onClick={openFeedback} title="新开一条任务携带反馈(原任务不动)">
1665
- 反馈
1666
- </button>
1680
+ {isChainTip ? (
1681
+ <button type="button" className="ghost" onClick={openFeedback} title="新开一条任务携带反馈(原任务不动)">
1682
+ 反馈
1683
+ </button>
1684
+ ) : (
1685
+ <>
1686
+ <span
1687
+ className="mdw-review-later"
1688
+ title="这条任务已有后续轮次——在旧轮次上反馈会把链分叉,请到最新一轮反馈"
1689
+ >
1690
+ 已进入后续轮次
1691
+ </span>
1692
+ {latestChild ? (
1693
+ <button
1694
+ type="button"
1695
+ className="ghost"
1696
+ onClick={openLatestRound}
1697
+ title={`到最新一轮 #${latestChild.id} 反馈`}
1698
+ >
1699
+ 去最新一轮 #{latestChild.id}
1700
+ </button>
1701
+ ) : null}
1702
+ </>
1703
+ )}
1667
1704
  </div>
1668
1705
  </div>
1669
1706
  ) : (