A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
[RSI] Mark onboarding shown only after the flow completes (#2245)
Seth Karten1316d187b7d7
diff --git a/packages/coding-agent/.changes/eng-6104-onboarding-completion-gate.md b/packages/coding-agent/.changes/eng-6104-onboarding-completion-gate.mdnew file mode 100644index 0000000000..0d47e628fd--- /dev/null+++ b/packages/coding-agent/.changes/eng-6104-onboarding-completion-gate.md@@ -0,0 +1 @@+- Escaping the onboarding splash or failing its login no longer permanently skips onboarding; the guide reruns on the next launch until a model is configured.diff --git a/packages/coding-agent/src/modes/interactive/interactive-mode.ts b/packages/coding-agent/src/modes/interactive/interactive-mode.tsindex efe3c0237e..5cdc283767 100644--- a/packages/coding-agent/src/modes/interactive/interactive-mode.ts+++ b/packages/coding-agent/src/modes/interactive/interactive-mode.ts@@ -1784,10 +1784,15 @@ export class InteractiveMode {const showPrimeCliSplash = this.shouldRunPrimeCliOnboardingSplash();let outcome: TelemetryOnboardingOutcome = "aborted";try {- this.markOnboardingShown();- await this.settingsManager.flush();await this.runOnboardingFlow(showPrimeCliSplash);outcome = isOnboardingModelReady(this.getOnboardingState()) ? "success" : "aborted";+ if (outcome === "success") {+ // Only a completed onboarding counts as seen: an escaped splash or a+ // failed login leaves the flag unset so the next launch retries, and+ // shouldRunOnboarding already skips users who configured a model.+ this.markOnboardingShown();+ await this.settingsManager.flush();+ }return true;} catch (error) {outcome = "error";diff --git a/packages/coding-agent/test/interactive-mode-onboarding-completion.test.ts b/packages/coding-agent/test/interactive-mode-onboarding-completion.test.tsnew file mode 100644index 0000000000..7fa42c394a--- /dev/null+++ b/packages/coding-agent/test/interactive-mode-onboarding-completion.test.ts@@ -0,0 +1,73 @@+import { beforeAll, describe, expect, it, vi } from "vitest";+import { InteractiveMode } from "../src/modes/interactive/interactive-mode.js";+import type { OnboardingStartupState } from "../src/modes/interactive/onboarding.js";+import { initTheme } from "../src/modes/interactive/theme/theme.js";++type Context = Record<string, unknown> & {+ settingsManager: {+ getOnboardingShown: () => boolean;+ setOnboardingShown: (shown: boolean) => void;+ flush: () => Promise<void>;+ };+};++type Prototype = {+ runStartupOnboarding(this: Context): Promise<boolean>;+};++const prototype = InteractiveMode.prototype as unknown as Prototype;++function makeContext(options: { modelReady: boolean }): Context {+ const shown = { value: false };+ const context: Context = {+ settingsManager: {+ getOnboardingShown: () => shown.value,+ setOnboardingShown: (value: boolean) => {+ shown.value = value;+ },+ flush: vi.fn(async () => {}),+ },+ shouldRunOnboarding: () => true,+ shouldRunPrimeCliOnboardingSplash: () => false,+ runOnboardingFlow: vi.fn(async () => {}),+ markOnboardingShown: InteractiveMode.prototype[+ "markOnboardingShown" as keyof typeof InteractiveMode.prototype+ ] as (this: Context) => void,+ getOnboardingState: (): OnboardingStartupState =>+ ({+ settingsManager: context.settingsManager,+ modelRegistry: {+ refresh: () => {},+ hasConfiguredAuth: () => options.modelReady,+ getProviderAuthStatus: () => ({+ configured: options.modelReady,+ source: options.modelReady ? "runtime" : undefined,+ }),+ authStorage: { get: () => undefined },+ },+ model: options.modelReady ? { id: "m", provider: "anthropic" } : undefined,+ }) as unknown as OnboardingStartupState,+ getCurrentModel: () => (options.modelReady ? { id: "m", provider: "anthropic" } : undefined),+ modelRegistry: {+ getProviderAuthStatus: () => ({ configured: options.modelReady, source: "runtime" }),+ authStorage: { get: () => undefined },+ },+ };+ return context;+}++describe("InteractiveMode startup onboarding completion", () => {+ beforeAll(() => initTheme("dark"));++ it("does not mark onboarding shown when the flow ends without a ready model", async () => {+ const context = makeContext({ modelReady: false });+ await prototype.runStartupOnboarding.call(context);+ expect(context.settingsManager.getOnboardingShown()).toBe(false);+ });++ it("marks onboarding shown only after a completed flow", async () => {+ const context = makeContext({ modelReady: true });+ await prototype.runStartupOnboarding.call(context);+ expect(context.settingsManager.getOnboardingShown()).toBe(true);+ });+});diff --git a/packages/coding-agent/test/interactive-mode-status.test.ts b/packages/coding-agent/test/interactive-mode-status.test.tsindex 0ad6020037..843fb8d974 100644--- a/packages/coding-agent/test/interactive-mode-status.test.ts+++ b/packages/coding-agent/test/interactive-mode-status.test.ts@@ -4147,7 +4147,7 @@ describe("InteractiveMode Prime CLI onboarding", () => {expect(fakeThis.uiServices.settingsManager.setOnboardingShown).toHaveBeenCalledWith(true);});- test("persists onboarding before opening the one-shot flow", async () => {+ test("persists onboarding only after the one-shot flow completes", async () => {let shown = false;let flushed = false;const fakeThis = createPrimeCliHarness(false);@@ -4160,8 +4160,9 @@ describe("InteractiveMode Prime CLI onboarding", () => {});fakeThis.runOnboardingFlow = vi.fn(async (showPrimeCliSplash?: boolean) => {expect(showPrimeCliSplash).toBe(true);- expect(shown).toBe(true);- expect(flushed).toBe(true);+ // The flag persists only after the flow completes with a ready model.+ expect(shown).toBe(false);+ expect(flushed).toBe(false);});await expect(runStartupOnboarding.call(fakeThis)).resolves.toBe(true);