mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 04:02:42 +00:00
refactor(commands): dedupe workspace config prompt
This commit is contained in:
@@ -323,6 +323,28 @@ export async function runConfigureWizard(
|
|||||||
logConfigUpdated(runtime);
|
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) {
|
if (opts.sections) {
|
||||||
const selected = opts.sections;
|
const selected = opts.sections;
|
||||||
if (!selected || selected.length === 0) {
|
if (!selected || selected.length === 0) {
|
||||||
@@ -331,25 +353,7 @@ export async function runConfigureWizard(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selected.includes("workspace")) {
|
if (selected.includes("workspace")) {
|
||||||
const workspaceInput = guardCancel(
|
await configureWorkspace();
|
||||||
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 (selected.includes("model")) {
|
if (selected.includes("model")) {
|
||||||
@@ -420,25 +424,7 @@ export async function runConfigureWizard(
|
|||||||
ranSection = true;
|
ranSection = true;
|
||||||
|
|
||||||
if (choice === "workspace") {
|
if (choice === "workspace") {
|
||||||
const workspaceInput = guardCancel(
|
await configureWorkspace();
|
||||||
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 persistConfig();
|
await persistConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user