All files / src/onboarding messages.ts

20% Statements 1/5
100% Branches 0/0
0% Functions 0/1
20% Lines 1/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75                                                                                                                                          1x          
/**
 * Strict discriminated-union message types for the onboarding wizard's
 * extension-host ↔ webview channel. Both sides import from this module;
 * adding a variant requires both receivers to be updated or tsc fails.
 */
 
import type { Bullet, WizardTrigger } from "../telemetry-events";
import type { PersonaSelection } from "./persona-resolver";
import type { SignedInUser } from "../extract-user-info";
 
export type SigninIntent =
    | { kind: "cloud" }
    | { kind: "enterprise"; customerDomain: string }
    | { kind: "dev"; environment: "staging" | "local" };
 
export type WebviewToExtension =
    | { type: "ready" }
    | {
          type: "log";
          level: "info" | "warn" | "error" | "debug";
          message: string;
      }
    | { type: "persona_advance"; selection: PersonaSelection }
    | { type: "signin_clicked"; intent: SigninIntent }
    | { type: "switch_account" }
    | { type: "bullet_run"; bullet: Bullet }
    | { type: "done_clicked" }
    | { type: "show_logs" }
    | { type: "contact_support" }
    | { type: "sign_out" }
    | { type: "copy_mcp_url" }
    | { type: "install_mcp" };
 
export type CurrentConnection = {
    persona: PersonaSelection["persona"];
    enterpriseCode?: string;
    internalDevSub?: "staging" | "local";
    authDomain?: string;
    signedInUser?: SignedInUser;
};
 
export type ExtensionToWebview =
    | {
          type: "init";
          devMode: boolean;
          logoUri: string;
          remoteMcpUrl: string;
          installEditorName?: string;
          trigger: WizardTrigger;
          alreadyConnected: boolean;
          currentConnection?: CurrentConnection;
      }
    | { type: "persona_accepted" }
    | { type: "persona_rejected"; error: string }
    | { type: "bullet_running"; bullet: Bullet }
    | {
          type: "bullet_passed";
          bullet: Bullet;
          authDomain?: string;
          signedInUser?: SignedInUser;
      }
    | {
          type: "bullet_failed";
          bullet: Bullet;
          error_code: string;
          message: string;
      }
    | { type: "signed_out" };
 
export function assertNever(value: never): never {
    throw new Error(
        `Unhandled discriminated-union variant: ${JSON.stringify(value)}`
    );
}