fix(vscode): detect workspace before runtime registration
This commit is contained in:
@@ -13,6 +13,7 @@ import { PROJECT_COLORS } from '@/lib/projectMeta';
|
||||
import { useSessionUIStore } from '@/sync/session-ui-store';
|
||||
import { runtimeFetch } from '@/lib/runtime-fetch';
|
||||
import { getRuntimeApiBaseUrl } from '@/lib/runtime-switch';
|
||||
import { getVSCodeBootstrapConfig, isVSCodeRuntime } from './utils/vscodeRuntime';
|
||||
|
||||
/** Pick a color key that's least used among existing projects */
|
||||
const pickAutoColor = (projects: ProjectEntry[]): string => {
|
||||
@@ -416,21 +417,11 @@ const createVSCodeWorkspaceProject = (
|
||||
};
|
||||
|
||||
const getVSCodeWorkspaceFolders = (): VSCodeWorkspaceFolderConfig[] | null => {
|
||||
if (typeof window === 'undefined') {
|
||||
return null;
|
||||
}
|
||||
|
||||
const runtimeApis = getRegisteredRuntimeAPIs();
|
||||
if (!runtimeApis?.runtime?.isVSCode) {
|
||||
const config = getVSCodeBootstrapConfig();
|
||||
if (!isVSCodeRuntime(runtimeApis, config)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const config = (window as unknown as {
|
||||
__VSCODE_CONFIG__?: {
|
||||
workspaceFolder?: unknown;
|
||||
workspaceFolders?: unknown;
|
||||
};
|
||||
}).__VSCODE_CONFIG__;
|
||||
const folders = Array.isArray(config?.workspaceFolders)
|
||||
? config.workspaceFolders
|
||||
.map((entry) => {
|
||||
@@ -542,8 +533,7 @@ const getVSCodeWorkspaceProject = (): { projects: ProjectEntry[]; activeProjectI
|
||||
// Always prefer the VS Code workspace projects over any persisted multi-project registry.
|
||||
const vscodeWorkspace = getVSCodeWorkspaceProject();
|
||||
const isVSCodeProjectsRuntime = (() => {
|
||||
if (typeof window === 'undefined') return false;
|
||||
return Boolean(getRegisteredRuntimeAPIs()?.runtime?.isVSCode);
|
||||
return isVSCodeRuntime(getRegisteredRuntimeAPIs(), getVSCodeBootstrapConfig());
|
||||
})();
|
||||
const effectiveInitialProjects = vscodeWorkspace?.projects ?? (isVSCodeProjectsRuntime ? [] : initialProjects);
|
||||
const persistedInitialActiveProjectId = vscodeWorkspace?.activeProjectId ?? (isVSCodeProjectsRuntime ? null : readPersistedActiveProjectId());
|
||||
|
||||
Reference in New Issue
Block a user