nx-kv 0.27.0 → 0.28.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 (42) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/package.json +1 -1
  3. package/src/modules/localtask/task-view.js +13 -0
  4. package/src/web/frontend/App.jsx +23 -6
  5. package/src/web/frontend/components/layout/crumbs.js +23 -1
  6. package/src/web/frontend/components/sidebar/model.js +13 -3
  7. package/src/web/frontend/components/sidebar/task-children.jsx +3 -2
  8. package/src/web/frontend/modules/board/board-view.js +83 -0
  9. package/src/web/frontend/page/dag/index.jsx +8 -2
  10. package/src/web/frontend/page/dir/index.jsx +4 -2
  11. package/src/web/frontend/page/dir/task.jsx +101 -36
  12. package/src/web/frontend/page/group/index.jsx +7 -4
  13. package/src/web/frontend/page/overview/index.jsx +18 -7
  14. package/src/web/frontend/page/progress/index.jsx +4 -2
  15. package/src/web/frontend/panels.jsx +13 -82
  16. package/src/web/frontend/route-map.js +102 -0
  17. package/src/web/frontend/workspace.js +91 -14
  18. package/src/web/public/assets/{Introduction-vTffOL-5.js → Introduction-9gBNccF6.js} +1 -1
  19. package/src/web/public/assets/{cloud-truDniwE.js → cloud-DMotpyNl.js} +3 -3
  20. package/src/web/public/assets/dag-B9_B7rnK.js +1 -0
  21. package/src/web/public/assets/dir-DdMpgTHK.js +3 -0
  22. package/src/web/public/assets/group-BF2tfUqG.js +1 -0
  23. package/src/web/public/assets/{index-CFkF2w23.js → index-BbAo8n1E.js} +13 -13
  24. package/src/web/public/assets/{md-history-BLnTGoI5.js → md-history-DunAB9Pp.js} +3 -3
  25. package/src/web/public/assets/{member-picker-CNGyhd0r.js → member-picker-CD66NFHl.js} +1 -1
  26. package/src/web/public/assets/overview-_Xza9umy.js +1 -0
  27. package/src/web/public/assets/progress-DRI-n9Gb.js +3 -0
  28. package/src/web/public/assets/{repos-CPSsUWZ5.js → repos-BfbPRMJ0.js} +7 -7
  29. package/src/web/public/assets/route-crumb-BHjAXhIY.js +1 -0
  30. package/src/web/public/assets/{settings-BQ3gTrIV.js → settings-CVOnFmxp.js} +4 -4
  31. package/src/web/public/assets/task-Nw-0PEB4.js +7 -0
  32. package/src/web/public/assets/{template-slots-Bc70bnzR.js → template-slots-bXUEg7EO.js} +1 -1
  33. package/src/web/public/assets/{templates-ChQO154-.js → templates-cWbR2cCh.js} +1 -1
  34. package/src/web/public/assets/{upload-CzUtsVcG.js → upload-F3aoeT7X.js} +1 -1
  35. package/src/web/public/index.html +1 -1
  36. package/src/web/public/assets/dag-BPV2Yvmk.js +0 -1
  37. package/src/web/public/assets/dir-Cmrrc252.js +0 -3
  38. package/src/web/public/assets/group-B26fV4Ec.js +0 -1
  39. package/src/web/public/assets/overview-CRPbHHGF.js +0 -1
  40. package/src/web/public/assets/progress-CNgMymPb.js +0 -3
  41. package/src/web/public/assets/route-crumb-DTo_wUoT.js +0 -1
  42. package/src/web/public/assets/task-D_7iKWwt.js +0 -7
@@ -12,7 +12,7 @@ import { Actions } from 'flexlayout-react';
12
12
  import { api } from '../../api/client.js';
13
13
  import { useToast } from '../../components/toast/index.jsx';
14
14
  import { Modal, useDialog } from '../../components/popup/index.jsx';
15
- import { GLOBAL_KEY } from '../../modules/board/board-view.js';
15
+ import { GLOBAL_KEY, findGroupTask } from '../../modules/board/board-view.js';
16
16
  import {
17
17
  buildReopenText,
18
18
  FEEDBACK_HEADING,
@@ -53,7 +53,7 @@ import {
53
53
  useDocs,
54
54
  } from '../../modules/md/doc-store.js';
55
55
 
56
- export default function PagePanel({ dirKey, task, beside = false, tabId, model, historyId = null }) {
56
+ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId, model, historyId = null }) {
57
57
  const app = useApp() || {};
58
58
  const toast = useToast();
59
59
  const { dialog, node: dialogNode } = useDialog();
@@ -61,16 +61,30 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
61
61
  const refreshLocal = app.refreshLocal;
62
62
  const tpl = app.tpl;
63
63
 
64
- const isGlobal = !dirKey || dirKey === GLOBAL_KEY;
65
- const scope = scopeOf(dirKey);
64
+ // 组锚定页(#86):dirKey 缺席、groupId 在场——路由是 #/group/<boardId>?task=N,
65
+ // 这条任务物理上落在哪个成员队列,在这里搜出来(优先 boardMark 指向本组的候选,
66
+ // 与组页「本组任务」同口径)。队列数据(rows 轮询)到位前解析为空,随后自然补上。
67
+ const groupAnchored = !!(groupId && !dirKey);
68
+ const groupResolved = useMemo(
69
+ () => (groupAnchored ? findGroupTask(rows, (app.repoData && app.repoData.boards) || [], groupId, task) : null),
70
+ [groupAnchored, rows, app.repoData, groupId, task]
71
+ );
72
+ // 本页所属队列的 key:组锚定 = 解析出的成员队列;目录锚定 = dirKey
73
+ const topicKey = (groupResolved && groupResolved.topic && groupResolved.topic.key) || dirKey || '';
74
+
75
+ const isGlobal = !groupAnchored && (!topicKey || topicKey === GLOBAL_KEY);
66
76
  const isDraft = isDraftTask(task);
77
+ // 文档作用域(#86):组锚定的**草稿**种在组 scope——组页「新增任务」从组路由
78
+ // 打开能寻回同一份;其余(实任务 / 目录页)都在队列 scope,同一任务两种锚共享一份文档。
79
+ const scope = groupAnchored && isDraft ? scopeOf(groupId) : scopeOf(topicKey);
67
80
  const id = docIdOf(scope, task);
68
81
 
69
82
  // 本目录的主题(提交/删除要它的 cwd)
70
83
  const topic = useMemo(() => {
84
+ if (groupAnchored) return (groupResolved && groupResolved.topic) || null;
71
85
  if (isGlobal) return rows.find((r) => r.isGlobal) || null;
72
- return rows.find((r) => r.key === dirKey) || null;
73
- }, [rows, dirKey, isGlobal]);
86
+ return rows.find((r) => r.key === topicKey) || null;
87
+ }, [rows, topicKey, isGlobal, groupAnchored, groupResolved]);
74
88
 
75
89
  const taskRow = useMemo(
76
90
  () => (topic?.tasks || []).find((x) => String(x.id) === String(task)) || null,
@@ -207,12 +221,16 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
207
221
  refreshLocal();
208
222
  return;
209
223
  }
210
- const landedKey = res?.key || dirKey;
224
+ const landedKey = res?.key || topicKey;
211
225
  saveDoc(docIdOf(scopeOf(landedKey), newId), { title: titleFromMd(text), body: text });
212
226
  if (attachments?.length) persistAtt(newId, attachments);
213
227
  toast(`已反馈「${title}」→ 新任务 #${newId}`);
214
228
  refreshLocal();
215
- if (app.openPage) app.openPage({ dirKey: landedKey, task: newId, name: `${title.slice(0, 24)}(反馈)` });
229
+ // 反馈新任务继承原任务的组语义(正文连 FM 一起带下去)——组锚定页就留在组里开
230
+ if (app.openPage) {
231
+ if (groupAnchored) app.openPage({ groupId, task: newId, name: `${title.slice(0, 24)}(反馈)` });
232
+ else app.openPage({ dirKey: landedKey, task: newId, name: `${title.slice(0, 24)}(反馈)` });
233
+ }
216
234
  });
217
235
  };
218
236
  /** 划选评论 → 就地回写原任务(#74),可带附件。
@@ -280,14 +298,14 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
280
298
  },
281
299
  });
282
300
  // 回写后的正文以服务端为准刷回编辑器(服务端拼装时新段只有服务端知道)
283
- const landedKey = res?.key || dirKey;
301
+ const landedKey = res?.key || topicKey;
284
302
  const sameId = String(res?.task?.id ?? task);
285
303
  const finalText = String(res?.task?.text ?? text ?? '');
286
304
  if (finalText) {
287
305
  saveDoc(docIdOf(scopeOf(landedKey), sameId), { title: titleFromMd(finalText), body: finalText });
288
306
  }
289
307
  if (attachments?.length) persistAtt(sameId, [...(doc?.attachments || []), ...attachments]);
290
- if (model && tabId && landedKey !== dirKey) {
308
+ if (model && tabId && landedKey !== topicKey) {
291
309
  model.doAction(Actions.updateNodeAttributes(tabId, { config: { dirKey: landedKey, task: sameId } }));
292
310
  }
293
311
  setDirty(false);
@@ -304,9 +322,9 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
304
322
  const parentRef = useMemo(() => {
305
323
  if (beside) return null; // 旁路原文自己不再开旁路
306
324
  const pid = String(docFm.parent || '').trim();
307
- const pdir = String(docFm.parentDir || dirKey || '').trim();
325
+ const pdir = String(docFm.parentDir || topicKey || '').trim();
308
326
  if (pid && !/^draft/i.test(pid)) {
309
- return { dirKey: pdir || dirKey, task: pid, name: `#${pid}` };
327
+ return { dirKey: pdir || topicKey, task: pid, name: `#${pid}` };
310
328
  }
311
329
  const body = String(doc?.body || '');
312
330
  const m = body.match(/>\s*锚定自「([^」]+)」/);
@@ -317,8 +335,8 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
317
335
  return titleFromMd(t.text || '') === title || String(t.text || '').includes(`# ${title}`);
318
336
  });
319
337
  if (!hit) return null;
320
- return { dirKey, task: String(hit.id), name: `#${hit.id}` };
321
- }, [beside, docFm.parent, docFm.parentDir, doc?.body, dirKey, topic, task]);
338
+ return { dirKey: topicKey, task: String(hit.id), name: `#${hit.id}` };
339
+ }, [beside, docFm.parent, docFm.parentDir, doc?.body, topicKey, topic, task]);
322
340
  const boardCtx = useMemo(() => {
323
341
  const bid = docFm.board;
324
342
  if (!bid) return null;
@@ -335,11 +353,18 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
335
353
  }, [docFm.board, app.repoData]);
336
354
 
337
355
  // 首开这一页时把内容「种」进去:真实任务用服务端正文,草稿用默认模板
356
+ // (组锚定草稿带上 board 语义——与组页「新增任务」种的同一份;已有文档不覆盖)
338
357
  useEffect(() => {
339
358
  if (docs[id]) return;
340
- if (isDraft) getDoc(id, { title: '', body: tpl ? tpl.defaultBody() : '' });
341
- else if (taskRow) getDoc(id, { title: titleFromMd(taskRow.text), body: taskRow.text });
342
- }, [id, isDraft, taskRow]);
359
+ if (isDraft) {
360
+ getDoc(id, {
361
+ title: '',
362
+ body: tpl
363
+ ? (groupAnchored ? withFrontmatter(tpl.defaultBody(), { board: groupId }) : tpl.defaultBody())
364
+ : '',
365
+ });
366
+ } else if (taskRow) getDoc(id, { title: titleFromMd(taskRow.text), body: taskRow.text });
367
+ }, [id, isDraft, taskRow, groupAnchored, groupId]);
343
368
 
344
369
  const [selMenu, setSelMenu] = useState(null);
345
370
  const [showShortcuts, setShowShortcuts] = useState(false);
@@ -440,7 +465,7 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
440
465
  name: '进程',
441
466
  config: boardId
442
467
  ? { groupKey: boardId, task: task != null ? String(task) : undefined }
443
- : { dirKey: dirKey || GLOBAL_KEY, task: task != null ? String(task) : undefined },
468
+ : { dirKey: topicKey || GLOBAL_KEY, task: task != null ? String(task) : undefined },
444
469
  location: 'right',
445
470
  });
446
471
  };
@@ -475,7 +500,7 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
475
500
  component: 'page',
476
501
  name: `链 #${task} · ${node.kind || node.historyId}`,
477
502
  config: {
478
- dirKey: dirKey || GLOBAL_KEY,
503
+ dirKey: topicKey || GLOBAL_KEY,
479
504
  task: String(task),
480
505
  historyId: Number(node.historyId),
481
506
  },
@@ -493,7 +518,7 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
493
518
  }
494
519
  toast('这个节点没有可打开的内容');
495
520
  },
496
- [model, app.model, isDraft, dirKey, task, toast],
521
+ [model, app.model, isDraft, topicKey, task, toast],
497
522
  );
498
523
 
499
524
  const closeBesideSelf = useCallback(() => {
@@ -584,7 +609,7 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
584
609
  attachmentCount: 0,
585
610
  current: true,
586
611
  taskId: Number(task),
587
- dirKey: dirKey || GLOBAL_KEY,
612
+ dirKey: topicKey || GLOBAL_KEY,
588
613
  });
589
614
  for (const c of children) {
590
615
  nodes.push({
@@ -600,7 +625,7 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
600
625
  }
601
626
  // 弹窗里即使只有当前节点也展示(说明这是链的尖)
602
627
  return nodes;
603
- }, [isDraft, taskRow, chainApi, task, dirKey]);
628
+ }, [isDraft, taskRow, chainApi, task, topicKey]);
604
629
 
605
630
  const historyNode = useMemo(() => {
606
631
  if (historyId == null || !taskRow) return null;
@@ -632,7 +657,7 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
632
657
  // 标题行 / frontmatter 的位置与真实落库一致,预览才不会假装干净)。
633
658
  const body = {
634
659
  cwd: isGlobal ? (topic?.cwd || undefined) : topic?.cwd,
635
- key: isGlobal ? GLOBAL_KEY : dirKey,
660
+ key: isGlobal ? GLOBAL_KEY : topicKey,
636
661
  ...(isDraft
637
662
  ? { text: composeText((doc?.title || '').trim() || '未命名任务', doc?.body || '') }
638
663
  : { id: Number(task) }),
@@ -640,7 +665,7 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
640
665
  api('/api/localtasks/preview', { method: 'POST', body })
641
666
  .then((d) => setPreview({ data: d }))
642
667
  .catch((e) => setPreview({ error: String(e.message || e) }));
643
- }, [isGlobal, topic?.cwd, dirKey, isDraft, doc?.title, doc?.body, task]);
668
+ }, [isGlobal, topic?.cwd, topicKey, isDraft, doc?.title, doc?.body, task]);
644
669
 
645
670
  // ─── 保存 / 提交 ───
646
671
  // 时间目标的落库口径:草稿 → POST 带 duration/goalPrompt(后端 sanitize 校验写法);
@@ -696,15 +721,24 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
696
721
  });
697
722
  // 归属改了会搬家(服务端按 frontmatter.project 落到新项目队列,任务 #43)——
698
723
  // 页签与文档跟过去(同「草稿提交落点跟到真实主题」一套),不然这页还开着旧队列的旧号。
724
+ // 组锚定页(#86)保持组锚:任务还是本组的,只是换了个成员队列。
699
725
  if (res?.moved) {
700
- const landedKey = res.key || dirKey;
726
+ const landedKey = res.key || topicKey;
701
727
  const newId = String(res.task?.id ?? task);
702
728
  const newDocId = docIdOf(scopeOf(landedKey), newId);
703
729
  persistAtt(newId, doc.attachments);
704
730
  promoteDoc(id, newDocId, { title: t, body: res.task?.text || b });
705
731
  if (model && tabId) {
706
- model.doAction(Actions.updateNodeAttributes(tabId, { config: { dirKey: landedKey, task: newId } }));
732
+ model.doAction(Actions.updateNodeAttributes(tabId, {
733
+ config: groupAnchored ? { groupId, task: newId } : { dirKey: landedKey, task: newId },
734
+ }));
707
735
  }
736
+ // 地址跟页签一起走(同「草稿转正」——刷新不能落在搬家前的旧号上)
737
+ app.onNavigate && app.onNavigate(
738
+ groupAnchored
739
+ ? `#/group/${encodeURIComponent(groupId || '')}?task=${encodeURIComponent(newId)}`
740
+ : `#/dir/${encodeURIComponent(landedKey || '')}?task=${encodeURIComponent(newId)}`
741
+ );
708
742
  setDirty(false);
709
743
  clearHistory(histRef.current, newDocId);
710
744
  toast(`已改归属项目:任务迁到「${res.name}」#${newId}`);
@@ -740,15 +774,25 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
740
774
  if (newId != null) {
741
775
  // 落点 = 服务端返回的真实主题 key(组任务按 project 推导,可能是别的项目/目录)。
742
776
  // 页签与文档都跟到真实落点——不然页签开着旧 scope,却指向别的队列里的任务号。
743
- const landedKey = res?.key || dirKey;
777
+ // 组锚定页保持组锚(#86):提交后的实任务带 boardMark,组路由照样解析得回;
778
+ // 文档搬去队列 scope(与目录页打开同一任务共享一份)。
779
+ const landedKey = res?.key || topicKey;
744
780
  const landedScope = scopeOf(landedKey);
745
781
  persistAtt(newId, doc.attachments);
746
782
  const newDocId = docIdOf(landedScope, String(newId));
747
783
  promoteDoc(id, newDocId, { title: t, body: b });
748
- // 页签的 config 换成新任务(否则刷新后还认着 draft 号)
784
+ // 页签的 config 换成新任务(否则刷新后还认着 draft 号);地址跟着走——
785
+ // 不然刷新还落在旧 draft 号上(那份草稿已转正搬走,会开出一份空壳新草稿)
749
786
  if (model && tabId) {
750
- model.doAction(Actions.updateNodeAttributes(tabId, { config: { dirKey: landedKey, task: String(newId) } }));
787
+ model.doAction(Actions.updateNodeAttributes(tabId, {
788
+ config: groupAnchored ? { groupId, task: String(newId) } : { dirKey: landedKey, task: String(newId) },
789
+ }));
751
790
  }
791
+ app.onNavigate && app.onNavigate(
792
+ groupAnchored
793
+ ? `#/group/${encodeURIComponent(groupId || '')}?task=${encodeURIComponent(String(newId))}`
794
+ : `#/dir/${encodeURIComponent(landedKey || '')}?task=${encodeURIComponent(String(newId))}`
795
+ );
752
796
  setDirty(false);
753
797
  clearHistory(histRef.current, newDocId);
754
798
  }
@@ -756,7 +800,7 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
756
800
  refreshLocal();
757
801
  });
758
802
 
759
- // ─── 导入 .md(在本目录里建一个任务,并开它的页签)───
803
+ // ─── 导入 .md(建一个任务,并开它的页签)───
760
804
  const importMd = async (file) => {
761
805
  const text = await file.text();
762
806
  const name = file.name.replace(/\.md$/i, '');
@@ -764,12 +808,21 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
764
808
  const bodyText = text.startsWith('#') ? text : `# ${name}\n\n${text}`;
765
809
  const res = await api('/api/localtasks', {
766
810
  method: 'POST',
767
- body: isGlobal ? { global: true, text: bodyText } : { cwd: topic.cwd, text: bodyText },
811
+ // 组锚定页(#86):按归属项目落队(与提交同一口径——组草稿页 topic 还没解析,
812
+ // cwd 寻不到);目录/全局页维持 cwd / 全局池。
813
+ body: isGlobal
814
+ ? { global: true, text: bodyText }
815
+ : groupAnchored && docFm.project
816
+ ? { project: docFm.project, text: bodyText }
817
+ : { cwd: topic?.cwd, text: bodyText },
768
818
  });
769
819
  toast(`已导入:${file.name}`);
770
820
  refreshLocal();
771
821
  const newId = res?.task?.id ?? res?.id;
772
- if (newId != null && app.openPage) app.openPage({ dirKey, task: String(newId), name: `#${newId}` });
822
+ if (newId != null && app.openPage) {
823
+ if (groupAnchored) app.openPage({ groupId, task: String(newId), name: `#${newId}` });
824
+ else app.openPage({ dirKey: topicKey, task: String(newId), name: `#${newId}` });
825
+ }
773
826
  });
774
827
  };
775
828
 
@@ -871,7 +924,9 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
871
924
  */
872
925
  const newTask = () => {
873
926
  const draftId = nextDraftId();
874
- const docId = docIdOf(scopeOf(dirKey), draftId);
927
+ // 草稿 doc 的 scope:组锚定页种在**组 scope**(与组页「新增任务」同一套,
928
+ // 组路由寻得回,#86);目录页种在本目录 scope
929
+ const docId = docIdOf(groupAnchored ? scopeOf(groupId) : scopeOf(topicKey), draftId);
875
930
  const fm = {};
876
931
  if (boardCtx && boardCtx.board && boardCtx.board.id) fm.board = boardCtx.board.id;
877
932
  if (docFm.project) fm.project = docFm.project;
@@ -879,7 +934,11 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
879
934
  title: '',
880
935
  body: withFrontmatter(tpl ? tpl.defaultBody() : '', fm),
881
936
  });
882
- app.openPage && app.openPage({ dirKey, task: draftId, name: '新任务' });
937
+ app.openPage && app.openPage(
938
+ groupAnchored
939
+ ? { groupId, task: draftId, name: '新任务' }
940
+ : { dirKey: topicKey, task: draftId, name: '新任务' }
941
+ );
883
942
  };
884
943
 
885
944
  /** 「更多 → 克隆任务」:以当前任务为模板快速复制一条新任务(#70)。
@@ -899,7 +958,9 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
899
958
  refreshLocal();
900
959
  const newId = res?.task?.id ?? res?.id;
901
960
  if (newId != null && app.openPage) {
902
- app.openPage({ dirKey, task: String(newId), name: `${(doc?.title || '任务').slice(0, 30)}(克隆)` });
961
+ // 克隆连 FM 一起复制——组任务的克隆还是组任务,组锚定页就留在组里开
962
+ if (groupAnchored) app.openPage({ groupId, task: String(newId), name: `${(doc?.title || '任务').slice(0, 30)}(克隆)` });
963
+ else app.openPage({ dirKey: topicKey, task: String(newId), name: `${(doc?.title || '任务').slice(0, 30)}(克隆)` });
903
964
  }
904
965
  });
905
966
  };
@@ -1091,7 +1152,11 @@ export default function PagePanel({ dirKey, task, beside = false, tabId, model,
1091
1152
  <div>
1092
1153
  <button
1093
1154
  className="btn ghost sm"
1094
- onClick={() => app.onNavigate && app.onNavigate(isGlobal ? '#/global' : '#/dir/' + encodeURIComponent(dirKey || ''))}
1155
+ onClick={() => app.onNavigate && app.onNavigate(
1156
+ groupAnchored
1157
+ ? '#/group/' + encodeURIComponent(groupId || '')
1158
+ : isGlobal ? '#/global' : '#/dir/' + encodeURIComponent(dirKey || '')
1159
+ )}
1095
1160
  >
1096
1161
  回到目录
1097
1162
  </button>
@@ -202,13 +202,16 @@ export default function GroupView({ dirKey, rows, repoData, model }) {
202
202
  if (!board) return;
203
203
  if (!sel) return toast('这个组还没有成员——先「添加成员」,再建任务');
204
204
  const id = nextDraftId();
205
- const docId = docIdOf(scopeOf(sel.topicKey || ''), id);
205
+ // 草稿 doc 种在**组 scope**(docIdOf(scopeOf(board.id), id)):从组路由
206
+ // #/group/<id>?task=draft-N 打开寻得回同一份(#86)。以前种在成员 scope、
207
+ // 打开走 dir 路由——组语义在建任务这步就断了。
208
+ const docId = docIdOf(scopeOf(board.id), id);
206
209
  // 与目录任务页同一条 defaultBody:已按槽位值渲染,不出现裸 {{背景}}
207
210
  saveDoc(docId, {
208
211
  title: '',
209
212
  body: withFrontmatter(tpl.defaultBody(), { board: board.id, project: sel.key }),
210
213
  });
211
- app.openPage?.({ dirKey: sel.topicKey || '', task: id, name: '新任务' });
214
+ app.openPage?.({ groupId: board.id, task: id, name: '新任务' });
212
215
  };
213
216
 
214
217
  return (
@@ -316,7 +319,7 @@ export default function GroupView({ dirKey, rows, repoData, model }) {
316
319
  <button
317
320
  className="rp-proj-task"
318
321
  title="打开这条任务"
319
- onClick={() => app.openPage && app.openPage({ dirKey: member.topicKey, task: String(task.id), name: `#${task.id}` })}
322
+ onClick={() => app.openPage && app.openPage({ groupId: board.id, task: String(task.id), name: `#${task.id}` })}
320
323
  >
321
324
  <span className="mono">#{task.id}</span>
322
325
  <span className="rp-ptag" title={`归属项目:${member.name}`}>{member.name}</span>
@@ -366,7 +369,7 @@ export default function GroupView({ dirKey, rows, repoData, model }) {
366
369
  key={member.key + ':' + task.id}
367
370
  className="rp-proj-task done"
368
371
  title="打开这条任务"
369
- onClick={() => app.openPage && app.openPage({ dirKey: member.topicKey, task: String(task.id), name: `#${task.id}` })}
372
+ onClick={() => app.openPage && app.openPage({ groupId: board.id, task: String(task.id), name: `#${task.id}` })}
370
373
  >
371
374
  <span className="mono">#{task.id}</span>
372
375
  <span className="rp-ptag" title={`归属项目:${member.name}`}>{member.name}</span>
@@ -18,7 +18,7 @@ import { Icon } from '../../components/icons.jsx';
18
18
  import { useToast } from '../../components/toast/index.jsx';
19
19
  import { useDialog } from '../../components/popup/index.jsx';
20
20
  import { titleFromMd } from '../../modules/md/md-parse.js';
21
- import { GLOBAL_KEY, splitQueueTasks } from '../../modules/board/board-view.js';
21
+ import { GLOBAL_KEY, splitQueueTasks, projectTasks, isPendingRow } from '../../modules/board/board-view.js';
22
22
 
23
23
  const NO_IDS = new Set();
24
24
 
@@ -41,23 +41,34 @@ export default function Overview({ rows, onNavigate, refreshLocal }) {
41
41
  // 「已领取」历史折叠:展开的分区 key 集合(默认全收起)。
42
42
  const [doneOpen, setDoneOpen] = useState(() => new Set());
43
43
 
44
- const dirs = useMemo(() => rows.filter((r) => !r.isGlobal), [rows]);
45
- const globalRow = rows.find((r) => r.isGlobal);
44
+ // #85 两种走向:总览是**项目走向**的页面——组任务(frontmatter.board)归组页管,
45
+ // 列表与计数按「剔除组任务」后的视图走(pending 一并在客户端按走向重数;
46
+ // 全局池不会有组任务,同样过滤无害)。其余字段原样透传。
47
+ const view = useMemo(
48
+ () =>
49
+ rows.map((r) => {
50
+ const tasks = projectTasks(r.tasks);
51
+ return { ...r, tasks, pending: tasks.filter(isPendingRow).length };
52
+ }),
53
+ [rows]
54
+ );
55
+ const dirs = useMemo(() => view.filter((r) => !r.isGlobal), [view]);
56
+ const globalRow = view.find((r) => r.isGlobal);
46
57
  const totalPending = dirs.reduce((n, r) => n + (r.pending || 0), 0) + (globalRow?.pending || 0);
47
- const waiting = rows.filter((r) => r.waiting);
58
+ const waiting = view.filter((r) => r.waiting);
48
59
 
49
60
  const secKeyOf = (r) => (r.isGlobal ? GLOBAL_KEY : r.key);
50
61
 
51
62
  // 跨目录的当前选中总数(只数仍存在且未删除的)
52
63
  const selCount = useMemo(() => {
53
64
  let n = 0;
54
- for (const r of rows) {
65
+ for (const r of view) {
55
66
  const cur = sel.get(secKeyOf(r));
56
67
  if (!cur || !cur.size) continue;
57
68
  for (const t of r.tasks || []) if (cur.has(Number(t.id)) && !t.deletedAt) n += 1;
58
69
  }
59
70
  return n;
60
- }, [rows, sel]);
71
+ }, [view, sel]);
61
72
 
62
73
  const idsOf = (secKey) => sel.get(secKey) || NO_IDS;
63
74
  const pickedOf = (secKey, pending) => {
@@ -107,7 +118,7 @@ export default function Overview({ rows, onNavigate, refreshLocal }) {
107
118
  /** 底部操作条的删除:把选中项按目录分组,逐组调批量删除接口。 */
108
119
  const dropAll = async () => {
109
120
  const groups = [];
110
- for (const r of rows) {
121
+ for (const r of view) {
111
122
  const key = secKeyOf(r);
112
123
  const cur = sel.get(key);
113
124
  if (!cur || !cur.size) continue;
@@ -11,7 +11,7 @@
11
11
  import { useEffect, useMemo, useState } from 'react';
12
12
  import { api } from '../../api/client.js';
13
13
  import { Icon } from '../../components/icons.jsx';
14
- import { GLOBAL_KEY } from '../../modules/board/board-view.js';
14
+ import { GLOBAL_KEY, isGroupTask } from '../../modules/board/board-view.js';
15
15
  import { parseFrontmatter, taskToProgress } from '../../modules/md/md-parse.js';
16
16
  import { closeRightSidebar, findOpenPanel } from '../../workspace.js';
17
17
  import { useToast } from '../../components/toast/index.jsx';
@@ -49,7 +49,9 @@ export default function ProgressPanel({
49
49
  return (rows || []).find((r) => r.key === dirKey) || null;
50
50
  }, [rows, dirKey, isGlobal]);
51
51
 
52
- const tasks = useMemo(() => (topic?.tasks || []).filter((t) => !t.deletedAt), [topic]);
52
+ // #85 两种走向:目录/全局模式是**项目走向**——组任务归组页管(组模式另一条
53
+ // 分支整组口径收成员队列,不受此影响)
54
+ const tasks = useMemo(() => (topic?.tasks || []).filter((t) => !t.deletedAt && !isGroupTask(t)), [topic]);
53
55
 
54
56
  const [now, setNow] = useState(Date.now());
55
57
  // 多选:存卡片键(目录模式 = 任务 id 数字;组模式 = "topicKey:id" 复合键——
@@ -7,7 +7,6 @@
7
7
  // 从 node.getConfig() 取。加一种面板 = 这里加一行。
8
8
  import { Suspense, lazy } from 'react';
9
9
  import { useApp } from './app-context.jsx';
10
- import { docIdOf, peekDoc, scopeOf } from './modules/md/doc-store.js';
11
10
  import SidebarPanel from './components/sidebar/panel.jsx';
12
11
  import { openFloatingPanel } from './workspace.js';
13
12
 
@@ -44,11 +43,13 @@ function DirPanelView({ dirKey }) {
44
43
  return wrap(<DirPanel dirKey={dirKey} />);
45
44
  }
46
45
 
47
- /** 一个 MD 页(编辑器):页签在工作区里,内容在会话内存里;beside=旁路原文(可关);historyId=链节点只读 */
48
- function PagePanelView({ dirKey, task, beside, tabId, model, historyId }) {
46
+ /** 一个 MD 页(编辑器):页签在工作区里,内容在会话内存里;beside=旁路原文(可关);historyId=链节点只读
47
+ * groupId(任务 #86)= 组锚定页:组任务详情路由 #/group/<boardId>?task=N,成员队列在面板内部解析 */
48
+ function PagePanelView({ dirKey, groupId, task, beside, tabId, model, historyId }) {
49
49
  return wrap(
50
50
  <PagePanel
51
51
  dirKey={dirKey}
52
+ groupId={groupId}
52
53
  task={task}
53
54
  beside={!!beside}
54
55
  tabId={tabId}
@@ -76,7 +77,11 @@ function ProgressPanelView({ dirKey, task, groupKey }) {
76
77
  rows={app.rows}
77
78
  refreshLocal={app.refreshLocal}
78
79
  model={app.model}
79
- onOpenTask={(id, dk) => app.openPage && app.openPage({ dirKey: dk || dirKey, task: String(id), name: `#${id}` })}
80
+ onOpenTask={(id, dk) =>
81
+ groupKey
82
+ ? app.openPage && app.openPage({ groupId: groupKey, task: String(id), name: `#${id}` })
83
+ : app.openPage && app.openPage({ dirKey: dk || dirKey, task: String(id), name: `#${id}` })
84
+ }
80
85
  onClosePage={(tabId) => app.closePanel && app.closePanel(tabId)}
81
86
  />
82
87
  );
@@ -108,6 +113,7 @@ export const PANELS = {
108
113
  page: { title: '页面', render: (cfg, ctx) => (
109
114
  <PagePanelView
110
115
  dirKey={cfg && cfg.dirKey}
116
+ groupId={cfg && cfg.groupId}
111
117
  task={cfg && cfg.task}
112
118
  beside={cfg && cfg.beside}
113
119
  historyId={cfg && cfg.historyId}
@@ -171,81 +177,6 @@ export function factory(node) {
171
177
 
172
178
  // ─── 路由 ↔ 面板 ────────────────────────────────────────────────
173
179
  //
174
- // 面板是「看得见的东西」,hash 是「能分享的地址」——两者必须指向同一件事:
175
- // 路由变化 → 打开/聚焦对应面板;选中面板变化 → 地址跟着走(replaceState,不触发 hashchange)。
176
- // 深链因此永远能复现同一屏:地址决定开哪块面板。
177
-
178
- export const GLOBAL_KEY = '__GLOBAL__';
179
-
180
- /** 面板 → 路由(选中的面板变了,地址跟着变) */
181
- export function routeOfPanel(node) {
182
- if (!node) return null;
183
- const cfg = node.getConfig() || {};
184
- switch (node.getComponent()) {
185
- case 'page':
186
- // 旁路原文(评论任务右侧)不改地址——否则路由 effect 会按原文重开主区,冲掉评论页
187
- if (cfg.beside) return null;
188
- return `#/dir/${encodeURIComponent(cfg.dirKey || '')}?task=${encodeURIComponent(cfg.task || '')}`;
189
- case 'dir':
190
- return cfg.dirKey === GLOBAL_KEY
191
- ? '#/global'
192
- : `#/dir/${encodeURIComponent(cfg.dirKey || '')}`;
193
- case 'group':
194
- return `#/group/${encodeURIComponent(cfg.boardId || '')}`;
195
- case 'repos':
196
- return '#/repos';
197
- case 'cloud':
198
- return '#/cloud';
199
- case 'overview':
200
- return '#/overview';
201
- case 'templates':
202
- return '#/templates';
203
- default:
204
- return null; // 侧栏 / 开始页 / 进程面板不是路由目标
205
- }
206
- }
207
-
208
- /** 草稿页签名:路由只认 draft-N,用 doc-store 里的草稿标题(读一次,不引响应性) */
209
- function draftTitleOf(route) {
210
- const task = String((route && route.task) || '');
211
- if (!task.startsWith('draft')) return '';
212
- const doc = peekDoc(docIdOf(scopeOf(route.key), task));
213
- return String((doc && doc.title) || '').trim();
214
- }
215
-
216
- /** 路由 → 面板规格(路由变了,打开/聚焦对应面板) */
217
- export function panelSpecOfRoute(route, ctx = {}) {
218
- if (!route) return null;
219
- switch (route.view) {
220
- case 'dir':
221
- // 带 ?task= → 那是**某一页**(页签面板);不带 → 目录的子任务表
222
- if (route.task) {
223
- return {
224
- component: 'page',
225
- name: ctx.pageTitle || draftTitleOf(route) || `页 ${route.task}`,
226
- config: { dirKey: route.key, task: route.task },
227
- };
228
- }
229
- return {
230
- component: 'dir',
231
- name: ctx.dirName || '目录',
232
- config: { dirKey: route.key },
233
- };
234
- case 'group':
235
- return {
236
- component: 'group',
237
- name: ctx.boardName || '项目组',
238
- config: { boardId: route.key },
239
- };
240
- case 'repos':
241
- return { component: 'repos', name: '仓库管理', config: {} };
242
- case 'cloud':
243
- return { component: 'cloud', name: '云端总览', config: {} };
244
- case 'overview':
245
- return { component: 'overview', name: '全部目录总览', config: {} };
246
- case 'templates':
247
- return { component: 'templates', name: '任务模板', config: {} };
248
- default:
249
- return null;
250
- }
251
- }
180
+ // 纯映射抽在 route-map.js(不引 React,单测可直接 import)——这里只转出口,
181
+ // 既有引用面(App.jsx 等)不用改。
182
+ export { GLOBAL_KEY, routeOfPanel, panelSpecOfRoute } from './route-map.js';