nx-kv 0.52.0 → 0.53.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 (73) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/package.json +1 -1
  3. package/src/modules/docs/actions/_manifest.generated.ts +3 -0
  4. package/src/modules/docs/actions/docs-bindings.ts +45 -8
  5. package/src/modules/docs/actions/docs-gc.ts +32 -0
  6. package/src/modules/docs/gc.ts +87 -0
  7. package/src/modules/docs/refs.ts +4 -1
  8. package/src/modules/docs/service.ts +25 -6
  9. package/src/modules/localtask/action-render.ts +1 -1
  10. package/src/modules/localtask/actions/localtask-config.ts +9 -4
  11. package/src/modules/repos/actions/repo-update.ts +1 -1
  12. package/src/modules/tasktool/delivery-template.ts +5 -1
  13. package/src/modules/tasktool/get.ts +9 -5
  14. package/src/modules/tasktool/plugins/waitgoal-config.ts +9 -2
  15. package/src/shared/prompt-blocks.ts +25 -3
  16. package/src/web/frontend/api/cli-tree.json +16 -1
  17. package/src/web/frontend/api/client.generated.ts +12 -2
  18. package/src/web/frontend/components/repos/get-loop-modal.tsx +27 -5
  19. package/src/web/frontend/components/sidebar/task-children.tsx +3 -1
  20. package/src/web/frontend/modules/md/styles/docs.css +8 -0
  21. package/src/web/frontend/page/doc/api.ts +0 -20
  22. package/src/web/frontend/page/doc/index.tsx +64 -17
  23. package/src/web/frontend/page/overview/api.ts +13 -0
  24. package/src/web/frontend/page/overview/index.tsx +60 -7
  25. package/src/web/frontend/page/refs/index.tsx +120 -41
  26. package/src/web/frontend/page/refs/style.css +13 -2
  27. package/src/web/frontend/page/repos/board-admin.tsx +3 -3
  28. package/src/web/frontend/page/repos/board-refs.tsx +3 -3
  29. package/src/web/frontend/page/repos/doc-search-modal.tsx +1 -3
  30. package/src/web/frontend/page/repos/index.tsx +19 -22
  31. package/src/web/frontend/page/repos/repo-table.tsx +1 -1
  32. package/src/web/frontend/page/settings/api.ts +11 -1
  33. package/src/web/frontend/page/settings/prompt-templates-section.tsx +6 -8
  34. package/src/web/frontend/refs/api.ts +65 -0
  35. package/src/web/frontend/refs/follow.ts +91 -0
  36. package/src/web/frontend/refs/index.ts +15 -0
  37. package/src/web/frontend/refs/ops.ts +58 -0
  38. package/src/web/frontend/refs/rows.ts +51 -0
  39. package/src/web/frontend/styles-v2/sidebar.css +6 -0
  40. package/src/web/frontend/workspace/layout.ts +38 -0
  41. package/src/web/frontend/workspace/open.ts +8 -1
  42. package/src/web/frontend/workspace/panels.ts +42 -1
  43. package/src/web/public/assets/{bar-Di7RK1fB.js → bar-BBGb6Y5_.js} +1 -1
  44. package/src/web/public/assets/{composer-launch-yGr4Ayzx.js → composer-launch-CjUpcCqD.js} +1 -1
  45. package/src/web/public/assets/{composer-panel-U2jaQLVQ.js → composer-panel-ECutPtRA.js} +1 -1
  46. package/src/web/public/assets/{dir-BY5ibEGY.js → dir-B8B1sEfY.js} +1 -1
  47. package/src/web/public/assets/doc-CmGraKDe.js +6 -0
  48. package/src/web/public/assets/{group-mIIARpRB.js → group-BA0tiEYP.js} +1 -1
  49. package/src/web/public/assets/{index-j44oS8Y3.css → index-59ZF4OlE.css} +1 -1
  50. package/src/web/public/assets/index-C2C8mDHD.js +2 -0
  51. package/src/web/public/assets/{md-history-wRTMWb12.js → md-history-8KUZ9ipc.js} +1 -1
  52. package/src/web/public/assets/overview-VC4HFUS_.js +1 -0
  53. package/src/web/public/assets/{progress-BRSLsiPg.js → progress-D0qBwZIV.js} +1 -1
  54. package/src/web/public/assets/refs-BhgP7Ryy.js +2 -0
  55. package/src/web/public/assets/refs-IQi1h4-q.css +1 -0
  56. package/src/web/public/assets/{repo-form-modal-dO99i73A.js → repo-form-modal-B_ruPwr0.js} +1 -1
  57. package/src/web/public/assets/repos-DP6AFrI6.js +14 -0
  58. package/src/web/public/assets/settings-C_8mDUqx.js +8 -0
  59. package/src/web/public/assets/{task-Cxa641GX.js → task-IoEm4Lmw.js} +1 -1
  60. package/src/web/public/assets/{task-utils-DSZKkq5e.js → task-utils-BqIPKFHQ.js} +1 -1
  61. package/src/web/public/assets/{templates-CExLUDs6.js → templates-B2zDwQG0.js} +1 -1
  62. package/src/web/public/assets/{use-rail-drag-D-17tqYm.js → use-rail-drag-2mF0AHna.js} +1 -1
  63. package/src/web/public/assets/workspace-BwpvQUst.js +28 -0
  64. package/src/web/public/index.html +7 -7
  65. package/src/web/public/assets/doc-DHi__8Em.js +0 -6
  66. package/src/web/public/assets/index-DiOQ8kPZ.js +0 -2
  67. package/src/web/public/assets/overview-DPDbuE5d.js +0 -1
  68. package/src/web/public/assets/refs-C5idWnUj.css +0 -1
  69. package/src/web/public/assets/refs-CZdjVlxE.js +0 -2
  70. package/src/web/public/assets/repos-BaE9B1it.js +0 -14
  71. package/src/web/public/assets/settings-BX78BaLf.js +0 -8
  72. package/src/web/public/assets/workspace-fCTiC3R4.js +0 -28
  73. /package/src/web/frontend/{page → modules}/refs/api.ts +0 -0
@@ -4,17 +4,23 @@
4
4
  // 不是实体文件。列表只展示「desc(缺省标题)+ 归属」:
5
5
  // · 列表数据来自 GET /api/docs/bindings(host=仓库 / group=组);
6
6
  // · 归属分色:repo(蓝)/ group(紫)/ group_repo(橙);
7
- // · 没有正文的行灰化并标「无正文」;
7
+ // · #114:不再有「无正文」这种兼容态——空文档要么补正文,要么被 docs gc 清掉;
8
8
  // · 点击行按 refId 打开(ref:<id>),不再用任何路径寻址;
9
9
  // · 「+」直接建一个空正文的 ref 并按当前面板位置默认归属,建完立即编辑。
10
10
  import { useCallback, useEffect, useMemo, useState } from 'react';
11
11
  import type { Model } from 'flexlayout-react';
12
12
  import {
13
- createRef,
13
+ createDoc,
14
+ detach,
15
+ descOf,
14
16
  docsBindings,
15
- unbindRef,
17
+ filterByScope,
18
+ labelOf,
19
+ normalizeScope,
20
+ scopeCounts,
16
21
  type BindingRow,
17
- } from './api.js';
22
+ type ScopeKey,
23
+ } from '../../refs/index.js';
18
24
  import { Icon } from '../../components/icons.jsx';
19
25
  import { useWikiNav } from '../doc/index.jsx';
20
26
  import type { DocOpenExtra } from '../doc/index.jsx';
@@ -22,21 +28,10 @@ import { closeRightPanelOf } from '../../workspace.js';
22
28
  import { useApp } from '../../app-context.jsx';
23
29
  import { useDialog } from '../../components/popup/index.jsx';
24
30
  import { useToast } from '../../components/toast/index.jsx';
25
- import { notifyDocsChanged, onDocsChanged } from '../../modules/md/doc-bus.js';
31
+ import { onDocsChanged } from '../../modules/md/doc-bus.js';
32
+ import { resolveFollowedHost, type FollowedHost, type FollowResolution } from '../../refs/index.js';
26
33
  import './style.css';
27
34
 
28
- function labelOf(b: BindingRow): string {
29
- // 标题 = 用户在 md 编辑器里起的标题(正文首行),没有正文才回落到 desc。
30
- // v8 没有路径名了,再落一层正文摘要——否则旧文档全叫「未命名文档」。
31
- return b.title || b.desc || b.summary || '未命名文档';
32
- }
33
-
34
- function descOf(b: BindingRow): string {
35
- // desc 是「快速定位」的一句话;与标题相同就不重复占一行。
36
- const desc = String(b.desc || '').trim();
37
- return desc && desc !== labelOf(b) ? desc : '';
38
- }
39
-
40
35
  type ScopeBadge = { cls: 'repo' | 'group'; text: string };
41
36
 
42
37
  function scopeBadgesOf(
@@ -53,10 +48,12 @@ function scopeBadgesOf(
53
48
  ];
54
49
  }
55
50
 
56
- export default function RefsPanel({ repoKey, boardKey, boardName, model }: {
51
+ export default function RefsPanel({ repoKey, boardKey, boardName, scope, model }: {
57
52
  repoKey?: string;
58
53
  boardKey?: string;
59
54
  boardName?: string;
55
+ /** 打开时指定的归属筛选(#117):repo / group / group_repo;缺省 all */
56
+ scope?: string;
60
57
  model?: Model | null;
61
58
  }) {
62
59
  const app = useApp();
@@ -64,22 +61,70 @@ export default function RefsPanel({ repoKey, boardKey, boardName, model }: {
64
61
  const { dialog, node: dialogNode } = useDialog();
65
62
  const { openByDocId } = useWikiNav(model);
66
63
 
64
+ // #105 跟随左侧打开的目录 / #109 只在「换目录」时更新。
65
+ // host → 换到路由指向的仓库 / 组,并记住(点开列表里的某一行后仍停在这里);
66
+ // none → 当前目录没登记仓库:显示未登记提示,不能拿旧宿主冒充;
67
+ // idle → 打开文档页 / 总览 / 仓库页等:**完全不动**,不刷新列表也不改标题。
68
+ // 解析规则见 follow.ts(三态是 #109 的修复点:此前 doc 视图回落 config,
69
+ // 于是点一行就把列表刷回最初打开时的项目)。
70
+ const followedRes = useMemo<FollowResolution>(() => resolveFollowedHost(
71
+ app.route,
72
+ app.rows,
73
+ (app.repoData?.repos || []) as any[],
74
+ (app.repoData?.boards || []) as any[]
75
+ ), [app.route, app.rows, app.repoData]);
76
+
77
+ // 记住最后一次「跟随到的」宿主:只被 dir/group/doc 的有效路由改写,idle 时保持不动。
78
+ const [latched, setLatched] = useState<FollowedHost | null>(() => {
79
+ if (repoKey) return { repoKey };
80
+ if (boardKey) return { groupKey: boardKey, name: boardName };
81
+ return null;
82
+ });
83
+ useEffect(() => {
84
+ if (followedRes.kind === 'host') {
85
+ setLatched({ repoKey: followedRes.repoKey, groupKey: followedRes.groupKey, name: followedRes.name });
86
+ } else if (followedRes.kind === 'none') {
87
+ setLatched(null);
88
+ }
89
+ // idle:保持上一次的宿主,避免「看一眼文档就换列表」
90
+ }, [followedRes]);
91
+
92
+ // #117:路由和文档宿主无关(仓库管理 / 总览等)时,**config 是显式意图**——
93
+ // 仓库管理页点「查看详情」必须切到那一行,不能被上一次的宿主钉住(此前就是这样点了没反应)。
94
+ useEffect(() => {
95
+ if (followedRes.kind !== 'idle') return;
96
+ if (repoKey) setLatched({ repoKey });
97
+ else if (boardKey) setLatched({ groupKey: boardKey, name: boardName });
98
+ }, [repoKey, boardKey, boardName, followedRes.kind]);
99
+
100
+ // 生效宿主 = 路由三态的即时结果(none 立刻清空),idle 才用记住的那一份;
101
+ // 走到这里 config 只作为**初始值**,不再作为回退——回退正是 #109 的 bug。
102
+ const effHost: FollowedHost | null =
103
+ followedRes.kind === 'host'
104
+ ? followedRes
105
+ : followedRes.kind === 'none'
106
+ ? null
107
+ : latched;
108
+ const effRepoKey = effHost?.repoKey;
109
+ const effBoardKey = effHost?.groupKey;
110
+
67
111
  // boardKey 可能传的是 id(组页面)——统一收成组 key(group/xxx)再去查归属
68
112
  const groupKey = useMemo(() => {
69
- const raw = String(boardKey || '');
113
+ const raw = String(effBoardKey || '');
70
114
  const b = (app.repoData?.boards || []).find(
71
115
  (x: any) => x.id === raw || x.key === raw || String(x.name || '').toLowerCase() === raw.toLowerCase()
72
116
  ) as any;
73
117
  return b?.key || raw;
74
- }, [app.repoData, boardKey]);
118
+ }, [app.repoData, effBoardKey]);
75
119
 
76
120
  const ownerName = useMemo(() => {
77
- if (repoKey) {
78
- const r = (app.repoData?.repos || []).find((x: any) => x.key === repoKey) as any;
79
- return r?.name || repoKey;
121
+ if (effRepoKey) {
122
+ const r = (app.repoData?.repos || []).find((x: any) => x.key === effRepoKey) as any;
123
+ return r?.name || effRepoKey;
80
124
  }
125
+ if (effHost?.groupKey && effHost.name) return effHost.name;
81
126
  return boardName || groupKey.replace(/^group\//, '') || '项目组';
82
- }, [app.repoData, repoKey, boardName, groupKey]);
127
+ }, [app.repoData, effRepoKey, boardName, groupKey, effHost]);
83
128
 
84
129
  const repoNameOf = useCallback((key: string) => {
85
130
  const r = (app.repoData?.repos || []).find((x: any) => x.key === key) as any;
@@ -99,6 +144,10 @@ export default function RefsPanel({ repoKey, boardKey, boardName, model }: {
99
144
  const [rows, setRows] = useState<BindingRow[] | null>(null);
100
145
  const [err, setErr] = useState('');
101
146
  const [tick, setTick] = useState(0);
147
+ // #117:归属(scope)是**筛选器**,不是装饰。仓库管理页点「查看详情」= 只看这一行的
148
+ // 精确归属(repo);组视图里可以切 全部 / 组 / 组内 / 仓库。
149
+ const [scopeFilter, setScopeFilter] = useState<ScopeKey>(() => normalizeScope(scope));
150
+ useEffect(() => { setScopeFilter(normalizeScope(scope)); }, [scope]);
102
151
 
103
152
  const reload = useCallback(() => setTick((n) => n + 1), []);
104
153
 
@@ -107,32 +156,33 @@ export default function RefsPanel({ repoKey, boardKey, boardName, model }: {
107
156
  setErr('');
108
157
  (async () => {
109
158
  try {
110
- const d = repoKey ? await docsBindings({ host: repoKey }) : await docsBindings({ group: groupKey });
159
+ const d = effRepoKey ? await docsBindings({ host: effRepoKey }) : await docsBindings({ group: groupKey });
111
160
  if (alive) setRows(d.bindings || []);
112
161
  } catch (e) {
113
162
  if (alive) { setRows([]); setErr(String((e as Error).message || e)); }
114
163
  }
115
164
  })();
116
165
  return () => { alive = false; };
117
- }, [repoKey, groupKey, tick]);
166
+ }, [effRepoKey, groupKey, tick]);
118
167
 
119
168
  // 文档页保存 / 新建 / 删除后自动刷新
120
169
  useEffect(() => onDocsChanged(reload), [reload]);
121
170
 
122
- const openExtra: DocOpenExtra = repoKey ? { repoKey } : { boardKey: groupKey, boardName };
171
+ const openExtra: DocOpenExtra = effRepoKey
172
+ ? { repoKey: effRepoKey }
173
+ : { boardKey: groupKey, boardName: ownerName };
123
174
  const openDoc = (refId: string) => openByDocId('ref:' + refId, null, openExtra);
124
175
 
125
176
  const guard = (fn: () => Promise<unknown>) => fn().catch((e) => toast(String((e as Error).message || e)));
126
177
 
127
178
  // +:直接建 ref(desc 空 + 当前宿主归属),建完立即打开编辑;不再弹窗、不拼任何文件名。
128
179
  const addDoc = () => guard(async () => {
129
- if (!repoKey && !groupKey) return;
130
- const owner = repoKey && groupKey ? 'group_repo' : repoKey ? 'repo' : 'group';
131
- const res = await createRef({ owner, repo: repoKey, group: owner === 'repo' ? undefined : groupKey, desc: '' });
180
+ if (!effRepoKey && !groupKey) return;
181
+ const owner = effRepoKey && groupKey ? 'group_repo' : effRepoKey ? 'repo' : 'group';
182
+ const refId = await createDoc({ owner, repo: effRepoKey, group: owner === 'repo' ? undefined : groupKey, desc: '' });
132
183
  toast('已新建文档');
133
- notifyDocsChanged();
134
184
  reload();
135
- openDoc(res.refId);
185
+ openDoc(refId);
136
186
  });
137
187
 
138
188
  // ×:解绑归属(文档不删)
@@ -140,14 +190,15 @@ export default function RefsPanel({ repoKey, boardKey, boardName, model }: {
140
190
  const label = labelOf(b);
141
191
  const ok = await dialog({ message: `从「${label}」摘除?只解除归属,文档不删。`, danger: true });
142
192
  if (!ok) return;
143
- await unbindRef({ ref: b.refId, type: b.type, repo: b.repoKey, group: b.groupKey || undefined });
193
+ await detach(b);
144
194
  toast('已摘除归属');
145
- notifyDocsChanged();
146
195
  reload();
147
196
  });
148
197
 
149
- const canAdd = !!(repoKey || groupKey);
150
- const count = rows ? rows.length : 0;
198
+ const canAdd = !!(effRepoKey || groupKey);
199
+ const counts = useMemo(() => scopeCounts(rows), [rows]);
200
+ const shownRows = useMemo(() => filterByScope(rows, scopeFilter), [rows, scopeFilter]);
201
+ const count = shownRows.length;
151
202
 
152
203
  return (
153
204
  <div className="nx-refs">
@@ -174,23 +225,52 @@ export default function RefsPanel({ repoKey, boardKey, boardName, model }: {
174
225
  </button>
175
226
  )}
176
227
  </div>
228
+ {/* #117:归属筛选器——仓库管理页「查看详情」直接落在 repo 这一档;
229
+ 组视图里能切 全部 / 组 / 组内 / 仓库,scope 不再是只能看的勋章。 */}
230
+ {rows && (counts.repo + counts.group + counts.group_repo > 1 || scopeFilter !== 'all') ? (
231
+ <div className="nx-refs-scopes" role="tablist" aria-label="按归属筛选文档">
232
+ {([
233
+ ['all', '全部', counts.all],
234
+ ['repo', '仓库', counts.repo],
235
+ ['group', '组', counts.group],
236
+ ['group_repo', '组内', counts.group_repo],
237
+ ] as Array<[string, string, number]>).map(([k, label, n]) =>
238
+ n > 0 || k === 'all' ? (
239
+ <button
240
+ key={k}
241
+ type="button"
242
+ role="tab"
243
+ aria-selected={scopeFilter === k}
244
+ className={'nx-refs-scope-filter' + (scopeFilter === k ? ' on' : '')}
245
+ onClick={() => setScopeFilter(k as ScopeKey)}
246
+ >
247
+ {label} <b>{n}</b>
248
+ </button>
249
+ ) : null
250
+ )}
251
+ </div>
252
+ ) : null}
177
253
  <div className="nx-refs-list">
178
254
  {err ? <div className="nx-refs-empty">{err}</div> : null}
179
255
  {!err && !rows ? <div className="nx-refs-empty">读取中…</div> : null}
180
- {!err && rows && !rows.length ? (
256
+ {!err && rows && !shownRows.length ? (
181
257
  <div className="nx-refs-empty">
182
258
  还没有文档<br />
183
- {canAdd ? '点右上角「+」新建,建完直接编辑' : '这个宿主还没有可挂的文档'}
259
+ {canAdd
260
+ ? '点右上角「+」新建,建完直接编辑'
261
+ : followedRes.kind === 'none'
262
+ ? '当前打开的目录还没登记为本机仓库:nx-kv repo add "<目录>" --key <key> 之后才有文档列表'
263
+ : '这个宿主还没有可挂的文档'}
184
264
  </div>
185
265
  ) : null}
186
- {(rows || []).map((b) => {
266
+ {shownRows.map((b) => {
187
267
  const title = labelOf(b);
188
268
  const desc = descOf(b);
189
269
  const badges = scopeBadgesOf(b, repoNameOf, groupNameOf);
190
270
  return (
191
271
  <div
192
272
  key={`${b.type}:${b.repoKey}:${b.groupKey || ''}:${b.refId}`}
193
- className={'nx-refs-row-wrap' + (b.hasBody ? '' : ' no-body') + (b.main ? ' main' : '')}
273
+ className={'nx-refs-row-wrap' + (b.main ? ' main' : '')}
194
274
  >
195
275
  <button
196
276
  type="button"
@@ -203,7 +283,6 @@ export default function RefsPanel({ repoKey, boardKey, boardName, model }: {
203
283
  {badges.map((x, i) => (
204
284
  <span key={`${x.cls}:${i}`} className={`nx-refs-scope ${x.cls}`}>{x.text}</span>
205
285
  ))}
206
- {!b.hasBody && <span className="nx-refs-chip none">无正文</span>}
207
286
  </span>
208
287
  <span className="nx-refs-row-text">{title}</span>
209
288
  </span>
@@ -13,6 +13,19 @@
13
13
  color:var(--mid,#838A93);display:inline-flex;align-items:center;
14
14
  }
15
15
  .nx-refs-h .iconbtn:hover{background:var(--soft,#F1F0EC);color:var(--ink,#16181C)}
16
+ /* #117:归属筛选器(全部 / 仓库 / 组 / 组内)——窄栏里一行药丸,可点切换 */
17
+ .nx-refs-scopes{
18
+ flex:none;display:flex;flex-wrap:wrap;gap:5px;padding:7px 10px;
19
+ border-bottom:1px solid var(--line,#E4E2DC);background:var(--paper,#fff);
20
+ }
21
+ .nx-refs-scope-filter{
22
+ border:1px solid transparent;background:var(--soft,#F1F0EC);color:var(--mid,#838A93);
23
+ font:inherit;font-size:10.5px;line-height:16px;padding:1px 8px;border-radius:999px;cursor:pointer;
24
+ }
25
+ .nx-refs-scope-filter b{margin-left:2px;font-weight:600;color:var(--ink-2,#5C646C)}
26
+ .nx-refs-scope-filter:hover{background:var(--soft-2,#E9E7E1)}
27
+ .nx-refs-scope-filter.on{background:#2F6F5E1A;border-color:#2F6F5E4D;color:#2F6F5E}
28
+ .nx-refs-scope-filter.on b{color:#2F6F5E}
16
29
  .nx-refs-list{flex:1;min-height:0;overflow:auto;padding:6px}
17
30
  .nx-refs-row{
18
31
  display:flex;flex-direction:column;align-items:stretch;gap:1px;width:100%;
@@ -66,8 +79,6 @@
66
79
  color:var(--faint,#A9AEB4);background:var(--soft,#F1F0EC);
67
80
  }
68
81
  /* 没有正文的条目:显式灰化,不隐藏(归属仍在,点开能看到原因) */
69
- .nx-refs-row-wrap.no-body{opacity:.58}
70
- .nx-refs-row-wrap.no-body:hover{opacity:.8}
71
82
  .nx-refs-row-tag{
72
83
  align-self:flex-start;
73
84
  font-size:10px;color:#9E4C00;background:#FBF3E4;border-radius:6px;padding:0 5px;
@@ -119,8 +119,8 @@ export default function BoardAdminModal({ boardList, unassigned, onClose, onFilt
119
119
  {!(b.repos || []).length ? <span className="muted">—</span> : null}
120
120
  </span>
121
121
  <span className="rp-board-admin-doc">
122
- <Button small title="打开组介绍文档"
123
- onClick={() => onOpenDoc(b)}>组介绍 ✎</Button>
122
+ <Button small title="在右侧栏列出这个组的文档"
123
+ onClick={() => onOpenDoc(b)}>文档</Button>
124
124
  {b.docCount && b.docCount > 1 ? <span className="muted">+{b.docCount - 1}</span> : null}
125
125
  </span>
126
126
  <span className="rp-board-admin-acts">
@@ -164,7 +164,7 @@ export default function BoardAdminModal({ boardList, unassigned, onClose, onFilt
164
164
  <button
165
165
  type="button"
166
166
  className={'rp-doc' + (boardForm.desc ? '' : ' ghost')}
167
- title="打开组介绍文档"
167
+ title="打开右侧栏文档列表(组介绍在里面维护)"
168
168
  onClick={() => {
169
169
  const b = boardList.find((x) => x.id === boardForm?.id);
170
170
  setBoardForm(null);
@@ -50,12 +50,12 @@ export default function BoardRefs({ filterBoard, refRepos, checkOf, onOpenDoc, o
50
50
  <span className="rp-context-desc" title={filterBoard.desc}>{filterBoard.desc}</span>
51
51
  ) : (
52
52
  <span className="muted rp-context-desc">
53
- 还没有领域描述 —— 点「组介绍文档」补一段:侧重什么、谁配合谁、关键路径与搜索关键词在哪。
53
+ 还没有领域描述 —— 点「文档列表」新建一篇组介绍:侧重什么、谁配合谁、关键路径与搜索关键词在哪。
54
54
  </span>
55
55
  )}
56
56
  <span className="acts">
57
- <Button small title="打开这个分组的组介绍文档"
58
- onClick={() => onOpenDoc(filterBoard)}>组介绍文档 ✎</Button>
57
+ <Button small title="在右侧栏列出这个组的文档(组 → 组内仓库 → 仓库自己)"
58
+ onClick={() => onOpenDoc(filterBoard)}>文档列表</Button>
59
59
  <a className="btn small ghost" href={'#/group/' + encodeURIComponent(filterBoard.id)}
60
60
  title="组页里看这个组的成员与任务">组页 ↗</a>
61
61
  <Button small onClick={() => onAddMember(filterBoard.id)}>添加成员</Button>
@@ -236,9 +236,7 @@ export default function DocSearchModal({ repos, boardList, onClose, onFilter, re
236
236
  {d.desc && d.title && d.desc !== d.title ? (
237
237
  <span className="rp-doc-row-desc">{d.desc}</span>
238
238
  ) : null}
239
- {!d.hasBody && (
240
- <span className="rp-bind-chip none" title={d.reason || '条目没有正文'}>无正文</span>
241
- )}
239
+ {/* #114:「无正文」徽标已去掉——空文档不再当作可展示状态 */}
242
240
  <span className="rp-doc-row-hosts">
243
241
  {hosts.length ? hosts.map((h) => (
244
242
  <button
@@ -16,7 +16,6 @@
16
16
  import RouteBreadcrumb from '../../components/layout/route-crumb.jsx';
17
17
  import { useCallback, useEffect, useMemo, useState } from 'react';
18
18
  import { bindRef, fetchRefCheck, listBoards, listRepos, openRepo, refSync, removeRepo, type RefCheckPayload } from './api.js';
19
- import { createRefDoc, docHostBindings, updateDocItem } from '../doc/api.js';
20
19
  import { useGuard, useToast } from '../../components/toast/index.jsx';
21
20
  import { useDialog } from '../../components/popup/index.jsx';
22
21
  import MemberPicker from '../../components/board/member-picker.jsx';
@@ -25,7 +24,6 @@ import GetLoopModal from '../../components/repos/get-loop-modal.jsx';
25
24
  import ToolActsBar from '../../components/tool-acts/bar.jsx';
26
25
  import { openPanel } from '../../workspace.js';
27
26
  import { useApp } from '../../app-context.jsx';
28
- import { useWikiNav } from '../doc/index.jsx';
29
27
  import RepoTable from './repo-table.jsx';
30
28
  import type {
31
29
  BoardRecord,
@@ -57,8 +55,7 @@ export default function ReposView() {
57
55
  const toast = useToast();
58
56
  const { dialog, node: dialogNode } = useDialog();
59
57
  const app = useApp();
60
- // 描述是文档 → 行内点标题要能开文档页签(useWikiNav 内部拿 app.model + 文档索引)
61
- const { openByDocId } = useWikiNav();
58
+ // 描述是文档 → 行内点标题要能开文档页签(#118:入口统一改成右侧栏文档列表)
62
59
 
63
60
  // ---- 数据面:仓库中心清单(扁平;每条带 boards)+ 看板 + 参考检查 ----
64
61
  const [repos, setRepos] = useState<RepoRecord[]>([]);
@@ -289,24 +286,22 @@ export default function ReposView() {
289
286
 
290
287
  // 组介绍入口:组上的主篇文档(ref:<refId>),没有就新建一个直接 ref。
291
288
  // 全程不推导路径 / 扩展名,归属直接写组。
292
- const openBoardDoc = (b: BoardRecord) => guard(async () => {
293
- if (b.docId) {
294
- openByDocId(b.docId);
289
+ // #118:组的「文档列表」入口与仓库行的「查看详情」保持同一套直觉——
290
+ // 在**右侧栏**开出这个组的文档列表(组 → 组内仓库 → 仓库自己),
291
+ // 不再把某一篇组介绍文档顶到中间正文区(那会把人从当前页面踢走)。
292
+ const openBoardDoc = (b: BoardRecord) => {
293
+ const m = app.model;
294
+ if (!m) {
295
+ toast('工作区不可用,无法打开文档列表');
295
296
  return;
296
297
  }
297
- if (b.key) {
298
- const set = await docHostBindings({ group: b.key }).catch(() => null);
299
- const main = ((set && set.bindings) || []).find((x) => x.type === 'group' && x.main);
300
- if (main) {
301
- openByDocId('ref:' + main.refId);
302
- return;
303
- }
304
- }
305
- const created = await createRefDoc({ owner: 'group', group: b.id, desc: `${b.name} · 组介绍` });
306
- await updateDocItem({ ref: 'ref:' + created.refId, body: `# ${b.name} · 组介绍\n\n` });
307
- openByDocId('ref:' + created.refId);
308
- await reload.all();
309
- });
298
+ openPanel(m, {
299
+ component: 'refs',
300
+ name: '文档列表',
301
+ config: { boardKey: b.key || b.id || '', boardName: b.name || '', scope: 'all' },
302
+ location: 'right',
303
+ });
304
+ };
310
305
 
311
306
  // 区块跳转:面板内容挂在 FlexLayout 的 tab 里(.flexlayout__tab_moveable 才是
312
307
  // 真正的滚动容器),scrollIntoView 在这条链上实测无效,必须手动算 scrollTop。
@@ -363,7 +358,8 @@ export default function ReposView() {
363
358
  },
364
359
  // 持续 get(waitgoal)配置弹窗(#145):保存后刷行数据(绿点/菜单态跟着变)
365
360
  getloop: (r) => setGlFor(r),
366
- // 查看详情:在**右侧栏**打开该仓库的文档列表(#186:不再弹 DocsModal)
361
+ // 查看详情:在**右侧栏**打开该仓库的文档列表(#186:不再弹 DocsModal);
362
+ // #117 起带 scope='repo',落到精确归属档
367
363
  docs: (r) => {
368
364
  const m = app.model;
369
365
  if (!m) {
@@ -373,7 +369,8 @@ export default function ReposView() {
373
369
  openPanel(m, {
374
370
  component: 'refs',
375
371
  name: '文档列表',
376
- config: { repoKey: r.key || '' },
372
+ // #117:仓库管理的「查看详情」= 只看这一行的精确归属(repo),不掺组域文档
373
+ config: { repoKey: r.key || '', scope: 'repo' },
377
374
  location: 'right',
378
375
  });
379
376
  },
@@ -287,7 +287,7 @@ function RepoRow({ r, showRef, showGroups, filterBoard, refRepoChipsByRepo, acts
287
287
  {r.getLoop && r.getLoop.enabled ? (
288
288
  <span
289
289
  className="rp-gl-dot"
290
- title={`持续 get 已开启(${Number(r.getLoop.waitMinutes) || 10} 分钟阻塞窗口)`}
290
+ title={`持续 get 已开启(${Number(r.getLoop.waitMinutes) > 0 ? `${Number(r.getLoop.waitMinutes)} 分钟阻塞窗口` : '不阻塞,没活立即返回'})`}
291
291
  aria-label="持续 get 已开启"
292
292
  />
293
293
  ) : null}
@@ -18,8 +18,18 @@ export function getLocaltaskSettings(): Promise<any> {
18
18
  return api('/api/localtasks');
19
19
  }
20
20
 
21
+ /** localtask 设置的 patch 形状(驼峰;与 PATCH /api/localtasks/setting 的契约一致)。
22
+ 收窄成具体字段而不是 Record<string,unknown>:#104 的 bug 就是调用方把
23
+ { method:'PATCH', body:{…} } 整个当 patch 传进来,宽类型查不出来。 */
24
+ export interface LocaltaskSettingPatch {
25
+ timeoutSec?: number;
26
+ ackPrompt?: string | string[];
27
+ appendMode?: 'xml' | 'plain';
28
+ blockTemplates?: unknown;
29
+ }
30
+
21
31
  /** 改 localtask 设置(PATCH /api/localtasks/setting;blockTemplates / appendMode 等)。 */
22
- export function saveLocaltaskSettings(patch: Record<string, unknown>): Promise<any> {
32
+ export function saveLocaltaskSettings(patch: LocaltaskSettingPatch): Promise<any> {
23
33
  return api('/api/localtasks/setting', { method: 'PATCH', body: patch });
24
34
  }
25
35
 
@@ -142,10 +142,10 @@ export default function PromptTemplatesSection() {
142
142
  if (busy) return;
143
143
  setBusy(true);
144
144
  try {
145
- const d = await saveLocaltaskSettings({
146
- method: 'PATCH',
147
- body: { blockTemplates: nextLists },
148
- });
145
+ // #104 真凶:这里曾写成 { method:'PATCH', body:{…} }——api 客户端本就把整对象当 body,
146
+ // 于是真正发出去的是 {method:'PATCH', body:{blockTemplates}},服务端 zod 把两层未知键
147
+ // 全部剥掉 → patch 为空 → 报「请至少指定一项」。直接传 patch 本身。
148
+ const d = await saveLocaltaskSettings({ blockTemplates: nextLists });
149
149
  applyLists(normalizeBlockTemplateLists(d?.blockTemplates), keep);
150
150
  toast(message);
151
151
  } catch (e) {
@@ -271,10 +271,8 @@ export default function PromptTemplatesSection() {
271
271
  if (busy || mode === state.appendMode) return;
272
272
  setBusy(true);
273
273
  try {
274
- const d = await saveLocaltaskSettings({
275
- method: 'PATCH',
276
- body: { appendMode: mode },
277
- });
274
+ // 同 persist:直接传 patch,不要套 { method, body }(#104)
275
+ const d = await saveLocaltaskSettings({ appendMode: mode === 'plain' ? 'plain' : 'xml' });
278
276
  // state 为 null 只可能发生在首轮加载前(那时没有按钮可点):保持 null 即可
279
277
  setState((cur) => (cur ? { ...cur, appendMode: d?.appendMode === 'plain' ? 'plain' : 'xml' } : cur));
280
278
  toast('已保存追加模式(全局生效)');
@@ -0,0 +1,65 @@
1
+ // refs 面板的 API 收口:列表读「ref + 归属」,新建/摘除直接操作 ref_bindings。
2
+ //
3
+ // 口径(v7 / 任务 #97):ref 是 DB 实体,没有路径 / 文件名 / 扩展名;
4
+ // 面板只消费 refId + desc + type(repo / group / group_repo)。
5
+ import { api } from '../api/client.js';
6
+
7
+ /** 一条归属行(GET /api/docs/bindings 的 bindings[])。 */
8
+ export interface BindingRow {
9
+ refId: string;
10
+ desc: string;
11
+ title: string;
12
+ /** 正文首行摘要(没有 `# 标题` 时的显示名兜底) */
13
+ summary: string;
14
+ hasBody: boolean;
15
+ type: 'repo' | 'group' | 'group_repo';
16
+ repoKey: string;
17
+ groupKey: string | null;
18
+ position: number;
19
+ main: boolean;
20
+ note: string;
21
+ tag: string;
22
+ }
23
+
24
+ /** 某个宿主的文档集(仓库 → host;组 → group)。 */
25
+ export function docsBindings(q: { host?: string; group?: string }): Promise<{ bindings: BindingRow[] }> {
26
+ const usp = new URLSearchParams();
27
+ if (q.host) usp.set('host', q.host);
28
+ if (q.group) usp.set('group', q.group);
29
+ return api('/api/docs/bindings?' + usp.toString());
30
+ }
31
+
32
+ /** 新建直接 ref(desc + 归属;正文为空、直接可编辑)。 */
33
+ export function createRef(body: {
34
+ desc?: string;
35
+ owner: 'repo' | 'group' | 'group_repo';
36
+ repo?: string;
37
+ group?: string;
38
+ }): Promise<{ refId: string; docId: string; desc: string }> {
39
+ return api('/api/docs/ref', { method: 'POST', body });
40
+ }
41
+
42
+ /** 解绑一条直接 ref 的归属(不删文档)。 */
43
+ export function unbindRef(body: {
44
+ ref: string;
45
+ type: 'repo' | 'group' | 'group_repo';
46
+ repo: string;
47
+ group?: string;
48
+ }): Promise<{ refId: string; removed: number; orphan: boolean }> {
49
+ return api('/api/docs/unbind', { method: 'POST', body });
50
+ }
51
+
52
+ /** 改 ref 的短描述(只动 desc,不碰正文)。 */
53
+ export function setDocDesc(ref: string, desc: string): Promise<any> {
54
+ return api('/api/docs/item', { method: 'PATCH', body: { ref, desc } });
55
+ }
56
+
57
+ /** 写文档正文 / 描述(PATCH /api/docs/item)——列表的「改 desc」与编辑页保存共用。 */
58
+ export function updateDocItem(body: { ref?: string; body?: string; desc?: string }): Promise<any> {
59
+ return api('/api/docs/item', { method: 'PATCH', body });
60
+ }
61
+
62
+ /** 删除文档(DELETE /api/docs/item;ref 是 docId)。 */
63
+ export function removeDocItem(body: { ref?: string }): Promise<any> {
64
+ return api('/api/docs/item', { method: 'DELETE', body });
65
+ }