| 1 | // Decision logic for the floating launcher card (DockLauncher) and its |
| 2 | // top-right toggle. The card is on screen while the transcript surface is wide |
| 3 | // enough for it to occupy space and the user has not dismissed it; it is |
| 4 | // independent of the dock panel's own open state — the panel has its own |
| 5 | // toggle, and this one only ever shows or hides the card. Keeping this as a |
| 6 | // pure function lets the toggle's pressed state and the card's render |
| 7 | // condition share one source of truth that is unit-tested directly (see |
| 8 | // src/__tests__/launcher-card-state.test.ts). |
| 9 | export type SpaceMode = "full" | "hidden"; |
| 10 | |
| 11 | export interface LauncherCardInput { |
| 12 | /** Space-yield mode reported by the card itself via onSpaceModeChange. */ |
| 13 | spaceMode: SpaceMode; |
| 14 | /** True when the user dismissed the card with the launcher toggle. */ |
| 15 | dismissed: boolean; |
| 16 | } |
| 17 | |
| 18 | export interface LauncherCardState { |
| 19 | /** The card could be on screen if not dismissed — the toggle is actionable. */ |
| 20 | renderable: boolean; |
| 21 | /** The card is actually on screen — the toggle shows its pressed state. */ |
| 22 | visible: boolean; |
| 23 | } |
| 24 | |
| 25 | export function resolveLauncherCardState({ spaceMode, dismissed }: LauncherCardInput): LauncherCardState { |
| 26 | const renderable = spaceMode === "full"; |
| 27 | return { renderable, visible: renderable && !dismissed }; |
| 28 | } |
| 29 |