@spzxg/cli-ui 0.6.13 → 0.6.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +100 -2
  2. package/README.md +131 -7
  3. package/dist/{cli-ui-embed-CXaGT9e4.js → cli-ui-embed-REq-GvM7.js} +20350 -19892
  4. package/dist/{cli-ui-index-bMQJjEBW.js → cli-ui-index-p_XTnmsN.js} +2 -2
  5. package/dist/{cli-ui-jszip.min-D_w3a6AF.js → cli-ui-jszip.min-0mqaiYeK.js} +1 -1
  6. package/dist/{cli-ui-jszip.min-AMeWMDT5.js → cli-ui-jszip.min-CJa9yrKW.js} +2 -2
  7. package/dist/{cli-ui-xlsx-DMzew4IO.js → cli-ui-xlsx-BPL7P3mE.js} +1 -1
  8. package/dist/cli-ui.css +1 -1
  9. package/dist/cli-ui.js +1 -1
  10. package/package.json +1 -1
  11. package/src/board/BrowserPane.tsx +93 -30
  12. package/src/board/ChangesPane.tsx +86 -62
  13. package/src/board/CliBoard.tsx +62 -27
  14. package/src/board/FileViewer.tsx +49 -13
  15. package/src/board/context.ts +38 -7
  16. package/src/board/diffLines.ts +46 -0
  17. package/src/board/diffRefresh.ts +63 -0
  18. package/src/board/fileDiff.tsx +117 -0
  19. package/src/board/fileKind.ts +5 -3
  20. package/src/board/fileScope.ts +4 -2
  21. package/src/board/fileWatch.ts +59 -9
  22. package/src/board/linkage.ts +68 -0
  23. package/src/board/pathResolve.ts +108 -0
  24. package/src/board/useBoardUpload.tsx +7 -7
  25. package/src/board/workspace.ts +7 -1
  26. package/src/chat/CliChat.tsx +197 -216
  27. package/src/chat/Composer.tsx +10 -9
  28. package/src/chat/queueEdit.ts +27 -0
  29. package/src/components.tsx +2 -2
  30. package/src/core/blocks.ts +4 -1
  31. package/src/core/client.ts +86 -9
  32. package/src/core/config.ts +1 -1
  33. package/src/core/conversation.ts +23 -5
  34. package/src/core/documentUpload.ts +22 -5
  35. package/src/core/provider.tsx +14 -8
  36. package/src/core/store.ts +307 -63
  37. package/src/core/types.ts +49 -0
  38. package/src/elements.tsx +8 -5
  39. package/src/msglist/CliMsgList.tsx +30 -9
  40. package/src/operator/node/AgentConnect.tsx +28 -29
  41. package/src/operator/node/AppearancePanel.tsx +1 -1
  42. package/src/operator/node/BranchHistory.tsx +11 -7
  43. package/src/operator/node/BranchNavigator.tsx +1 -1
  44. package/src/operator/node/BrowserPane.tsx +7 -7
  45. package/src/operator/node/Chat.tsx +53 -272
  46. package/src/operator/node/CommandPalette.tsx +1 -1
  47. package/src/operator/node/Composer.tsx +13 -6
  48. package/src/operator/node/Layout.tsx +1 -1
  49. package/src/operator/node/Markdown.tsx +6 -36
  50. package/src/operator/node/Modal.tsx +1 -1
  51. package/src/operator/node/OnboardingWizard.tsx +11 -9
  52. package/src/operator/node/Orchestrator.tsx +18 -8
  53. package/src/operator/node/ProjectLanding.tsx +1 -1
  54. package/src/operator/node/ProjectsColumn.tsx +1 -1
  55. package/src/operator/node/ProviderAuth.tsx +16 -16
  56. package/src/operator/node/RunSwitch.tsx +1 -1
  57. package/src/operator/node/Services.tsx +1 -1
  58. package/src/operator/node/SessionRail.tsx +55 -19
  59. package/src/operator/node/SessionView.tsx +18 -16
  60. package/src/operator/node/SettingsView.tsx +1 -1
  61. package/src/operator/node/TaskBoard.tsx +1 -1
  62. package/src/operator/node/TaskChanges.tsx +83 -108
  63. package/src/operator/node/TaskHero.tsx +5 -5
  64. package/src/operator/node/TasksColumn.tsx +1 -1
  65. package/src/operator/node/Transcript.tsx +15 -250
  66. package/src/operator/node/Welcome.tsx +1 -1
  67. package/src/operator/node/WorktreePrune.tsx +1 -1
  68. package/src/operator/node/api.ts +17 -0
  69. package/src/operator/node/boardBackend.ts +4 -1
  70. package/src/operator/node/boardEvents.ts +17 -3
  71. package/src/operator/node/boardInteraction.ts +7 -4
  72. package/src/operator/node/boardState.ts +23 -14
  73. package/src/operator/node/composerDraft.ts +22 -0
  74. package/src/operator/node/fileLinks.ts +4 -38
  75. package/src/operator/node/format.ts +13 -104
  76. package/src/operator/node/github.tsx +14 -14
  77. package/src/operator/node/liveStream.ts +47 -6
  78. package/src/operator/node/modals.tsx +59 -22
  79. package/src/operator/node/recheckOnReturn.ts +28 -0
  80. package/src/operator/node/shared.tsx +10 -50
  81. package/src/operator/node/types.ts +9 -0
  82. package/src/operator/node/useOrchestrator.ts +9 -8
  83. package/src/operator/node/useRecaps.ts +15 -4
  84. package/src/operator/node/useTaskStream.ts +2 -2
  85. package/src/operator.base.css +9 -4
  86. package/src/operator.css +9 -4
  87. package/src/styles.css +22 -8
  88. package/src/ui/Markdown.tsx +36 -21
  89. package/src/ui/Popover.tsx +1 -1
  90. package/src/ui/QueuedMessages.tsx +58 -15
  91. package/src/ui/SubagentChat.tsx +42 -6
  92. package/src/ui/Transcript.tsx +19 -14
  93. package/src/ui/fileLinks.ts +6 -3
  94. package/src/ui/format.ts +27 -9
  95. package/src/ui/icons.tsx +2 -0
  96. package/src/ui/shared.tsx +11 -7
  97. package/src/ui/transcriptModel.ts +40 -9
  98. package/src/ui/useTranscriptWindow.ts +253 -0
  99. package/src/operator/node/icons.tsx +0 -88
  100. package/src/operator/node/transcriptModel.ts +0 -129
@@ -5,13 +5,13 @@ import { useContext } from "react";
5
5
  import { OperatorBoardContext } from "./boardInteraction";
6
6
  import { FileLinkContext } from "./fileLinks";
7
7
 
8
- import { memo, useId, useState } from "react";
9
- import type { ToolData, ToolPeek, AskQuestion, AskAnswers, InputRequest } from "./protocol/types";
10
- import { Icon } from "./icons";
8
+ import { memo, useState } from "react";
9
+ import type { AskQuestion, AskAnswers } from "./protocol/types";
10
+ import { Icon } from "../../ui/icons";
11
11
  import { Markdown } from "./Markdown";
12
- import { splitMessage } from "../../core/blocks";
13
12
  import { withoutBoardContext } from "../../board/context";
14
- import { clockTime, diffCls, splitAttachments, type MsgAttachment } from "./format";
13
+ import { clockTime, splitAttachments, type MsgAttachment } from "./format";
14
+ import type { AttachmentScope } from "../../ui/format";
15
15
  import { CONTEXT_OVERFLOW_NOTICE } from "./protocol/promptLimits";
16
16
  import { AUTH_EXPIRED_NOTICE } from "./protocol/authFailure";
17
17
  import { USAGE_LIMIT_NOTICE } from "./protocol/usageLimit";
@@ -19,237 +19,22 @@ import { APPROVAL_BLOCKED_NOTICE } from "./protocol/approvalFailure";
19
19
  import type { Msg } from "./types";
20
20
  import { clientFeatures } from "./protocol/features";
21
21
  import { Avatar } from "./shared";
22
- import { toolDataOf } from "./transcriptModel";
22
+ import { toolDataOf } from "../../ui/transcriptModel";
23
23
  import { ReferenceCard } from "../../ui/ReferenceCard";
24
+ // Tool / question / browser-input cards and the /clear break are the shared ones
25
+ // (ui/Transcript); this file only draws the node's message rows around them.
26
+ import { AskView, InputView, ToolView, SessionBreak } from "../../ui/Transcript";
27
+ export { SessionBreak };
24
28
  import { splitQuotedMessage } from "../../ui/reference";
25
29
 
26
- // The always-visible "peek" tier — Claude Code's `⎿` line. Counts show no
27
- // content; diffs/snippets show a capped hunk with a clickable "+N more" that
28
- // opens the full body. TodoWrite renders its checklist inline.
29
- function PeekView({ peek, expandable, onExpand }: { peek: ToolPeek; expandable: boolean; onExpand: () => void }) {
30
- const corner = <span className="tcorner">⎿</span>;
31
- if (peek.kind === "count") {
32
- return (
33
- <button className="tpeek tpeek-count" style={{ cursor: expandable ? "pointer" : "default" }} onClick={() => expandable && onExpand()}>
34
- {corner}<span className="tpeek-txt">{peek.text}</span>
35
- {expandable && <span className="tpeek-more">展开</span>}
36
- </button>
37
- );
38
- }
39
- if (peek.kind === "todos") {
40
- return (
41
- <div className="tpeek tpeek-todos">
42
- {peek.items.map((t, i) => (
43
- <div className={`tdo ${t.status}`} key={i}>
44
- <span className="tdo-box">{t.status === "completed" ? "✔" : t.status === "in_progress" ? "▣" : "▢"}</span>
45
- <span className="tdo-txt">{t.text}</span>
46
- </div>
47
- ))}
48
- </div>
49
- );
50
- }
51
- if (peek.kind === "diff") {
52
- return (
53
- <div className="tpeek tpeek-diff">
54
- <div className="tpeek-sum">{corner}<span className="dstat add">+{peek.added}</span><span className="dstat del">−{peek.removed}</span>{peek.label && <span className="tpeek-txt">{peek.label}</span>}</div>
55
- <pre className="tpeek-pre diff">{peek.lines.map((l, i) => <div className={`dl ${diffCls(l.sign)}`} key={i}>{l.sign} {l.text}</div>)}</pre>
56
- {peek.truncated ? <button className="tpeek-more btn-link" onClick={onExpand}>还有 {peek.truncated} 行</button> : null}
57
- </div>
58
- );
59
- }
60
- // lines (Bash output)
61
- return (
62
- <div className="tpeek tpeek-lines">
63
- {peek.label && <div className="tpeek-sum">{corner}<span className="tpeek-txt">{peek.label}</span></div>}
64
- <pre className="tpeek-pre">{peek.lines.join("\n") || "(无输出)"}</pre>
65
- {peek.truncated ? <button className="tpeek-more btn-link" onClick={onExpand}>还有 {peek.truncated} 行</button> : null}
66
- </div>
67
- );
68
- }
69
30
 
70
- function ToolView({ data }: { data: ToolData }) {
71
- const [open, setOpen] = useState<boolean | null>(null);
72
- const bodyId = useId();
73
- const hasDiff = !!data.diff?.length;
74
- const expandable = !!(data.detail || hasDiff || data.result !== undefined);
75
- // Failures surface their output automatically, like Claude Code.
76
- const showBody = open ?? (!!data.isError && data.result !== undefined);
77
- return (
78
- <div className="tool">
79
- <button className="tool-h" title={data.title} aria-expanded={expandable ? showBody : undefined} aria-controls={expandable ? bodyId : undefined} style={{ cursor: expandable ? "pointer" : "default" }} onClick={() => expandable && setOpen(!showBody)}>
80
- {expandable && <span className={`tchev ${showBody ? "open" : ""}`}>{Icon.chevRight()}</span>}
81
- <span className="tg">{data.title}</span>
82
- {data.result !== undefined && <span className={data.isError ? "tx" : "tcheck"}>{data.isError ? Icon.x() : Icon.check()}</span>}
83
- </button>
84
- {data.peek && !showBody && <PeekView peek={data.peek} expandable={expandable} onExpand={() => setOpen(true)} />}
85
- {showBody && (
86
- <div className="tool-body" id={bodyId}>
87
- {data.detail && <pre className="tool-pre">{data.detail}</pre>}
88
- {hasDiff && (
89
- <pre className="tool-pre diff">{data.diff!.map((l, i) => <div className={`dl ${diffCls(l.sign)}`} key={i}>{l.sign} {l.text}</div>)}</pre>
90
- )}
91
- {data.result !== undefined && (
92
- <>
93
- {(data.detail || hasDiff) && <div className="tool-divider">结果</div>}
94
- <pre className={`tool-pre ${data.isError ? "err" : ""}`}>{data.result || "(无输出)"}</pre>
95
- </>
96
- )}
97
- </div>
98
- )}
99
- </div>
100
- );
101
- }
102
-
103
- // Interactive AskUserQuestion card: option pickers (+ an "Other" free-text per
104
- // question) while pending; a read-only summary once answered.
105
- function AskView({ data, agentLabel, onAnswer }: { data: ToolData; agentLabel: string; onAnswer: (answers: AskAnswers) => void }) {
106
- const questions = data.ask?.questions ?? [];
107
- const existing = data.ask?.answers;
108
- const [state, setState] = useState(() => questions.map(() => ({ picked: [] as string[], other: "" })));
109
- const [submitted, setSubmitted] = useState(false);
110
-
111
- if (existing) {
112
- return (
113
- <div className="ask answered">
114
- <div className="ask-head">{Icon.spark()} 你的回答</div>
115
- {questions.map((q, i) => (
116
- <div className="ask-q" key={i}>
117
- <div className="ask-qh"><span className="ask-chip">{q.header}</span>{q.question}</div>
118
- <div className="ask-picked">{(existing[i] ?? []).join("、") || "—"}</div>
119
- </div>
120
- ))}
121
- </div>
122
- );
123
- }
124
-
125
- const toggle = (qi: number, label: string, multi: boolean) =>
126
- setState((s) => s.map((st, i) => {
127
- if (i !== qi) return st;
128
- if (multi) {
129
- const has = st.picked.includes(label);
130
- return { ...st, picked: has ? st.picked.filter((l) => l !== label) : [...st.picked, label] };
131
- }
132
- return { picked: [label], other: "" }; // single-select replaces, clears Other
133
- }));
134
- const setOther = (qi: number, v: string) =>
135
- setState((s) => s.map((st, i) => (i === qi ? (questions[i].multiSelect ? { ...st, other: v } : { picked: [], other: v }) : st)));
136
31
 
137
- const answers: AskAnswers = state.map((st) => [...st.picked, ...(st.other.trim() ? [st.other.trim()] : [])]);
138
- const complete = answers.every((a) => a.length > 0);
139
- const submit = () => { if (complete && !submitted) { setSubmitted(true); onAnswer(answers); } };
140
-
141
- return (
142
- <div className="ask">
143
- <div className="ask-head">{Icon.spark()} {agentLabel} 需要你的输入</div>
144
- {questions.map((q, i) => (
145
- <div className="ask-q" key={i}>
146
- <div className="ask-qh"><span className="ask-chip">{q.header}</span>{q.question}{q.multiSelect && <span className="ask-multi">可多选</span>}</div>
147
- <div className="ask-opts">
148
- {q.options.map((o) => (
149
- <button key={o.label} className={`ask-opt ${state[i].picked.includes(o.label) ? "on" : ""}`} onClick={() => toggle(i, o.label, !!q.multiSelect)} disabled={submitted}>
150
- <span className="ask-opt-l">{o.label}</span>
151
- {o.description && <span className="ask-opt-d">{o.description}</span>}
152
- </button>
153
- ))}
154
- <input className="ask-other" placeholder="其他…" value={state[i].other} disabled={submitted} onChange={(e) => setOther(i, e.target.value)} />
155
- </div>
156
- </div>
157
- ))}
158
- <div className="ask-foot">
159
- <button className="btn btn-accent btn-sm" onClick={submit} disabled={!complete || submitted}>{submitted ? "发送中…" : "发送回答"}</button>
160
- </div>
161
- </div>
162
- );
163
- }
164
32
 
165
33
  /** Ask the session rail to show this task's browser (SessionRail / SessionView listen). */
166
34
  export function showTaskBrowser(taskId?: string): void {
167
35
  window.dispatchEvent(new CustomEvent("orch:show-browser", {detail:{taskId}}));
168
36
  }
169
37
 
170
- // browser_ask_user card (lib/browserInput.ts): what the agent needs to carry on
171
- // in the browser — codes, accounts, passwords, choices — typed or picked right
172
- // here while the browser waits on the page. Passwords are masked and never kept.
173
- function InputView({ input, agentLabel, onSubmit, onShowBrowser }: { onShowBrowser?:()=>void; input: InputRequest; agentLabel: string; onSubmit?: (id: string, values: string[]) => Promise<string | null> }) {
174
- const [vals, setVals] = useState<string[]>(() => input.fields.map(() => ""));
175
- const [shown, setShown] = useState<boolean[]>(() => input.fields.map(() => false));
176
- const [busy, setBusy] = useState(false);
177
- const [err, setErr] = useState<string | null>(null);
178
- const browser = clientFeatures().browser;
179
-
180
- if (input.status !== "pending") {
181
- return (
182
- <div className="ask answered">
183
- <div className="ask-head">{Icon.lock()} {input.status === "answered" ? "你提供的信息" : "已取消 —— 这一轮被停止了"}</div>
184
- <div className="ask-q"><div className="ask-qh">{input.message}</div></div>
185
- {input.status === "answered" && input.fields.map((f, i) => (
186
- <div className="ask-q" key={i}>
187
- <div className="ask-qh"><span className="ask-chip">{f.label}</span></div>
188
- <div className="ask-picked">{f.secret ? "••••••(只交给浏览器脚本,没有保存,也没有发给模型)" : input.values?.[i] ?? "—"}</div>
189
- </div>
190
- ))}
191
- </div>
192
- );
193
- }
194
-
195
- const set = (i: number, v: string) => setVals((a) => a.map((x, j) => (j === i ? v : x)));
196
- const complete = vals.every((v) => v.trim());
197
- const submit = async () => {
198
- if (!complete || busy || !onSubmit) return;
199
- setBusy(true);
200
- setErr(null);
201
- try {
202
- const e = await onSubmit(input.id, vals.map((v, i) => input.fields[i].secret ? v : v.trim()));
203
- if (e) { setErr(e); setBusy(false); }
204
- } catch (error) {
205
- setErr(error instanceof Error ? error.message : "提交失败,请重试");
206
- setBusy(false);
207
- }
208
- };
209
- return (
210
- <div className="ask">
211
- <div className="ask-head">{Icon.lock()} {agentLabel} 需要你提供信息 · 浏览器正停在这一页等待</div>
212
- <div className="ask-q"><div className="ask-qh" style={{ whiteSpace: "pre-wrap" }}>{input.message}</div></div>
213
- {input.fields.map((f, i) => (
214
- <div className="ask-q" key={i}>
215
- <div className="ask-qh"><span className="ask-chip">{f.label}</span>{f.secret && <span className="ask-multi">保密</span>}</div>
216
- <div className="ask-opts">
217
- {f.options?.map((o) => (
218
- <button key={o} className={`ask-opt ${vals[i] === o ? "on" : ""}`} onClick={() => set(i, o)} disabled={busy}>
219
- <span className="ask-opt-l">{o}</span>
220
- </button>
221
- ))}
222
- <div className="input-row">
223
- <input
224
- className="ask-other"
225
- type={f.secret && !shown[i] ? "password" : "text"}
226
- autoComplete={f.secret ? "new-password" : "off"}
227
- placeholder={f.options?.length ? "其他…" : f.placeholder || `输入${f.label}`}
228
- value={f.options?.includes(vals[i]) ? "" : vals[i]}
229
- disabled={busy}
230
- autoFocus={i === 0 && !f.options?.length}
231
- onChange={(e) => set(i, e.target.value)}
232
- onKeyDown={(e) => { if (e.key === "Enter" && !e.nativeEvent.isComposing) void submit(); }}
233
- />
234
- {f.secret && (
235
- <button className="btn btn-ghost btn-sm" type="button" onClick={() => setShown((a) => a.map((x, j) => (j === i ? !x : x)))}>
236
- {shown[i] ? "隐藏" : "显示"}
237
- </button>
238
- )}
239
- </div>
240
- </div>
241
- </div>
242
- ))}
243
- <div className="ask-foot" style={{ gap: 8, alignItems: "center" }}>
244
- {err && <span className="input-err">{err}</span>}
245
- {input.fields.some((f) => f.secret) && !err && <span className="input-note">密码只交给浏览器脚本,不保存、不发给模型</span>}
246
- <span style={{ flex: 1 }} />
247
- {browser && <button className="btn btn-line btn-sm" onClick={onShowBrowser ?? (()=>showTaskBrowser())}>查看浏览器</button>}
248
- <button className="btn btn-accent btn-sm" onClick={() => void submit()} disabled={!complete || busy}>{busy ? "发送中…" : "提交"}</button>
249
- </div>
250
- </div>
251
- );
252
- }
253
38
 
254
39
  // The transcript lines browser_handoff / a page prompt write (lib/browserHandoff.ts,
255
40
  // lib/browser.ts — both start with 🖐): the user has to act in the page itself. Buttons to open the live browser and to hand
@@ -297,7 +82,7 @@ function AttachmentStrip({ items }: { items: MsgAttachment[] }) {
297
82
  </a>
298
83
  ) : (
299
84
  <a key={i} href={a.url} target="_blank" rel="noreferrer" className="file-chip" title={`打开 ${a.name}`} onClick={event => {
300
- const taskId = /\/api\/tasks\/([^/]+)\/uploads\//.exec(a.url)?.[1] ?? scope?.taskId;
85
+ const taskId = /\/api\/tasks\/([^/]+)\/(?:uploads|files)(?:\/|\?)/.exec(a.url)?.[1] ?? scope?.taskId;
301
86
  if (taskId && event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey && open?.({ kind: "file", taskId: decodeURIComponent(taskId), path: a.path })) event.preventDefault();
302
87
  }}>
303
88
  {Icon.clip()} <span>{a.name}</span>
@@ -313,18 +98,12 @@ function AttachmentStrip({ items }: { items: MsgAttachment[] }) {
313
98
  // changes), so unchanged messages skip re-rendering — and re-parsing their
314
99
  // markdown — entirely. Callers must pass identity-stable handlers or the memo
315
100
  // is defeated (SessionView wraps its handlers for exactly this reason).
316
- function AutomaticBoardBackground({content}:{content:string}) {
317
- const blocks=splitMessage(content).filter(part=>part.kind==='block'&&part.block.kind==='viewing');
318
- if(!blocks.length)return null;
319
- return <details className="cli-auto-background"><summary>自动看板背景</summary>{blocks.map((part,index)=>part.kind==='block'?<pre key={index}>{part.block.text}</pre>:null)}</details>;
320
- }
321
-
322
101
  function QuotedUserText({ text }: { text: string }) {
323
102
  const quoted = splitQuotedMessage(text);
324
103
  return quoted ? <><ReferenceCard title={quoted.quote.author} text={quoted.quote.text} renderContent={value => <Markdown>{value}</Markdown>} />{quoted.text && <Markdown>{quoted.text}</Markdown>}</> : <Markdown>{text}</Markdown>;
325
104
  }
326
105
 
327
- export const MessageView = memo(function MessageView({ m, initial, hideWho, running, agent, agentLabel = "智能体", userLabel = "你", speakerLabel = "智能体", onAnswer, onInput, onBrowser, onCancelQueued, onClear, onReconnect, onRetry, onQuote, readOnly }: { readOnly?: boolean; userLabel?: string; speakerLabel?: string; onQuote?: (m: Msg, selected?: string) => void; m: Msg; initial: boolean; hideWho: boolean; running?: boolean; agent?: string | null; agentLabel?: string; onAnswer?: (askId: string, questions: AskQuestion[], answers: AskAnswers) => void; onInput?: (inputId: string, values: string[]) => Promise<string | null>; onBrowser?: (action: "handback") => Promise<string | null>; onCancelQueued?: (pendingId: string) => void; onClear?: () => void; onReconnect?: () => void; onRetry?: (msgId: string) => void }) {
106
+ export const MessageView = memo(function MessageView({ m, initial, hideWho, running, agent, agentLabel = "智能体", userLabel = "你", speakerLabel = "智能体", onAnswer, onInput, onBrowser, onCancelQueued, onClear, onReconnect, onRetry, onQuote, readOnly, attachmentScope }: { attachmentScope?: AttachmentScope; readOnly?: boolean; userLabel?: string; speakerLabel?: string; onQuote?: (m: Msg, selected?: string) => void; m: Msg; initial: boolean; hideWho: boolean; running?: boolean; agent?: string | null; agentLabel?: string; onAnswer?: (askId: string, questions: AskQuestion[], answers: AskAnswers) => void; onInput?: (inputId: string, values: string[]) => Promise<string | null>; onBrowser?: (action: "handback") => Promise<string | null>; onCancelQueued?: (pendingId: string) => void; onClear?: () => void; onReconnect?: () => void; onRetry?: (msgId: string) => void }) {
328
107
  const openBoard=useContext(OperatorBoardContext);
329
108
  const fileScope=useContext(FileLinkContext);
330
109
  const onShowBrowser=()=>{if(fileScope&&openBoard)openBoard({kind:'browser',taskId:fileScope.taskId});else showTaskBrowser(fileScope?.taskId);};
@@ -332,13 +111,12 @@ export const MessageView = memo(function MessageView({ m, initial, hideWho, runn
332
111
  if (m.role === "queued") {
333
112
  // A follow-up the user typed mid-turn, waiting its turn. Reads like a user
334
113
  // bubble but dimmed, tagged "Queued", with an × to drop it before it runs.
335
- const { text, attachments } = splitAttachments(withoutBoardContext(m.content));
114
+ const { text, attachments } = splitAttachments(withoutBoardContext(m.content), attachmentScope);
336
115
  return (
337
116
  <div className="msg user queued">
338
117
  <div className="who"><Avatar who="user" /> 你<span className="badge queued-badge">排队中</span>{m.ts != null && <span className="msg-time">{clockTime(m.ts)}</span>}</div>
339
118
  <div className="msg-body">
340
119
  {text && <QuotedUserText text={text} />}
341
- <AutomaticBoardBackground content={m.content}/>
342
120
  <AttachmentStrip items={attachments} />
343
121
  {onCancelQueued && <button className="queued-x" title="从队列中移除" aria-label="从队列中移除" onClick={() => onCancelQueued(m.id)}>{Icon.x()}</button>}
344
122
  </div>
@@ -351,7 +129,7 @@ export const MessageView = memo(function MessageView({ m, initial, hideWho, runn
351
129
  if (child.subagentMessage) return null;
352
130
  if (child.subagent) return <SubagentEntry info={child.subagent} generation={m.generation} />;
353
131
  if (data.input) {
354
- return <div className="msg msg-tool" inert={readOnly||undefined}><InputView input={data.input} agentLabel={agentLabel} onSubmit={onInput} onShowBrowser={onShowBrowser} /></div>;
132
+ return <div className="msg msg-tool" inert={readOnly||undefined}><InputView input={data.input} agentLabel={agentLabel} onSubmit={onInput} onBrowser={clientFeatures().browser ? onShowBrowser ?? (() => showTaskBrowser()) : undefined} unavailableNote={null} /></div>;
355
133
  }
356
134
  if (data.ask) {
357
135
  return <div className="msg msg-tool" inert={readOnly||undefined}><AskView data={data} agentLabel={agentLabel} onAnswer={(answers) => onAnswer?.(data.ask?.id || m.toolId || "", data.ask?.questions ?? [], answers)} /></div>;
@@ -444,7 +222,7 @@ export const MessageView = memo(function MessageView({ m, initial, hideWho, runn
444
222
  }
445
223
  const isUser = m.role === "user";
446
224
  // Only user messages carry attachment markers; assistant text passes through.
447
- const { text, attachments } = isUser ? splitAttachments(withoutBoardContext(m.content)) : { text: m.content, attachments: [] };
225
+ const { text, attachments } = isUser ? splitAttachments(withoutBoardContext(m.content), attachmentScope) : { text: m.content, attachments: [] };
448
226
  return (
449
227
  <div className={`msg ${isUser ? "user" : "assistant"} ${initial ? "initial" : ""}`}>
450
228
  {!hideWho && (
@@ -458,7 +236,6 @@ export const MessageView = memo(function MessageView({ m, initial, hideWho, runn
458
236
  <div className="msg-body">
459
237
  {initial && <div className="initial-tag">{Icon.spark()} 已随项目上下文发送</div>}
460
238
  {text && (isUser ? <QuotedUserText text={text} /> : <Markdown>{text}</Markdown>)}
461
- {isUser&&<AutomaticBoardBackground content={m.content}/>}
462
239
  <AttachmentStrip items={attachments} />
463
240
  </div>
464
241
  {onQuote && text.trim() && <div className="msg-actions"><button title="引用这条消息(选中文字可仅引用选中部分)" aria-label="引用消息" onMouseDown={(e) => e.preventDefault()} onClick={(e) => {
@@ -471,15 +248,3 @@ export const MessageView = memo(function MessageView({ m, initial, hideWho, runn
471
248
  );
472
249
  });
473
250
 
474
- export function SessionBreak({ summary }: { summary: string }) {
475
- return (
476
- <div className="sbreak">
477
- <span className="ln" />
478
- <div className="card">
479
- <div className="cl">{Icon.clear()} 上下文已清空 · 摘要已保存</div>
480
- <div className="ct">{summary}</div>
481
- </div>
482
- <span className="ln" />
483
- </div>
484
- );
485
- }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { useState } from "react";
4
- import { Icon } from "./icons";
4
+ import { Icon } from "../../ui/icons";
5
5
  import { Modal } from "./Modal";
6
6
 
7
7
  // Coach marks + the post-merge nudge for the built-in "Welcome" tutorial project
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { useCallback, useEffect, useMemo, useState } from "react";
4
- import { Icon } from "./icons";
4
+ import { Icon } from "../../ui/icons";
5
5
  import { jget, jsend } from "./api";
6
6
  import { LoadNote, ErrNote } from "./shared";
7
7
  import { fmtBytes } from "./format";
@@ -38,3 +38,20 @@ export function downloadExport(path: string) {
38
38
  a.click();
39
39
  a.remove();
40
40
  }
41
+
42
+ /**
43
+ * Withdraw a queued (not-yet-run) follow-up. Resolves false when the message had
44
+ * already been dequeued to run (nothing removed) — so "edit" won't put a copy
45
+ * back into the composer; throws when the request itself failed.
46
+ */
47
+ export async function cancelPendingMessage(taskId: string, pendingId: string, doFetch: typeof fetch = fetch): Promise<boolean> {
48
+ let response: Response;
49
+ try {
50
+ response = await doFetch(`/api/tasks/${taskId}/pending`, { method: "DELETE", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ pendingId }) });
51
+ } catch {
52
+ throw new Error("撤回失败:连不上执行节点,请稍后重试");
53
+ }
54
+ if (!response.ok) throw new Error(`撤回失败(HTTP ${response.status}),请稍后重试`);
55
+ const body = (await response.json().catch(() => null)) as { removed?: boolean } | null;
56
+ return body?.removed !== false;
57
+ }
@@ -4,6 +4,7 @@ import { clientId } from '../../core/id';
4
4
  import { taskFileApiUrl } from './fileLinks';
5
5
  import { openLive } from './liveStream';
6
6
  import { clientFeatures } from './protocol/features';
7
+ import { documentRequest } from '../../core/documentUpload';
7
8
  /** Node transport for the shared file and browser UI. No center routes or synthetic conversation data. */
8
9
  export function createOperatorBoardBackend(fetcher: typeof fetch = (...args) => fetch(...args)): BoardBackend {
9
10
  const client = createCenterClient({ baseUrl: '', fetch: async (input, init) => {
@@ -18,9 +19,11 @@ export function createOperatorBoardBackend(fetcher: typeof fetch = (...args) =>
18
19
  const viewers=new Map<string,{taskId:string;socket:WebSocket}>();
19
20
  return { ...client.board!, directLinks: true, browserLive:undefined,
20
21
  async info(id) {
22
+ const root= documentRequest<{ workspaceRoot?: string }>(fetcher,`/api/tasks/${encodeURIComponent(id)}/file-sync/capabilities`).catch(()=>null);
21
23
  const response=await fetcher(`/api/tasks/${encodeURIComponent(id)}`,{cache:'no-store'});
22
24
  if(!response.ok)throw new CenterError('无法读取任务看板',`HTTP_${response.status}`,response.status);
23
- const task=await response.json();return{job_id:id,dispatched:!!task.started||!!task.worktree_path,files:true,browser:clientFeatures().browser,remote_task_id:id};
25
+ const task=await response.json(),capabilities=await root;return{job_id:id,dispatched:!!task.started||!!task.worktree_path,files:true,browser:clientFeatures().browser,remote_task_id:id,
26
+ ...(typeof capabilities?.workspaceRoot==='string'?{workspaceRoot:capabilities.workspaceRoot}:{})};
24
27
  },
25
28
  fileUrl(id, path, options) { const url = taskFileApiUrl(id, path); return options?.download ? `${url}${url.includes('?') ? '&' : '?'}download=1` : url; },
26
29
  fileLinkBase: async id => `/api/tasks/${encodeURIComponent(id)}/files`,
@@ -29,9 +29,23 @@ export function useOperatorFileWatch(taskId:string,enabled:boolean,handlers:Oper
29
29
  useEffect(()=>{
30
30
  if(!enabled)return;
31
31
  const unobserve=observeTaskFiles(taskId);
32
- const unsubscribe=subscribeWorkspaceFiles(getOperatorBoardBackend(),taskId,event=>{current.current.onChange?.(event);notifyCallback(current.current.handlers.onFilesChange,cloneWorkspaceChange(event));notifyCallback(current.current.handlers.onEvent,cloneWorkspaceChange(event));},
33
- {intervalMs,onStatus:status=>{notifyCallback(current.current.handlers.onFilesWatch,{...status});notifyCallback(current.current.handlers.onEvent,{...status});}});
34
- return()=>{unobserve();unsubscribe();};
32
+ const subscriptions=new Map<string,()=>void>();
33
+ const sync=()=>{
34
+ const sources=new Set([taskId,...readVisibleBoardSources(taskId)]);
35
+ for(const [source,stop] of subscriptions)if(!sources.has(source)){stop();subscriptions.delete(source);}
36
+ for(const source of sources)if(!subscriptions.has(source)){
37
+ // Reserve before subscribing: the initial status callback may navigate.
38
+ subscriptions.set(source,()=>{});
39
+ const stop=subscribeWorkspaceFiles(getOperatorBoardBackend(),source,event=>{
40
+ if(source===taskId)current.current.onChange?.(event);
41
+ notifyCallback(current.current.handlers.onFilesChange,cloneWorkspaceChange(event));
42
+ notifyCallback(current.current.handlers.onEvent,cloneWorkspaceChange(event));
43
+ },{intervalMs,onStatus:status=>{notifyCallback(current.current.handlers.onFilesWatch,{...status});notifyCallback(current.current.handlers.onEvent,{...status});}});
44
+ if(subscriptions.has(source))subscriptions.set(source,stop);else stop();
45
+ }
46
+ };
47
+ const unwatch=subscribeBoardState(taskId,sync);sync();
48
+ return()=>{unwatch();unobserve();for(const stop of subscriptions.values())stop();subscriptions.clear();};
35
49
  },[taskId,enabled,intervalMs]);
36
50
  }
37
51
  export function useOperatorContextEvents(taskId:string,enabled:boolean,handlers:OperatorBoardHandlers={}){
@@ -1,15 +1,18 @@
1
1
  import { createContext } from 'react';
2
+ import { createBoardSurfaces } from '../../board/linkage';
2
3
  import type { WorkspaceHandlers } from '../../core/provider';
3
4
  import type { CliEvent } from '../../core/store';
4
5
  import type { Quote } from './composerDraft';
5
6
  export type OperatorBoardTab = 'files' | 'changes' | 'context' | 'preview' | 'browser';
6
- export interface OperatorBoardOptions extends WorkspaceHandlers { watchFiles?:boolean; fileWatchIntervalMs?:number; onEvent?:(event:CliEvent)=>void; tabs?: OperatorBoardTab[]; availableTabs?: OperatorBoardTab[]; defaultTab?: OperatorBoardTab; autoContext?: boolean }
7
+ export interface OperatorBoardOptions extends WorkspaceHandlers { readOnly?:boolean; watchFiles?:boolean; fileWatchIntervalMs?:number; onEvent?:(event:CliEvent)=>void; tabs?: OperatorBoardTab[]; availableTabs?: OperatorBoardTab[]; defaultTab?: OperatorBoardTab; autoContext?: boolean }
7
8
  export type OperatorBoardTarget = { kind: 'file'; taskId: string; path: string } | { kind: 'browser'; taskId: string };
8
9
  export interface OperatorBoardRequest { sequence: number; target: OperatorBoardTarget }
9
10
  export const OperatorBoardContext = createContext<((target: OperatorBoardTarget) => boolean) | null>(null);
10
11
 
11
12
  export const OperatorBoardQuoteContext = createContext<((quote:Quote)=>void)|null>(null);
12
13
 
13
- const surfaces=new Set<(target:OperatorBoardTarget)=>boolean>();
14
- export function registerOperatorBoard(surface:(target:OperatorBoardTarget)=>boolean):()=>void {surfaces.add(surface);return()=>{surfaces.delete(surface);};}
15
- export function openOperatorBoard(target:OperatorBoardTarget):boolean {for(const surface of [...surfaces].reverse())if(surface(target))return true;return false;}
14
+ // The page's board receivers: the same registry the center store uses (board/linkage),
15
+ // one instance for the node workspace. Last registered is asked first.
16
+ const surfaces=createBoardSurfaces<OperatorBoardTarget>();
17
+ export function registerOperatorBoard(surface:(target:OperatorBoardTarget)=>boolean):()=>void {return surfaces.register(surface);}
18
+ export function openOperatorBoard(target:OperatorBoardTarget):boolean {return surfaces.open(target);}
@@ -1,10 +1,12 @@
1
1
  import { useSyncExternalStore } from 'react';
2
2
  import type { BoardFile, BoardView } from '../../board/workspace';
3
- import { rememberBoardFile, cloneBoardView, reportBoardOwner, activateBoardOwner, selectedBoardOwner } from '../../board/context';
3
+ import { rememberBoardFile, cloneBoardView } from '../../board/context';
4
+ import { createBoardOwners } from '../../board/linkage';
4
5
  import { notifyCallback } from '../../core/callbacks';
5
6
  const cache=new Map<string,{stamp:string;view:BoardView|null}>();
6
7
  const listeners=new Map<string,Set<()=>void>>();
7
- const owners=new Map<string,Map<string,BoardView>>();
8
+ // Which of a task's boards is in effect: the same owner rules as the center store (board/linkage).
9
+ const owners=createBoardOwners();
8
10
  // Mounted directory identity is transient; it must not become retained browsing history.
9
11
  const directorySources=new Map<string,Map<string,string>>();
10
12
  const key=(id:string)=>`cli-ui:operator-board:${id}`;
@@ -24,8 +26,8 @@ export function readBoardState(taskId:string):BoardView|null {
24
26
  }
25
27
  /** Internal: background refresh covers every visible owner, not just the selected board. */
26
28
  export function readVisibleBoardSources(taskId:string):string[] {
27
- const active=owners.get(taskId);
28
- const views=active?.size?[...active]:[['',readBoardState(taskId)] as const];
29
+ const active=owners.entries(taskId);
30
+ const views=active.length?active:[['',readBoardState(taskId)] as const];
29
31
  const sources=new Set<string>();
30
32
  for(const [owner,view] of views){
31
33
  if(!view||view.visible===false)continue;
@@ -51,24 +53,31 @@ export function visitBoardFile(taskId:string,file:BoardFile):void {
51
53
  publishBoardState(taskId,{...current,history:recent([...(current.history??[]),file])});
52
54
  }
53
55
  export function reportBoardState(taskId:string,owner:string,view:BoardView,directorySource?:string):void {
54
- const sources=owners.get(taskId)??new Map<string,BoardView>();
56
+ const previousView=readBoardState(taskId),previousSources=JSON.stringify(readVisibleBoardSources(taskId));
55
57
  if(directorySource){const directories=directorySources.get(taskId)??new Map<string,string>();directories.set(owner,directorySource);directorySources.set(taskId,directories);}
56
58
  else{const directories=directorySources.get(taskId);directories?.delete(owner);if(!directories?.size)directorySources.delete(taskId);}
57
- const history=readBoardState(taskId)?.history??view.history??[];
58
- const selected=reportBoardOwner(sources,owner,{...view,history});owners.set(taskId,sources);
59
- if(selected)publishBoardState(taskId,{...selected[1],history});
59
+ // Roots can arrive after a tab closes: enrich existing visits without reordering them.
60
+ const identity=(file:BoardFile)=>JSON.stringify([file.sourceId??taskId,file.path]);
61
+ const absolutePaths=new Map((view.history??[]).filter(file=>typeof file.absolutePath==='string'&&file.absolutePath).map(file=>[identity(file),file.absolutePath]));
62
+ const history=(readBoardState(taskId)?.history??view.history??[]).map(file=>{
63
+ const absolutePath=absolutePaths.get(identity(file));
64
+ return absolutePath&&absolutePath!==file.absolutePath?{...file,absolutePath}:file;
65
+ });
66
+ const selected=owners.report(taskId,owner,{...view,history});
67
+ if(selected)publishBoardState(taskId,{...selected,history});
68
+ if(readBoardState(taskId)===previousView&&JSON.stringify(readVisibleBoardSources(taskId))!==previousSources)for(const listener of [...listeners.get(taskId)??[]])notifyCallback(listener,undefined);
60
69
  }
61
70
  export function activateBoardState(taskId:string,owner:string):void {
62
- const sources=owners.get(taskId);if(!sources)return;
63
- const selected=activateBoardOwner(sources,owner);if(!selected)return;
64
- const previous=readBoardState(taskId),file=selected[1].current;
71
+ const selected=owners.activate(taskId,owner);if(!selected)return;
72
+ const previous=readBoardState(taskId),file=selected.current;
65
73
  const history=file?rememberBoardFile(previous?.history??[],file):previous?.history??[];
66
- publishBoardState(taskId,{...selected[1],history});
74
+ publishBoardState(taskId,{...selected,history});
67
75
  }
68
76
  export function releaseBoardState(taskId:string,owner:string):void {
69
- const sources=owners.get(taskId);sources?.delete(owner);if(!sources?.size)owners.delete(taskId);
77
+ const previousView=readBoardState(taskId),previousSources=JSON.stringify(readVisibleBoardSources(taskId));
78
+ const remaining=owners.report(taskId,owner,null);
70
79
  const directories=directorySources.get(taskId);directories?.delete(owner);if(!directories?.size)directorySources.delete(taskId);
71
80
  const previous=readBoardState(taskId);if(!previous)return;
72
- const remaining=sources?.size?selectedBoardOwner(sources)?.[1]:null;
73
81
  publishBoardState(taskId,remaining?{...remaining,history:previous.history,visible:remaining.visible!==false}:{...previous,visible:false});
82
+ if(readBoardState(taskId)===previousView&&JSON.stringify(readVisibleBoardSources(taskId))!==previousSources)for(const listener of [...listeners.get(taskId)??[]])notifyCallback(listener,undefined);
74
83
  }
@@ -1,4 +1,8 @@
1
1
  import type { UploadPhase } from "../../core/documentUpload";
2
+ import { withoutBoardContext } from "../../board/context";
3
+ import { ORIGINALS_NOTE } from "../../core/blocks";
4
+ import { clientId } from "../../core/id";
5
+ import { splitAttachments } from "./format";
2
6
 
3
7
  export type Quote = { id: string; author: string; text: string; sourceTaskId?: string };
4
8
  export type Attachment = {
@@ -40,6 +44,24 @@ export function writeDraft(id: string, draft: ComposerDraft) {
40
44
  memory.set(id,{stamp:stamp(id),draft});
41
45
  window.dispatchEvent(new CustomEvent(DRAFT_EVENT, { detail: { id, draft } }));
42
46
  }
47
+ /**
48
+ * 编辑排队消息:撤回成功后放回输入框。文字(含引用)和附件原件在前,输入框里还没发的草稿接在后面——两边都不丢。
49
+ * 去掉发送时会自动重新附带的部分:「看板正在看」的被动背景、带原件时自动加的那句提示。
50
+ */
51
+ export function restoreQueuedDraft(taskId: string, content: string, workspaceRoot?: string): void {
52
+ const { text, attachments } = splitAttachments(withoutBoardContext(content), { taskId, workspaceRoot });
53
+ const body = text.split("\n").filter((line) => line.trim() !== ORIGINALS_NOTE).join("\n").replace(/\n{3,}/g, "\n\n").trim();
54
+ const current = readDraft(taskId);
55
+ writeDraft(taskId, {
56
+ ...current,
57
+ text: [body, current.text].filter((value) => value.trim()).join("\n\n"),
58
+ attachments: [
59
+ ...attachments.map((a): Attachment => ({ key: clientId(), kind: a.kind, name: a.name, path: a.path, preview: a.kind === "image" ? a.url : "", status: "ready" })),
60
+ ...current.attachments,
61
+ ],
62
+ });
63
+ }
64
+
43
65
  export function quoteText(quote: Quote): string {
44
66
  return `引用 ${quote.author}:\n${quote.text.split("\n").map((line) => `> ${line}`).join("\n")}`;
45
67
  }
@@ -5,26 +5,17 @@
5
5
  // 打不开。这里改写到 /api/tasks/<id>/files/…(服务端见 lib/taskFiles.ts),
6
6
  // Markdown 则改到 /view 预览页渲染。
7
7
  import { createContext } from "react";
8
+ import { localFilePath } from "../../ui/fileLinks";
9
+
10
+ // 本地文件路径的识别规则与中枢适配共用(ui/fileLinks 的 localFilePath);这里只管改写成节点的文件地址。
11
+ export { localFilePath };
8
12
 
9
13
  /** 当前渲染的 Markdown 属于哪个任务、相对哪个目录(预览页里是 md 文件所在目录)。 */
10
14
  export type FileLinkScope = { taskId: string; baseDir?: string } | null;
11
15
  export const FileLinkContext = createContext<FileLinkScope>(null);
12
16
 
13
- const SCHEME = /^[a-z][a-z0-9+.-]*:/i;
14
17
  const WIN_ABS = /^[a-z]:[\\/]/i;
15
18
 
16
- function normalize(p: string): string {
17
- const abs = p.startsWith("/");
18
- const out: string[] = [];
19
- for (const seg of p.split("/")) {
20
- if (!seg || seg === ".") continue;
21
- if (seg === ".." && out.length && out[out.length - 1] !== "..") out.pop();
22
- else if (seg === ".." && abs) continue;
23
- else out.push(seg);
24
- }
25
- return (abs ? "/" : "") + out.join("/");
26
- }
27
-
28
19
  export function isMarkdownPath(p: string): boolean {
29
20
  return /\.(md|markdown)$/i.test(p);
30
21
  }
@@ -40,31 +31,6 @@ export function markdownViewUrl(taskId: string, p: string): string {
40
31
  return `/view?task=${encodeURIComponent(taskId)}&path=${encodeURIComponent(p)}`;
41
32
  }
42
33
 
43
- /**
44
- * 链接指向本地文件时,返回它的路径(相对任务工作目录,或绝对路径);
45
- * 网址、锚点、应用自己的地址等返回 null(保持原样)。
46
- */
47
- export function localFilePath(href: string | undefined | null, baseDir = ""): string | null {
48
- let h = String(href ?? "").trim();
49
- if (!h || h.startsWith("#") || h.startsWith("//") || h.startsWith("/api/") || h.startsWith("/view?")) return null;
50
- if (/^file:/i.test(h)) h = h.replace(/^file:(\/\/localhost)?(\/\/)?/i, "");
51
- else if (SCHEME.test(h) && !WIN_ABS.test(h)) return null;
52
- // 去掉查询和锚点(#L12 之类),再解码(Markdown 解析器会把中文转成 %XX)。
53
- h = h.replace(/[?#].*$/, "");
54
- try {
55
- h = decodeURI(h);
56
- } catch {
57
- // 保持原样
58
- }
59
- h = h.replace(/\\/g, "/");
60
- // 编辑器风格的行号:src/a.ts:12 或 :12:5
61
- h = h.replace(/:(\d+)(:\d+)?$/, "");
62
- if (!h) return null;
63
- if (h === "~" || h.startsWith("~/")) return h;
64
- if (h.startsWith("/") || WIN_ABS.test(h)) return WIN_ABS.test(h) ? h : normalize(h);
65
- return normalize(baseDir ? `${baseDir.replace(/\/+$/, "")}/${h}` : h);
66
- }
67
-
68
34
  /** 链接改写的最终结果:Markdown → 预览页;其他文件 → 文件接口;不是本地文件 → null。 */
69
35
  export function rewriteFileHref(scope: FileLinkScope, href: string | undefined | null): string | null {
70
36
  if (!scope) return null;