Commit 656a0cbd authored by edy's avatar edy

fix(ui): show specific error reason when expert chat is not ready

When ensureChatAvailable fails for expert mode, the error message
previously used chatStatusMessage which shows "聊天服务已就绪" when
the runtime/gateway are healthy — misleading the user when the real
issue is project-level readiness (projectReady=false or missing
currentProjectId).

Now the error message identifies the actual failure:
- 项目工作区未就绪 when projectReady is false
- 未选择项目 when currentProjectId is missing
- 本地运行时未就绪 when runtime is not running
- 网关未连接 when gateway is not connected
- Falls back to the original chatStatusMessage for uncovered cases
Co-Authored-By: 's avatarClaude Opus 4.8 <noreply@anthropic.com>
parent e7115c62
......@@ -495,7 +495,31 @@ export function useChatStreamingController(deps: UseChatStreamingControllerDeps)
return confirmedWorkspace
}
throw new Error(confirmedWorkspace.chatStatusMessage ?? ui.chatNotReadyError)
// Build a specific error message identifying the actual failure reason,
// rather than blindly using chatStatusMessage which may say "chat ready"
// when the real problem is project-level readiness.
const missingParts: string[] = []
if (confirmedViewMode === "experts") {
if (confirmedWorkspace.chatReady && !confirmedWorkspace.projectReady) {
missingParts.push("项目工作区未就绪")
}
if (!confirmedWorkspace.currentProjectId) {
missingParts.push("未选择项目")
}
}
if (confirmedWorkspace.chatReady && !confirmedCanExchange) {
const runtimeReady = confirmedRuntime?.activeMode === "external-gateway" || confirmedRuntime?.processState === "running"
if (!runtimeReady) {
missingParts.push("本地运行时未就绪")
} else if (confirmedGateway?.state !== "connected") {
missingParts.push("网关未连接")
}
}
throw new Error(
missingParts.length > 0
? `${missingParts.join(",")},请稍后重试`
: (confirmedWorkspace.chatStatusMessage ?? ui.chatNotReadyError)
)
}, [appendTrace, desktopApi.gateway, desktopApi.runtime, desktopApi.workspace, setGatewayStatus, setRuntimeStatus, setWorkspace, ui.bindFirstError, ui.chatNotReadyError, ui.checkingChat, ui.checkingChatDetail, ui.connectingGateway, ui.connectingGatewayDetail, ui.startingRuntime, ui.startingRuntimeDetail, updateAssistantStatus])
const submitPrompt = useCallback(async ({
......
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