summaryrefslogtreecommitdiffhomepage
path: root/src/features/layout/store.svelte.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-09-05 17:33:06 +0900
committerAdam Malczewski <[email protected]>2026-09-05 17:33:06 +0900
commit254f90a4081a3f15dfe54277da922579dbaee254 (patch)
treef5f4e409196109baf938cd9d557e244242df18ce /src/features/layout/store.svelte.ts
parent535215bfd1fee6087613108f42d28cd2807184d3 (diff)
downloaddispatch-web-254f90a4081a3f15dfe54277da922579dbaee254.tar.gz
dispatch-web-254f90a4081a3f15dfe54277da922579dbaee254.zip
feat(layout): plan 04 — ABI layout.applyOps + reset affordance
Diffstat (limited to 'src/features/layout/store.svelte.ts')
-rw-r--r--src/features/layout/store.svelte.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/features/layout/store.svelte.ts b/src/features/layout/store.svelte.ts
index 3d7de3f..5fdf100 100644
--- a/src/features/layout/store.svelte.ts
+++ b/src/features/layout/store.svelte.ts
@@ -54,6 +54,16 @@ export interface LayoutStore {
onServerTree(workspaceId: string, tree: LayoutTree): void;
/** A user edit (the panels' dropdowns / TileRoot ops). Persists via PUT. */
onTreeChange(next: LayoutTree): void;
+ /**
+ * Reset the workspace's layout to the default seed (plan 04 §4.4 — the
+ * plugins modal's "Reset layout to default" affordance:
+ * `DELETE /workspaces/:id/layout` → re-seed → broadcast). Resolves to
+ * `null` on success (the fresh seed is applied locally + pushed via WS to
+ * every client) or to the FAILURE REASON — the no-provider 404 resolves
+ * to the user-facing "no layout plugin enabled" (the button's gate renders
+ * the same reason before this runs).
+ */
+ resetToDefault(workspaceId: string): Promise<string | null>;
/** Multi-client coherence (§11): re-probe on `extensions-changed`. */
onExtensionsChanged(): void;
}
@@ -260,6 +270,21 @@ export function createLayoutStore(opts: LayoutStoreOptions): LayoutStore {
}, debounceMs);
},
+ async resetToDefault(workspaceId): Promise<string | null> {
+ const result = await http.deleteTree(workspaceId);
+ if (result.ok) {
+ // The server re-seeded and broadcast (every client resets); this
+ // client applies the fresh seed immediately too (idempotent with the
+ // WS echo). Only the ACTIVE workspace's tree is ours to update.
+ notePresent();
+ if (workspaceId === activeWorkspaceId) applyServerTree(result.tree);
+ return null;
+ }
+ // The no-provider 404: the user-facing reason the plan specifies.
+ if (result.notFound) return "no layout plugin enabled";
+ return result.error;
+ },
+
onExtensionsChanged() {
void runProbe(activeWorkspaceId, false).catch(() => {
// runProbe never throws for HTTP failures; this guard is for the