feat(conversation): replicate table quote-to-chat action (TODO 02)

This commit is contained in:
xiaohan.yuan committed 2026-10-17 05:57:49 +08:00
1 parent e335588826
commit ed31a7c1b4
20 files changed
+939 -46

No files matched your search

+5 -2
View File
@@ -532,7 +532,7 @@ export function registerIpc(getWindow: () => BrowserWindow | null): void {
const win = getWindow()
const { sessionId, text } = payload
if (!(await sessions.listSessions()).some((session) => session.id === sessionId)) throw new Error('会话不存在')
if (typeof text !== 'string' || (!text.trim() && !payload.attachments?.length)) throw new Error('消息为空')
if (typeof text !== 'string' || (!text.trim() && !payload.attachments?.length && !payload.quotes?.length)) throw new Error('消息为空')
if ([...runTasks.values()].some((run) => run.sessionId === sessionId)) throw new Error('该会话正在运行')
const attachments = await Promise.all((payload.attachments ?? []).map((item) => getAttachment(item.id)))
const promptAttachments = await attachmentPrompt(attachments)
@@ -601,6 +601,7 @@ export function registerIpc(getWindow: () => BrowserWindow | null): void {
planId: payload.planId,
attachments,
resources: references,
quotes: payload.quotes?.length ? payload.quotes : undefined,
skills: capabilitySnapshot.references,
capabilityContext: capabilitySnapshot.context || undefined,
expertId: context.expertId ?? undefined,
@@ -661,7 +662,9 @@ export function registerIpc(getWindow: () => BrowserWindow | null): void {
}
runEmitters.set(runId, emit)
const interactionBroker = createInteractionBroker(runId, controller.signal, emit)
const promptText = [text, promptAttachments.text, references.length ? `引用工作区资源:\n${references.join('\n')}` : '', capabilitySnapshot.context].filter(Boolean).join('\n\n')
// 对话中引用的内容块(原版 message-quote)随消息一起交给模型;表格 markdown 原样附带。
const quoteText = (payload.quotes ?? []).map((quote) => quote.markdown.trim()).filter(Boolean).join('\n\n')
const promptText = [text, quoteText, promptAttachments.text, references.length ? `引用工作区资源:\n${references.join('\n')}` : '', capabilitySnapshot.context].filter(Boolean).join('\n\n')
// 回合在后台推进,立刻把 runId 还给渲染进程
const initialMessages = payload.action ? structuredClone([...history, userMessage, assistant]) : undefined