mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 09:11:26 +00:00
refactor(commands): dedupe workspace config prompt
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user