From 55b7100ab91b6ebf7d936213584d3e804481a906 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 15 Feb 2026 06:19:12 +0000 Subject: [PATCH] refactor(commands): dedupe workspace config prompt --- src/commands/configure.wizard.ts | 62 +++++++++++++------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/src/commands/configure.wizard.ts b/src/commands/configure.wizard.ts index 06b2dcd1a3b..4961e0c5cf3 100644 --- a/src/commands/configure.wizard.ts +++ b/src/commands/configure.wizard.ts @@ -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(); }