diff options
| author | Adam Malczewski <[email protected]> | 2026-06-28 15:29:55 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-28 15:29:55 +0900 |
| commit | 12cf599378bab3df6cb688fac1288fa7414b389a (patch) | |
| tree | ff4a6260cd7c2720abed097fe3c434193b2c421c /src/features/workspaces/adapter/http.ts | |
| parent | 4373761a75b7b8b56ba6f3c8c942a13acd18e7c5 (diff) | |
| parent | 9d18dcfb84d5b5ae03e6be16b5e5af92bf10d530 (diff) | |
| download | dispatch-web-12cf599378bab3df6cb688fac1288fa7414b389a.tar.gz dispatch-web-12cf599378bab3df6cb688fac1288fa7414b389a.zip | |
Merge branch 'feature/workspace-star' into predev
# Conflicts:
# backend-handoff.md
# src/features/workspaces/ui/WorkspaceCard.test.ts
Diffstat (limited to 'src/features/workspaces/adapter/http.ts')
| -rw-r--r-- | src/features/workspaces/adapter/http.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/features/workspaces/adapter/http.ts b/src/features/workspaces/adapter/http.ts index 01fe677..5673881 100644 --- a/src/features/workspaces/adapter/http.ts +++ b/src/features/workspaces/adapter/http.ts @@ -25,6 +25,8 @@ import type { * - `PUT /workspaces/:id/title` → rename * - `PUT /workspaces/:id/default-cwd` → set/clear default cwd * - `PUT /workspaces/:id/default-computer` → set/clear default computer (SSH handoff #2) + * - `PUT /workspaces/:id/star` (create-on-miss) → star (concurrency priority) + * - `DELETE /workspaces/:id/star` (create-on-miss) → unstar * - `DELETE /workspaces/:id` (409 for "default") → delete */ export type WorkspaceResult<T> = @@ -38,6 +40,10 @@ export interface WorkspaceHttp { setTitle(id: string, title: string): Promise<WorkspaceResult<Workspace>>; setDefaultCwd(id: string, defaultCwd: string | null): Promise<WorkspaceResult<Workspace>>; setDefaultComputer(id: string, computerId: string | null): Promise<WorkspaceResult<Workspace>>; + /** Star a workspace (concurrency priority). Create-on-miss; no body. */ + star(id: string): Promise<WorkspaceResult<Workspace>>; + /** Unstar a workspace. Create-on-miss; no body. */ + unstar(id: string): Promise<WorkspaceResult<Workspace>>; delete(id: string): Promise<WorkspaceResult<{ closedCount: number }>>; } @@ -141,6 +147,30 @@ export function createWorkspaceHttp(httpBase: string, fetchImpl: typeof fetch): } }, + async star(id): Promise<WorkspaceResult<Workspace>> { + try { + const res = await fetchImpl(`${httpBase}/workspaces/${encodeURIComponent(id)}/star`, { + method: "PUT", + }); + if (!res.ok) return { ok: false, error: await errText(res) }; + return { ok: true, value: (await res.json()) as WorkspaceResponse }; + } catch (err) { + return { ok: false, error: err instanceof Error ? err.message : "Star failed" }; + } + }, + + async unstar(id): Promise<WorkspaceResult<Workspace>> { + try { + const res = await fetchImpl(`${httpBase}/workspaces/${encodeURIComponent(id)}/star`, { + method: "DELETE", + }); + if (!res.ok) return { ok: false, error: await errText(res) }; + return { ok: true, value: (await res.json()) as WorkspaceResponse }; + } catch (err) { + return { ok: false, error: err instanceof Error ? err.message : "Unstar failed" }; + } + }, + async delete(id): Promise<WorkspaceResult<{ closedCount: number }>> { try { const res = await fetchImpl(`${httpBase}/workspaces/${encodeURIComponent(id)}`, { |
