refactor(commands): dedupe workspace config prompt

This commit is contained in:
Peter Steinberger
2026-02-15 06:19:12 +00:00
parent 26bf041add
commit 55b7100ab9

View File

@@ -323,6 +323,28 @@ export async function runConfigureWizard(
logConfigUpdated(runtime);
};
const configureWorkspace = async () => {
const workspaceInput = guardCancel(
await text({
message: "Workspace directory",
initialValue: workspaceDir,
}),
runtime,
);
workspaceDir = resolveUserPath(String(workspaceInput ?? "").trim() || DEFAULT_WORKSPACE);
nextConfig = {
...nextConfig,
agents: {
...nextConfig.agents,
defaults: {
...nextConfig.agents?.defaults,
workspace: workspaceDir,
},
},
};
await ensureWorkspaceAndSessions(workspaceDir, runtime);
};
if (opts.sections) {
const selected = opts.sections;
if (!selected || selected.length === 0) {
@@ -331,25 +353,7 @@ export async function runConfigureWizard(
}
if (selected.includes("workspace")) {
const workspaceInput = guardCancel(
await text({
message: "Workspace directory",
initialValue: workspaceDir,
}),
runtime,
);
workspaceDir = resolveUserPath(String(workspaceInput ?? "").trim() || DEFAULT_WORKSPACE);
nextConfig = {
...nextConfig,
agents: {
...nextConfig.agents,
defaults: {
...nextConfig.agents?.defaults,
workspace: workspaceDir,
},
},
};
await ensureWorkspaceAndSessions(workspaceDir, runtime);
await configureWorkspace();
}
if (selected.includes("model")) {
@@ -420,25 +424,7 @@ export async function runConfigureWizard(
ranSection = true;
if (choice === "workspace") {
const workspaceInput = guardCancel(
await text({
message: "Workspace directory",
initialValue: workspaceDir,
}),
runtime,
);
workspaceDir = resolveUserPath(String(workspaceInput ?? "").trim() || DEFAULT_WORKSPACE);
nextConfig = {
...nextConfig,
agents: {
...nextConfig.agents,
defaults: {
...nextConfig.agents?.defaults,
workspace: workspaceDir,
},
},
};
await ensureWorkspaceAndSessions(workspaceDir, runtime);
await configureWorkspace();
await persistConfig();
}