Skip to content

Commit 669c65c

Browse files
committed
fix(onboard): connect guided hatch through Gateway
1 parent f649017 commit 669c65c

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎src/commands/onboard-guided.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ const ensureAuthProfileStore = vi.hoisted(() =>
2323
vi.fn(() => ({ version: 1 as const, profiles: {} })),
2424
);
2525
const detectAvailableSetupProviderIds = vi.hoisted(() => vi.fn());
26+
const launchTuiCli = vi.hoisted(() => vi.fn(async (_opts: unknown) => undefined));
2627

2728
vi.mock("../../packages/terminal-core/src/restore.js", () => ({ restoreTerminalState }));
29+
vi.mock("../tui/tui-launch.js", () => ({ launchTuiCli }));
2830

2931
vi.mock("./auth-choice-prompt.js", async (importActual) => ({
3032
...(await importActual<typeof import("./auth-choice-prompt.js")>()),
@@ -282,6 +284,7 @@ describe("runGuidedOnboarding", () => {
282284
issues: [],
283285
config: localOnboarding.persisted.config ?? {},
284286
}));
287+
launchTuiCli.mockClear();
285288
});
286289

287290
afterEach(() => {
@@ -408,6 +411,23 @@ describe("runGuidedOnboarding", () => {
408411
expect(deps.launchHatchTui).toHaveBeenCalledWith("/tmp/work");
409412
});
410413

414+
it("launches the guided terminal hatch through the running Gateway", async () => {
415+
const prompter = createWizardPrompter();
416+
const deps: GuidedOnboardingDeps = setupDeps({ prompter });
417+
delete deps.launchHatchTui;
418+
419+
await runGuidedOnboarding(
420+
{ acceptRisk: true, workspace: "/tmp/work", tui: true },
421+
makeRuntime(),
422+
deps,
423+
);
424+
425+
expect(launchTuiCli).toHaveBeenCalledOnce();
426+
const options = launchTuiCli.mock.calls[0]?.[0] as Record<string, unknown>;
427+
expect(options).toMatchObject({ deliver: false });
428+
expect(options).not.toHaveProperty("local");
429+
});
430+
411431
it("uses --skip-ui to skip both browser and terminal handoffs", async () => {
412432
const prompter = createWizardPrompter();
413433
const deps = setupDeps({ prompter });

‎src/commands/onboard-guided.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,10 +718,10 @@ async function launchHatchTui(workspace: string): Promise<void> {
718718
const hasBootstrap = fs.existsSync(path.join(workspace, DEFAULT_BOOTSTRAP_FILENAME));
719719
restoreTerminalState("guided hatch tui", { resumeStdinIfPaused: false });
720720
try {
721+
// Setup already started the Gateway; local mode would contend for its state lock.
721722
// No timeoutMs: the run-level TUI timeout overrides the configured agent
722723
// timeout for every turn in the session, not just the hatch message.
723724
await launchTuiCli({
724-
local: true,
725725
deliver: false,
726726
// Seed the first-run hatch only when the workspace bootstrap exists;
727727
// re-runs against an established agent open a plain chat instead.

0 commit comments

Comments
 (0)