| 1 | import type { DecisionSurfaceKind as MockDecisionSurfaceKind } from "../lib/decisionSurfaceMock"; |
| 2 | import type { State } from "../lib/useController"; |
| 3 | import type { ActiveWorkView, WorkspaceConflictView } from "../lib/types"; |
| 4 | |
| 5 | export type AppDecisionSurfaceKind = MockDecisionSurfaceKind | "extension_form"; |
| 6 | |
| 7 | type PendingClose = { tabId: string; work: ActiveWorkView; stopping: boolean } | null; |
| 8 | |
| 9 | /** |
| 10 | * Single footer decision surface precedence. Composer stays mounted |
| 11 | * underneath and is only visually/a11y-hidden so per-session draft caches |
| 12 | * survive. |
| 13 | */ |
| 14 | export function projectDecisionSurface(input: { |
| 15 | approval: State["approval"]; |
| 16 | ask: State["ask"]; |
| 17 | mcpInteraction: State["mcpInteraction"]; |
| 18 | extensionForm: State["extensionForm"]; |
| 19 | workspaceConflict: WorkspaceConflictView | null; |
| 20 | pendingClose: PendingClose; |
| 21 | clearContextPending: boolean; |
| 22 | }): AppDecisionSurfaceKind | null { |
| 23 | if (input.approval) { |
| 24 | return input.approval.tool === "exit_plan_mode" ? "plan_approval" : "tool_approval"; |
| 25 | } |
| 26 | if (input.ask) return "ask"; |
| 27 | if (input.mcpInteraction) return "mcp_interaction"; |
| 28 | if (input.extensionForm) return "extension_form"; |
| 29 | if (input.workspaceConflict) return "workspace_conflict"; |
| 30 | if (input.pendingClose) return "close_active"; |
| 31 | if (input.clearContextPending) return "clear_context"; |
| 32 | return null; |
| 33 | } |
| 34 |