- Move leftSidebarMode from URL state to local useState in unified-shell,
avoiding force-dynamic router round-trip that made the button appear broken - Replace fileURLToPath(new URL(..., import.meta.url)) with process.cwd()
in bb-pi-bootstrap.ts — import.meta.url is a webpack:// URL in Next.js,
causing cross-realm TypeError when passed to Node.js fileURLToPath()
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { listProjects } from './registry';
|
|
import { resolveProjectScope } from './project-scope';
|
|
|
|
export interface ResolveAgentWorkspaceOptions {
|
|
currentProjectRoot?: string;
|
|
requestedProjectKey?: string | null;
|
|
requestedProjectRoot?: string | null;
|
|
}
|
|
|
|
export interface ResolvedAgentWorkspace {
|
|
root: string;
|
|
key: string;
|
|
source: 'explicit-root' | 'scope-selection';
|
|
}
|
|
|
|
export async function resolveAgentWorkspace(options: ResolveAgentWorkspaceOptions = {}): Promise<ResolvedAgentWorkspace> {
|
|
const currentProjectRoot = options.currentProjectRoot ?? process.cwd();
|
|
|
|
if (options.requestedProjectRoot && options.requestedProjectRoot.trim()) {
|
|
const root = options.requestedProjectRoot.trim();
|
|
return {
|
|
root,
|
|
key: root.toLowerCase(),
|
|
source: 'explicit-root',
|
|
};
|
|
}
|
|
|
|
const registryProjects = await listProjects();
|
|
const scope = resolveProjectScope({
|
|
currentProjectRoot,
|
|
registryProjects,
|
|
requestedProjectKey: options.requestedProjectKey ?? null,
|
|
requestedMode: 'single',
|
|
});
|
|
|
|
return {
|
|
root: process.platform === 'win32' ? scope.selected.root : scope.selected.displayPath,
|
|
key: scope.selected.key,
|
|
source: 'scope-selection',
|
|
};
|
|
}
|