@@ -23,8 +23,10 @@ const ensureAuthProfileStore = vi.hoisted(() =>
2323 vi . fn ( ( ) => ( { version : 1 as const , profiles : { } } ) ) ,
2424) ;
2525const detectAvailableSetupProviderIds = vi . hoisted ( ( ) => vi . fn ( ) ) ;
26+ const launchTuiCli = vi . hoisted ( ( ) => vi . fn ( async ( _opts : unknown ) => undefined ) ) ;
2627
2728vi . mock ( "../../packages/terminal-core/src/restore.js" , ( ) => ( { restoreTerminalState } ) ) ;
29+ vi . mock ( "../tui/tui-launch.js" , ( ) => ( { launchTuiCli } ) ) ;
2830
2931vi . 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 } ) ;
0 commit comments