nx-kv 0.42.3 → 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.
- package/CHANGELOG.md +65 -0
- package/README.md +1 -1
- package/assets/kv-get/SKILL.md +4 -4
- package/assets/kv-get/references/localget.md +2 -2
- package/package.json +1 -1
- package/src/core/attachmentdb/docs.js +12 -0
- package/src/core/attachmentdb/relations.js +17 -0
- package/src/core/attachmentdb.js +1 -0
- package/src/modules/docs/attach.js +46 -1
- package/src/modules/docs/brief.js +35 -4
- package/src/modules/docs/index.js +15 -1
- package/src/modules/docs/service.js +10 -6
- package/src/modules/localtask/action-attach.js +25 -0
- package/src/modules/localtask/action-flags.js +0 -1
- package/src/modules/localtask/action-lifecycle.js +6 -4
- package/src/modules/localtask/action-waiting.js +3 -3
- package/src/modules/localtask/repo/rows.js +3 -0
- package/src/modules/localtask/repo/tasks.js +18 -2
- package/src/modules/localtask/task-lifecycle.js +3 -3
- package/src/modules/localtask/task-view.js +14 -6
- package/src/modules/tasktool/attach-resource.js +3 -0
- package/src/modules/tasktool/attach.js +62 -0
- package/src/modules/tasktool/get.js +1 -2
- package/src/modules/tasktool/plugins/waitgoal-config.js +1 -1
- package/src/modules/tasktool/wait.js +2 -2
- package/src/shared/doc-title.js +71 -0
- package/src/web/frontend/components/md/attach-area.jsx +56 -6
- package/src/web/frontend/components/md/attach-common.js +16 -3
- package/src/web/frontend/components/md/attach-modal.jsx +42 -2
- package/src/web/frontend/components/md/md-panes-helpers.js +4 -1
- package/src/web/frontend/components/repos/get-loop-modal.jsx +1 -1
- package/src/web/frontend/components/task-panel/layout.jsx +64 -0
- package/src/web/frontend/components/task-panel/page-shell.jsx +38 -0
- package/src/web/frontend/components/tool-acts/modules.js +2 -0
- package/src/web/frontend/modules/md/md-render.js +34 -11
- package/src/web/frontend/modules/md/progress-chain.js +29 -0
- package/src/web/frontend/modules/md/progress-search.js +14 -0
- package/src/web/frontend/modules/md/styles/chrome.css +9 -0
- package/src/web/frontend/modules/md/styles/panels.css +2 -0
- package/src/web/frontend/modules/md/styles/shell.css +2 -10
- package/src/web/frontend/page/dir/index.jsx +8 -5
- package/src/web/frontend/page/dir/landing.jsx +92 -99
- package/src/web/frontend/page/dir/task.jsx +19 -3
- package/src/web/frontend/page/doc/index.jsx +24 -12
- package/src/web/frontend/page/group/index.jsx +145 -68
- package/src/web/frontend/page/progress/index.jsx +67 -19
- package/src/web/frontend/styles-v2/views.css +5 -1
- package/src/web/public/assets/Introduction-DAXj7E6q.js +6 -0
- package/src/web/public/assets/{bar-C0LZwZoX.js → bar-KTPTE33i.js} +1 -1
- package/src/web/public/assets/{cloud-ol3se4zn.js → cloud-CLco1knr.js} +1 -1
- package/src/web/public/assets/{composer-panel-O04Eac_2.js → composer-panel-D3N_wO9r.js} +1 -1
- package/src/web/public/assets/deleted-panel-B6sZddUs.js +1 -0
- package/src/web/public/assets/dir-DEbQhSfL.js +5 -0
- package/src/web/public/assets/group-CxqVtyyh.js +2 -0
- package/src/web/public/assets/index-DGvBoOdp.css +1 -0
- package/src/web/public/assets/{index-BAS6Qpjs.js → index-DNB8tgNi.js} +2 -2
- package/src/web/public/assets/md-history-C9vOgGLz.js +39 -0
- package/src/web/public/assets/{overview-CIeUo4At.js → overview-9nXafXeK.js} +1 -1
- package/src/web/public/assets/progress-Bx0reVYl.js +3 -0
- package/src/web/public/assets/{refs-BpET-Lxl.js → refs-B5YIZ9SG.js} +1 -1
- package/src/web/public/assets/{repos-K67Ie07A.js → repos-Dbr-i-gg.js} +2 -2
- package/src/web/public/assets/{route-crumb-B7T_Hupr.js → route-crumb-BfRi1GKw.js} +1 -1
- package/src/web/public/assets/{settings-Bek4c_r_.js → settings-B4FvZtu0.js} +1 -1
- package/src/web/public/assets/{status-tag-B7CrVhQP.js → status-tag-p3fo3Hbr.js} +1 -1
- package/src/web/public/assets/{task-DHca1uMu.js → task-CUb7dohw.js} +3 -3
- package/src/web/public/assets/{templates-6moKn9GB.js → templates-BGhPIp0x.js} +1 -1
- package/src/web/public/assets/tool-bar-DpwpQ47h.js +1 -0
- package/src/web/public/index.html +2 -2
- package/src/web/public/assets/Introduction--ILYt-bQ.js +0 -1
- package/src/web/public/assets/dir-B_HW1kpE.js +0 -5
- package/src/web/public/assets/group-BCOXDlvk.js +0 -1
- package/src/web/public/assets/index-CZzMw1zg.css +0 -1
- package/src/web/public/assets/md-history-DCgN2zcc.js +0 -39
- package/src/web/public/assets/progress-DHDlz9O9.js +0 -3
- package/src/web/public/assets/task-row-W12GJMCO.js +0 -1
- package/src/web/public/assets/tool-bar-CDUi6q4z.js +0 -1
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
listTaskAttachmentsBySeq,
|
|
41
41
|
resolveRefId,
|
|
42
42
|
unlinkAttachment,
|
|
43
|
+
updateAttachmentNote,
|
|
43
44
|
upsertFileAttachment,
|
|
44
45
|
} from '../../core/attachmentdb.js';
|
|
45
46
|
import * as service from '../localtask/service.js';
|
|
@@ -73,6 +74,35 @@ function annotateFileRows(rows, lookups, store, mirror) {
|
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
/**
|
|
78
|
+
* 给 ref 型附件补**文档标题**(#168):标题 = 文档正文首行的 `# 标题`。
|
|
79
|
+
* 服务端补(读盘),前端直接显示——用户「填写了标题」后,附件区与 md 编辑器
|
|
80
|
+
* 里的引用名就该是那个标题,而不是文件名。读不到就留空(前端回落附件名)。
|
|
81
|
+
*/
|
|
82
|
+
async function annotateRefTitles(attachments) {
|
|
83
|
+
const refs = (attachments || [])
|
|
84
|
+
.filter((a) => a.kind === 'ref')
|
|
85
|
+
.map((a) => ({ id: a.refId || a.targetKey || '', locator: a.relPath || a.targetKey || '' }));
|
|
86
|
+
if (!refs.length) return attachments;
|
|
87
|
+
let titles = new Map();
|
|
88
|
+
try {
|
|
89
|
+
const { refTitlesOf } = await import('../docs/brief.js');
|
|
90
|
+
titles = await refTitlesOf(refs);
|
|
91
|
+
} catch {
|
|
92
|
+
titles = new Map();
|
|
93
|
+
}
|
|
94
|
+
for (const a of attachments) {
|
|
95
|
+
if (a.kind !== 'ref') continue;
|
|
96
|
+
const t = titles.get(String(a.refId || a.targetKey || ''));
|
|
97
|
+
if (!t) continue;
|
|
98
|
+
a.docTitle = t;
|
|
99
|
+
// 视图标题一并覆盖:附件区、md 编辑器引用名、指令段都读它——一处改,处处一致
|
|
100
|
+
a.title = t;
|
|
101
|
+
a.name = t;
|
|
102
|
+
}
|
|
103
|
+
return attachments;
|
|
104
|
+
}
|
|
105
|
+
|
|
76
106
|
/**
|
|
77
107
|
* 领取/查看时刻的附件标注:本机仓优先 → 云端镜像兜底 → 标注本地路径。
|
|
78
108
|
*
|
|
@@ -116,6 +146,7 @@ export async function annotateTaskDelivery(task, { sync: allowSync = true, topic
|
|
|
116
146
|
|
|
117
147
|
const mirror = await cloudMirrorIndex(gid, cfg.attachmentsDir);
|
|
118
148
|
const attachments = annotateFileRows(rows, targetLookupsOf(getDb(), rows), store, mirror);
|
|
149
|
+
await annotateRefTitles(attachments);
|
|
119
150
|
if (inlineDocs) await inlineDocContent(attachments);
|
|
120
151
|
return { task: { ...task, attachments }, sync };
|
|
121
152
|
}
|
|
@@ -330,6 +361,7 @@ export async function listTaskAttachments({ id, cwd, key } = {}) {
|
|
|
330
361
|
const mirror = await cloudMirrorIndex(gid, cfg.attachmentsDir);
|
|
331
362
|
const rows = listTaskAttachmentsBySeq(getDb(), { topicKey: cur.key || key, seq: cur.id });
|
|
332
363
|
const attachments = annotateFileRows(rows, targetLookupsOf(getDb(), rows), store, mirror);
|
|
364
|
+
await annotateRefTitles(attachments);
|
|
333
365
|
|
|
334
366
|
return {
|
|
335
367
|
task: { id: cur.id, key: cur.key || key },
|
|
@@ -343,6 +375,36 @@ export async function listTaskAttachments({ id, cwd, key } = {}) {
|
|
|
343
375
|
};
|
|
344
376
|
}
|
|
345
377
|
|
|
378
|
+
/**
|
|
379
|
+
* 改一条附件绑定上的**说明**(desc,#168):面板里给已挂载的文档绑定补/改说明。
|
|
380
|
+
* 只动边上的 note(角色/位置不动)——「这条边是什么」与「它讲什么」分开。
|
|
381
|
+
*/
|
|
382
|
+
export async function noteTaskAttachment({ id, cwd, key, attachment, note = '' } = {}) {
|
|
383
|
+
const cur = await service.getTask({ id, cwd, key });
|
|
384
|
+
const topicKey = cur.key || key || '';
|
|
385
|
+
const attId = String(attachment || '').trim();
|
|
386
|
+
if (!attId) throw badInput('需要 --attachment <资源 id>(见 localtask attachments 输出)');
|
|
387
|
+
const db = getDb();
|
|
388
|
+
let changed = 0;
|
|
389
|
+
tx(
|
|
390
|
+
(conn) => {
|
|
391
|
+
const gid = taskGlobalIdOf(conn, { topicKey, seq: cur.id });
|
|
392
|
+
if (!gid) throw badInput(`任务 #${cur.id} 已不存在`);
|
|
393
|
+
changed = updateAttachmentNote(conn, { host: 'task', hostId: gid, attachmentId: attId, note });
|
|
394
|
+
},
|
|
395
|
+
{ db, mode: 'IMMEDIATE' }
|
|
396
|
+
);
|
|
397
|
+
if (!changed) throw badInput(`这条任务上没有附件 ${attId}`);
|
|
398
|
+
return {
|
|
399
|
+
status: 'ok',
|
|
400
|
+
key: cur.key || key,
|
|
401
|
+
name: topicNameOf(cur),
|
|
402
|
+
task: { id: cur.id },
|
|
403
|
+
attachment: attId,
|
|
404
|
+
note: String(note || ''),
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
346
408
|
/**
|
|
347
409
|
* 解除任务与一条资源的关系(CLI `localtask detach`)。
|
|
348
410
|
*
|
|
@@ -15,14 +15,13 @@
|
|
|
15
15
|
import { waitForTask } from './wait.js';
|
|
16
16
|
import { getLoopForCwd, DEFAULT_GET_LOOP_TEMPLATE } from './getloop.js';
|
|
17
17
|
|
|
18
|
-
export async function getTask({ cwd,
|
|
18
|
+
export async function getTask({ cwd, timeoutSec, open = true, params } = {}) {
|
|
19
19
|
const loop = await getLoopForCwd(cwd);
|
|
20
20
|
// 项目开启「持续 get」时,循环指令作为 getloop 区块随其余系统段一起由
|
|
21
21
|
// buildTaskDelivery 统一编排(不再在 get 层后置拼接,避免同一份 instruction
|
|
22
22
|
// 有两个拼装入口)。
|
|
23
23
|
const r = await waitForTask({
|
|
24
24
|
cwd,
|
|
25
|
-
summary,
|
|
26
25
|
// 未开启持续 get → instant(waitForTask 内部忽略 timeout 直接快路径);
|
|
27
26
|
// 开启 → 阻塞窗口 = 项目配置分钟数(显式 --timeout 仍最高优先)。
|
|
28
27
|
timeoutSec: timeoutSec ?? (loop.enabled ? loop.waitMinutes * 60 : undefined),
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import { badInput } from '../../../core/errors.js';
|
|
16
16
|
|
|
17
17
|
export const DEFAULT_GET_LOOP_TEMPLATE =
|
|
18
|
-
'{{#if task}}不要直接结束本轮:完成上面的任务({{task.id}})之后,继续调用 nx-kv localtask get
|
|
18
|
+
'{{#if task}}不要直接结束本轮:完成上面的任务({{task.id}})之后,继续调用 nx-kv localtask get 领取下一条任务。队列里有活会立即返回;没活时每次最多阻塞 {{getloop.waitMinutes}} 分钟,直到 get 返回 timeout 为止。{{/if}}';
|
|
19
19
|
|
|
20
20
|
export const GET_LOOP_DEFAULT_MINUTES = 10; // 阻塞窗口默认 10 分钟(上限仍受 wait 的 600s 夹制)
|
|
21
21
|
|
|
@@ -300,7 +300,7 @@ function blocksCoverBody(templates) {
|
|
|
300
300
|
* 返回带 source: 'local' | 'global' 标明任务来自哪个队列。
|
|
301
301
|
* @param {string} [cwd] 工作目录(主题按目录名识别);缺省 → 进程当前 cwd。
|
|
302
302
|
* 注意:显式传 cwd **不会**关闭全局兜底——本地空了一定去全局领。
|
|
303
|
-
* @param {string} summary
|
|
303
|
+
* @param {string} [summary] 当前现状(#171 起不再必填:面板上没有对应输入界面)
|
|
304
304
|
* @param {number} [timeoutSec] 阻塞上限(秒);缺省 → 页面配置(推荐 180,最大 600)
|
|
305
305
|
* @param {number} [timeoutMs] 兼容旧参数(毫秒)
|
|
306
306
|
* @param {boolean} [open] 是否自动打开浏览器弹窗(测试可关)
|
|
@@ -319,7 +319,7 @@ export async function waitForTask({
|
|
|
319
319
|
getLoopWaitMinutes = 0, // 项目级阻塞窗口(分钟):进 getloop 模板 ctx,让 agent 知道每轮会等多久
|
|
320
320
|
} = {}) {
|
|
321
321
|
const { key, cwd, name } = normalizeCwd(rawCwd);
|
|
322
|
-
const summary = normalizeSummary(rawSummary); //
|
|
322
|
+
const summary = normalizeSummary(rawSummary, { optional: true }); // #171:现状不再必填
|
|
323
323
|
// 领取方身份:记进 task.claimedBy(事后能看出"这条被谁领的")
|
|
324
324
|
const by = { key, cwd, name };
|
|
325
325
|
// 仓库上下文:这个目录属于哪个已登记仓库、周围关联哪些看板。
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// 文档标题口径(#168):**标题 = 正文第一行的 `# 标题`**,其余一律不算。
|
|
2
|
+
//
|
|
3
|
+
// 为什么不用「首个 # 行」或「首个非空行」:
|
|
4
|
+
// · 首个 # 行 —— 正文中间插一行 # 就会改标题(标题不该被正文结构牵动);
|
|
5
|
+
// · 首个非空行 —— 正文第一行是普通文字时,标题被**正文首行顶替**(#168 bug 2:
|
|
6
|
+
// 「正文第一行会影响标题」)。标题是文档自己的字段,只有首行 # 才作数。
|
|
7
|
+
//
|
|
8
|
+
// 纯函数、无依赖:前后端共用(前端文档页取标题 / 后端读盘给 ref 标注标题)。
|
|
9
|
+
// 任务标题另有口径(titleFromMd:首个非空行也可以),两者刻意不合并。
|
|
10
|
+
|
|
11
|
+
/** 去 frontmatter 后的正文首行(trim 后)。没有正文行 → ''。 */
|
|
12
|
+
function firstLineOf(body) {
|
|
13
|
+
const text = String(body ?? '');
|
|
14
|
+
// 去掉 frontmatter(--- … ---),标题只看正文部分
|
|
15
|
+
const s = text.replace(/^/, '').replace(/\r\n/g, '\n');
|
|
16
|
+
const m = s.match(/^---\n([\s\S]*?)\n---\n?/);
|
|
17
|
+
const rest = m ? s.slice(m[0].length) : s;
|
|
18
|
+
for (const line of rest.split('\n')) {
|
|
19
|
+
const t = line.trim();
|
|
20
|
+
if (t) return t;
|
|
21
|
+
}
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 文档标题:正文**首行**是 `# 标题` 时取其文字,否则空串(调用方决定回落)。
|
|
27
|
+
* @param {string} body 文档正文
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
export function docTitleFromMd(body) {
|
|
31
|
+
const first = firstLineOf(body);
|
|
32
|
+
const m = first.match(/^#\s+(.+)$/);
|
|
33
|
+
return m ? m[1].trim() : '';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 文档正文是否以 `# 标题` 开头(编辑标题时用来判断「改首行」还是「补首行」)。
|
|
38
|
+
* @param {string} body
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
export function hasDocTitleLine(body) {
|
|
42
|
+
return !!docTitleFromMd(body);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 改写文档正文的标题行:首行是 # 标题就替换它,否则在文首补一行。
|
|
47
|
+
* 返回新正文(不改动原字符串)。
|
|
48
|
+
* @param {string} body
|
|
49
|
+
* @param {string} title 新标题(空 → 用「未命名文档」)
|
|
50
|
+
* @returns {string}
|
|
51
|
+
*/
|
|
52
|
+
export function setDocTitleInMd(body, title) {
|
|
53
|
+
const text = String(body ?? '');
|
|
54
|
+
const t = String(title || '').trim() || '未命名文档';
|
|
55
|
+
const s = text.replace(/\r\n/g, '\n');
|
|
56
|
+
const m = s.match(/^---\n([\s\S]*?)\n---\n?/);
|
|
57
|
+
const front = m ? s.slice(0, m[0].length) : '';
|
|
58
|
+
const rest = m ? s.slice(m[0].length) : s;
|
|
59
|
+
const lines = rest.split('\n');
|
|
60
|
+
// 找到第一个非空行
|
|
61
|
+
const idx = lines.findIndex((l) => l.trim());
|
|
62
|
+
if (idx < 0) {
|
|
63
|
+
return `${front}# ${t}\n`;
|
|
64
|
+
}
|
|
65
|
+
if (/^#\s+/.test(lines[idx].trim())) {
|
|
66
|
+
lines[idx] = `# ${t}`;
|
|
67
|
+
} else {
|
|
68
|
+
lines.splice(idx, 0, `# ${t}`);
|
|
69
|
+
}
|
|
70
|
+
return `${front}${lines.join('\n')}`;
|
|
71
|
+
}
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
// 图片缩略图点开大图;pdf/其它给打开/下载;task 点击跳任务;ref 点击开文档;
|
|
8
8
|
// 移除时二选一:只解除关联 / 连资源与字节一起删。
|
|
9
9
|
import { useCallback, useEffect, useImperativeHandle, useMemo, useState } from 'react';
|
|
10
|
-
import { Modal } from '../popup/index.jsx';
|
|
10
|
+
import { Modal, useDialog } from '../popup/index.jsx';
|
|
11
11
|
import { useToast } from '../toast/index.jsx';
|
|
12
|
+
import { api } from '../../api/client.js';
|
|
12
13
|
import { uploadOne, droppedFiles } from '../cloud/upload.js';
|
|
13
14
|
import AttachModal from './attach-modal.jsx';
|
|
14
15
|
import {
|
|
@@ -42,6 +43,7 @@ export default function AttachArea({
|
|
|
42
43
|
onOpenDoc,
|
|
43
44
|
}) {
|
|
44
45
|
const toast = useToast();
|
|
46
|
+
const { dialog, node: dialogNode } = useDialog();
|
|
45
47
|
const [list, setList] = useState([]);
|
|
46
48
|
const [loading, setLoading] = useState(false);
|
|
47
49
|
const [error, setError] = useState('');
|
|
@@ -50,6 +52,8 @@ export default function AttachArea({
|
|
|
50
52
|
const [dropping, setDropping] = useState(false);
|
|
51
53
|
const [sortBy, setSortBy] = useState('position');
|
|
52
54
|
const [removeOf, setRemoveOf] = useState(null);
|
|
55
|
+
// #168:ref 条目的两个动作——改说明(✎)/ 换指向(⇄,替换成另一篇文档)
|
|
56
|
+
const [replaceOf, setReplaceOf] = useState(null);
|
|
53
57
|
const [removing, setRemoving] = useState(false);
|
|
54
58
|
const [preview, setPreview] = useState(null);
|
|
55
59
|
|
|
@@ -120,6 +124,41 @@ export default function AttachArea({
|
|
|
120
124
|
}
|
|
121
125
|
};
|
|
122
126
|
|
|
127
|
+
// #168:改一条绑定的说明(desc)——面板直改,不必重挂
|
|
128
|
+
const editNote = async (item) => {
|
|
129
|
+
if (!item) return;
|
|
130
|
+
try {
|
|
131
|
+
const res = await dialog({
|
|
132
|
+
title: `说明 · ${item.name}`,
|
|
133
|
+
input: true,
|
|
134
|
+
placeholder: '这一行里大概是什么(交付清单会透出给 agent)',
|
|
135
|
+
value: item.note || '',
|
|
136
|
+
okText: '保存说明',
|
|
137
|
+
});
|
|
138
|
+
if (res === null) return;
|
|
139
|
+
const note = typeof res === 'string' ? res : (res && (res.value || res.note)) || '';
|
|
140
|
+
const path = host === 'doc'
|
|
141
|
+
? `/api/docs/attach-note?ref=${encodeURIComponent(String(refId || ''))}`
|
|
142
|
+
: '/api/localtasks/attach-note';
|
|
143
|
+
const body = host === 'doc'
|
|
144
|
+
? { attachment: item.id, note }
|
|
145
|
+
: { id: Number(hostId), ...(hostKey ? { key: hostKey } : hostCwd ? { cwd: hostCwd } : {}), attachment: item.id, note };
|
|
146
|
+
await api(path, { method: 'PATCH', body });
|
|
147
|
+
toast(note ? `已保存说明:${note}` : '已清空说明');
|
|
148
|
+
await load();
|
|
149
|
+
onChanged?.();
|
|
150
|
+
} catch (e) {
|
|
151
|
+
toast(`改说明失败:${(e && e.message) || e}`);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// #168:换指向——重新打开「添加附件」弹窗(只选文档),提交后把旧绑定换掉
|
|
156
|
+
const startReplace = (item) => {
|
|
157
|
+
if (!item) return;
|
|
158
|
+
setReplaceOf(item);
|
|
159
|
+
setModalOpen(true);
|
|
160
|
+
};
|
|
161
|
+
|
|
123
162
|
const doRemove = async (purge) => {
|
|
124
163
|
const item = removeOf;
|
|
125
164
|
if (!item) return;
|
|
@@ -159,6 +198,8 @@ export default function AttachArea({
|
|
|
159
198
|
dropFiles(null, e);
|
|
160
199
|
}}
|
|
161
200
|
>
|
|
201
|
+
{/* 「改说明」用的输入弹窗挂在这里(#168) */}
|
|
202
|
+
{dialogNode}
|
|
162
203
|
<div className={'att-area-head' + (dragOver && !disabled ? ' is-over' : '')}>
|
|
163
204
|
<span className="att-area-title">
|
|
164
205
|
附件
|
|
@@ -194,14 +235,14 @@ export default function AttachArea({
|
|
|
194
235
|
{inline.length ? (
|
|
195
236
|
<div className="att-section">
|
|
196
237
|
<div className="att-section-head">{AREA_LABEL.inline}<span className="att-section-hint">正文里的引用,删正文行会跟着消失</span></div>
|
|
197
|
-
{inline.map((a) => renderItem(a, { onRemove: setRemoveOf, onPreview: setPreview, onOpenTask, onOpenDoc, key: a.id }))}
|
|
238
|
+
{inline.map((a) => renderItem(a, { onRemove: setRemoveOf, onPreview: setPreview, onOpenTask, onOpenDoc, onEditNote: editNote, onReplace: startReplace, key: a.id }))}
|
|
198
239
|
</div>
|
|
199
240
|
) : null}
|
|
200
241
|
|
|
201
242
|
{area.length ? (
|
|
202
243
|
<div className="att-section">
|
|
203
244
|
<div className="att-section-head">{AREA_LABEL.area}<span className="att-section-hint">不依赖正文,删正文行也不会丢</span></div>
|
|
204
|
-
{area.map((a) => renderItem(a, { onRemove: setRemoveOf, onPreview: setPreview, onOpenTask, onOpenDoc, key: a.id }))}
|
|
245
|
+
{area.map((a) => renderItem(a, { onRemove: setRemoveOf, onPreview: setPreview, onOpenTask, onOpenDoc, onEditNote: editNote, onReplace: startReplace, key: a.id }))}
|
|
205
246
|
</div>
|
|
206
247
|
) : null}
|
|
207
248
|
|
|
@@ -215,8 +256,10 @@ export default function AttachArea({
|
|
|
215
256
|
allow={allow}
|
|
216
257
|
taskOptions={taskOptions}
|
|
217
258
|
docOptions={docOptions}
|
|
218
|
-
|
|
219
|
-
|
|
259
|
+
replaceAttachment={replaceOf ? replaceOf.id : null}
|
|
260
|
+
replaceNote={replaceOf ? replaceOf.note || '' : ''}
|
|
261
|
+
onClose={() => { setModalOpen(false); setReplaceOf(null); }}
|
|
262
|
+
onDone={async () => { setReplaceOf(null); await load(); onChanged?.(); }}
|
|
220
263
|
/>
|
|
221
264
|
|
|
222
265
|
{removeOf ? (
|
|
@@ -261,7 +304,7 @@ export default function AttachArea({
|
|
|
261
304
|
);
|
|
262
305
|
}
|
|
263
306
|
|
|
264
|
-
function renderItem(a, { onRemove, onPreview, onOpenTask, onOpenDoc }) {
|
|
307
|
+
function renderItem(a, { onRemove, onPreview, onOpenTask, onOpenDoc, onEditNote, onReplace }) {
|
|
265
308
|
const src = a.kind === 'image' ? contentUrl(a.id) : '';
|
|
266
309
|
return (
|
|
267
310
|
<div className={`att-item att-kind-${a.kind}`} key={a.id}>
|
|
@@ -310,6 +353,13 @@ function renderItem(a, { onRemove, onPreview, onOpenTask, onOpenDoc }) {
|
|
|
310
353
|
</span>
|
|
311
354
|
) : null}
|
|
312
355
|
|
|
356
|
+
{a.kind === 'ref' ? (
|
|
357
|
+
<span className="att-item-acts">
|
|
358
|
+
<button type="button" className="att-act" title="改这条绑定的一行说明(交付清单会透出)" onClick={() => onEditNote?.(a)}>✎ 说明</button>
|
|
359
|
+
<button type="button" className="att-act" title="换成另一篇文档(替换这条绑定)" onClick={() => onReplace?.(a)}>⇄ 更换</button>
|
|
360
|
+
</span>
|
|
361
|
+
) : null}
|
|
362
|
+
|
|
313
363
|
<button type="button" className="att-x" aria-label={`移除 ${a.name}`} onClick={() => onRemove(a)}>×</button>
|
|
314
364
|
</div>
|
|
315
365
|
);
|
|
@@ -85,11 +85,24 @@ export function endpointOf(host, { hostId, hostKey, hostCwd, refId }) {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
/** 待确认条目 → attach 请求体(文件先上传拿到 fileId)。
|
|
89
|
-
|
|
88
|
+
/** 待确认条目 → attach 请求体(文件先上传拿到 fileId)。
|
|
89
|
+
*
|
|
90
|
+
* 文档来源的**字段名按宿主分**(#165 二轮):任务侧 action 收 `ref`
|
|
91
|
+
* (localtask.attach),文档侧收 `doc`(docs.attach)——之前两侧都发 `doc`,
|
|
92
|
+
* 面板「给任务挂文档」必然失败(未知键透传,attachToTask 收不到 ref)。
|
|
93
|
+
* `note`(绑定说明 / desc)与 `inline`(文档进原文,#162)随条目透传。
|
|
94
|
+
*/
|
|
95
|
+
export function attachBodyOf(item, host = 'task') {
|
|
90
96
|
if (item.source === 'file') return { fileId: item.fileId, name: item.name };
|
|
91
97
|
if (item.source === 'url') return { url: item.url, name: item.name };
|
|
92
98
|
if (item.source === 'task') return { task: String(item.seq), name: item.name };
|
|
93
|
-
if (item.source === 'ref')
|
|
99
|
+
if (item.source === 'ref') {
|
|
100
|
+
const body = host === 'doc'
|
|
101
|
+
? { doc: item.docRef, name: item.name }
|
|
102
|
+
: { ref: item.docRef, name: item.name };
|
|
103
|
+
if (item.note) body.note = item.note;
|
|
104
|
+
if (host !== 'doc' && item.inline) body.inline = true;
|
|
105
|
+
return body;
|
|
106
|
+
}
|
|
94
107
|
return {};
|
|
95
108
|
}
|
|
@@ -41,6 +41,10 @@ export default function AttachModal({
|
|
|
41
41
|
allow = { file: true, url: true, task: false, ref: false },
|
|
42
42
|
taskOptions = [],
|
|
43
43
|
docOptions = null,
|
|
44
|
+
// #168:替换模式——提交成功后把这条旧绑定换掉(换指向)
|
|
45
|
+
replaceAttachment = null,
|
|
46
|
+
// #168:换指向时沿用旧绑定的说明(用户写的 desc 不该因为换篇文档就丢)
|
|
47
|
+
replaceNote = '',
|
|
44
48
|
onClose,
|
|
45
49
|
onDone,
|
|
46
50
|
}) {
|
|
@@ -152,11 +156,19 @@ export default function AttachModal({
|
|
|
152
156
|
rel: d.rel || '',
|
|
153
157
|
size: 0,
|
|
154
158
|
status: 'pending',
|
|
159
|
+
// 文档绑定的两个可选属性(#162):说明(desc,随边落库、交付清单透出)
|
|
160
|
+
// 与「进原文」(任务侧:交付带全文而不是只给路径)
|
|
161
|
+
note: '',
|
|
162
|
+
inline: false,
|
|
155
163
|
},
|
|
156
164
|
]);
|
|
157
165
|
setRefSearch('');
|
|
158
166
|
};
|
|
159
167
|
|
|
168
|
+
/** 改某个待确认文档条目的说明 / 进原文开关 */
|
|
169
|
+
const patchRefItem = (key, patch) =>
|
|
170
|
+
setItems((prev) => prev.map((x) => (x.key === key ? { ...x, ...patch } : x)));
|
|
171
|
+
|
|
160
172
|
const removeItem = (key) => setItems((prev) => prev.filter((x) => x.key !== key));
|
|
161
173
|
|
|
162
174
|
const submitOne = async (it) => {
|
|
@@ -168,7 +180,11 @@ export default function AttachModal({
|
|
|
168
180
|
fileId = r.fileId || r.id;
|
|
169
181
|
if (!fileId) throw new Error('上传未返回 fileId');
|
|
170
182
|
}
|
|
171
|
-
await ep.attach(attachBodyOf({ ...it, fileId }));
|
|
183
|
+
await ep.attach(attachBodyOf({ ...it, fileId, note: it.note || replaceNote || '' }, host));
|
|
184
|
+
// #168:换指向——新绑定挂好后解除旧的那条(旧资源进孤儿池,不删字节)
|
|
185
|
+
if (replaceAttachment) {
|
|
186
|
+
try { await ep.detach(replaceAttachment, false); } catch { /* 旧边解不掉也不影响新绑定 */ }
|
|
187
|
+
}
|
|
172
188
|
setItems((prev) => prev.filter((x) => x.key !== it.key));
|
|
173
189
|
return true;
|
|
174
190
|
} catch (e) {
|
|
@@ -228,7 +244,7 @@ export default function AttachModal({
|
|
|
228
244
|
|
|
229
245
|
return (
|
|
230
246
|
<Modal
|
|
231
|
-
title=
|
|
247
|
+
title={replaceAttachment ? '更换文档绑定' : '添加附件'}
|
|
232
248
|
size="md"
|
|
233
249
|
onClose={busy ? undefined : onClose}
|
|
234
250
|
busy={busy}
|
|
@@ -368,6 +384,30 @@ export default function AttachModal({
|
|
|
368
384
|
{badgeOf(it.source === 'file' ? (/^image\//i.test(it.mime) ? 'image' : 'file') : it.source)}
|
|
369
385
|
</span>
|
|
370
386
|
{it.size ? <span className="att-pending-size">{fmtSize(it.size)}</span> : null}
|
|
387
|
+
{/* 文档条目:说明(desc)+ 进原文(任务侧才有效,#162) */}
|
|
388
|
+
{it.source === 'ref' ? (
|
|
389
|
+
<span className="att-pending-ref-opts">
|
|
390
|
+
<input
|
|
391
|
+
className="att-pending-note"
|
|
392
|
+
type="text"
|
|
393
|
+
value={it.note || ''}
|
|
394
|
+
placeholder="说明(这一行里大概是什么)"
|
|
395
|
+
disabled={busy}
|
|
396
|
+
onChange={(e) => patchRefItem(it.key, { note: e.target.value })}
|
|
397
|
+
/>
|
|
398
|
+
{host === 'task' ? (
|
|
399
|
+
<label className="att-pending-inline" title="交付时把文档全文附进提示词,而不是只给路径">
|
|
400
|
+
<input
|
|
401
|
+
type="checkbox"
|
|
402
|
+
checked={!!it.inline}
|
|
403
|
+
disabled={busy}
|
|
404
|
+
onChange={(e) => patchRefItem(it.key, { inline: e.target.checked })}
|
|
405
|
+
/>
|
|
406
|
+
进原文
|
|
407
|
+
</label>
|
|
408
|
+
) : null}
|
|
409
|
+
</span>
|
|
410
|
+
) : null}
|
|
371
411
|
{it.status === 'uploading' ? <span className="att-pending-state">上传中…</span> : null}
|
|
372
412
|
{it.status === 'error' ? (
|
|
373
413
|
<>
|
|
@@ -33,7 +33,10 @@ export function blockHtml(text, attachments) {
|
|
|
33
33
|
// 下发——本函数是**逐块**调用的,renderMarkdownHtml 会把文件附件拼成 chip
|
|
34
34
|
// 附在每个块末尾,拖一个 md 进来就是「每一行都显示」(#118)。
|
|
35
35
|
const imgs = (attachments || []).filter((a) => a?.type === 'image');
|
|
36
|
-
|
|
36
|
+
// #168:ref 条目也传下去——只用来把 `nxkv://ref/<id>` 的显示名换成**文档标题**
|
|
37
|
+
// (渲染层只查标题表,不产生任何 chip,逐块下发是安全的)。
|
|
38
|
+
const refs = (attachments || []).filter((a) => a?.kind === 'ref');
|
|
39
|
+
return renderMarkdownHtml(raw, [...imgs, ...refs]).replace(
|
|
37
40
|
/<p class="mdw-empty">[\s\S]*?<\/p>/g,
|
|
38
41
|
''
|
|
39
42
|
);
|
|
@@ -22,7 +22,7 @@ const GETLOOP_LINE_MAX = 2000;
|
|
|
22
22
|
// 内置「持续 get」默认模板的预设文案(与服务端 waitgoal-config 默认同文案;%s = 任务编号,
|
|
23
23
|
// 存取时与 {{task.id}} 互转)。服务端常量带 core 依赖,前端本地声明。
|
|
24
24
|
const GETLOOP_DEFAULT_PRESET =
|
|
25
|
-
'不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get
|
|
25
|
+
'不要直接结束本轮:完成上面的任务(%s)之后,继续调用 nx-kv localtask get 领取下一条任务,直到 get 返回 timeout 为止。';
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @param {object} repo 仓库记录(含 getLoop)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// 任务面板页的**整页布局组件**(#170):项目组页与目录(dir)任务页共用。
|
|
2
|
+
//
|
|
3
|
+
// 用户口径:「路由还是各自路由,指的 ui 样式统一,布局完全抽离出组件复用」——
|
|
4
|
+
// 两页的**路由与数据语义各自保留**(组页 = 多条成员 topic 的视图,目录页 = 一条
|
|
5
|
+
// topic 的视图),但**排布骨架必须同源**:否则两页各写一遍容器/间距/块序,
|
|
6
|
+
// 改一处另一处就漂(「仍然不一致」的根因)。
|
|
7
|
+
//
|
|
8
|
+
// 骨架(块序固定,间距由 rp-page 的 flex gap 统一):
|
|
9
|
+
//
|
|
10
|
+
// rp-page
|
|
11
|
+
// ├ rp-group-head 头部:h2(图标 + 名字 + 计数 chips)+ 右对齐动作区
|
|
12
|
+
// ├ intro 简介槽(组介绍 / 项目介绍)
|
|
13
|
+
// ├ batch 批量条槽(多选操作;没有就不占位)
|
|
14
|
+
// ├ list 任务列表槽(TaskPanel)
|
|
15
|
+
// └ footer 页脚槽(翻页条)
|
|
16
|
+
//
|
|
17
|
+
// 各页只往槽里放自己的内容与动作,**不自己写布局**。
|
|
18
|
+
import { Icon } from '../icons.jsx';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {object} props
|
|
22
|
+
* @param {string} props.name 页面主体名(组名 / 目录名)
|
|
23
|
+
* @param {Array<{text:string}|string>} [props.counts] 头部计数 chips
|
|
24
|
+
* @param {string} [props.icon] 名字前的图标(缺省 folder)
|
|
25
|
+
* @param {React.ReactNode} [props.actions] 头部右侧动作区(工具区)
|
|
26
|
+
* @param {React.ReactNode} [props.intro] 简介槽
|
|
27
|
+
* @param {React.ReactNode} [props.batch] 批量条槽
|
|
28
|
+
* @param {React.ReactNode} [props.list] 任务列表槽
|
|
29
|
+
* @param {React.ReactNode} [props.footer] 页脚槽(翻页条)
|
|
30
|
+
* @param {React.ReactNode} [props.extra] 额外内容(骨架之外的零散块)
|
|
31
|
+
*/
|
|
32
|
+
export default function TaskPanelLayout({
|
|
33
|
+
name,
|
|
34
|
+
counts = [],
|
|
35
|
+
icon = 'folder',
|
|
36
|
+
actions = null,
|
|
37
|
+
intro = null,
|
|
38
|
+
batch = null,
|
|
39
|
+
list = null,
|
|
40
|
+
footer = null,
|
|
41
|
+
extra = null,
|
|
42
|
+
}) {
|
|
43
|
+
return (
|
|
44
|
+
<div className="rp-page">
|
|
45
|
+
<div className="rp-group-head">
|
|
46
|
+
<h2>
|
|
47
|
+
<Icon name={icon} size={15} /> {name}
|
|
48
|
+
{counts.map((c, i) => {
|
|
49
|
+
const text = typeof c === 'string' ? c : (c && c.text) || '';
|
|
50
|
+
return text ? (
|
|
51
|
+
<span className="rp-chip-count" key={i}>{text}</span>
|
|
52
|
+
) : null;
|
|
53
|
+
})}
|
|
54
|
+
</h2>
|
|
55
|
+
{actions ? <div className="rp-group-acts">{actions}</div> : null}
|
|
56
|
+
</div>
|
|
57
|
+
{intro}
|
|
58
|
+
{batch}
|
|
59
|
+
{list}
|
|
60
|
+
{footer}
|
|
61
|
+
{extra}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// 任务面板页的**共享外壳**(#169):项目组页与目录(dir)任务页共用同一份结构。
|
|
2
|
+
//
|
|
3
|
+
// 为什么抽组件:两页此前各写各的容器类名(.rp-page / .rp-group-head 各写一遍),
|
|
4
|
+
// 背景、内距、间距靠 CSS 巧合对齐——一处改了另一处就漂(用户验收:「两个页面的
|
|
5
|
+
// 背景色不一致,复用组件呀」)。现在**结构与样式同源**:一个组件一份 DOM,
|
|
6
|
+
// 两页只传数据(名字 / 计数 chips / 工具区 / 内容)。
|
|
7
|
+
//
|
|
8
|
+
// 结构:rp-page 容器 → rp-group-head(h2:图标 + 名字 + 计数 chips;右侧动作区
|
|
9
|
+
// 右对齐)→ 内容。动作区由调用方传入(ToolActsBar),组件只管摆位。
|
|
10
|
+
import { Icon } from '../icons.jsx';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {object} props
|
|
14
|
+
* @param {string} props.name 页面主体名(组名 / 目录名)
|
|
15
|
+
* @param {Array<{text:string}|string>} [props.counts] 头部计数 chips(字符串或 {text})
|
|
16
|
+
* @param {string} [props.icon] 名字前的图标(缺省 folder)
|
|
17
|
+
* @param {React.ReactNode} [props.actions] 右侧动作区(工具区)
|
|
18
|
+
* @param {React.ReactNode} props.children 页面内容
|
|
19
|
+
*/
|
|
20
|
+
export default function PageShell({ name, counts = [], icon = 'folder', actions = null, children }) {
|
|
21
|
+
return (
|
|
22
|
+
<div className="rp-page">
|
|
23
|
+
<div className="rp-group-head">
|
|
24
|
+
<h2>
|
|
25
|
+
<Icon name={icon} size={15} /> {name}
|
|
26
|
+
{counts.map((c, i) => {
|
|
27
|
+
const text = typeof c === 'string' ? c : (c && c.text) || '';
|
|
28
|
+
return text ? (
|
|
29
|
+
<span className="rp-chip-count" key={i}>{text}</span>
|
|
30
|
+
) : null;
|
|
31
|
+
})}
|
|
32
|
+
</h2>
|
|
33
|
+
{actions ? <div className="rp-group-acts">{actions}</div> : null}
|
|
34
|
+
</div>
|
|
35
|
+
{children}
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -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
|
|