Skip to content

Commit d1f8c33

Browse files
authored
fix(onboard): provision workspace before config commit (#124092)
1 parent d74a69e commit d1f8c33

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

‎src/commands/onboard-non-interactive/local.default-agent.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,28 @@ describe("runNonInteractiveLocalSetup default-agent ownership", () => {
226226
expect(mocks.ensureWorkspaceAndSessions).not.toHaveBeenCalled();
227227
});
228228

229+
it("does not publish config when the existing agent workspace cannot be provisioned", async () => {
230+
mocks.ensureWorkspaceAndSessions.mockRejectedValueOnce(new Error("workspace is unwritable"));
231+
232+
await expect(
233+
runNonInteractiveLocalSetup({
234+
opts: {
235+
nonInteractive: true,
236+
mode: "local",
237+
authChoice: "skip",
238+
skipHooks: true,
239+
skipSkills: true,
240+
skipHealth: true,
241+
},
242+
runtime,
243+
baseConfig: { agents: { entries: { ops: { default: true } } } },
244+
}),
245+
).rejects.toThrow("workspace is unwritable");
246+
247+
expect(mocks.commitConfig).not.toHaveBeenCalled();
248+
expect(mocks.logConfigUpdated).not.toHaveBeenCalled();
249+
});
250+
229251
it("provisions and reports the keyed default agent while preserving the global workspace", async () => {
230252
const baseConfig = {
231253
agents: {

‎src/commands/onboard-non-interactive/local.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ export async function runNonInteractiveLocalSetup(params: {
281281
nextConfig = applySkipBootstrapConfig(nextConfig);
282282
}
283283

284+
const finalTarget = resolveOnboardingAgentTarget(nextConfig, selectedAgentId);
285+
await ensureOnboardingAgentWorkspace(finalTarget, runtime, {
286+
skipBootstrap: Boolean(nextConfig.agents?.defaults?.skipBootstrap),
287+
skipOptionalBootstrapFiles: nextConfig.agents?.defaults?.skipOptionalBootstrapFiles,
288+
});
289+
284290
nextConfig = applyWizardMetadata(nextConfig, { command: "onboard", mode });
285291
nextConfig = await commitNonInteractiveOnboardConfig({
286292
nextConfig,
@@ -289,12 +295,6 @@ export async function runNonInteractiveLocalSetup(params: {
289295
});
290296
logConfigUpdated(runtime);
291297

292-
const finalTarget = resolveOnboardingAgentTarget(nextConfig, selectedAgentId);
293-
await ensureOnboardingAgentWorkspace(finalTarget, runtime, {
294-
skipBootstrap: Boolean(nextConfig.agents?.defaults?.skipBootstrap),
295-
skipOptionalBootstrapFiles: nextConfig.agents?.defaults?.skipOptionalBootstrapFiles,
296-
});
297-
298298
const daemonRuntimeRaw = opts.daemonRuntime ?? DEFAULT_GATEWAY_DAEMON_RUNTIME;
299299
let daemonInstallStatus:
300300
| {

0 commit comments

Comments
 (0)