( id: string, metadata: WorkspaceMetadataPatch, )
| 411 | export type WorkspaceMetadataPatch = { displayName?: string | null; description?: string | null }; |
| 412 | |
| 413 | export async function updateWorkspaceMetadata( |
| 414 | id: string, |
| 415 | metadata: WorkspaceMetadataPatch, |
| 416 | ): Promise<Workspace> { |
| 417 | const res = await fetch(`/api/workspaces/${encodeURIComponent(id)}/metadata`, { |
| 418 | method: 'PATCH', |
| 419 | headers: { 'content-type': 'application/json' }, |
| 420 | body: JSON.stringify(metadata), |
| 421 | }); |
| 422 | if (!res.ok) { |
| 423 | const msg = await res.text().catch(() => ''); |
| 424 | throw new Error(`update workspace metadata failed: ${res.status} ${msg}`); |
| 425 | } |
| 426 | const body = (await res.json()) as { workspace: Workspace }; |
| 427 | return body.workspace; |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * Kill the PTY for this workspace. Server-side PersistentSession disposes, |
no test coverage detected