Skip to content

The agent that grows with you

fix(desktop): continuing without setup can no longer reopen the setup chat

alt-glitch751b1c0c5d36
diff --git a/apps/desktop/src/app/contrib/onboarding-kickoff-machine.ts b/apps/desktop/src/app/contrib/onboarding-kickoff-machine.ts
index 6a6224f6894..09efa07c574 100644
--- a/apps/desktop/src/app/contrib/onboarding-kickoff-machine.ts
+++ b/apps/desktop/src/app/contrib/onboarding-kickoff-machine.ts
@@ -61,10 +61,8 @@ export interface KickoffMachine {
dispose(): void
/** Aborts every call that carries `signal` and fails the kickoff with `reason`. */
stop(reason: KickoffFailure): void
- /** Passed to every kickoff RPC, so `stop` rejects the ones still in flight. */
+ /** Passed to every kickoff RPC, so `stop` rejects the ones still in flight and any started after it. */
signal: AbortSignal
- /** `work`, or `stop`'s reason if that comes first: for steps that take no signal. */
- until<T>(work: Promise<T>): Promise<T>
}
export function createKickoffMachine(): KickoffMachine {
@@ -83,16 +81,6 @@ export function createKickoffMachine(): KickoffMachine {
}
}
- const until = <T>(work: Promise<T>): Promise<T> =>
- stopReason
- ? Promise.reject(stopReason)
- : Promise.race([
- work,
- new Promise<never>((_, reject) =>
- stopper.signal.addEventListener('abort', () => reject(stopReason), { once: true })
- )
- ])
-
const enter = (next: KickoffState, detail?: string) => {
log(`${state} -> ${next}${detail ? ` (${detail})` : ''}`)
state = next
@@ -181,5 +169,5 @@ export function createKickoffMachine(): KickoffMachine {
}
}
- return { attempt, dispose: () => offExit?.(), enter, signal: stopper.signal, stop, until }
+ return { attempt, dispose: () => offExit?.(), enter, signal: stopper.signal, stop }
}
diff --git a/apps/desktop/src/app/contrib/onboarding-kickoff.ts b/apps/desktop/src/app/contrib/onboarding-kickoff.ts
index 0b641a04daa..eeedf56ffa7 100644
--- a/apps/desktop/src/app/contrib/onboarding-kickoff.ts
+++ b/apps/desktop/src/app/contrib/onboarding-kickoff.ts
@@ -183,7 +183,7 @@ export function useOnboardingKickoff({ requestGateway, resumeSession, runSlashCo
$newChatProfile.set(setupProfile)
}
- await machine.until(ensureGatewayProfile(setupProfile))
+ await ensureGatewayProfile(setupProfile)
// Finds the setup chat by title or creates it; `empty` is true only before its first turn.
const setupChat = await requestGateway<OnboardingEnsureSetupSessionResult>(
@@ -204,13 +204,22 @@ export function useOnboardingKickoff({ requestGateway, resumeSession, runSlashCo
const { record, setupChat, setupProfile } = prepared
+ // The way out covers the waits only. Opening switches the session and cannot be cancelled halfway, so a
+ // stop there would roll back under a resume that still lands on the setup chat.
+ window.clearTimeout(offerExit)
+ $introStartExit.set(null)
+
machine.enter('opening', `session ${setupChat.session_id}`)
const guideRequest: AmbientGatewayRequest = (method, params, timeout) =>
requestGatewayForProfile(setupProfile, method, params, timeout)
- const runtimeId = await machine.until(
- adoptGuideSession(setupProfile, setupChat.session_id, record.free_tier_route, resumeSession, guideRequest)
+ const runtimeId = await adoptGuideSession(
+ setupProfile,
+ setupChat.session_id,
+ record.free_tier_route,
+ resumeSession,
+ guideRequest
)
// A relaunch reopens the same setup chat; one whose opening was cut off is sent the command again.