nx-kv 0.41.0 → 0.41.1
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 +29 -6
- package/README.md +1 -0
- package/package.json +2 -2
- package/src/core/attachmentdb/docs.js +104 -0
- package/src/core/attachmentdb/ids.js +96 -0
- package/src/core/attachmentdb/query.js +189 -0
- package/src/core/attachmentdb/relations.js +153 -0
- package/src/core/attachmentdb/resources.js +225 -0
- package/src/core/attachmentdb.js +42 -715
- package/src/core/db/import-json/data.js +140 -0
- package/src/core/db/import-json/extras.js +69 -0
- package/src/core/db/import-json/links.js +147 -0
- package/src/core/db/import-json/refs.js +183 -0
- package/src/core/db/import-json/repos.js +180 -0
- package/src/core/db/import-json/scan.js +35 -0
- package/src/core/db/import-json/tasks.js +317 -0
- package/src/core/db/import-json.js +31 -1061
- package/src/modules/docs/attach.js +181 -0
- package/src/modules/docs/index.js +20 -448
- package/src/modules/docs/knowledge.js +7 -2
- package/src/modules/docs/render.js +84 -0
- package/src/modules/docs/service.js +200 -0
- package/src/modules/localtask/action-attach.js +88 -0
- package/src/modules/localtask/action-flags.js +6 -0
- package/src/modules/localtask/action-lifecycle.js +190 -0
- package/src/modules/localtask/action-maintenance.js +130 -0
- package/src/modules/localtask/action-move.js +58 -0
- package/src/modules/localtask/action-query.js +46 -0
- package/src/modules/localtask/action-remove.js +116 -0
- package/src/modules/localtask/action-render.js +200 -0
- package/src/modules/localtask/action-submit.js +186 -0
- package/src/modules/localtask/action-topics.js +46 -0
- package/src/modules/localtask/action-waiting.js +95 -0
- package/src/modules/localtask/index.js +29 -1104
- package/src/modules/repos/boards/core.js +255 -0
- package/src/modules/repos/boards/docs.js +53 -0
- package/src/modules/repos/boards/members.js +228 -0
- package/src/modules/repos/boards/transfer.js +159 -0
- package/src/modules/repos/boards.js +25 -661
- package/src/modules/repos/cli/board-actions.js +177 -0
- package/src/modules/repos/cli/ref-actions.js +157 -0
- package/src/modules/repos/cli/remote-actions.js +141 -0
- package/src/modules/repos/cli/render.js +168 -0
- package/src/modules/repos/cli/repo-actions.js +199 -0
- package/src/modules/repos/cli/transfer-actions.js +105 -0
- package/src/modules/repos/index.js +18 -920
- package/src/modules/repos/service/bind-topics.js +97 -0
- package/src/modules/repos/service/context.js +189 -0
- package/src/modules/repos/service/crud.js +345 -0
- package/src/modules/repos/service/identity.js +188 -0
- package/src/modules/repos/service/store.js +274 -0
- package/src/modules/repos/service.js +41 -1061
- package/src/modules/repos/transfer/diff.js +126 -0
- package/src/modules/repos/transfer/export.js +223 -0
- package/src/modules/repos/transfer/import.js +377 -0
- package/src/modules/repos/transfer/layout.js +135 -0
- package/src/modules/repos/transfer/render.js +72 -0
- package/src/modules/repos/transfer.js +11 -922
- package/src/modules/tasktool/attach-resource.js +293 -0
- package/src/modules/tasktool/attach-template.js +266 -0
- package/src/modules/tasktool/attach.js +70 -558
- package/src/modules/tasktool/delivery-template.js +2 -1
- package/src/modules/tasktool/doc-inline.js +84 -0
- package/src/modules/tasktool/groupctx.js +3 -1
- package/src/modules/tasktool/plugins/timegoal-core-store.js +151 -0
- package/src/modules/tasktool/plugins/timegoal-cwd-store.js +441 -0
- package/src/modules/tasktool/plugins/timegoal-store.js +16 -842
- package/src/modules/tasktool/plugins/timegoal-task-store.js +289 -0
- package/src/modules/tasktool/wait.js +3 -1
- package/src/modules/todo/attachments.js +149 -0
- package/src/modules/todo/locate.js +82 -0
- package/src/modules/todo/service.js +42 -382
- package/src/modules/todo/store.js +158 -0
- package/src/shared/prompt-blocks.js +13 -4
- package/src/web/frontend/components/md/find-bar.jsx +38 -0
- package/src/web/frontend/components/md/live-block.jsx +129 -0
- package/src/web/frontend/components/md/md-panes-helpers.js +92 -0
- package/src/web/frontend/components/md/md-panes-keys.js +193 -0
- package/src/web/frontend/components/md/md-panes-root.jsx +158 -0
- package/src/web/frontend/components/md/md-panes.jsx +124 -1342
- package/src/web/frontend/components/md/slash-menu.jsx +83 -0
- package/src/web/frontend/components/md/status-bar.jsx +46 -0
- package/src/web/frontend/components/md/use-live-preview.js +279 -0
- package/src/web/frontend/components/md/use-slash-menu.js +80 -0
- package/src/web/frontend/components/md/use-source-editor.js +297 -0
- package/src/web/frontend/modules/md/md-blocks.js +248 -0
- package/src/web/frontend/modules/md/md-parse.js +23 -507
- package/src/web/frontend/modules/md/md-render.js +258 -0
- package/src/web/frontend/modules/md/style.css +7 -1605
- package/src/web/frontend/modules/md/styles/chrome.css +252 -0
- package/src/web/frontend/modules/md/styles/docs.css +185 -0
- package/src/web/frontend/modules/md/styles/editor.css +308 -0
- package/src/web/frontend/modules/md/styles/panels.css +372 -0
- package/src/web/frontend/modules/md/styles/shell.css +363 -0
- package/src/web/frontend/modules/md/styles/templates.css +125 -0
- package/src/web/frontend/page/dag/edges.js +55 -0
- package/src/web/frontend/page/dag/head-bar.jsx +46 -0
- package/src/web/frontend/page/dag/index.jsx +57 -420
- package/src/web/frontend/page/dag/layout.js +83 -0
- package/src/web/frontend/page/dag/model.js +47 -0
- package/src/web/frontend/page/dag/node-card.jsx +123 -0
- package/src/web/frontend/page/dag/use-interactions.js +135 -0
- package/src/web/frontend/page/dir/task-ack.js +38 -0
- package/src/web/frontend/page/dir/task-actions.js +379 -0
- package/src/web/frontend/page/dir/task-beside-header.jsx +18 -0
- package/src/web/frontend/page/dir/task-board-section.jsx +38 -0
- package/src/web/frontend/page/dir/task-chain.js +172 -0
- package/src/web/frontend/page/dir/task-derived-ctx.js +46 -0
- package/src/web/frontend/page/dir/task-dock-panel.jsx +227 -0
- package/src/web/frontend/page/dir/task-dock.js +79 -0
- package/src/web/frontend/page/dir/task-feedback.js +207 -0
- package/src/web/frontend/page/dir/task-goal-section.jsx +50 -0
- package/src/web/frontend/page/dir/task-goal.js +36 -0
- package/src/web/frontend/page/dir/task-history-view.jsx +44 -0
- package/src/web/frontend/page/dir/task-not-found.jsx +23 -0
- package/src/web/frontend/page/dir/task-preview-modal.jsx +82 -0
- package/src/web/frontend/page/dir/task-sel-menu.js +54 -0
- package/src/web/frontend/page/dir/task-status-bar.jsx +61 -0
- package/src/web/frontend/page/dir/task-utils.js +7 -0
- package/src/web/frontend/page/dir/task.jsx +117 -1532
- package/src/web/frontend/page/repos/bind-modals.jsx +118 -0
- package/src/web/frontend/page/repos/board-admin.jsx +226 -0
- package/src/web/frontend/page/repos/board-refs.jsx +97 -0
- package/src/web/frontend/page/repos/doc-search-modal.jsx +241 -0
- package/src/web/frontend/page/repos/filters-bar.jsx +44 -0
- package/src/web/frontend/page/repos/index.jsx +248 -1834
- package/src/web/frontend/page/repos/pending-section.jsx +163 -0
- package/src/web/frontend/page/repos/ref-panel.jsx +406 -0
- package/src/web/frontend/page/repos/remote-modal.jsx +112 -0
- package/src/web/frontend/page/repos/repo-form-modal.jsx +219 -0
- package/src/web/frontend/page/repos/repo-table.jsx +216 -0
- package/src/web/frontend/page/settings/prompt-template-params.js +214 -0
- package/src/web/frontend/page/settings/prompt-templates-section.jsx +1 -213
- package/src/web/frontend/style-v2.css +6 -1232
- package/src/web/frontend/style.css +10 -2434
- package/src/web/frontend/styles/base.css +139 -0
- package/src/web/frontend/styles/board.css +322 -0
- package/src/web/frontend/styles/buttons-cards.css +244 -0
- package/src/web/frontend/styles/modals.css +458 -0
- package/src/web/frontend/styles/panels.css +366 -0
- package/src/web/frontend/styles/repos-admin.css +207 -0
- package/src/web/frontend/styles/repos.css +330 -0
- package/src/web/frontend/styles/settings.css +244 -0
- package/src/web/frontend/styles/submit-bar.css +124 -0
- package/src/web/frontend/styles-v2/dag.css +285 -0
- package/src/web/frontend/styles-v2/dir.css +210 -0
- package/src/web/frontend/styles-v2/shell.css +251 -0
- package/src/web/frontend/styles-v2/sidebar.css +199 -0
- package/src/web/frontend/styles-v2/views.css +287 -0
- package/src/web/frontend/workspace/layout.js +399 -0
- package/src/web/frontend/workspace/open.js +246 -0
- package/src/web/frontend/workspace/panels.js +417 -0
- package/src/web/frontend/workspace.js +8 -1044
- package/src/web/public/assets/Introduction-Dnh0L_ss.js +1 -0
- package/src/web/public/assets/app-context-D7HAx67n.js +1 -0
- package/src/web/public/assets/bar-CgCAhY5x.js +1 -0
- package/src/web/public/assets/{board-view-t8CKtq17.js → board-view-CZKZsyk-.js} +1 -1
- package/src/web/public/assets/{button-M9TUn-AR.js → button-Cmo-6aoW.js} +1 -1
- package/src/web/public/assets/cloud-DMeqfWK9.js +3 -0
- package/src/web/public/assets/composer-launch-Bf4rXhLs.js +1 -0
- package/src/web/public/assets/composer-panel-C0qsxE7e.js +1 -0
- package/src/web/public/assets/dag-BBtSqd-X.js +1 -0
- package/src/web/public/assets/dir-UUWImKeX.js +5 -0
- package/src/web/public/assets/frontmatter-QvrjUNzF.js +2 -0
- package/src/web/public/assets/group-DFMGHQ-H.js +1 -0
- package/src/web/public/assets/index-CgEWvYQk.js +2 -0
- package/src/web/public/assets/md-history-CKumOs4q.js +39 -0
- package/src/web/public/assets/md-parse-awNLHAzO.js +13 -0
- package/src/web/public/assets/{member-picker--32VkTmv.js → member-picker-BAgkj36N.js} +1 -1
- package/src/web/public/assets/model-DzdWfp14.js +2 -0
- package/src/web/public/assets/{overview-B788GcJE.js → overview-BrcPfsJO.js} +1 -1
- package/src/web/public/assets/progress-DHDlz9O9.js +3 -0
- package/src/web/public/assets/refs-CqvRGv8w.js +1 -0
- package/src/web/public/assets/repos-DGrGWDnX.js +14 -0
- package/src/web/public/assets/route-crumb-yyPGKKKq.js +1 -0
- package/src/web/public/assets/settings-9zNucAPD.js +6 -0
- package/src/web/public/assets/{status-tag-BPbfa4zt.js → status-tag-bDdrFgpZ.js} +1 -1
- package/src/web/public/assets/task-CG4fzV6s.js +11 -0
- package/src/web/public/assets/{task-status-BP6y8MVu.js → task-status-BnymQMTw.js} +1 -1
- package/src/web/public/assets/templates-DdHWIxUE.js +1 -0
- package/src/web/public/assets/tool-bar-D8q3kOOl.js +1 -0
- package/src/web/public/assets/upload-BIMbGcCB.js +1 -0
- package/src/web/public/assets/workspace-C_5X2gIr.js +28 -0
- package/src/web/public/index.html +8 -4
- package/src/web/public/assets/Introduction-DKqRmABL.js +0 -1
- package/src/web/public/assets/bar-B8QJ4EnF.js +0 -1
- package/src/web/public/assets/cloud-C2O_1vT5.js +0 -3
- package/src/web/public/assets/composer-launch-BgMj0T3Y.js +0 -1
- package/src/web/public/assets/composer-panel-C5XUApWJ.js +0 -1
- package/src/web/public/assets/dag-CWAWk_gt.js +0 -1
- package/src/web/public/assets/dir-Cu5B5z6J.js +0 -5
- package/src/web/public/assets/group-YA-FgKS3.js +0 -1
- package/src/web/public/assets/index-DxX-ZzRP.js +0 -30
- package/src/web/public/assets/md-history-4sXoj4RH.js +0 -28
- package/src/web/public/assets/md-parse-C2bDc3IZ.js +0 -25
- package/src/web/public/assets/progress-CfzFVSDu.js +0 -3
- package/src/web/public/assets/refs-qtxw66hp.js +0 -1
- package/src/web/public/assets/repos-CpVuGaP2.js +0 -14
- package/src/web/public/assets/route-crumb-B8oEN8BB.js +0 -1
- package/src/web/public/assets/settings-BmWNBqcv.js +0 -6
- package/src/web/public/assets/task-DsFCNaOJ.js +0 -11
- package/src/web/public/assets/templates-4Xaj2m9L.js +0 -1
- package/src/web/public/assets/tool-bar-CfBWzhpV.js +0 -1
- package/src/web/public/assets/upload-L1g-pfvZ.js +0 -1
|
@@ -7,44 +7,28 @@
|
|
|
7
7
|
// 文档内容存在会话内存(doc-store.js),页签身份在 FlexLayout 模型里——
|
|
8
8
|
// 两者分工明确:布局归布局,内容归内容。
|
|
9
9
|
import RouteBreadcrumb from '../../components/layout/route-crumb.jsx';
|
|
10
|
-
import {
|
|
11
|
-
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
10
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
11
|
import { Actions } from 'flexlayout-react';
|
|
13
12
|
import { api } from '../../api/client.js';
|
|
14
13
|
import { useToast } from '../../components/toast/index.jsx';
|
|
15
|
-
import {
|
|
14
|
+
import { useDialog } from '../../components/popup/index.jsx';
|
|
16
15
|
import { GLOBAL_KEY, findGroupTask } from '../../modules/board/board-view.js';
|
|
17
|
-
import {
|
|
18
|
-
buildReopenText,
|
|
19
|
-
FEEDBACK_HEADING,
|
|
20
|
-
PLAIN_FEEDBACK_HEADING,
|
|
21
|
-
quoteBlock,
|
|
22
|
-
} from '../../modules/board/reopen-text.js';
|
|
23
16
|
import { extractAckNodes } from '../../modules/board/ack-nodes.js';
|
|
24
17
|
import ToolBar from '../../components/md/tool-bar.jsx';
|
|
25
18
|
import { MdPanes } from '../../components/md/md-panes.jsx';
|
|
26
19
|
import AckRail from '../../components/md/ack-rail.jsx';
|
|
27
|
-
import AttachBar from '../../components/md/attach-bar.jsx';
|
|
28
|
-
import AttachArea from '../../components/md/attach-area.jsx';
|
|
29
|
-
import { docIdOfLocator } from '../../components/md/attach-common.js';
|
|
30
|
-
import StatusTag from '../../components/status-tag/index.jsx';
|
|
31
20
|
import SelMenu from '../../components/md/sel-menu.jsx';
|
|
32
21
|
import { openComposer } from '../../components/md/composer-launch.js';
|
|
33
22
|
import ShortcutSheet from '../../components/md/shortcut-sheet.jsx';
|
|
34
23
|
import { TaskChainModal } from '../../components/md/task-chain.jsx';
|
|
35
24
|
import { useApp } from '../../app-context.jsx';
|
|
36
|
-
import { openBesideMain
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
25
|
+
import { openBesideMain } from '../../workspace.js';
|
|
26
|
+
import { persistAtt } from '../../components/md/attachments.js';
|
|
27
|
+
import { pushHistory, redoHistory, undoHistory } from '../../modules/md/md-history.js';
|
|
39
28
|
import {
|
|
40
|
-
insertAttachmentSnippet,
|
|
41
29
|
liveBodyBlocks,
|
|
42
30
|
renderMarkdownHtml,
|
|
43
|
-
slugName,
|
|
44
31
|
titleFromMd,
|
|
45
|
-
parseFrontmatter,
|
|
46
|
-
stripFrontmatter,
|
|
47
|
-
stripPhantomEmptyLines,
|
|
48
32
|
stripTitleHeading,
|
|
49
33
|
withFrontmatter,
|
|
50
34
|
} from '../../modules/md/md-parse.js';
|
|
@@ -52,13 +36,26 @@ import {
|
|
|
52
36
|
docIdOf,
|
|
53
37
|
getDoc,
|
|
54
38
|
isDraftTask,
|
|
55
|
-
nextDraftId,
|
|
56
|
-
peekDoc,
|
|
57
|
-
promoteDoc,
|
|
58
39
|
saveDoc,
|
|
59
40
|
scopeOf,
|
|
60
41
|
useDocs,
|
|
61
42
|
} from '../../modules/md/doc-store.js';
|
|
43
|
+
import { useDock } from './task-dock.js';
|
|
44
|
+
import { useGoal } from './task-goal.js';
|
|
45
|
+
import { useChain } from './task-chain.js';
|
|
46
|
+
import { useSelMenu } from './task-sel-menu.js';
|
|
47
|
+
import { useAck } from './task-ack.js';
|
|
48
|
+
import { useTaskActions } from './task-actions.js';
|
|
49
|
+
import { useFeedback } from './task-feedback.js';
|
|
50
|
+
import { useDerivedCtx } from './task-derived-ctx.js';
|
|
51
|
+
import { PreviewModal } from './task-preview-modal.jsx';
|
|
52
|
+
import { DockPanel } from './task-dock-panel.jsx';
|
|
53
|
+
import { StatusBar } from './task-status-bar.jsx';
|
|
54
|
+
import { goalSection } from './task-goal-section.jsx';
|
|
55
|
+
import { HistoryView } from './task-history-view.jsx';
|
|
56
|
+
import { BoardSection } from './task-board-section.jsx';
|
|
57
|
+
import { NotFoundView } from './task-not-found.jsx';
|
|
58
|
+
import { BesideHeader } from './task-beside-header.jsx';
|
|
62
59
|
|
|
63
60
|
export default function PagePanel({ dirKey, groupId, task, beside = false, tabId, model, historyId = null }) {
|
|
64
61
|
const app = useApp() || {};
|
|
@@ -103,375 +100,37 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
103
100
|
// #47:撤掉「阅读」模式——老草稿里存过的 preview 一律按实时预览处理,只有 edit 是源码态
|
|
104
101
|
const editorMode = doc && doc.mode === 'edit' ? 'edit' : 'split';
|
|
105
102
|
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const [goalDraft, setGoalDraft] = useState(null);
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
setGoalDraft(null);
|
|
112
|
-
}, [id]);
|
|
113
|
-
const declaredGoal = taskRow?.timegoal || null;
|
|
114
|
-
const goal = goalDraft || { duration: declaredGoal?.duration || '', prompt: declaredGoal?.prompt || '' };
|
|
115
|
-
// 只有「待领取」能改时间目标声明(已领取在计时、已交付是终态;要改先 reopen)
|
|
116
|
-
const goalEditable = isDraft || (!!taskRow && taskRow.status === 'pending');
|
|
103
|
+
// ─── 钩子状态 ───
|
|
104
|
+
const dock = useDock();
|
|
105
|
+
const { dockOpen, setDockOpen, dockTab, dockH, dockRef, dockMax, showDockTab, onDockDragStart, toggleDockMax } = dock;
|
|
117
106
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
// 注意:hooks 必须留在所有提前 return 之前(下面「读不到文档」会提前返回)。
|
|
121
|
-
const canShowGoalLog = !isDraft && !!declaredGoal && task != null;
|
|
122
|
-
const [goalLog, setGoalLog] = useState({ busy: false, error: '', data: null });
|
|
123
|
-
const loadGoalLog = useCallback(() => {
|
|
124
|
-
if (isDraft || !topicKey || task == null) return;
|
|
125
|
-
setGoalLog((s) => ({ ...s, busy: true, error: '' }));
|
|
126
|
-
const q = new URLSearchParams({ id: String(task), key: String(topicKey) });
|
|
127
|
-
api(`/api/localtasks/timegoal-log?${q.toString()}`)
|
|
128
|
-
.then((d) => setGoalLog((s) => ({ ...s, data: d, busy: false })))
|
|
129
|
-
.catch((e) => setGoalLog((s) => ({ ...s, busy: false, error: String(e.message || e) })));
|
|
130
|
-
}, [isDraft, topicKey, task]);
|
|
131
|
-
useEffect(() => {
|
|
132
|
-
if (canShowGoalLog) loadGoalLog();
|
|
133
|
-
}, [canShowGoalLog, loadGoalLog]);
|
|
107
|
+
const goalState = useGoal({ id, isDraft, topicKey, task, taskRow });
|
|
108
|
+
const { goalDraft, setGoalDraft, goal, goalEditable, declaredGoal, goalLog, loadGoalLog, canShowGoalLog } = goalState;
|
|
134
109
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
// 点条目展开对应面板;抽屉上沿可拖拉调高;▾ 收起后只剩状态栏。
|
|
139
|
-
const DOCK_MIN = 96;
|
|
140
|
-
const [dockOpen, setDockOpen] = useState(() => localStorage.getItem('nxkv.taskDockOpen') !== '0');
|
|
141
|
-
const [dockTab, setDockTab] = useState(() => localStorage.getItem('nxkv.taskDockTab') || 'attach');
|
|
142
|
-
const [dockH, setDockH] = useState(() => {
|
|
143
|
-
const v = Number(localStorage.getItem('nxkv.taskDockH'));
|
|
144
|
-
return Number.isFinite(v) && v >= DOCK_MIN ? v : 176;
|
|
110
|
+
const chainState = useChain({
|
|
111
|
+
isDraft, task, taskRow, topicKey, topic, isGlobal, groupAnchored, groupId,
|
|
112
|
+
app, model, historyId, toast,
|
|
145
113
|
});
|
|
146
|
-
const
|
|
147
|
-
dockHRef.current = dockH;
|
|
148
|
-
const dockRef = useRef(null);
|
|
149
|
-
const [dockMax, setDockMax] = useState(false);
|
|
150
|
-
const dockPrevHRef = useRef(176);
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
localStorage.setItem('nxkv.taskDockOpen', dockOpen ? '1' : '0');
|
|
153
|
-
}, [dockOpen]);
|
|
154
|
-
useEffect(() => {
|
|
155
|
-
localStorage.setItem('nxkv.taskDockTab', dockTab);
|
|
156
|
-
}, [dockTab]);
|
|
157
|
-
const showDockTab = useCallback((tab) => {
|
|
158
|
-
setDockTab(tab);
|
|
159
|
-
setDockOpen(true);
|
|
160
|
-
}, []);
|
|
161
|
-
const onDockDragStart = useCallback(
|
|
162
|
-
(e) => {
|
|
163
|
-
if (!dockOpen) return;
|
|
164
|
-
e.preventDefault();
|
|
165
|
-
setDockMax(false);
|
|
166
|
-
const startY = e.clientY;
|
|
167
|
-
const startH = dockHRef.current;
|
|
168
|
-
const hostH = dockRef.current?.parentElement?.clientHeight || window.innerHeight;
|
|
169
|
-
const clamp = (h) =>
|
|
170
|
-
Math.max(DOCK_MIN, Math.min(Math.round(hostH * 0.62), Math.round(h)));
|
|
171
|
-
const move = (ev) => {
|
|
172
|
-
const h = clamp(startH - (ev.clientY - startY));
|
|
173
|
-
dockHRef.current = h;
|
|
174
|
-
setDockH(h);
|
|
175
|
-
};
|
|
176
|
-
const up = () => {
|
|
177
|
-
window.removeEventListener('mousemove', move);
|
|
178
|
-
window.removeEventListener('mouseup', up);
|
|
179
|
-
document.body.style.userSelect = '';
|
|
180
|
-
document.body.style.cursor = '';
|
|
181
|
-
localStorage.setItem('nxkv.taskDockH', String(dockHRef.current));
|
|
182
|
-
};
|
|
183
|
-
document.body.style.userSelect = 'none';
|
|
184
|
-
document.body.style.cursor = 'row-resize';
|
|
185
|
-
window.addEventListener('mousemove', move);
|
|
186
|
-
window.addEventListener('mouseup', up);
|
|
187
|
-
},
|
|
188
|
-
[dockOpen]
|
|
189
|
-
);
|
|
190
|
-
const openGoalLog = useCallback(() => {
|
|
191
|
-
showDockTab('check');
|
|
192
|
-
loadGoalLog();
|
|
193
|
-
}, [showDockTab, loadGoalLog]);
|
|
194
|
-
// 面板右上角「最大化 / 还原」(VSCode 的 panel 控制钮之一):在常规高度与宿主 62% 之间切
|
|
195
|
-
const toggleDockMax = useCallback(() => {
|
|
196
|
-
if (dockMax) {
|
|
197
|
-
setDockH(dockPrevHRef.current);
|
|
198
|
-
setDockMax(false);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
dockPrevHRef.current = dockHRef.current;
|
|
202
|
-
const hostH = dockRef.current?.parentElement?.clientHeight || window.innerHeight;
|
|
203
|
-
const h = Math.max(DOCK_MIN, Math.round(hostH * 0.62));
|
|
204
|
-
dockHRef.current = h;
|
|
205
|
-
setDockH(h);
|
|
206
|
-
setDockMax(true);
|
|
207
|
-
}, [dockMax]);
|
|
208
|
-
// 头部「添加附件」:附件区只在面板的 attach tab 挂载,先切过去再开弹窗(下一拍等挂载)
|
|
209
|
-
const openAttachPanel = useCallback(() => {
|
|
210
|
-
showDockTab('attach');
|
|
211
|
-
setTimeout(() => attachAreaRef.current?.open(), 0);
|
|
212
|
-
}, [showDockTab]);
|
|
114
|
+
const { chainNodes, historyNode, isChainTip, latestChild, openLatestRound, openHistoryBeside } = chainState;
|
|
213
115
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// 「反馈」(#75):**新开一条任务**(不是重做/就地重开),原完成任务留档不动。
|
|
217
|
-
/** 反馈:开一块 **md 编辑面板** 写意见;提交后**新建一条任务**(forkOf 指回本条),原任务不动。
|
|
218
|
-
* #104:不再是浮层里的输入框弹窗——工作区里新开一块 md 编辑页,顶部带
|
|
219
|
-
* 「反馈 #xx 的任务」引用信息,正文下面是完整的 md 编辑器。 */
|
|
220
|
-
const openFeedback = () => {
|
|
221
|
-
const m = model || app.model;
|
|
222
|
-
if (!m) return;
|
|
223
|
-
openComposer(m, {
|
|
224
|
-
mode: 'feedback',
|
|
225
|
-
taskLabel: task != null ? '#' + task : '',
|
|
226
|
-
taskTitle: String(doc?.title || '').replace(/^#+\s*/, ''),
|
|
227
|
-
// 之前的引用(#105):反馈针对的是**上轮总结**;没有就退回原任务正文开头
|
|
228
|
-
prevQuote: String(taskRow?.roundSummary || '').trim()
|
|
229
|
-
|| String(doc?.body || '').trim().slice(0, 400),
|
|
230
|
-
// 原文定位(#107):点引用区在右侧并排打开这条任务的原文
|
|
231
|
-
src: { dirKey: topicKey || dirKey || GLOBAL_KEY, task: String(task), name: `原文 #${task}` },
|
|
232
|
-
onSubmit: (payload) => spawnFeedbackTask(payload),
|
|
233
|
-
});
|
|
234
|
-
};
|
|
235
|
-
/** 服务端当前任务(#79):评论/反馈的 base 以**盘上正文**为准——会话 doc 可能
|
|
236
|
-
* 过期(别的会话改过 / 上一轮重开追加过 / 首轮还没加载完),拿旧正文拼回去
|
|
237
|
-
* 整篇重写就是「评论一次丢一次」。草稿没有服务端正文,返回 null。 */
|
|
238
|
-
const fetchServerTask = async () => {
|
|
239
|
-
if (isDraft || task == null || /^draft/i.test(String(task))) return null;
|
|
240
|
-
const q = isGlobal
|
|
241
|
-
? `key=${encodeURIComponent(GLOBAL_KEY)}&id=${Number(task)}`
|
|
242
|
-
: `cwd=${encodeURIComponent(topic?.cwd || '')}&id=${Number(task)}`;
|
|
243
|
-
return api(`/api/localtasks/item?${q}`).catch(() => null);
|
|
244
|
-
};
|
|
245
|
-
/** 验收反馈 → 新开任务(#75):正文 = 完整之前的任务 + 上轮总结 + 本轮反馈;
|
|
246
|
-
* forkOf 指回本条。#79:base 取服务端当前正文,取不到才退回会话 doc——
|
|
247
|
-
* 两头都空就中止(真实任务),绝不发一条丢掉原任务的空壳反馈。 */
|
|
248
|
-
const spawnFeedbackTask = ({ text: fbRaw, attachments = [], inserts = '' } = {}) => {
|
|
249
|
-
const fb = String(fbRaw || '').trim();
|
|
250
|
-
closeSelMenu();
|
|
251
|
-
if (!fb && !(attachments && attachments.length)) {
|
|
252
|
-
toast('写一下反馈');
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
const title = doc?.title || `#${task}`;
|
|
256
|
-
guard(async () => {
|
|
257
|
-
const fresh = await fetchServerTask();
|
|
258
|
-
const baseText = String(fresh?.text ?? '').trim() || String(doc?.body ?? '').trim();
|
|
259
|
-
if (!baseText && !isDraft) {
|
|
260
|
-
toast('拿不到任务当前正文,已取消反馈(防止丢内容)');
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
let feedbackBody = fb || '(见附件)';
|
|
264
|
-
if (inserts) feedbackBody = `${feedbackBody}${inserts}`;
|
|
265
|
-
const text = buildReopenText({
|
|
266
|
-
base: baseText,
|
|
267
|
-
feedback: feedbackBody,
|
|
268
|
-
ackSummary: fresh?.roundSummary || taskRow?.roundSummary || '',
|
|
269
|
-
feedbackHeading: FEEDBACK_HEADING,
|
|
270
|
-
bold: true,
|
|
271
|
-
});
|
|
272
|
-
const linkFields =
|
|
273
|
-
!isDraft && task != null && !/^draft/i.test(String(task))
|
|
274
|
-
? { forkOf: String(task), forkKind: 'reopen' }
|
|
275
|
-
: {};
|
|
276
|
-
const res = await api('/api/localtasks', {
|
|
277
|
-
method: 'POST',
|
|
278
|
-
body: isGlobal
|
|
279
|
-
? { global: true, text, ...linkFields }
|
|
280
|
-
: { cwd: topic?.cwd, text, ...linkFields },
|
|
281
|
-
});
|
|
282
|
-
const newId = String(res?.task?.id ?? res?.id ?? '');
|
|
283
|
-
if (!newId) {
|
|
284
|
-
toast('反馈已提交,但未拿到新任务编号');
|
|
285
|
-
refreshLocal();
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const landedKey = res?.key || topicKey;
|
|
289
|
-
saveDoc(docIdOf(scopeOf(landedKey), newId), { title: titleFromMd(text), body: text });
|
|
290
|
-
if (attachments?.length) persistAtt(newId, attachments);
|
|
291
|
-
toast(`已反馈「${title}」→ 新任务 #${newId}`);
|
|
292
|
-
refreshLocal();
|
|
293
|
-
// 反馈新任务继承原任务的组语义(正文连 FM 一起带下去)——组锚定页就留在组里开
|
|
294
|
-
if (app.openPage) {
|
|
295
|
-
if (groupAnchored) app.openPage({ groupId, task: newId, name: `${title.slice(0, 24)}(反馈)` });
|
|
296
|
-
else app.openPage({ dirKey: landedKey, task: newId, name: `${title.slice(0, 24)}(反馈)` });
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
};
|
|
300
|
-
/** 划选评论 → 就地回写原任务(#74),可带附件。
|
|
301
|
-
* #79 防丢数据:第一个区块永远是**完整的之前的任务**,接着才是引用字符和评论。
|
|
302
|
-
* 干净态(无未保存编辑、无附件片段)干脆不传 text——服务端把评论段原子追加到
|
|
303
|
-
* 盘上正文,谁先改过都不丢;带未保存编辑 / 附件片段时才由面板拉服务端最新正文
|
|
304
|
-
* 整篇回写(编辑器里正在写的内容以编辑器为准)。 */
|
|
305
|
-
const submitCommentInPlace = ({ text: fbRaw, attachments = [], inserts = '', quote } = {}) => {
|
|
306
|
-
const fb = String(fbRaw || '').trim();
|
|
307
|
-
const quoteText = String(quote || lastSel.current || '').trim();
|
|
308
|
-
closeSelMenu();
|
|
309
|
-
if (!fb && !(attachments && attachments.length)) {
|
|
310
|
-
toast('写一下要提的问题');
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
if (!quoteText && !fb) {
|
|
314
|
-
toast('先划选一段再评论');
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
if (isDraft || task == null || /^draft/i.test(String(task))) {
|
|
318
|
-
toast('草稿先提交成任务再评论');
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
const title = doc?.title || `#${task}`;
|
|
322
|
-
guard(async () => {
|
|
323
|
-
// 纯文字 + 无未保存编辑 → 服务端拼装(不传 text,base = 服务端正文)
|
|
324
|
-
const serverCompose = !dirty && !inserts && !(attachments && attachments.length);
|
|
325
|
-
let text;
|
|
326
|
-
if (!serverCompose) {
|
|
327
|
-
const fresh = await fetchServerTask();
|
|
328
|
-
const baseText = String(fresh?.text ?? '').trim() || String(doc?.body ?? '').trim();
|
|
329
|
-
if (!baseText) {
|
|
330
|
-
toast('拿不到任务当前正文,已取消评论(防止丢内容)');
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
const feedbackBody = [
|
|
334
|
-
quoteBlock(quoteText),
|
|
335
|
-
fb || '(见附件)',
|
|
336
|
-
inserts,
|
|
337
|
-
].filter(Boolean).join('\n\n');
|
|
338
|
-
text = buildReopenText({
|
|
339
|
-
base: baseText,
|
|
340
|
-
feedback: feedbackBody,
|
|
341
|
-
ackSummary: '',
|
|
342
|
-
feedbackHeading: PLAIN_FEEDBACK_HEADING,
|
|
343
|
-
bold: false,
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
const res = await api('/api/localtasks/reopen', {
|
|
347
|
-
method: 'POST',
|
|
348
|
-
body: {
|
|
349
|
-
...(isGlobal ? { key: GLOBAL_KEY } : { cwd: topic?.cwd }),
|
|
350
|
-
id: Number(task),
|
|
351
|
-
...(text ? { text } : {}),
|
|
352
|
-
kind: 'comment',
|
|
353
|
-
quote: quoteText,
|
|
354
|
-
feedback: fb,
|
|
355
|
-
attachments: (attachments || []).map((a) => ({
|
|
356
|
-
id: a.id,
|
|
357
|
-
name: a.name,
|
|
358
|
-
type: a.type,
|
|
359
|
-
size: a.size,
|
|
360
|
-
url: a.url || '',
|
|
361
|
-
})),
|
|
362
|
-
},
|
|
363
|
-
});
|
|
364
|
-
// 回写后的正文以服务端为准刷回编辑器(服务端拼装时新段只有服务端知道)
|
|
365
|
-
const landedKey = res?.key || topicKey;
|
|
366
|
-
const sameId = String(res?.task?.id ?? task);
|
|
367
|
-
const finalText = String(res?.task?.text ?? text ?? '');
|
|
368
|
-
if (finalText) {
|
|
369
|
-
saveDoc(docIdOf(scopeOf(landedKey), sameId), { title: titleFromMd(finalText), body: finalText });
|
|
370
|
-
}
|
|
371
|
-
if (attachments?.length) persistAtt(sameId, [...(doc?.attachments || []), ...attachments]);
|
|
372
|
-
if (model && tabId && landedKey !== topicKey) {
|
|
373
|
-
model.doAction(Actions.updateNodeAttributes(tabId, { config: { dirKey: landedKey, task: sameId } }));
|
|
374
|
-
}
|
|
375
|
-
setDirty(false);
|
|
376
|
-
toast(`已回写评论「${title}」#${sameId}`);
|
|
377
|
-
refreshLocal();
|
|
378
|
-
});
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
// 工作组语义(frontmatter):组面板「新增任务」创建的草稿带 board/project——
|
|
382
|
-
// 工具区给「归属项目」下拉(限本组成员),提交按 project 路由进对应项目的队列。
|
|
383
|
-
// 非组任务没有 frontmatter,整段不渲染,零噪音。
|
|
384
|
-
const docFm = useMemo(() => (doc ? parseFrontmatter(doc.body) : {}), [doc && doc.body]);
|
|
385
|
-
// 评论任务的原文锚点:frontmatter.parent(新建评论写入);旧数据从「锚定自「标题」」回推
|
|
386
|
-
const parentRef = useMemo(() => {
|
|
387
|
-
if (beside) return null; // 旁路原文自己不再开旁路
|
|
388
|
-
const pid = String(docFm.parent || '').trim();
|
|
389
|
-
const pdir = String(docFm.parentDir || topicKey || '').trim();
|
|
390
|
-
if (pid && !/^draft/i.test(pid)) {
|
|
391
|
-
return { dirKey: pdir || topicKey, task: pid, name: `#${pid}` };
|
|
392
|
-
}
|
|
393
|
-
const body = String(doc?.body || '');
|
|
394
|
-
const m = body.match(/>\s*锚定自「([^」]+)」/);
|
|
395
|
-
if (!m) return null;
|
|
396
|
-
const title = m[1].trim();
|
|
397
|
-
const hit = (topic?.tasks || []).find((t) => {
|
|
398
|
-
if (String(t.id) === String(task)) return false;
|
|
399
|
-
return titleFromMd(t.text || '') === title || String(t.text || '').includes(`# ${title}`);
|
|
400
|
-
});
|
|
401
|
-
if (!hit) return null;
|
|
402
|
-
return { dirKey: topicKey, task: String(hit.id), name: `#${hit.id}` };
|
|
403
|
-
}, [beside, docFm.parent, docFm.parentDir, doc?.body, topicKey, topic, task]);
|
|
404
|
-
const boardCtx = useMemo(() => {
|
|
405
|
-
const bid = docFm.board;
|
|
406
|
-
if (!bid) return null;
|
|
407
|
-
const allBoards = (app.repoData && app.repoData.boards) || [];
|
|
408
|
-
const b = allBoards.find((x) => x.id === bid || x.key === bid || x.name === bid);
|
|
409
|
-
if (!b) return null;
|
|
410
|
-
const allRepos = (app.repoData && app.repoData.repos) || [];
|
|
411
|
-
const byKey = new Map(allRepos.map((r) => [r.key, r]));
|
|
412
|
-
const members = (b.repos || [])
|
|
413
|
-
.map((m) => byKey.get(m.key))
|
|
414
|
-
.filter(Boolean)
|
|
415
|
-
.map((r) => ({ key: r.key, name: r.name }));
|
|
416
|
-
return { board: b, members };
|
|
417
|
-
}, [docFm.board, app.repoData]);
|
|
116
|
+
const selMenuState = useSelMenu({ id });
|
|
117
|
+
const { selMenu, setSelMenu, lastSel, placeSelMenu, onEditorTextSel, closeSelMenu } = selMenuState;
|
|
418
118
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
useEffect(() => {
|
|
422
|
-
if (docs[id]) return;
|
|
423
|
-
if (isDraft) {
|
|
424
|
-
getDoc(id, {
|
|
425
|
-
title: '',
|
|
426
|
-
body: tpl
|
|
427
|
-
? (groupAnchored ? withFrontmatter(tpl.defaultBody(), { board: groupId }) : tpl.defaultBody())
|
|
428
|
-
: '',
|
|
429
|
-
});
|
|
430
|
-
} else if (taskRow) getDoc(id, { title: titleFromMd(taskRow.text), body: taskRow.text });
|
|
431
|
-
}, [id, isDraft, taskRow, groupAnchored, groupId]);
|
|
119
|
+
const ackState = useAck({ id, taskRow, dockTab, dockOpen });
|
|
120
|
+
const { ackOpen, setAckOpen, ackOverflow, reviewSumRef, ackLong } = ackState;
|
|
432
121
|
|
|
433
|
-
|
|
122
|
+
// ─── 本地状态 ───
|
|
123
|
+
const [preview, setPreview] = useState(null);
|
|
434
124
|
const [showShortcuts, setShowShortcuts] = useState(false);
|
|
435
125
|
const [chainOpen, setChainOpen] = useState(false);
|
|
126
|
+
const [dirty, setDirty] = useState(false);
|
|
436
127
|
const fileMdRef = useRef(null);
|
|
437
128
|
const fileAttRef = useRef(null);
|
|
438
129
|
const attachAreaRef = useRef(null);
|
|
439
130
|
const articleRef = useRef(null);
|
|
440
131
|
const reviewBarRef = useRef(null);
|
|
441
|
-
const reviewSumRef = useRef(null);
|
|
442
132
|
const editorApiRef = useRef(null);
|
|
443
|
-
const lastSel = useRef('');
|
|
444
133
|
const histRef = useRef(new Map());
|
|
445
|
-
const [dirty, setDirty] = useState(false);
|
|
446
|
-
// 验收条 ack:默认夹紧,过长可展开全文(任务 #20:长总结被 line-clamp 截断)
|
|
447
|
-
const [ackOpen, setAckOpen] = useState(false);
|
|
448
|
-
const [ackOverflow, setAckOverflow] = useState(false);
|
|
449
|
-
const ackLong = String(taskRow?.roundSummary || '').length > 140;
|
|
450
|
-
useEffect(() => {
|
|
451
|
-
setAckOpen(false);
|
|
452
|
-
setAckOverflow(false);
|
|
453
|
-
}, [id, taskRow?.roundSummary]);
|
|
454
|
-
useLayoutEffect(() => {
|
|
455
|
-
const el = reviewSumRef.current;
|
|
456
|
-
if (!el) {
|
|
457
|
-
setAckOverflow(false);
|
|
458
|
-
return undefined;
|
|
459
|
-
}
|
|
460
|
-
// -webkit-line-clamp 下首帧 scrollHeight 偶发等于 clientHeight——用 ResizeObserver
|
|
461
|
-
// + rAF 再量一次;长文案另有字符数兜底,避免按钮永远不出现。
|
|
462
|
-
const measure = () => {
|
|
463
|
-
if (ackOpen) return;
|
|
464
|
-
setAckOverflow(el.scrollHeight > el.clientHeight + 1);
|
|
465
|
-
};
|
|
466
|
-
measure();
|
|
467
|
-
const raf = requestAnimationFrame(measure);
|
|
468
|
-
const ro = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(measure) : null;
|
|
469
|
-
ro?.observe(el);
|
|
470
|
-
return () => {
|
|
471
|
-
cancelAnimationFrame(raf);
|
|
472
|
-
ro?.disconnect();
|
|
473
|
-
};
|
|
474
|
-
}, [ackOpen, taskRow?.roundSummary, taskRow?.completedAt, dockTab, dockOpen]);
|
|
475
134
|
|
|
476
135
|
// 阅读视图:剥掉首个一级标题行——它就是文档标题(页头已渲染),正文再渲染一遍是重复
|
|
477
136
|
const previewHtml = useMemo(
|
|
@@ -485,12 +144,7 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
485
144
|
);
|
|
486
145
|
|
|
487
146
|
// ack 定位轨(任务 #48):反复 ack 反馈的长任务页,按轮次快速跳转。
|
|
488
|
-
// 轮次从正文里抽(每轮一个「## 上一轮完成总结」段)——正文即历史,正文变了轨也跟着变。
|
|
489
147
|
const ackNodes = useMemo(() => (doc ? extractAckNodes(doc.body) : []), [doc && doc.body]);
|
|
490
|
-
// 滚动容器:实时预览是 .mdw-lp(可滚),阅读态是 .mdw-preview。
|
|
491
|
-
// ⚠️ articleRef 指的是 **.mdw-lp-sheet**(live)/ **article**(阅读),两者都是
|
|
492
|
-
// 滚动容器的**子节点**——要往上找(closest),不是往下查(querySelector)。
|
|
493
|
-
// 两种态的 DOM 形状不同,轨内部按态分别定位(见 ack-rail.jsx 的 blockAt)。
|
|
494
148
|
const [ackScrollRoot, setAckScrollRoot] = useState(null);
|
|
495
149
|
useEffect(() => {
|
|
496
150
|
const root = articleRef.current;
|
|
@@ -502,243 +156,54 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
502
156
|
return () => mo?.disconnect();
|
|
503
157
|
}, [doc && doc.mode]);
|
|
504
158
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
lastSel.current = '';
|
|
508
|
-
}, [id]);
|
|
509
|
-
|
|
510
|
-
useEffect(() => {
|
|
511
|
-
// 滚动收起浮层
|
|
512
|
-
const close = () => setSelMenu(null);
|
|
513
|
-
document.addEventListener('scroll', close, true);
|
|
514
|
-
return () => document.removeEventListener('scroll', close, true);
|
|
515
|
-
}, []);
|
|
516
|
-
|
|
517
|
-
const guard = (fn) => fn().catch((e) => toast(String(e.message || e)));
|
|
518
|
-
|
|
519
|
-
// 工具栏「进程」:面板化之后进程不再是内嵌右侧栏,而是工作区里独立的一块
|
|
520
|
-
// (可拖动 / 可浮出 / 可单独关掉)。已开着同一目录的进程面板就聚焦它,不重复开。
|
|
521
|
-
// 注意 config 要带上 dirKey:进程面板是按**目录**取任务的,缺了会落到全局池。
|
|
522
|
-
// 任务带工作组语义(frontmatter.board,任务 #56)→ 进程按**组**聚合打开:
|
|
523
|
-
// 组发布的任务散在成员项目各自的队列里,单目录视图看不见全景。
|
|
524
|
-
const openProgress = () => {
|
|
525
|
-
const m = model || app.model;
|
|
526
|
-
if (!m) return;
|
|
527
|
-
const boardId = docFm && docFm.board ? String(docFm.board) : '';
|
|
528
|
-
openPanel(m, {
|
|
529
|
-
component: 'progress',
|
|
530
|
-
name: '进程',
|
|
531
|
-
config: boardId
|
|
532
|
-
? { groupKey: boardId, task: task != null ? String(task) : undefined }
|
|
533
|
-
: { dirKey: topicKey || GLOBAL_KEY, task: task != null ? String(task) : undefined },
|
|
534
|
-
location: 'right',
|
|
535
|
-
});
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
/** 评论任务:在主区右侧并排打开原文(可单独关掉;不改路由) */
|
|
539
|
-
const openParentBeside = useCallback(() => {
|
|
540
|
-
if (!parentRef) {
|
|
541
|
-
toast('这条任务没有可定位的原文');
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
const m = model || app.model;
|
|
545
|
-
if (!m) return;
|
|
546
|
-
openBesideMain(m, {
|
|
547
|
-
component: 'page',
|
|
548
|
-
name: parentRef.name || `原文 ${parentRef.task}`,
|
|
549
|
-
config: { dirKey: parentRef.dirKey, task: String(parentRef.task) },
|
|
550
|
-
});
|
|
551
|
-
}, [parentRef, model, app.model, toast]);
|
|
552
|
-
|
|
553
|
-
/** 任务链节点 → 旁路查看:history 快照 / 祖先或子任务正文 */
|
|
554
|
-
const openHistoryBeside = useCallback(
|
|
555
|
-
(node) => {
|
|
556
|
-
const m = model || app.model;
|
|
557
|
-
if (!m || isDraft) return;
|
|
558
|
-
if (node?.current) {
|
|
559
|
-
toast('当前节点就是本页');
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
562
|
-
// 同任务 history 快照
|
|
563
|
-
if (node?.historyId != null) {
|
|
564
|
-
openBesideMain(m, {
|
|
565
|
-
component: 'page',
|
|
566
|
-
name: `链 #${task} · ${node.kind || node.historyId}`,
|
|
567
|
-
config: {
|
|
568
|
-
dirKey: topicKey || GLOBAL_KEY,
|
|
569
|
-
task: String(task),
|
|
570
|
-
historyId: Number(node.historyId),
|
|
571
|
-
},
|
|
572
|
-
});
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
// fork 祖先 / 子任务:打开对应任务页(旁路)
|
|
576
|
-
if (node?.taskId != null && node?.dirKey) {
|
|
577
|
-
openBesideMain(m, {
|
|
578
|
-
component: 'page',
|
|
579
|
-
name: node.excerpt ? String(node.excerpt).slice(0, 24) : `#${node.taskId}`,
|
|
580
|
-
config: { dirKey: String(node.dirKey), task: String(node.taskId) },
|
|
581
|
-
});
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
toast('这个节点没有可打开的内容');
|
|
585
|
-
},
|
|
586
|
-
[model, app.model, isDraft, topicKey, task, toast],
|
|
587
|
-
);
|
|
159
|
+
const guard = useCallback((fn) => fn().catch((e) => toast(String(e.message || e))), [toast]);
|
|
160
|
+
const markDirty = useCallback(() => setDirty(true), []);
|
|
588
161
|
|
|
589
|
-
const
|
|
590
|
-
const m = model || app.model;
|
|
591
|
-
if (!m || !tabId) return;
|
|
592
|
-
m.doAction(Actions.deleteTab(tabId));
|
|
593
|
-
}, [model, app.model, tabId]);
|
|
162
|
+
const { docFm, parentRef, boardCtx } = useDerivedCtx({ doc, beside, topicKey, topic, task, app });
|
|
594
163
|
|
|
595
|
-
//
|
|
596
|
-
const [chainApi, setChainApi] = useState(null);
|
|
164
|
+
// 首开这一页时把内容「种」进去:真实任务用服务端正文,草稿用默认模板
|
|
597
165
|
useEffect(() => {
|
|
598
|
-
if (
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
: `cwd=${encodeURIComponent(topic?.cwd || '')}&id=${Number(task)}`;
|
|
606
|
-
api(`/api/localtasks/chain?${q}`)
|
|
607
|
-
.then((d) => {
|
|
608
|
-
if (!cancelled) setChainApi(d);
|
|
609
|
-
})
|
|
610
|
-
.catch(() => {
|
|
611
|
-
if (!cancelled) setChainApi(null);
|
|
612
|
-
});
|
|
613
|
-
return () => {
|
|
614
|
-
cancelled = true;
|
|
615
|
-
};
|
|
616
|
-
}, [isDraft, task, isGlobal, topic?.cwd, taskRow?.history?.length, taskRow?.forkOf, taskRow?.reopenCount]);
|
|
617
|
-
|
|
618
|
-
const chainNodes = useMemo(() => {
|
|
619
|
-
if (isDraft || !taskRow) return [];
|
|
620
|
-
const tip =
|
|
621
|
-
String(taskRow.text || '')
|
|
622
|
-
.split('\n')
|
|
623
|
-
.map((l) => l.trim())
|
|
624
|
-
.find(Boolean) || '';
|
|
625
|
-
const tipEx = tip.replace(/^#+\s*/, '').slice(0, 100);
|
|
626
|
-
|
|
627
|
-
// 1) 同任务 history 链
|
|
628
|
-
const hist = Array.isArray(taskRow.history) ? taskRow.history : [];
|
|
629
|
-
if (hist.length) {
|
|
630
|
-
const nodes = hist.map((h) => ({
|
|
631
|
-
historyId: h.id,
|
|
632
|
-
kind: h.kind,
|
|
633
|
-
at: h.at,
|
|
634
|
-
excerpt: h.excerpt || h.feedback || '',
|
|
635
|
-
feedback: h.feedback,
|
|
636
|
-
quote: h.quote,
|
|
637
|
-
attachmentCount: (h.attachments || []).length,
|
|
638
|
-
current: false,
|
|
639
|
-
}));
|
|
640
|
-
nodes.push({
|
|
641
|
-
historyId: null,
|
|
642
|
-
kind: 'current',
|
|
643
|
-
at: taskRow.lastReopenedAt || taskRow.createdAt || '',
|
|
644
|
-
excerpt: tipEx,
|
|
645
|
-
attachmentCount: 0,
|
|
646
|
-
current: true,
|
|
647
|
-
});
|
|
648
|
-
return nodes;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
// 2) fork 派生链(祖先 → 本条 → 子任务)
|
|
652
|
-
const ancestors = Array.isArray(chainApi?.ancestors) ? [...chainApi.ancestors].reverse() : [];
|
|
653
|
-
const children = Array.isArray(chainApi?.children) ? chainApi.children : [];
|
|
654
|
-
if (!ancestors.length && !children.length && !taskRow.forkOf) return [];
|
|
655
|
-
const nodes = [];
|
|
656
|
-
for (const a of ancestors) {
|
|
657
|
-
if (a.missing) continue;
|
|
658
|
-
nodes.push({
|
|
659
|
-
historyId: null,
|
|
660
|
-
kind: a.forkKind || 'origin',
|
|
661
|
-
at: a.createdAt || '',
|
|
662
|
-
excerpt: a.excerpt || `#${a.id}`,
|
|
663
|
-
attachmentCount: 0,
|
|
664
|
-
current: false,
|
|
665
|
-
taskId: a.id,
|
|
666
|
-
dirKey: a.key,
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
nodes.push({
|
|
670
|
-
historyId: null,
|
|
671
|
-
kind: 'current',
|
|
672
|
-
at: taskRow.createdAt || '',
|
|
673
|
-
excerpt: tipEx,
|
|
674
|
-
attachmentCount: 0,
|
|
675
|
-
current: true,
|
|
676
|
-
taskId: Number(task),
|
|
677
|
-
dirKey: topicKey || GLOBAL_KEY,
|
|
678
|
-
});
|
|
679
|
-
for (const c of children) {
|
|
680
|
-
nodes.push({
|
|
681
|
-
historyId: null,
|
|
682
|
-
kind: c.forkKind || 'comment',
|
|
683
|
-
at: c.createdAt || '',
|
|
684
|
-
excerpt: c.excerpt || `#${c.id}`,
|
|
685
|
-
attachmentCount: 0,
|
|
686
|
-
current: false,
|
|
687
|
-
taskId: c.id,
|
|
688
|
-
dirKey: c.key,
|
|
166
|
+
if (docs[id]) return;
|
|
167
|
+
if (isDraft) {
|
|
168
|
+
getDoc(id, {
|
|
169
|
+
title: '',
|
|
170
|
+
body: tpl
|
|
171
|
+
? (groupAnchored ? withFrontmatter(tpl.defaultBody(), { board: groupId }) : tpl.defaultBody())
|
|
172
|
+
: '',
|
|
689
173
|
});
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
return nodes;
|
|
693
|
-
}, [isDraft, taskRow, chainApi, task, topicKey]);
|
|
174
|
+
} else if (taskRow) getDoc(id, { title: titleFromMd(taskRow.text), body: taskRow.text });
|
|
175
|
+
}, [id, isDraft, taskRow, groupAnchored, groupId]);
|
|
694
176
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
177
|
+
// ─── 动作钩子 ───
|
|
178
|
+
const actions = useTaskActions({
|
|
179
|
+
doc, id, isDraft, task, taskRow, topicKey, topic, isGlobal, boardCtx, docFm,
|
|
180
|
+
groupAnchored, groupId, rows, app, model, tabId, tpl, refreshLocal,
|
|
181
|
+
markDirty, histRef, editorApiRef, attachAreaRef,
|
|
182
|
+
setDirty,
|
|
183
|
+
goal, goalEditable, declaredGoal, guard, dialog, showDockTab,
|
|
184
|
+
});
|
|
185
|
+
const { composeText, submit, importMd, delTask, canClosePending, closeTask, addFiles, newTask, cloneCur, forkCur, openProgress, openAttachPanel } = actions;
|
|
700
186
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
const
|
|
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]);
|
|
187
|
+
const feedback = useFeedback({
|
|
188
|
+
doc, isDraft, task, taskRow, topicKey, topic, isGlobal, dirKey,
|
|
189
|
+
groupAnchored, groupId, app, model, tabId, refreshLocal,
|
|
190
|
+
closeSelMenu, lastSel, selMenu, dirty, setDirty, guard,
|
|
191
|
+
});
|
|
192
|
+
const { openFeedback, submitCommentInPlace, openCommentFromToolbar } = feedback;
|
|
716
193
|
|
|
717
|
-
|
|
194
|
+
// ─── 时间目标 UI(#78)───
|
|
195
|
+
const openGoalLog = useCallback(() => {
|
|
196
|
+
showDockTab('check');
|
|
197
|
+
loadGoalLog();
|
|
198
|
+
}, [showDockTab, loadGoalLog]);
|
|
718
199
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
const fm = parseFrontmatter(bodyText);
|
|
723
|
-
const hasFm = Object.keys(fm).length > 0;
|
|
724
|
-
let bare = stripFrontmatter(bodyText);
|
|
725
|
-
// 幻影空块清洗(#92):块编辑器的 ZWSP 空块不落库——落库即「一段莫名空白」,
|
|
726
|
-
// 下次打开还在、再编辑又攒一条。编辑会话内不受影响(清洗只在保存组合时跑)。
|
|
727
|
-
bare = stripPhantomEmptyLines(bare);
|
|
728
|
-
if (!/^#\s+/m.test(bare)) bare = `# ${t}\n\n${bare}`;
|
|
729
|
-
else bare = bare.replace(/^#\s+.+$/m, `# ${t}`);
|
|
730
|
-
return hasFm ? withFrontmatter(bare, fm) : bare;
|
|
731
|
-
};
|
|
200
|
+
const { goalBadge, goalMenu } = goalSection({
|
|
201
|
+
goal, goalDraft, setGoalDraft, goalEditable, declaredGoal, openGoalLog, markDirty, task,
|
|
202
|
+
});
|
|
732
203
|
|
|
733
204
|
// ─── 预览提示词(任务 #65)───
|
|
734
|
-
// 工具栏「更多 → 预览提示词」:把 agent 执行 get 时会收到的**原文**摆出来。
|
|
735
|
-
// 后端是只读接口(不领取 / 不写盘 / 不启动时间目标计时 / 不为附件发网),
|
|
736
|
-
// 排版与 CLI 取任务共用 tasktool/delivery-text.js 同一份代码。
|
|
737
|
-
const [preview, setPreview] = useState(null); // null | {busy} | {error} | {data}
|
|
738
205
|
const openPreview = useCallback(() => {
|
|
739
206
|
setPreview({ busy: true });
|
|
740
|
-
// 草稿还没落库:把编辑器里的正文送去渲染(走与提交相同的 composeText,
|
|
741
|
-
// 标题行 / frontmatter 的位置与真实落库一致,预览才不会假装干净)。
|
|
742
207
|
const body = {
|
|
743
208
|
cwd: isGlobal ? (topic?.cwd || undefined) : topic?.cwd,
|
|
744
209
|
key: isGlobal ? GLOBAL_KEY : topicKey,
|
|
@@ -749,391 +214,9 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
749
214
|
api('/api/localtasks/preview', { method: 'POST', body })
|
|
750
215
|
.then((d) => setPreview({ data: d }))
|
|
751
216
|
.catch((e) => setPreview({ error: String(e.message || e) }));
|
|
752
|
-
}, [isGlobal, topic?.cwd, topicKey, isDraft, doc?.title, doc?.body, task]);
|
|
753
|
-
|
|
754
|
-
// ─── 保存 / 提交 ───
|
|
755
|
-
// 时间目标的落库口径:草稿 → POST 带 duration/goalPrompt(后端 sanitize 校验写法);
|
|
756
|
-
// 已有任务 → 与服务端声明比对,有变化才发(duration 空 = 清除,clearGoal);
|
|
757
|
-
// 只写附加要求不写时长是非法声明,发布端就拦下。
|
|
758
|
-
const goalPatchOf = () => {
|
|
759
|
-
const duration = (goal.duration || '').trim();
|
|
760
|
-
const prompt = (goal.prompt || '').trim();
|
|
761
|
-
if (prompt && !duration) return { error: '时间目标要填时长(如 2h / 90m);只写附加要求无效' };
|
|
762
|
-
if (!goalEditable) return {};
|
|
763
|
-
if (!isDraft) {
|
|
764
|
-
const prevDur = declaredGoal?.duration || '';
|
|
765
|
-
const prevPrompt = declaredGoal?.prompt || '';
|
|
766
|
-
if (duration === prevDur && prompt === prevPrompt) return {};
|
|
767
|
-
return duration ? { duration, goalPrompt: prompt } : { clearGoal: true };
|
|
768
|
-
}
|
|
769
|
-
return duration ? { duration, goalPrompt: prompt } : {};
|
|
770
|
-
};
|
|
217
|
+
}, [isGlobal, topic?.cwd, topicKey, isDraft, doc?.title, doc?.body, task, composeText]);
|
|
771
218
|
|
|
772
|
-
|
|
773
|
-
if (!doc) return;
|
|
774
|
-
const t = (doc.title || '').trim() || '未命名任务';
|
|
775
|
-
// frontmatter 在文件头(组任务的工作组/项目语义),标题行要插在它**后面**——
|
|
776
|
-
// 剥出来处理再原样放回,保持 `---` 块始终在最前。
|
|
777
|
-
const fm = parseFrontmatter(doc.body);
|
|
778
|
-
const b = composeText(t, doc.body);
|
|
779
|
-
// 归属项目路由:frontmatter.project 指向本组成员 → 提交/同步走那个项目的队列
|
|
780
|
-
// (草稿可能挂在默认项目的 scope 下,提交落点以归属项目为准)。
|
|
781
|
-
const projTopic = fm.project
|
|
782
|
-
? rows.find((r) => !r.isGlobal && r.repo && r.repo.key === fm.project)
|
|
783
|
-
: null;
|
|
784
|
-
// 组任务走与 CLI 同一条**严格口径**:显式交 board/project,服务端校验成员资格并
|
|
785
|
-
// 按项目登记路径路由(proj-a 还没有队列主题时也能落对地方——这正是组面板建任务
|
|
786
|
-
// 的常态)。认不出组(rows 未就绪 / 成员已变)但认得出 project 时,交 project 走
|
|
787
|
-
// 项目口径;服务端统一推导落点,面板不再自己判队列。
|
|
788
|
-
const groupSubmit = !!(boardCtx && fm.project &&
|
|
789
|
-
boardCtx.members.some((m) => m.key === fm.project));
|
|
790
|
-
const gp = goalPatchOf();
|
|
791
|
-
if (gp.error) {
|
|
792
|
-
toast(gp.error);
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
if (!isDraft) {
|
|
796
|
-
const res = await api('/api/localtasks/item', {
|
|
797
|
-
method: 'PATCH',
|
|
798
|
-
body: {
|
|
799
|
-
cwd: isGlobal ? (projTopic ? projTopic.cwd : undefined) : topic?.cwd,
|
|
800
|
-
key: isGlobal && !projTopic ? GLOBAL_KEY : undefined,
|
|
801
|
-
id: Number(task),
|
|
802
|
-
text: b,
|
|
803
|
-
...gp,
|
|
804
|
-
},
|
|
805
|
-
});
|
|
806
|
-
// 归属改了会搬家(服务端按 frontmatter.project 落到新项目队列,任务 #43)——
|
|
807
|
-
// 页签与文档跟过去(同「草稿提交落点跟到真实主题」一套),不然这页还开着旧队列的旧号。
|
|
808
|
-
// 组锚定页(#86)保持组锚:任务还是本组的,只是换了个成员队列。
|
|
809
|
-
if (res?.moved) {
|
|
810
|
-
const landedKey = res.key || topicKey;
|
|
811
|
-
const newId = String(res.task?.id ?? task);
|
|
812
|
-
const newDocId = docIdOf(scopeOf(landedKey), newId);
|
|
813
|
-
persistAtt(newId, doc.attachments);
|
|
814
|
-
promoteDoc(id, newDocId, { title: t, body: res.task?.text || b });
|
|
815
|
-
if (model && tabId) {
|
|
816
|
-
model.doAction(Actions.updateNodeAttributes(tabId, {
|
|
817
|
-
config: groupAnchored ? { groupId, task: newId } : { dirKey: landedKey, task: newId },
|
|
818
|
-
}));
|
|
819
|
-
}
|
|
820
|
-
// 地址跟页签一起走(同「草稿转正」——刷新不能落在搬家前的旧号上)
|
|
821
|
-
app.onNavigate && app.onNavigate(
|
|
822
|
-
groupAnchored
|
|
823
|
-
? `#/group/${encodeURIComponent(groupId || '')}?task=${encodeURIComponent(newId)}`
|
|
824
|
-
: `#/dir/${encodeURIComponent(landedKey || '')}?task=${encodeURIComponent(newId)}`
|
|
825
|
-
);
|
|
826
|
-
setDirty(false);
|
|
827
|
-
clearHistory(histRef.current, newDocId);
|
|
828
|
-
toast(`已改归属项目:任务迁到「${res.name}」#${newId}`);
|
|
829
|
-
refreshLocal();
|
|
830
|
-
return;
|
|
831
|
-
}
|
|
832
|
-
persistAtt(task, doc.attachments);
|
|
833
|
-
saveDoc(id, { title: t, body: b });
|
|
834
|
-
setDirty(false);
|
|
835
|
-
clearHistory(histRef.current, id);
|
|
836
|
-
toast(gp.clearGoal ? '已同步 MD · 时间目标已清除' : gp.duration ? '已同步 MD · 时间目标已更新' : '已同步 MD');
|
|
837
|
-
refreshLocal();
|
|
838
|
-
return;
|
|
839
|
-
}
|
|
840
|
-
// 草稿 → 提交成任务:换身份(页签的 config 跟着改,内容搬到新任务号下)
|
|
841
|
-
const res = await api('/api/localtasks', {
|
|
842
|
-
method: 'POST',
|
|
843
|
-
body: {
|
|
844
|
-
// 落点判定交给服务端统一口径(tasktool/add.js 的 submitTask 一份实现):
|
|
845
|
-
// 组 → 严格 board+project;只认出 frontmatter.project → 项目口径(服务端
|
|
846
|
-
// 校验登记并推导落点);都没有 → 当前 scope(全局池 / 本目录队列)。
|
|
847
|
-
...(groupSubmit
|
|
848
|
-
? { text: b, board: boardCtx.board.id, project: fm.project }
|
|
849
|
-
: fm.project
|
|
850
|
-
? { text: b, project: fm.project }
|
|
851
|
-
: isGlobal
|
|
852
|
-
? { global: true, text: b }
|
|
853
|
-
: { cwd: topic?.cwd, text: b }),
|
|
854
|
-
...gp,
|
|
855
|
-
},
|
|
856
|
-
});
|
|
857
|
-
const newId = res?.task?.id ?? res?.id;
|
|
858
|
-
if (newId != null) {
|
|
859
|
-
// 落点 = 服务端返回的真实主题 key(组任务按 project 推导,可能是别的项目/目录)。
|
|
860
|
-
// 页签与文档都跟到真实落点——不然页签开着旧 scope,却指向别的队列里的任务号。
|
|
861
|
-
// 组锚定页保持组锚(#86):提交后的实任务带 boardMark,组路由照样解析得回;
|
|
862
|
-
// 文档搬去队列 scope(与目录页打开同一任务共享一份)。
|
|
863
|
-
const landedKey = res?.key || topicKey;
|
|
864
|
-
const landedScope = scopeOf(landedKey);
|
|
865
|
-
persistAtt(newId, doc.attachments);
|
|
866
|
-
const newDocId = docIdOf(landedScope, String(newId));
|
|
867
|
-
promoteDoc(id, newDocId, { title: t, body: b });
|
|
868
|
-
// 页签的 config 换成新任务(否则刷新后还认着 draft 号);地址跟着走——
|
|
869
|
-
// 不然刷新还落在旧 draft 号上(那份草稿已转正搬走,会开出一份空壳新草稿)
|
|
870
|
-
if (model && tabId) {
|
|
871
|
-
model.doAction(Actions.updateNodeAttributes(tabId, {
|
|
872
|
-
config: groupAnchored ? { groupId, task: String(newId) } : { dirKey: landedKey, task: String(newId) },
|
|
873
|
-
}));
|
|
874
|
-
}
|
|
875
|
-
app.onNavigate && app.onNavigate(
|
|
876
|
-
groupAnchored
|
|
877
|
-
? `#/group/${encodeURIComponent(groupId || '')}?task=${encodeURIComponent(String(newId))}`
|
|
878
|
-
: `#/dir/${encodeURIComponent(landedKey || '')}?task=${encodeURIComponent(String(newId))}`
|
|
879
|
-
);
|
|
880
|
-
setDirty(false);
|
|
881
|
-
clearHistory(histRef.current, newDocId);
|
|
882
|
-
}
|
|
883
|
-
toast(`已提交:${slugName(t)}`);
|
|
884
|
-
refreshLocal();
|
|
885
|
-
});
|
|
886
|
-
|
|
887
|
-
// ─── 导入 .md(建一个任务,并开它的页签)───
|
|
888
|
-
const importMd = async (file) => {
|
|
889
|
-
const text = await file.text();
|
|
890
|
-
const name = file.name.replace(/\.md$/i, '');
|
|
891
|
-
await guard(async () => {
|
|
892
|
-
const bodyText = text.startsWith('#') ? text : `# ${name}\n\n${text}`;
|
|
893
|
-
const res = await api('/api/localtasks', {
|
|
894
|
-
method: 'POST',
|
|
895
|
-
// 组锚定页(#86):按归属项目落队(与提交同一口径——组草稿页 topic 还没解析,
|
|
896
|
-
// cwd 寻不到);目录/全局页维持 cwd / 全局池。
|
|
897
|
-
body: isGlobal
|
|
898
|
-
? { global: true, text: bodyText }
|
|
899
|
-
: groupAnchored && docFm.project
|
|
900
|
-
? { project: docFm.project, text: bodyText }
|
|
901
|
-
: { cwd: topic?.cwd, text: bodyText },
|
|
902
|
-
});
|
|
903
|
-
toast(`已导入:${file.name}`);
|
|
904
|
-
refreshLocal();
|
|
905
|
-
const newId = res?.task?.id ?? res?.id;
|
|
906
|
-
if (newId != null && app.openPage) {
|
|
907
|
-
if (groupAnchored) app.openPage({ groupId, task: String(newId), name: `#${newId}` });
|
|
908
|
-
else app.openPage({ dirKey: topicKey, task: String(newId), name: `#${newId}` });
|
|
909
|
-
}
|
|
910
|
-
});
|
|
911
|
-
};
|
|
912
|
-
|
|
913
|
-
// ─── 删除本页(软删除)───
|
|
914
|
-
const delTask = async () => {
|
|
915
|
-
if (!doc || isDraft) return;
|
|
916
|
-
const title = doc.title || `#${task}`;
|
|
917
|
-
const ok = await dialog({
|
|
918
|
-
title: `删除任务「${title}」`,
|
|
919
|
-
message: '软删除:CLI localtask task restore 可恢复。',
|
|
920
|
-
danger: true,
|
|
921
|
-
okText: '删除',
|
|
922
|
-
});
|
|
923
|
-
if (!ok) return;
|
|
924
|
-
guard(async () => {
|
|
925
|
-
await api('/api/localtasks/item', {
|
|
926
|
-
method: 'DELETE',
|
|
927
|
-
body: isGlobal ? { key: GLOBAL_KEY, id: Number(task) } : { cwd: topic.cwd, id: Number(task) },
|
|
928
|
-
});
|
|
929
|
-
toast(`已删除「${title}」`);
|
|
930
|
-
if (model && tabId) model.doAction(Actions.deleteTab(tabId));
|
|
931
|
-
refreshLocal();
|
|
932
|
-
});
|
|
933
|
-
};
|
|
934
|
-
|
|
935
|
-
// ─── #75 待领取任务直接收口(不要求先领取)───
|
|
936
|
-
const canClosePending = !isDraft && !!taskRow && taskRow.status === 'pending';
|
|
937
|
-
const closeTask = (kind) => {
|
|
938
|
-
if (!canClosePending) return;
|
|
939
|
-
guard(async () => {
|
|
940
|
-
const title = doc?.title || `#${task}`;
|
|
941
|
-
const scope = isGlobal ? { key: GLOBAL_KEY } : { cwd: topic?.cwd };
|
|
942
|
-
if (kind === 'done') {
|
|
943
|
-
const summary = await dialog({
|
|
944
|
-
title: `标为完成「${title}」`,
|
|
945
|
-
message: '任务还没被领取。确认把当前正文视为已完成?可写一句完成总结。',
|
|
946
|
-
input: true,
|
|
947
|
-
placeholder: '完成总结(可选;留空使用默认说明)',
|
|
948
|
-
okText: '标为完成',
|
|
949
|
-
});
|
|
950
|
-
if (summary === null || summary === undefined) return;
|
|
951
|
-
await api('/api/localtasks/items/close', {
|
|
952
|
-
method: 'POST',
|
|
953
|
-
body: { ...scope, ids: [Number(task)], status: 'done', summary: String(summary).trim() },
|
|
954
|
-
});
|
|
955
|
-
toast(`已标为完成 #${task}`);
|
|
956
|
-
} else {
|
|
957
|
-
const ok = await dialog({
|
|
958
|
-
title: `取消任务「${title}」`,
|
|
959
|
-
message: '只处理待领取任务。取消为终态,原文留档。',
|
|
960
|
-
danger: true,
|
|
961
|
-
okText: '取消任务',
|
|
962
|
-
});
|
|
963
|
-
if (!ok) return;
|
|
964
|
-
await api('/api/localtasks/items/close', {
|
|
965
|
-
method: 'POST',
|
|
966
|
-
body: { ...scope, ids: [Number(task)], status: 'cancelled' },
|
|
967
|
-
});
|
|
968
|
-
toast(`已取消 #${task}`);
|
|
969
|
-
}
|
|
970
|
-
refreshLocal();
|
|
971
|
-
});
|
|
972
|
-
};
|
|
973
|
-
|
|
974
|
-
const addFiles = async (fileList, opts = {}) => {
|
|
975
|
-
if (!doc) return;
|
|
976
|
-
// 本机仓优先:图片嵌在光标处、文件追加文尾(嵌入即附件,正文随任务走);
|
|
977
|
-
// 本机仓不可达时 items 带 dataURL 走 localStorage 老路(fileInserts 为空)。
|
|
978
|
-
const { items, imageInserts, fileInserts } = await filesToAttachments(fileList);
|
|
979
|
-
// 上传是异步的——await 后读最新会话文档,避免并发贴图/输入用陈旧正文覆盖。
|
|
980
|
-
const cur = peekDoc(id) || doc;
|
|
981
|
-
const b = cur.body || '';
|
|
982
|
-
const imgIns = imageInserts.join('');
|
|
983
|
-
let body = b;
|
|
984
|
-
let caretAt = null;
|
|
985
|
-
if (imgIns) {
|
|
986
|
-
const placed = insertAttachmentSnippet(b, imgIns, opts);
|
|
987
|
-
body = placed.body;
|
|
988
|
-
caretAt = placed.insertAt + imgIns.length;
|
|
989
|
-
}
|
|
990
|
-
if (fileInserts.length) {
|
|
991
|
-
body = insertAttachmentSnippet(body, fileInserts.join(''), {}).body;
|
|
992
|
-
}
|
|
993
|
-
const patch = {};
|
|
994
|
-
if (body !== b) patch.body = body;
|
|
995
|
-
if (items.length) patch.attachments = [...(cur.attachments || []), ...items];
|
|
996
|
-
if (!Object.keys(patch).length) return;
|
|
997
|
-
saveDoc(id, patch);
|
|
998
|
-
if (opts.mode === 'edit' && caretAt != null) {
|
|
999
|
-
requestAnimationFrame(() => {
|
|
1000
|
-
editorApiRef.current?.focus?.();
|
|
1001
|
-
const ta = document.querySelector('.mdw-editor');
|
|
1002
|
-
if (ta) {
|
|
1003
|
-
try { ta.setSelectionRange(caretAt, caretAt); } catch { /* ignore */ }
|
|
1004
|
-
}
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
// 已落库任务:贴图即同步——agent 领取只认服务端正文里的 ,
|
|
1008
|
-
// 不能等用户再点「保存并同步」(否则仓里有图、attachments count 仍是 0)。
|
|
1009
|
-
if (!isDraft) {
|
|
1010
|
-
if (patch.attachments) persistAtt(task, patch.attachments);
|
|
1011
|
-
const synced = composeText(cur.title, patch.body || body);
|
|
1012
|
-
saveDoc(id, { body: synced, title: titleFromMd(synced) });
|
|
1013
|
-
try {
|
|
1014
|
-
await api('/api/localtasks/item', {
|
|
1015
|
-
method: 'PATCH',
|
|
1016
|
-
body: {
|
|
1017
|
-
cwd: isGlobal ? undefined : topic?.cwd,
|
|
1018
|
-
key: isGlobal ? GLOBAL_KEY : undefined,
|
|
1019
|
-
id: Number(task),
|
|
1020
|
-
text: synced,
|
|
1021
|
-
},
|
|
1022
|
-
});
|
|
1023
|
-
setDirty(false);
|
|
1024
|
-
refreshLocal();
|
|
1025
|
-
toast(items.length ? `已添加附件并同步(${items.length})` : '已同步附件');
|
|
1026
|
-
} catch (e) {
|
|
1027
|
-
markDirty();
|
|
1028
|
-
toast(`附件已插入,同步失败:${e.message || e}`);
|
|
1029
|
-
}
|
|
1030
|
-
return;
|
|
1031
|
-
}
|
|
1032
|
-
markDirty();
|
|
1033
|
-
};
|
|
1034
|
-
|
|
1035
|
-
const closeSelMenu = () => {
|
|
1036
|
-
setSelMenu(null);
|
|
1037
|
-
lastSel.current = '';
|
|
1038
|
-
};
|
|
1039
|
-
|
|
1040
|
-
/** 「更多 → 新任务」:新草稿**带着当前上下文**(工作组 + 归属项目)。
|
|
1041
|
-
*
|
|
1042
|
-
* 原来这里只是开一个新页签(nextDraftId),草稿正文是空模板、**没有 frontmatter**——
|
|
1043
|
-
* 于是「在组内的任务里新建任务」会丢掉归属:新任务落进本目录队列,而不是组里那个
|
|
1044
|
-
* 项目(任务 #64:「创建新任务会丢失相关的一个上下文」)。
|
|
1045
|
-
*
|
|
1046
|
-
* 现在与组页「新增任务」同一套口径:正文 = 模板默认正文 + frontmatter(board/project)。
|
|
1047
|
-
*/
|
|
1048
|
-
const newTask = () => {
|
|
1049
|
-
const draftId = nextDraftId();
|
|
1050
|
-
// 草稿 doc 的 scope:组锚定页种在**组 scope**(与组页「新增任务」同一套,
|
|
1051
|
-
// 组路由寻得回,#86);目录页种在本目录 scope
|
|
1052
|
-
const docId = docIdOf(groupAnchored ? scopeOf(groupId) : scopeOf(topicKey), draftId);
|
|
1053
|
-
const fm = {};
|
|
1054
|
-
if (boardCtx && boardCtx.board && boardCtx.board.id) fm.board = boardCtx.board.id;
|
|
1055
|
-
if (docFm.project) fm.project = docFm.project;
|
|
1056
|
-
saveDoc(docId, {
|
|
1057
|
-
title: '',
|
|
1058
|
-
body: withFrontmatter(tpl ? tpl.defaultBody() : '', fm),
|
|
1059
|
-
});
|
|
1060
|
-
app.openPage && app.openPage(
|
|
1061
|
-
groupAnchored
|
|
1062
|
-
? { groupId, task: draftId, name: '新任务' }
|
|
1063
|
-
: { dirKey: topicKey, task: draftId, name: '新任务' }
|
|
1064
|
-
);
|
|
1065
|
-
};
|
|
1066
|
-
|
|
1067
|
-
/** 「更多 → 克隆任务」:以当前任务为模板快速复制一条新任务(#70)。
|
|
1068
|
-
* 只复制正文内容,**不带派生链**(forkOf 留空——那条语义属于评论/反馈派生),
|
|
1069
|
-
* 也不继承时间目标与依赖;源任务不动,克隆后两条并存。 */
|
|
1070
|
-
const cloneCur = () => {
|
|
1071
|
-
if (isDraft || task == null || /^draft/i.test(String(task))) {
|
|
1072
|
-
toast('草稿没有可克隆的队列任务');
|
|
1073
|
-
return;
|
|
1074
|
-
}
|
|
1075
|
-
guard(async () => {
|
|
1076
|
-
const res = await api('/api/localtasks/clone', {
|
|
1077
|
-
method: 'POST',
|
|
1078
|
-
body: isGlobal ? { id: Number(task) } : { id: Number(task), cwd: topic?.cwd },
|
|
1079
|
-
});
|
|
1080
|
-
toast(`已克隆为新任务 #${res.task?.id ?? res.id}`);
|
|
1081
|
-
refreshLocal();
|
|
1082
|
-
const newId = res?.task?.id ?? res?.id;
|
|
1083
|
-
if (newId != null && app.openPage) {
|
|
1084
|
-
// 克隆连 FM 一起复制——组任务的克隆还是组任务,组锚定页就留在组里开
|
|
1085
|
-
if (groupAnchored) app.openPage({ groupId, task: String(newId), name: `${(doc?.title || '任务').slice(0, 30)}(克隆)` });
|
|
1086
|
-
else app.openPage({ dirKey: topicKey, task: String(newId), name: `${(doc?.title || '任务').slice(0, 30)}(克隆)` });
|
|
1087
|
-
}
|
|
1088
|
-
});
|
|
1089
|
-
};
|
|
1090
|
-
|
|
1091
|
-
/** 「更多 → Fork 任务」:clone 的原文复制 + 保留源任务链(#67)。
|
|
1092
|
-
* 与 clone 同文案、同不继承约束;区别只是新任务挂到源任务下(task_links),
|
|
1093
|
-
* 评论/反馈链在任务链弹窗里继续可见。 */
|
|
1094
|
-
const forkCur = () => {
|
|
1095
|
-
if (isDraft || task == null || /^draft/i.test(String(task))) {
|
|
1096
|
-
toast('草稿没有可 Fork 的队列任务');
|
|
1097
|
-
return;
|
|
1098
|
-
}
|
|
1099
|
-
guard(async () => {
|
|
1100
|
-
const res = await api('/api/localtasks/fork', {
|
|
1101
|
-
method: 'POST',
|
|
1102
|
-
body: isGlobal ? { id: Number(task) } : { id: Number(task), cwd: topic?.cwd },
|
|
1103
|
-
});
|
|
1104
|
-
toast(`已 Fork 为新任务 #${res.task?.id ?? res.id}(保留任务链)`);
|
|
1105
|
-
refreshLocal();
|
|
1106
|
-
const newId = res?.task?.id ?? res?.id;
|
|
1107
|
-
if (newId != null && app.openPage) {
|
|
1108
|
-
if (groupAnchored) app.openPage({ groupId, task: String(newId), name: `${(doc?.title || '任务').slice(0, 30)}(Fork)` });
|
|
1109
|
-
else app.openPage({ dirKey: topicKey, task: String(newId), name: `${(doc?.title || '任务').slice(0, 30)}(Fork)` });
|
|
1110
|
-
}
|
|
1111
|
-
});
|
|
1112
|
-
};
|
|
1113
|
-
|
|
1114
|
-
/** 工具栏「评论」:只用当前可见选区;**新开 md 编辑面板**(#104) */
|
|
1115
|
-
const openCommentFromToolbar = () => {
|
|
1116
|
-
const live = String(window.getSelection() || '').trim();
|
|
1117
|
-
const quote = live || (selMenu?.text ? String(selMenu.text) : '');
|
|
1118
|
-
if (!quote) {
|
|
1119
|
-
toast('先划选一段再评论');
|
|
1120
|
-
return;
|
|
1121
|
-
}
|
|
1122
|
-
lastSel.current = quote;
|
|
1123
|
-
const m = model || app.model;
|
|
1124
|
-
if (!m) return;
|
|
1125
|
-
openComposer(m, {
|
|
1126
|
-
mode: 'comment',
|
|
1127
|
-
quote,
|
|
1128
|
-
taskLabel: task != null ? '#' + task : '',
|
|
1129
|
-
taskTitle: String(doc?.title || '').replace(/^#+\s*/, ''),
|
|
1130
|
-
src: { dirKey: topicKey || dirKey || GLOBAL_KEY, task: String(task), name: `原文 #${task}` },
|
|
1131
|
-
onSubmit: (payload) => submitCommentInPlace({ ...payload, quote }),
|
|
1132
|
-
});
|
|
1133
|
-
closeSelMenu();
|
|
1134
|
-
};
|
|
1135
|
-
|
|
1136
|
-
/** 标题与正文首行 # 双向同步 */
|
|
219
|
+
// ─── 标题与正文双向同步 ───
|
|
1137
220
|
const onTitle = (next, kind = 'typing') => {
|
|
1138
221
|
if (!doc) return;
|
|
1139
222
|
pushHistory(histRef.current, id, { title: doc.title, body: doc.body }, kind);
|
|
@@ -1172,31 +255,9 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
1172
255
|
requestAnimationFrame(() => editorApiRef.current?.caretFromDiff?.(doc.body, snap.body));
|
|
1173
256
|
};
|
|
1174
257
|
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
kind,
|
|
1179
|
-
text,
|
|
1180
|
-
...extra,
|
|
1181
|
-
x: Math.min(window.innerWidth - 300, Math.max(8, x)),
|
|
1182
|
-
y: Math.min(window.innerHeight - 240, Math.max(8, y)),
|
|
1183
|
-
});
|
|
1184
|
-
};
|
|
1185
|
-
|
|
1186
|
-
const onEditorTextSel = (info) => {
|
|
1187
|
-
if (!info?.text || info.text.length < 1) {
|
|
1188
|
-
setSelMenu(null);
|
|
1189
|
-
return;
|
|
1190
|
-
}
|
|
1191
|
-
lastSel.current = info.text;
|
|
1192
|
-
setSelMenu({
|
|
1193
|
-
kind: 'format',
|
|
1194
|
-
text: info.text,
|
|
1195
|
-
x: Math.min(window.innerWidth - 300, Math.max(8, info.x)),
|
|
1196
|
-
y: Math.min(window.innerHeight - 240, Math.max(8, info.y)),
|
|
1197
|
-
});
|
|
1198
|
-
};
|
|
1199
|
-
|
|
258
|
+
// ─── 划选浮条(#124 跨块选区)───
|
|
259
|
+
// ⚠️ 测试断言依赖 task.jsx 内出现 blockRange / liveBodyBlocks(doc.body) / deleteBlockRange 字样,
|
|
260
|
+
// 故 onPreviewMouseUp 与 SelMenu 的 onCopy/onDelete 保持在本文件内联。
|
|
1200
261
|
const onPreviewMouseUp = (e) => {
|
|
1201
262
|
if (!doc || editorMode === 'edit') return;
|
|
1202
263
|
if (e.target.closest?.('#mdw-sel-menu')) return;
|
|
@@ -1213,7 +274,6 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
1213
274
|
}
|
|
1214
275
|
// 跨块选区(#124):两端落在不同视图块 → 记下触到的块区间,浮层多给
|
|
1215
276
|
// 「删除选区」(块粒度整段移除)与「复制」(整段 Markdown 源码)。
|
|
1216
|
-
// 单块选区不带 blockRange,浮层与行为维持原样。
|
|
1217
277
|
const elOf = (n) => (n?.nodeType === 3 ? n.parentElement : n);
|
|
1218
278
|
const bA = elOf(sel.anchorNode)?.closest?.('.mdw-lp-block');
|
|
1219
279
|
const bF = elOf(sel.focusNode)?.closest?.('.mdw-lp-block');
|
|
@@ -1233,6 +293,26 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
1233
293
|
placeSelMenu('task', text, last.right - 60, last.bottom + 8, blockRange ? { blockRange } : {});
|
|
1234
294
|
};
|
|
1235
295
|
|
|
296
|
+
const openParentBeside = useCallback(() => {
|
|
297
|
+
if (!parentRef) {
|
|
298
|
+
toast('这条任务没有可定位的原文');
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const m = model || app.model;
|
|
302
|
+
if (!m) return;
|
|
303
|
+
openBesideMain(m, {
|
|
304
|
+
component: 'page',
|
|
305
|
+
name: parentRef.name || `原文 ${parentRef.task}`,
|
|
306
|
+
config: { dirKey: parentRef.dirKey, task: String(parentRef.task) },
|
|
307
|
+
});
|
|
308
|
+
}, [parentRef, model, app.model, toast]);
|
|
309
|
+
|
|
310
|
+
const closeBesideSelf = useCallback(() => {
|
|
311
|
+
const m = model || app.model;
|
|
312
|
+
if (!m || !tabId) return;
|
|
313
|
+
m.doAction(Actions.deleteTab(tabId));
|
|
314
|
+
}, [model, app.model, tabId]);
|
|
315
|
+
|
|
1236
316
|
const pickAtt = (accept) => {
|
|
1237
317
|
fileAttRef.current.accept = accept;
|
|
1238
318
|
fileAttRef.current?.click();
|
|
@@ -1253,125 +333,17 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
1253
333
|
|
|
1254
334
|
// 链节点旁路:只读展示 history 快照(不占编辑文档)
|
|
1255
335
|
if (historyId != null) {
|
|
1256
|
-
|
|
1257
|
-
const html = historyNode
|
|
1258
|
-
? renderMarkdownHtml(historyNode.text || '', historyNode.attachments || [])
|
|
1259
|
-
: '';
|
|
1260
|
-
return (
|
|
1261
|
-
<div className="mdw is-beside">
|
|
1262
|
-
<div className="mdw-beside-h">
|
|
1263
|
-
<span className="mdw-beside-lab">链节点 · {kindLab} #{historyId}</span>
|
|
1264
|
-
<span className="grow" />
|
|
1265
|
-
<button
|
|
1266
|
-
type="button"
|
|
1267
|
-
className="iconbtn"
|
|
1268
|
-
title="关闭"
|
|
1269
|
-
aria-label="关闭"
|
|
1270
|
-
onClick={closeBesideSelf}
|
|
1271
|
-
>
|
|
1272
|
-
×
|
|
1273
|
-
</button>
|
|
1274
|
-
</div>
|
|
1275
|
-
<div className="mdw-hist-ro">
|
|
1276
|
-
{!historyNode ? (
|
|
1277
|
-
<div className="muted">找不到链节点 #{historyId}</div>
|
|
1278
|
-
) : (
|
|
1279
|
-
<>
|
|
1280
|
-
<div className="mdw-hist-meta">
|
|
1281
|
-
<span>{historyNode.at || '—'}</span>
|
|
1282
|
-
{historyNode.quote ? <span>锚定:{historyNode.quote.slice(0, 80)}</span> : null}
|
|
1283
|
-
{historyNode.feedback ? <span>反馈:{historyNode.feedback.slice(0, 80)}</span> : null}
|
|
1284
|
-
{historyNode.summary ? <span>上轮总结:{historyNode.summary.slice(0, 80)}</span> : null}
|
|
1285
|
-
</div>
|
|
1286
|
-
<article
|
|
1287
|
-
className="md-body"
|
|
1288
|
-
dangerouslySetInnerHTML={{ __html: html || '<p class="muted">(空)</p>' }}
|
|
1289
|
-
/>
|
|
1290
|
-
</>
|
|
1291
|
-
)}
|
|
1292
|
-
</div>
|
|
1293
|
-
</div>
|
|
1294
|
-
);
|
|
336
|
+
return <HistoryView historyId={historyId} historyNode={historyNode} closeBesideSelf={closeBesideSelf} />;
|
|
1295
337
|
}
|
|
1296
338
|
|
|
1297
339
|
// 读不到文档分两种:**还在读**(队列首轮没回来)与**确实没有这一条**(被删 / 深链写错)。
|
|
1298
|
-
// 后者不该永远转圈——给一句实话 + 一个出口(回目录)。
|
|
1299
340
|
if (!doc) {
|
|
1300
341
|
if (app.localReady === false || isDraft) {
|
|
1301
342
|
return <div className="mdw"><div className="pad muted">载入中…</div></div>;
|
|
1302
343
|
}
|
|
1303
|
-
return
|
|
1304
|
-
<div className="mdw">
|
|
1305
|
-
<div className="pad stack">
|
|
1306
|
-
<div><strong>找不到任务 #{task}</strong></div>
|
|
1307
|
-
<div className="hint">它可能已被删除(软删除可用 nx-kv localtask task restore 恢复),或这个深链写错了。</div>
|
|
1308
|
-
<div>
|
|
1309
|
-
<button
|
|
1310
|
-
className="btn ghost sm"
|
|
1311
|
-
onClick={() => app.onNavigate && app.onNavigate(
|
|
1312
|
-
groupAnchored
|
|
1313
|
-
? '#/group/' + encodeURIComponent(groupId || '')
|
|
1314
|
-
: isGlobal ? '#/global' : '#/dir/' + encodeURIComponent(dirKey || '')
|
|
1315
|
-
)}
|
|
1316
|
-
>
|
|
1317
|
-
回到目录
|
|
1318
|
-
</button>
|
|
1319
|
-
</div>
|
|
1320
|
-
</div>
|
|
1321
|
-
</div>
|
|
1322
|
-
);
|
|
344
|
+
return <NotFoundView task={task} app={app} groupAnchored={groupAnchored} groupId={groupId} isGlobal={isGlobal} dirKey={dirKey} />;
|
|
1323
345
|
}
|
|
1324
346
|
|
|
1325
|
-
// ─── 时间目标 UI(#78)───
|
|
1326
|
-
// 设置收进「更多」菜单(goalMenu),外部只以勋章回显(goalBadge)——头部不再
|
|
1327
|
-
// 给整行;没设(无草稿值也无声明)勋章就不出现,零噪音。勋章跟随 goalDraft
|
|
1328
|
-
// (正在编辑的草稿值),落库仍走 submit 里的 goalPatchOf 同一套口径。
|
|
1329
|
-
const goalDur = (goal.duration || '').trim();
|
|
1330
|
-
const goalPrompt = (goal.prompt || '').trim();
|
|
1331
|
-
const goalBadge = (goalDur || goalPrompt)
|
|
1332
|
-
? {
|
|
1333
|
-
label: `⏱ ${goalDur || '目标'}`,
|
|
1334
|
-
title: goalPrompt
|
|
1335
|
-
|| (goalEditable ? '任务级时间目标(在「更多」里设置;领取即计时)' : '已领取计时,声明不可改'),
|
|
1336
|
-
}
|
|
1337
|
-
: null;
|
|
1338
|
-
const goalMenu = (goalEditable || declaredGoal) ? (
|
|
1339
|
-
<div className="mdw-goal-menu">
|
|
1340
|
-
<div className="mdw-goal-menu-lab">时间目标</div>
|
|
1341
|
-
{goalEditable ? (
|
|
1342
|
-
<>
|
|
1343
|
-
<input
|
|
1344
|
-
className="mdw-goal-dur mono"
|
|
1345
|
-
value={goal.duration}
|
|
1346
|
-
placeholder="2h / 90m / 30分钟,留空不带"
|
|
1347
|
-
onChange={(e) => {
|
|
1348
|
-
setGoalDraft({ ...goal, duration: e.target.value });
|
|
1349
|
-
markDirty();
|
|
1350
|
-
}}
|
|
1351
|
-
/>
|
|
1352
|
-
<input
|
|
1353
|
-
className="mdw-goal-prompt"
|
|
1354
|
-
value={goal.prompt}
|
|
1355
|
-
placeholder="附加要求(可选,随 check 指令一起固化)"
|
|
1356
|
-
onChange={(e) => {
|
|
1357
|
-
setGoalDraft({ ...goal, prompt: e.target.value });
|
|
1358
|
-
markDirty();
|
|
1359
|
-
}}
|
|
1360
|
-
/>
|
|
1361
|
-
</>
|
|
1362
|
-
) : (
|
|
1363
|
-
<span className="mdw-goal-ro mono" title={declaredGoal?.prompt || '已领取计时,声明不可改'}>
|
|
1364
|
-
{declaredGoal?.duration || '—'} · 已领取计时
|
|
1365
|
-
</span>
|
|
1366
|
-
)}
|
|
1367
|
-
{declaredGoal && task != null ? (
|
|
1368
|
-
<button type="button" className="ghost" onClick={openGoalLog} title="查看时间目标的每轮 check 记录">
|
|
1369
|
-
查看每轮 check 日志
|
|
1370
|
-
</button>
|
|
1371
|
-
) : null}
|
|
1372
|
-
</div>
|
|
1373
|
-
) : null;
|
|
1374
|
-
|
|
1375
347
|
return (
|
|
1376
348
|
<div className={`mdw${beside ? ' is-beside' : ''}`} data-mode={editorMode} onMouseUp={onPreviewMouseUp}>
|
|
1377
349
|
{dialogNode}
|
|
@@ -1382,24 +354,9 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
1382
354
|
onOpenNode={openHistoryBeside}
|
|
1383
355
|
onClose={() => setChainOpen(false)}
|
|
1384
356
|
/>
|
|
1385
|
-
{beside &&
|
|
1386
|
-
<div className="mdw-beside-h">
|
|
1387
|
-
<span className="mdw-beside-lab">原文(旁路)</span>
|
|
1388
|
-
<span className="grow" />
|
|
1389
|
-
<button
|
|
1390
|
-
type="button"
|
|
1391
|
-
className="iconbtn"
|
|
1392
|
-
title="关闭原文面板"
|
|
1393
|
-
aria-label="关闭原文面板"
|
|
1394
|
-
onClick={closeBesideSelf}
|
|
1395
|
-
>
|
|
1396
|
-
×
|
|
1397
|
-
</button>
|
|
1398
|
-
</div>
|
|
1399
|
-
)}
|
|
357
|
+
{beside && <BesideHeader onClose={closeBesideSelf} />}
|
|
1400
358
|
<div className="mdw-main">
|
|
1401
359
|
<div className="mdw-top">
|
|
1402
|
-
{/* 路径条放进这条工具栏里(#44 反馈「mdw-top 在这个区域里面」) */}
|
|
1403
360
|
<RouteBreadcrumb />
|
|
1404
361
|
<div className="mdw-head">
|
|
1405
362
|
<div className="mdw-title">{isDraft ? (doc.title || '新 MD 任务') : (doc.title || '任务')}</div>
|
|
@@ -1411,42 +368,8 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
1411
368
|
</div>
|
|
1412
369
|
</div>
|
|
1413
370
|
|
|
1414
|
-
{
|
|
1415
|
-
草稿与未领取可改(改写 frontmatter),已领取只读;提交按 project 路由队列。 */}
|
|
1416
|
-
{boardCtx && (
|
|
1417
|
-
<div className="mdw-goal">
|
|
1418
|
-
<span
|
|
1419
|
-
className="mdw-goal-lab"
|
|
1420
|
-
title="归属项目(限本组成员):决定提交进哪个项目的队列;由组面板「新增任务」创建时自动携带本组语义"
|
|
1421
|
-
>
|
|
1422
|
-
归属项目
|
|
1423
|
-
</span>
|
|
1424
|
-
{goalEditable ? (
|
|
1425
|
-
<select
|
|
1426
|
-
className="mdw-proj-pick"
|
|
1427
|
-
value={docFm.project || ''}
|
|
1428
|
-
onChange={(e) => {
|
|
1429
|
-
saveDoc(id, {
|
|
1430
|
-
body: withFrontmatter(doc.body, { ...docFm, board: boardCtx.board.id, project: e.target.value }),
|
|
1431
|
-
});
|
|
1432
|
-
markDirty();
|
|
1433
|
-
}}
|
|
1434
|
-
>
|
|
1435
|
-
{boardCtx.members.map((m) => (
|
|
1436
|
-
<option key={m.key} value={m.key}>{m.name}</option>
|
|
1437
|
-
))}
|
|
1438
|
-
</select>
|
|
1439
|
-
) : (
|
|
1440
|
-
<span className="mdw-proj-ro" title="归属项目(在本组创建时写入,随任务走)">
|
|
1441
|
-
{(boardCtx.members.find((m) => m.key === docFm.project) || {}).name || docFm.project || '—'}
|
|
1442
|
-
</span>
|
|
1443
|
-
)}
|
|
1444
|
-
</div>
|
|
1445
|
-
)}
|
|
371
|
+
<BoardSection boardCtx={boardCtx} docFm={docFm} goalEditable={goalEditable} doc={doc} id={id} markDirty={markDirty} />
|
|
1446
372
|
|
|
1447
|
-
{/* #78:头部只留 新任务 / 提交;其余动作(含进程/原文/快捷键)全进「更多」,
|
|
1448
|
-
时间目标在「更多」顶部编辑、外部勋章回显。MD 格式条撤出头部——
|
|
1449
|
-
划选浮条 + 行首 / 命令 + Ctrl/⌘B 等快捷键已覆盖。 */}
|
|
1450
373
|
<ToolBar
|
|
1451
374
|
mode={editorMode}
|
|
1452
375
|
onMode={(m) => saveDoc(id, { mode: m })}
|
|
@@ -1491,280 +414,34 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
1491
414
|
onUndo={undo}
|
|
1492
415
|
onRedo={redo}
|
|
1493
416
|
onCloseSelMenu={closeSelMenu}
|
|
1494
|
-
/* @ 附件选择面板的取数描述(#108):任务侧附件清单(正文内嵌 + 附件区)。
|
|
1495
|
-
草稿还没有附件关系(AttachArea 同口径:提交任务后才挂得上),不传。 */
|
|
1496
417
|
attachHost={isDraft ? null : {
|
|
1497
418
|
host: 'task',
|
|
1498
419
|
hostId: Number(task),
|
|
1499
420
|
hostKey: isGlobal ? GLOBAL_KEY : undefined,
|
|
1500
421
|
hostCwd: isGlobal ? undefined : topic?.cwd,
|
|
1501
|
-
// 「+ 添加附件」弹窗的配置(#109):与本页附件区同一套
|
|
1502
422
|
allow: { file: true, url: true, task: true, ref: true },
|
|
1503
423
|
taskOptions: (topic.tasks || []).map((t) => ({ id: t.id, text: t.text, status: t.status })),
|
|
1504
424
|
}}
|
|
1505
425
|
/>
|
|
1506
426
|
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
/>
|
|
1518
|
-
{/* 面板头(#79):左上功能切换 tab,右上两个控制钮(最大化 / 关闭)——照 VSCode 底部面板 */}
|
|
1519
|
-
<div className="mdw-dock-head">
|
|
1520
|
-
<div className="mdw-dock-tabs" role="tablist" aria-label="信息面板">
|
|
1521
|
-
<button
|
|
1522
|
-
type="button"
|
|
1523
|
-
role="tab"
|
|
1524
|
-
aria-selected={dockTab === 'attach'}
|
|
1525
|
-
className={`mdw-dock-tab${dockTab === 'attach' ? ' is-on' : ''}`}
|
|
1526
|
-
onClick={() => showDockTab('attach')}
|
|
1527
|
-
>
|
|
1528
|
-
附件
|
|
1529
|
-
</button>
|
|
1530
|
-
{canShowGoalLog ? (
|
|
1531
|
-
<button
|
|
1532
|
-
type="button"
|
|
1533
|
-
role="tab"
|
|
1534
|
-
aria-selected={dockTab === 'check'}
|
|
1535
|
-
className={`mdw-dock-tab${dockTab === 'check' ? ' is-on' : ''}`}
|
|
1536
|
-
onClick={openGoalLog}
|
|
1537
|
-
>
|
|
1538
|
-
check
|
|
1539
|
-
<span className="mdw-dock-tab-num">{goalLog.data?.count ?? 0}</span>
|
|
1540
|
-
</button>
|
|
1541
|
-
) : null}
|
|
1542
|
-
<button
|
|
1543
|
-
type="button"
|
|
1544
|
-
role="tab"
|
|
1545
|
-
aria-selected={dockTab === 'feedback'}
|
|
1546
|
-
className={`mdw-dock-tab${dockTab === 'feedback' ? ' is-on' : ''}`}
|
|
1547
|
-
onClick={() => showDockTab('feedback')}
|
|
1548
|
-
>
|
|
1549
|
-
反馈
|
|
1550
|
-
</button>
|
|
1551
|
-
</div>
|
|
1552
|
-
<div className="mdw-dock-acts">
|
|
1553
|
-
<button
|
|
1554
|
-
type="button"
|
|
1555
|
-
className="mdw-dock-act"
|
|
1556
|
-
onClick={toggleDockMax}
|
|
1557
|
-
title={dockMax ? '还原面板高度' : '最大化面板高度'}
|
|
1558
|
-
aria-label={dockMax ? '还原面板高度' : '最大化面板高度'}
|
|
1559
|
-
>
|
|
1560
|
-
<Icon name={dockMax ? 'collapse' : 'expand'} />
|
|
1561
|
-
</button>
|
|
1562
|
-
<button
|
|
1563
|
-
type="button"
|
|
1564
|
-
className="mdw-dock-act"
|
|
1565
|
-
onClick={() => setDockOpen(false)}
|
|
1566
|
-
title="关闭面板(底部状态栏仍保留入口)"
|
|
1567
|
-
aria-label="关闭面板"
|
|
1568
|
-
>
|
|
1569
|
-
<Icon name="x" />
|
|
1570
|
-
</button>
|
|
1571
|
-
</div>
|
|
1572
|
-
</div>
|
|
1573
|
-
<div className="mdw-dock-body">
|
|
1574
|
-
{dockTab === 'attach' ? (
|
|
1575
|
-
isDraft ? (
|
|
1576
|
-
<AttachBar
|
|
1577
|
-
attachments={doc.attachments}
|
|
1578
|
-
onRemove={(aid) => {
|
|
1579
|
-
const next = (doc.attachments || []).filter((x) => x.id !== aid);
|
|
1580
|
-
markDirty();
|
|
1581
|
-
saveDoc(id, { attachments: next });
|
|
1582
|
-
if (!isDraft) persistAtt(task, next);
|
|
1583
|
-
}}
|
|
1584
|
-
/>
|
|
1585
|
-
) : topic ? (
|
|
1586
|
-
<AttachArea
|
|
1587
|
-
ref={attachAreaRef}
|
|
1588
|
-
host="task"
|
|
1589
|
-
hostId={Number(task)}
|
|
1590
|
-
hostKey={isGlobal ? GLOBAL_KEY : undefined}
|
|
1591
|
-
hostCwd={isGlobal ? undefined : topic.cwd}
|
|
1592
|
-
allow={{ file: true, url: true, task: true, ref: true }}
|
|
1593
|
-
taskOptions={(topic.tasks || []).map((t) => ({ id: t.id, text: t.text, status: t.status }))}
|
|
1594
|
-
onChanged={refreshLocal}
|
|
1595
|
-
onOpenTask={(hit) => {
|
|
1596
|
-
if (!app.openPage || !hit || hit.seq == null) return;
|
|
1597
|
-
app.openPage({
|
|
1598
|
-
dirKey: hit.key || topicKey,
|
|
1599
|
-
task: String(hit.seq),
|
|
1600
|
-
name: `#${hit.seq}`,
|
|
1601
|
-
});
|
|
1602
|
-
}}
|
|
1603
|
-
onOpenDoc={(locator) => {
|
|
1604
|
-
const docId = docIdOfLocator(locator);
|
|
1605
|
-
if (!model || !docId) return;
|
|
1606
|
-
openPanel(model, {
|
|
1607
|
-
component: 'doc',
|
|
1608
|
-
name: locator.split('/').pop() || locator,
|
|
1609
|
-
config: { docId },
|
|
1610
|
-
location: 'center',
|
|
1611
|
-
});
|
|
1612
|
-
}}
|
|
1613
|
-
/>
|
|
1614
|
-
) : (
|
|
1615
|
-
<div className="mdw-dock-empty">没有可挂载附件的上下文。</div>
|
|
1616
|
-
)
|
|
1617
|
-
) : null}
|
|
1618
|
-
|
|
1619
|
-
{dockTab === 'check' ? (
|
|
1620
|
-
<div className="mdw-dock-check">
|
|
1621
|
-
{goalLog.busy && !goalLog.data ? <div className="mdw-dock-empty">读取中…</div> : null}
|
|
1622
|
-
{goalLog.error ? <div className="mdw-dock-empty">读取失败:{goalLog.error}</div> : null}
|
|
1623
|
-
{goalLog.data ? (
|
|
1624
|
-
<>
|
|
1625
|
-
<div className="mdw-dock-meta mono">
|
|
1626
|
-
{`时间目标 ${goalLog.data.duration || '—'}`}
|
|
1627
|
-
{goalLog.data.startedAt ? ` · 开始 ${goalLog.data.startedAt}` : ''}
|
|
1628
|
-
{goalLog.data.deadline ? ` · 截止 ${goalLog.data.deadline}` : ' · 尚未开始计时'}
|
|
1629
|
-
{goalLog.data.archived ? ' · 已归档' : ''}
|
|
1630
|
-
{` · ${goalLog.data.count || 0} 轮`}
|
|
1631
|
-
</div>
|
|
1632
|
-
{(goalLog.data.count || 0) > 0 ? (
|
|
1633
|
-
<div className="mdw-goal-log">
|
|
1634
|
-
{goalLog.data.entries.map((e, i) => (
|
|
1635
|
-
<div key={`${e.checkedAt}-${i}`} className="mdw-goal-log-row">
|
|
1636
|
-
<div className="mdw-goal-log-head mono">
|
|
1637
|
-
R{i + 1} · {e.checkedAt} · {e.reached ? '已到点' : '未到点'} · 已用{' '}
|
|
1638
|
-
{fmtSec(e.elapsedSec)} · 剩余 {fmtSec(e.remainingSec)}
|
|
1639
|
-
</div>
|
|
1640
|
-
{e.summary ? <div className="mdw-goal-log-body">{e.summary}</div> : null}
|
|
1641
|
-
{e.progress ? <div className="mdw-goal-log-prog">{e.progress}</div> : null}
|
|
1642
|
-
</div>
|
|
1643
|
-
))}
|
|
1644
|
-
</div>
|
|
1645
|
-
) : (
|
|
1646
|
-
<div className="mdw-dock-empty">还没有 check 记录——任务领取后每轮 check 会出现在这里。</div>
|
|
1647
|
-
)}
|
|
1648
|
-
</>
|
|
1649
|
-
) : null}
|
|
1650
|
-
</div>
|
|
1651
|
-
) : null}
|
|
1652
|
-
|
|
1653
|
-
{dockTab === 'feedback' ? (
|
|
1654
|
-
!isDraft && taskRow?.completedAt ? (
|
|
1655
|
-
<div className="mdw-review" ref={reviewBarRef}>
|
|
1656
|
-
<div className="mdw-review-main">
|
|
1657
|
-
<span className="mdw-review-badge">已完成 · 等待验收</span>
|
|
1658
|
-
<span className="mdw-review-at mono">{taskRow.completedAt}</span>
|
|
1659
|
-
{taskRow.roundSummary ? (
|
|
1660
|
-
<>
|
|
1661
|
-
<div
|
|
1662
|
-
ref={reviewSumRef}
|
|
1663
|
-
className={`mdw-review-sum${ackOpen ? ' is-open' : ''}`}
|
|
1664
|
-
title={ackOpen || !(ackOverflow || ackLong) ? 'agent 的完成总结(ack)' : '点击下方展开全文'}
|
|
1665
|
-
dangerouslySetInnerHTML={{ __html: ackHtml }}
|
|
1666
|
-
/>
|
|
1667
|
-
{(ackOverflow || ackLong || ackOpen) && (
|
|
1668
|
-
<button
|
|
1669
|
-
type="button"
|
|
1670
|
-
className="mdw-review-more"
|
|
1671
|
-
onClick={() => setAckOpen((o) => !o)}
|
|
1672
|
-
>
|
|
1673
|
-
{ackOpen ? '收起' : '展开全文'}
|
|
1674
|
-
</button>
|
|
1675
|
-
)}
|
|
1676
|
-
</>
|
|
1677
|
-
) : null}
|
|
1678
|
-
</div>
|
|
1679
|
-
<div className="mdw-review-acts">
|
|
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
|
-
)}
|
|
1704
|
-
</div>
|
|
1705
|
-
</div>
|
|
1706
|
-
) : (
|
|
1707
|
-
<div className="mdw-dock-empty">任务完成后,agent 的完成总结会显示在这里。</div>
|
|
1708
|
-
)
|
|
1709
|
-
) : null}
|
|
1710
|
-
</div>
|
|
1711
|
-
</div>
|
|
1712
|
-
)}
|
|
427
|
+
<DockPanel
|
|
428
|
+
dockOpen={dockOpen} dockTab={dockTab} dockH={dockH} dockRef={dockRef} dockMax={dockMax}
|
|
429
|
+
showDockTab={showDockTab} onDockDragStart={onDockDragStart} toggleDockMax={toggleDockMax} setDockOpen={setDockOpen}
|
|
430
|
+
canShowGoalLog={canShowGoalLog} goalLog={goalLog} openGoalLog={openGoalLog}
|
|
431
|
+
isDraft={isDraft} task={task} topic={topic} topicKey={topicKey} isGlobal={isGlobal} doc={doc} id={id} model={model} app={app}
|
|
432
|
+
refreshLocal={refreshLocal} markDirty={markDirty} saveDoc={saveDoc} persistAtt={persistAtt}
|
|
433
|
+
attachAreaRef={attachAreaRef} reviewBarRef={reviewBarRef} reviewSumRef={reviewSumRef}
|
|
434
|
+
taskRow={taskRow} ackOpen={ackOpen} setAckOpen={setAckOpen} ackOverflow={ackOverflow} ackLong={ackLong} ackHtml={ackHtml}
|
|
435
|
+
isChainTip={isChainTip} latestChild={latestChild} openFeedback={openFeedback} openLatestRound={openLatestRound}
|
|
436
|
+
/>
|
|
1713
437
|
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
onClick={() => showDockTab('attach')}
|
|
1720
|
-
title="附件(点击展开信息面板)"
|
|
1721
|
-
>
|
|
1722
|
-
<Icon name="list" />
|
|
1723
|
-
<span className="mdw-sbar-lab">附件</span>
|
|
1724
|
-
</button>
|
|
1725
|
-
{canShowGoalLog ? (
|
|
1726
|
-
<button
|
|
1727
|
-
type="button"
|
|
1728
|
-
className={`mdw-sbar-item${dockOpen && dockTab === 'check' ? ' is-on' : ''}`}
|
|
1729
|
-
onClick={openGoalLog}
|
|
1730
|
-
title="时间目标每轮 check(点击展开信息面板)"
|
|
1731
|
-
>
|
|
1732
|
-
<Icon name="clock" />
|
|
1733
|
-
<span className="mdw-sbar-lab">check</span>
|
|
1734
|
-
<span className="mdw-sbar-num">{goalLog.data?.count ?? 0}</span>
|
|
1735
|
-
</button>
|
|
1736
|
-
) : null}
|
|
1737
|
-
<button
|
|
1738
|
-
type="button"
|
|
1739
|
-
className={`mdw-sbar-item${dockOpen && dockTab === 'feedback' ? ' is-on' : ''}`}
|
|
1740
|
-
onClick={() => showDockTab('feedback')}
|
|
1741
|
-
title="完成总结 / 反馈(点击展开信息面板)"
|
|
1742
|
-
>
|
|
1743
|
-
<Icon name="edit" />
|
|
1744
|
-
<span className="mdw-sbar-lab">反馈</span>
|
|
1745
|
-
</button>
|
|
1746
|
-
<span className="mdw-sbar-grow" />
|
|
1747
|
-
{!isDraft && taskRow ? (
|
|
1748
|
-
<span className="mdw-sbar-stat" title="任务状态">
|
|
1749
|
-
{/* #121 统一组件:蓝=进行中、绿=已完成、浅灰=待领取、灰虚线=收口 */}
|
|
1750
|
-
<StatusTag t={taskRow} />
|
|
1751
|
-
</span>
|
|
1752
|
-
) : null}
|
|
1753
|
-
<button
|
|
1754
|
-
type="button"
|
|
1755
|
-
className={`mdw-sbar-chev${dockOpen ? ' is-open' : ''}`}
|
|
1756
|
-
onClick={() => setDockOpen((v) => !v)}
|
|
1757
|
-
title={dockOpen ? '收起信息面板' : '展开信息面板'}
|
|
1758
|
-
aria-expanded={dockOpen}
|
|
1759
|
-
aria-label={dockOpen ? '收起信息面板' : '展开信息面板'}
|
|
1760
|
-
>
|
|
1761
|
-
<Icon name="chevron" />
|
|
1762
|
-
</button>
|
|
1763
|
-
</div>
|
|
438
|
+
<StatusBar
|
|
439
|
+
dockOpen={dockOpen} dockTab={dockTab} showDockTab={showDockTab} setDockOpen={setDockOpen}
|
|
440
|
+
canShowGoalLog={canShowGoalLog} goalLog={goalLog} openGoalLog={openGoalLog}
|
|
441
|
+
isDraft={isDraft} taskRow={taskRow}
|
|
442
|
+
/>
|
|
1764
443
|
</div>
|
|
1765
444
|
|
|
1766
|
-
{/* ack 定位轨(任务 #48):反复 ack 反馈的长任务页,一轮一个节点,点击跳过去。
|
|
1767
|
-
只有真的有多轮时才有内容(ackNodes 为空 → 组件自身返回 null)。 */}
|
|
1768
445
|
<AckRail nodes={ackNodes} scrollRoot={ackScrollRoot} />
|
|
1769
446
|
|
|
1770
447
|
<SelMenu
|
|
@@ -1774,8 +451,6 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
1774
451
|
closeSelMenu();
|
|
1775
452
|
}}
|
|
1776
453
|
onCompose={() => {
|
|
1777
|
-
// #104:评论 = 新开一块 md 编辑面板(顶部带引用的那段话),
|
|
1778
|
-
// 不再用浮层里的输入框弹窗。
|
|
1779
454
|
const m = model || app.model;
|
|
1780
455
|
if (!m) return;
|
|
1781
456
|
const quote = String(selMenu?.text || lastSel.current || '');
|
|
@@ -1847,93 +522,3 @@ export default function PagePanel({ dirKey, groupId, task, beside = false, tabId
|
|
|
1847
522
|
</div>
|
|
1848
523
|
);
|
|
1849
524
|
}
|
|
1850
|
-
|
|
1851
|
-
/**
|
|
1852
|
-
* 预览弹层(任务 #65):「agent 执行 get 会收到的提示词」。
|
|
1853
|
-
*
|
|
1854
|
-
* 只展示服务端渲染好的原文(data.rendered)+ 段落来源,**不在前端二次拼装**——
|
|
1855
|
-
* 前端一拼就会与真实交付漂移,而预览的全部价值就是「所见即所得」。
|
|
1856
|
-
*/
|
|
1857
|
-
function PreviewModal({ state, onClose }) {
|
|
1858
|
-
const toast = useToast();
|
|
1859
|
-
const data = state?.data;
|
|
1860
|
-
const copy = async () => {
|
|
1861
|
-
try {
|
|
1862
|
-
await navigator.clipboard.writeText(String(data?.rendered || ''));
|
|
1863
|
-
toast('已复制原文');
|
|
1864
|
-
} catch {
|
|
1865
|
-
toast('复制失败(剪贴板不可用)');
|
|
1866
|
-
}
|
|
1867
|
-
};
|
|
1868
|
-
const sw = data?.switches || {};
|
|
1869
|
-
const swLine = data
|
|
1870
|
-
? [
|
|
1871
|
-
`ack ${sw.ack?.on ? `开(${sw.ack.count} 条)` : '关'}`,
|
|
1872
|
-
`交付上下文 ${sw.deliveryTemplate?.custom ? '自定义' : '内置默认'}`,
|
|
1873
|
-
`持续 get ${data.getLoop?.enabled ? `开(${data.getLoop.waitMinutes} 分钟)` : '关'}`,
|
|
1874
|
-
].join(' · ')
|
|
1875
|
-
: '';
|
|
1876
|
-
const title = data
|
|
1877
|
-
? `预览:agent 执行 get 会收到的提示词${data.task?.id ? ` · #${data.task.id}` : ' · 草稿'}`
|
|
1878
|
-
: '预览:agent 执行 get 会收到的提示词';
|
|
1879
|
-
return (
|
|
1880
|
-
<Modal
|
|
1881
|
-
title={title}
|
|
1882
|
-
size='wide'
|
|
1883
|
-
onClose={onClose}
|
|
1884
|
-
footer={
|
|
1885
|
-
<>
|
|
1886
|
-
<span className='mdw-prev-hint'>与 CLI 取任务共用同一份排版;不含「已取得下一条任务…」头部行。</span>
|
|
1887
|
-
<span className='grow' />
|
|
1888
|
-
<button type='button' className='btn ghost sm' onClick={copy} disabled={!data}>复制原文</button>
|
|
1889
|
-
<button type='button' className='btn sm' onClick={onClose}>关闭</button>
|
|
1890
|
-
</>
|
|
1891
|
-
}
|
|
1892
|
-
>
|
|
1893
|
-
{state.busy && <div className='mdw-prev-note'>渲染中…</div>}
|
|
1894
|
-
{state.error && (
|
|
1895
|
-
<div className='mdw-prev-note'>
|
|
1896
|
-
预览失败:{state.error}
|
|
1897
|
-
{/* 「接口不存在」= 正在跑的 serve 进程比页面资产旧(路由启动时加载、
|
|
1898
|
-
资产现读磁盘,#65 验收反馈实锤过这个 404)——引导重启,别让它
|
|
1899
|
-
看起来像瞬时故障。与 overview 批量删除 / use-templates 同一处理。 */}
|
|
1900
|
-
{/接口不存在/.test(String(state.error)) && (
|
|
1901
|
-
<div className='mdw-prev-hint'>
|
|
1902
|
-
本机面板服务较旧:重启面板(结束当前 serve 进程后重新启动)即可生效,刷新页面不够。
|
|
1903
|
-
</div>
|
|
1904
|
-
)}
|
|
1905
|
-
</div>
|
|
1906
|
-
)}
|
|
1907
|
-
{data && (
|
|
1908
|
-
<>
|
|
1909
|
-
<pre className='mdw-prev-body'>{data.rendered || ''}</pre>
|
|
1910
|
-
{data.segments?.length ? (
|
|
1911
|
-
<details className='mdw-prev-seg'>
|
|
1912
|
-
<summary>段落来源({data.segments.length} 段)</summary>
|
|
1913
|
-
<ol>
|
|
1914
|
-
{data.segments.map((s, i) => (
|
|
1915
|
-
<li key={i}>
|
|
1916
|
-
<span className='mdw-prev-seg-lab'>{s.label}</span>
|
|
1917
|
-
<span className='mdw-prev-seg-n'>{String(s.text || '').length} 字</span>
|
|
1918
|
-
</li>
|
|
1919
|
-
))}
|
|
1920
|
-
</ol>
|
|
1921
|
-
<div className='mdw-prev-note'>改这些段去「设置 → 提示词 / 模板」;「持续 get」在项目级设置里。</div>
|
|
1922
|
-
</details>
|
|
1923
|
-
) : (
|
|
1924
|
-
<div className='mdw-prev-note'>当前没有任何模板段:交付时就只有任务正文。</div>
|
|
1925
|
-
)}
|
|
1926
|
-
<div className='mdw-prev-switch'>{swLine}</div>
|
|
1927
|
-
</>
|
|
1928
|
-
)}
|
|
1929
|
-
</Modal>
|
|
1930
|
-
);
|
|
1931
|
-
}
|
|
1932
|
-
|
|
1933
|
-
/** 秒 → 人读(check 日志的已用/剩余)。 */
|
|
1934
|
-
function fmtSec(v) {
|
|
1935
|
-
const s = Math.max(0, Number(v) || 0);
|
|
1936
|
-
if (s >= 3600) return `${Math.floor(s / 3600)}h ${Math.floor((s % 3600) / 60)}m`;
|
|
1937
|
-
if (s >= 60) return `${Math.floor(s / 60)}m ${s % 60}s`;
|
|
1938
|
-
return `${s}s`;
|
|
1939
|
-
}
|