@spzxg/cli-ui 0.6.17 → 0.6.19

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.
@@ -298,7 +298,12 @@ function ChatSession({ project, task, tasks, agents, messages, running, transcri
298
298
  )}
299
299
  </div>
300
300
  </div>
301
- {!readOnly && composer?.show !== false ? <Composer tasks={tasks} onFork={onFork} task={task} agentLabel={agentLabel(agents, task.agent)} disabled={task.started!==1} configBusy={configBusy} running={running} onSend={async text => { const sent = await onSend(text); if (sent && !running) scrollToBottom("auto"); return sent; }} onStop={onStop} onClear={onClear} quoteRequest={quoteRequest} onQuoteHandled={()=>setQuoteRequest(null)} controls={controls}
301
+ {!readOnly && composer?.show !== false ? <Composer tasks={tasks} onFork={onFork} task={task} agentLabel={agentLabel(agents, task.agent)} disabled={task.started!==1} configBusy={configBusy} running={running} onSend={async text => {
302
+ if (running) await stopTurn().catch(() => false);
303
+ const sent = await onSend(text);
304
+ if (sent) scrollToBottom("auto");
305
+ return sent;
306
+ }} onStop={onStop} onClear={onClear} quoteRequest={quoteRequest} onQuoteHandled={()=>setQuoteRequest(null)} controls={controls}
302
307
  fileUpload={composer?.fileUpload} queued={queued} /> : queued}
303
308
  </SubagentChatScope></FileLinkContext.Provider>
304
309
  );
@@ -273,7 +273,7 @@ export function Composer({ task, agentLabel, disabled, running, onSend, onStop,
273
273
  <button className="attach-x" disabled={locked} aria-label={`移除 ${a.name}`} onClick={() => removeAtt(a.key)}>×</button>
274
274
  </div>)}</div>}
275
275
  <div className="comp-area"><textarea ref={ref} rows={2} value={draft.text} disabled={locked} aria-label="消息输入框" aria-expanded={mentionOpen} aria-controls={mentionOpen ? `mentions-${task.id}` : undefined} aria-activedescendant={mentionOpen && candidates.length ? `mention-${candidates[Math.min(mentionIndex, candidates.length - 1)].id}` : undefined}
276
- placeholder={configBusy ? "正在保存设置…" : disabled ? "启动会话后即可回复…" : sources.length ? "描述这些新分支要继续完成的工作…" : running ? "补充下一步,当前轮次结束后发送…" : `和 ${agentLabel} 一起工作`}
276
+ placeholder={configBusy ? "正在保存设置…" : disabled ? "启动会话后即可回复…" : sources.length ? "描述这些新分支要继续完成的工作…" : running ? "输入新消息,发送将停止当前轮次并立即执行…" : `和 ${agentLabel} 一起工作`}
277
277
  onCompositionStart={() => { composing.current = true; }} onCompositionEnd={() => { composing.current = false; }}
278
278
  onChange={(e) => { const text = e.target.value; update((d) => ({ ...d, text })); setSlash(text.trim().startsWith("/")); setCaret(e.target.selectionStart); setMentionClosed(false); setMentionIndex(0); }}
279
279
  onSelect={(e) => setCaret(e.currentTarget.selectionStart)}
@@ -312,7 +312,7 @@ export function Composer({ task, agentLabel, disabled, running, onSend, onStop,
312
312
  <RunControls {...controls} disabled={controls.disabled || sending} />
313
313
  <div className="send-group">
314
314
  {showStop ? <button type="button" className="send stop" disabled={stopping} aria-busy={stopping} aria-label={stopping ? "正在停止" : "停止当前轮次"} title={stopping ? "正在停止…" : "停止当前轮次"} onClick={() => void stop()}>{stopping ? <span className="spinner" /> : Icon.stop()}</button>
315
- : <button type="button" className={`send${running ? " queue" : ""}`} disabled={!canSend} aria-busy={sending} aria-label={sending ? "正在发送" : sources.length ? `派生 ${sources.length} 个分支` : running ? "排队发送" : "发送消息"} title={sending ? "发送中…" : running ? "本轮结束后发送" : "发送消息(Enter)"} onClick={() => void submit()}>{sending ? <span className="spinner" /> : Icon.send()}</button>}
315
+ : <button type="button" className={`send${running ? " queue" : ""}`} disabled={!canSend} aria-busy={sending} aria-label={sending ? "正在发送" : sources.length ? `派生 ${sources.length} 个分支` : running ? "排队发送" : "发送消息"} title={sending ? "发送中…" : running ? "停止当前轮次并立即发送" : "发送消息(Enter)"} onClick={() => void submit()}>{sending ? <span className="spinner" /> : Icon.send()}</button>}
316
316
  </div>
317
317
  </div>
318
318
  </div>
@@ -1,4 +1,4 @@
1
- import { memo, useContext, type ComponentProps, type MouseEvent, type ReactNode } from "react";
1
+ import { createContext, memo, useContext, type ComponentProps, type MouseEvent, type ReactNode } from "react";
2
2
  import ReactMarkdown, { defaultUrlTransform } from "react-markdown";
3
3
  import remarkGfm from "remark-gfm";
4
4
  import rehypeHighlight from "rehype-highlight";
@@ -50,12 +50,18 @@ export interface MarkdownLinks {
50
50
  * 只高亮写明语言的代码块(自动识别在流式输出时很耗),并 memo,文字没变的消息重渲染时跳过整个解析。
51
51
  * 长得像文件路径的行内代码(report.md、src/a.ts:12)按本地文件链接处理。
52
52
  */
53
+ const InLinkContext = createContext(false);
54
+
53
55
  export function createMarkdown({ Link, Image }: MarkdownLinks) {
56
+ function Anchor({ children, ...props }: ComponentProps<"a">) {
57
+ return <InLinkContext.Provider value={true}><Link {...props}>{children}</Link></InLinkContext.Provider>;
58
+ }
54
59
  function Code({ children, ...props }: ComponentProps<"code">) {
55
- const path = inlineFilePath(children);
60
+ const inLink = useContext(InLinkContext);
61
+ const path = inLink ? null : inlineFilePath(children);
56
62
  return path ? <Link href={path}><code {...props}>{children}</code></Link> : <code {...props}>{children}</code>;
57
63
  }
58
- const components = { a: Link, img: Image, code: Code };
64
+ const components = { a: Anchor, img: Image, code: Code };
59
65
  return memo(function Markdown({ children, highlight = true }: { children: string; highlight?: boolean }) {
60
66
  return (
61
67
  <div className="md">