|
| 1 | +import type { |
| 2 | + Workspace, |
| 3 | + WorkspaceAgent, |
| 4 | + WorkspaceAgentMetadata, |
| 5 | +} from "coder/site/src/api/typesGenerated"; |
| 6 | + |
| 7 | +// Re-export SDK types for convenience |
| 8 | +export type { Workspace, WorkspaceAgent, WorkspaceAgentMetadata }; |
| 9 | + |
| 10 | +export type WorkspaceFilter = "mine" | "shared" | "all"; |
| 11 | + |
| 12 | +/** A workspace page in the dashboard, opened in the browser. */ |
| 13 | +export type DashboardPage = "workspace" | "settings"; |
| 14 | + |
| 15 | +/** What the panel may offer for the current session. */ |
| 16 | +export interface WorkspacesCapabilities { |
| 17 | + readonly authenticated: boolean; |
| 18 | + /** Filters the user may select, in display order. */ |
| 19 | + readonly filters: readonly WorkspaceFilter[]; |
| 20 | +} |
| 21 | + |
| 22 | +export interface FilteredWorkspaces { |
| 23 | + readonly filter: WorkspaceFilter; |
| 24 | + readonly workspaces: readonly Workspace[]; |
| 25 | + /** True while the first list for this filter is still on its way. */ |
| 26 | + readonly loading: boolean; |
| 27 | +} |
| 28 | + |
| 29 | +export interface AgentMetadataState { |
| 30 | + readonly metadata: readonly WorkspaceAgentMetadata[]; |
| 31 | + /** The watcher failure, which replaces the metadata in the UI. */ |
| 32 | + readonly error: string | null; |
| 33 | + /** True until the agent reports for the first time. */ |
| 34 | + readonly loading: boolean; |
| 35 | +} |
| 36 | + |
| 37 | +/** Keyed by agent id. */ |
| 38 | +export type AgentMetadataMap = Readonly<Record<string, AgentMetadataState>>; |
| 39 | + |
| 40 | +/** Everything the panel renders. Fields are replaced, never mutated. */ |
| 41 | +export interface WorkspacesState { |
| 42 | + readonly capabilities: WorkspacesCapabilities; |
| 43 | + readonly workspaces: FilteredWorkspaces; |
| 44 | + readonly metadata: AgentMetadataMap; |
| 45 | + readonly error: string | null; |
| 46 | +} |
| 47 | + |
| 48 | +/** A state slice: present fields changed, absent ones did not. */ |
| 49 | +export type WorkspacesUpdate = Partial<WorkspacesState>; |
| 50 | + |
| 51 | +export interface OpenWorkspaceParams { |
| 52 | + workspaceId: string; |
| 53 | + /** Which agent to connect to. Picked interactively when omitted. */ |
| 54 | + agentId?: string; |
| 55 | +} |
| 56 | + |
| 57 | +export interface ViewInDashboardParams { |
| 58 | + workspaceId: string; |
| 59 | + page: DashboardPage; |
| 60 | +} |
| 61 | + |
| 62 | +export interface SetFilterParams { |
| 63 | + filter: WorkspaceFilter; |
| 64 | +} |
| 65 | + |
| 66 | +export interface WatchAgentsParams { |
| 67 | + /** The agents whose metadata the webview is showing. */ |
| 68 | + agentIds: readonly string[]; |
| 69 | +} |
0 commit comments