Commit 7ffa84fe authored by AI-甘富林's avatar AI-甘富林

fix(desktop): improve project readiness and expert switching

parent f492464b
......@@ -428,6 +428,22 @@ function normalizeProjectPackageConfig(record: StoredProjectRecord | null): Proj
};
}
function hasDirectWorkspaceEntry(record: StoredProjectRecord | null): boolean {
if (!record) {
return false;
}
const packageConfig = normalizeProjectPackageConfig(record);
return Boolean(
packageConfig?.defaultEntry?.type === "workspace-entry"
|| packageConfig?.entries.some((entry) => entry.type === "workspace-entry")
|| record.workspaceEntryEnabled === true
|| record.executionEntryEnabled === true
|| typeof record.workspaceEntry === "string"
|| typeof record.executionEntry === "string"
);
}
export class ProjectStoreService {
private readonly configService: AppConfigService;
private readonly qSkillsRoot?: string;
......@@ -795,6 +811,7 @@ export class ProjectStoreService {
}): Promise<ProjectSummary> {
const projectId = input.projectId?.trim() || slugify(input.projectName);
const bundleProjectRecord = await this.readProjectRecord(projectId);
const directWorkspaceEntry = hasDirectWorkspaceEntry(bundleProjectRecord);
const availableWorkspaceSkillIds = await this.readWorkspaceSkillIds();
const materializedBoundSkillIds = uniqueSkillIds(input.boundSkillIds ?? []);
const declaredBoundSkillIds = uniqueSkillIds(input.declaredBoundSkillIds ?? bundleProjectRecord?.boundSkillIds ?? []);
......@@ -819,11 +836,12 @@ export class ProjectStoreService {
});
}
const lastError = missingBoundSkillIds.length > 0
const missingBoundSkillsBlockProject = missingBoundSkillIds.length > 0 && !directWorkspaceEntry;
const lastError = missingBoundSkillsBlockProject
? `Missing bound skills: ${missingBoundSkillIds.join(", ")}`
: undefined;
const nextReady = (input.ready ?? bundleProjectRecord?.ready ?? true)
&& (requestedBoundSkillIds.length === 0 || validBoundSkillIds.length > 0);
&& (directWorkspaceEntry || requestedBoundSkillIds.length === 0 || validBoundSkillIds.length > 0);
const project = await this.upsertProject({
...(bundleProjectRecord ?? {}),
id: projectId,
......
......@@ -2215,7 +2215,7 @@ export default function App() {
const isBound = !bindingRequired;
const hasConversationProject = viewMode === "chat"
? visibleProjects.length > 0
: Boolean(workspace?.projectReady && activeProject?.id);
: Boolean(workspace?.projectReady && activeProject?.id && workspace?.currentProjectId === activeProject.id);
const startupStateActive = viewMode !== "settings" && ((refreshing && !workspace) || !shellReady || (isBound && chatLaunchState !== "ready"));
const hasVisibleConversation = messages.length > 0 || sendPhase !== "idle";
const showStartupOverlay = startupStateActive && !hasVisibleConversation;
......@@ -4222,7 +4222,7 @@ export default function App() {
async function switchExpert(projectId: string) {
setViewMode("experts");
if (projectId === activeProject?.id && viewMode === "experts") {
if (workspace?.currentProjectId === projectId && viewMode === "experts") {
return;
}
await switchProject(projectId);
......
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