Commit e1298d9f authored by AI-甘富林's avatar AI-甘富林

fix(chat): preserve streaming conversation when switching sessions

parent 6dec17bf
This diff is collapsed.
......@@ -712,6 +712,17 @@ export class ProjectStoreService {
await writeJsonFile(await this.getSessionMessagesPath(sessionId), messages);
}
async upsertSessionMessage(sessionId: string, message: ChatMessage): Promise<void> {
const messages = await this.listSessionMessages(sessionId);
const existingIndex = messages.findIndex((entry) => entry.id === message.id);
if (existingIndex >= 0) {
messages[existingIndex] = message;
} else {
messages.push(message);
}
await writeJsonFile(await this.getSessionMessagesPath(sessionId), messages);
}
async listCurrentProjectSkills(): Promise<WorkspaceSkillSummary[]> {
const project = await this.getActiveProject();
return this.listProjectSkills(project.id);
......
This diff is collapsed.
export const IPC_CHANNELS = {
workspaceGetSummary: "workspace:get-summary",
workspaceWarmup: "workspace:warmup",
windowMinimize: "window:minimize",
windowMaximize: "window:maximize",
windowClose: "window:close",
gatewayStatus: "gateway:status",
gatewayConnect: "gateway:connect",
gatewayDisconnect: "gateway:disconnect",
......@@ -20,6 +23,7 @@
configSave: "config:save",
projectsList: "projects:list",
projectsSetActive: "projects:set-active",
projectsResolveIntent: "projects:resolve-intent",
skillCatalogList: "skill-catalog:list",
chatListSessions: "chat:list-sessions",
chatListSessionsByProject: "chat:list-sessions-by-project",
......@@ -27,6 +31,7 @@
chatCreateSessionForProject: "chat:create-session-for-project",
chatCloseSession: "chat:close-session",
chatListMessages: "chat:list-messages",
chatPickImageAttachment: "chat:pick-image-attachment",
chatSendPrompt: "chat:send-prompt",
chatStreamPrompt: "chat:stream-prompt",
chatStreamEvent: "chat:stream-event",
......@@ -38,6 +43,7 @@
profileGetSummary: "profile:get-summary",
creditsGetSummary: "credits:get-summary",
skillsList: "skills:list",
expertsList: "experts:list",
modelConfigGetSummary: "model-config:get-summary",
systemGetSummary: "system:get-summary"
} as const;
......@@ -66,6 +72,7 @@ export type SetupMode = "employee-key" | "direct-provider";
export type ChatLaunchState = "unbound" | "starting" | "ready" | "error";
export type WorkspaceStartupPhase = "idle" | "syncing-config" | "syncing-projects" | "starting-runtime" | "connecting-gateway" | "ready" | "error";
export type SkillDownloadState = "pending" | "downloading" | "ready" | "failed" | "removed";
export type ExpertEntryMode = "standalone" | "home-chat-shortcut";
export type DailyReportDeliveryState = "draft" | "sent" | "failed";
export interface WorkspaceWarmupResult {
......@@ -256,6 +263,17 @@ export interface WorkspaceSkillSummary {
lastError?: string;
}
export interface ExpertDefinition {
id: string;
name: string;
entryMode: ExpertEntryMode;
description?: string;
starterPrompt?: string;
promptFile?: string;
promptAvailable: boolean;
projectMatchKeywords: string[];
}
export interface PluginSummary {
id: string;
name: string;
......@@ -349,6 +367,16 @@ export interface ProjectSummary {
defaultEntryType?: ProjectPackageEntryType;
}
export interface ProjectIntentSuggestion {
projectId: string;
projectName: string;
projectDisplayName: string;
score: number;
confidence: "low" | "medium" | "high";
reason: string;
matchedAliases: string[];
}
export interface ProjectSessionSummary extends SessionSummary {
projectId: string;
}
......@@ -386,6 +414,18 @@ export interface ProjectSessionState {
draft: string;
}
export interface ChatAttachment {
kind: "image";
name: string;
mimeType: string;
localPath: string;
}
export interface ProjectResolvedAttachment extends ChatAttachment {
projectPath: string;
relativeProjectPath: string;
}
export interface ProjectExecutionRequest {
sessionId: string;
projectId: string;
......@@ -393,6 +433,7 @@ export interface ProjectExecutionRequest {
userPrompt: string;
context: ProjectContextSnapshot;
selectedSkillId: string | null;
attachments?: ProjectResolvedAttachment[];
projectConfig?: ProjectPackageConfig | null;
}
......@@ -418,9 +459,12 @@ export interface ChatMessage {
role: MessageRole;
content: string;
createdAt: string;
streamState?: "streaming" | "error";
statusLabel?: string;
statusDetail?: string;
}
export type ChatExecutionPolicySource = "cloud-default" | "cloud-skill-binding" | "local-fallback";
export type ChatExecutionPolicySource = "cloud-default" | "cloud-skill-binding" | "local-fallback" | "client-config";
export type ChatExecutionRoutingMode = ModelRoutingMode | SkillModelBindingMode | "fallback";
export interface ChatExecutionPolicy {
......@@ -437,6 +481,8 @@ export interface ChatStreamPromptResult {
requestId: string;
sessionId: string;
runId?: string;
userMessageId?: string;
assistantMessageId: string;
executionPolicy?: ChatExecutionPolicy;
}
......@@ -482,6 +528,7 @@ export interface ChatStreamErrorEvent {
sessionId: string;
runId?: string;
message: string;
errorCategory?: string;
}
export type ChatStreamEvent = ChatStreamStartedEvent | ChatStreamStatusEvent | ChatStreamDeltaEvent | ChatStreamCompletedEvent | ChatStreamErrorEvent;
......@@ -494,6 +541,60 @@ export interface PromptResult {
executionPolicy?: ChatExecutionPolicy;
}
export interface ModelEndpointConfig {
baseUrl: string;
apiKeyConfigured: boolean;
modelId?: string;
}
export interface DigitalHumanModelConfig {
volcRegion: string;
volcService: string;
volcHost: string;
volcScheme: string;
ttsVoice: string;
qiniuBucket: string;
qiniuDomain: string;
qiniuKeyPrefix: string;
volcAccessKeyConfigured: boolean;
volcSecretKeyConfigured: boolean;
qiniuAccessKeyConfigured: boolean;
qiniuSecretKeyConfigured: boolean;
}
export interface ExpertModelConfig {
image: ModelEndpointConfig;
video: ModelEndpointConfig;
copywriting: ModelEndpointConfig;
digitalHuman: DigitalHumanModelConfig;
}
export const FIXED_EXPERT_MODEL_ENDPOINTS = {
copywriting: {
baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
modelId: "qwen3.5-plus"
},
image: {
baseUrl: "https://ark.cn-beijing.volces.com/api/v3/images/generations",
modelId: "doubao-seedream-5-0-260128"
},
video: {
baseUrl: "https://ark.cn-beijing.volces.com/api/v3",
modelId: "doubao-seedance-2-0-260128"
}
} as const;
export const FIXED_DIGITAL_HUMAN_CONFIG = {
volcRegion: "cn-north-1",
volcService: "cv",
volcHost: "visual.volcengineapi.com",
volcScheme: "https",
ttsVoice: "zh-CN-YunxiNeural",
qiniuBucket: "alketas",
qiniuDomain: "http://tcwwu6wg4.hd-bkt.clouddn.com",
qiniuKeyPrefix: "omnihuman"
} as const;
export interface AppConfig {
setupMode: SetupMode;
provider: string;
......@@ -507,6 +608,7 @@ export interface AppConfig {
cloudApiBaseUrl: string;
runtimeCloudApiBaseUrl: string;
runtimeMode: RuntimeModePreference;
expertModelConfig: ExpertModelConfig;
}
export interface DiagnosticsExportResult {
......@@ -515,6 +617,19 @@ export interface DiagnosticsExportResult {
startupLogPath?: string;
}
export interface ModelEndpointInput {
baseUrl?: string;
apiKey?: string;
modelId?: string;
}
export interface DigitalHumanModelInput {
volcAccessKey?: string;
volcSecretKey?: string;
qiniuAccessKey?: string;
qiniuSecretKey?: string;
}
export interface SaveConfigInput {
setupMode: SetupMode;
provider: string;
......@@ -528,6 +643,12 @@ export interface SaveConfigInput {
cloudApiBaseUrl: string;
runtimeCloudApiBaseUrl: string;
runtimeMode: RuntimeModePreference;
expertModelConfig?: {
image?: ModelEndpointInput;
video?: ModelEndpointInput;
copywriting?: ModelEndpointInput;
digitalHuman?: DigitalHumanModelInput;
};
}
export interface AuthSessionSummary {
......@@ -651,6 +772,11 @@ export interface DesktopApi {
getSummary(): Promise<WorkspaceSummary>;
warmup(): Promise<WorkspaceWarmupResult>;
};
window: {
minimize(): Promise<void>;
maximize(): Promise<void>;
close(): Promise<void>;
};
gateway: {
status(): Promise<GatewayStatus>;
connect(): Promise<GatewayStatus>;
......@@ -681,6 +807,7 @@ export interface DesktopApi {
projects: {
list(): Promise<ProjectSummary[]>;
setActive(projectId: string): Promise<WorkspaceSummary>;
resolveIntent(prompt: string, currentProjectId?: string): Promise<ProjectIntentSuggestion | null>;
};
skillCatalog: {
list(): Promise<SkillCatalogItem[]>;
......@@ -699,6 +826,9 @@ export interface DesktopApi {
skills: {
list(): Promise<SkillSummary[]>;
};
experts: {
list(): Promise<ExpertDefinition[]>;
};
modelConfig: {
getSummary(): Promise<ModelConfigSummary>;
};
......@@ -712,8 +842,9 @@ export interface DesktopApi {
createSessionForProject(projectId: string, title?: string): Promise<ProjectSessionSummary>;
closeSession(sessionId: string): Promise<ProjectSessionSummary[]>;
listMessages(sessionId: string): Promise<ChatMessage[]>;
sendPrompt(sessionId: string, prompt: string, skillId?: string): Promise<PromptResult>;
streamPrompt(sessionId: string, prompt: string, skillId?: string): Promise<ChatStreamPromptResult>;
pickImageAttachment(): Promise<ChatAttachment | null>;
sendPrompt(sessionId: string, prompt: string, skillId?: string, attachments?: ChatAttachment[]): Promise<PromptResult>;
streamPrompt(sessionId: string, prompt: string, skillId?: string, attachments?: ChatAttachment[]): Promise<ChatStreamPromptResult>;
onStreamEvent(listener: ChatStreamListener): () => void;
};
diagnostics: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment