完善客户端模块与工作区能力
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
inman
2026-08-13 19:45:30 +08:00
parent 0148b91a15
commit 22add3f01f
97 changed files with 4756 additions and 3226 deletions

View File

@@ -76,6 +76,7 @@ type ServerConversationSummary = {
workspace_id: string;
agent_session_id: string | null;
title: string;
latest_message_preview?: string | null;
turn_revision: number;
phase: DesignConversationSummary['phase'];
brief: ServerBrief;
@@ -270,6 +271,19 @@ function mapWorkspace(workspace: ServerWorkspace): DesignWorkspace {
};
}
function normalizeMessagePreview(value: string | null | undefined): string | null {
const preview = value?.replace(/\s+/gu, ' ').trim();
return preview || null;
}
function latestServerMessagePreview(messages: ServerMessage[]): string | null {
for (let index = messages.length - 1; index >= 0; index -= 1) {
const preview = normalizeMessagePreview(messages[index]?.text);
if (preview) return preview;
}
return null;
}
function mapConversationSummary(
conversation: ServerConversationSummary,
): DesignConversationSummary {
@@ -277,6 +291,9 @@ function mapConversationSummary(
conversationId: conversation.conversation_id,
workspaceId: conversation.workspace_id,
title: conversation.title,
latestMessagePreview: normalizeMessagePreview(
conversation.latest_message_preview,
) ?? normalizeMessagePreview(conversation.brief.summary),
turnRevision: conversation.turn_revision,
phase: conversation.phase,
brief: mapBrief(conversation.brief),
@@ -286,18 +303,22 @@ function mapConversationSummary(
}
function mapConversation(conversation: ServerConversation): DesignConversation {
const messages = conversation.messages.map((message, index) => ({
id: `${conversation.conversation_id}:${message.turn_revision}:${message.role}:${index}`,
role: message.role,
kind: message.kind,
text: message.text,
quickReplies: message.quick_replies,
generationQuote: mapQuote(message.generation_quote),
turnRevision: message.turn_revision,
createdAt: message.created_at,
}));
return {
...mapConversationSummary(conversation),
messages: conversation.messages.map((message, index) => ({
id: `${conversation.conversation_id}:${message.turn_revision}:${message.role}:${index}`,
role: message.role,
kind: message.kind,
text: message.text,
quickReplies: message.quick_replies,
generationQuote: mapQuote(message.generation_quote),
turnRevision: message.turn_revision,
createdAt: message.created_at,
})),
latestMessagePreview: latestServerMessagePreview(messages)
?? normalizeMessagePreview(conversation.latest_message_preview)
?? normalizeMessagePreview(conversation.brief.summary),
messages,
};
}