Files
IdeaSDK/frontend/src/adapters/layout.ts
Blomios e916ecd95e fix(layout): auto-réparer l'onglet actif
stale

Le backend renvoie l'id actif autoritaire et le
    frontend l'adopte pour éviter de rejouer un layout
    disparu après overwrite externe.

Co-Authored-By: Claude Opus 4.8
    <noreply@anthropic.com>
2026-06-25 16:23:40 +02:00

57 lines
1.9 KiB
TypeScript

/**
* Tauri adapter for {@link LayoutGateway} (L4). Together with the sibling
* adapters this is the *only* place that calls `invoke()`; components reach it
* exclusively through the port.
*
* Commands and payload keys are camelCase, matching the backend DTO convention.
* The `load_layout`/`mutate_layout` commands return the layout tree directly
* (the backend `LayoutDto` is `#[serde(transparent)]` over the tree).
*/
import { invoke } from "@tauri-apps/api/core";
import type { LayoutKind, LayoutList, LayoutOperation, LayoutTree } from "@/domain";
import type { LayoutGateway } from "@/ports";
export class TauriLayoutGateway implements LayoutGateway {
loadLayout(projectId: string, layoutId?: string): Promise<LayoutTree> {
return invoke<LayoutTree>("load_layout", { projectId, layoutId });
}
mutateLayout(
projectId: string,
operation: LayoutOperation,
layoutId?: string,
): Promise<LayoutTree> {
return invoke<LayoutTree>("mutate_layout", { projectId, layoutId, operation });
}
listLayouts(projectId: string): Promise<LayoutList> {
return invoke<LayoutList>("list_layouts", { projectId });
}
createLayout(projectId: string, name: string, kind?: LayoutKind): Promise<{ layoutId: string }> {
return invoke<{ layoutId: string }>("create_layout", {
request: { projectId, name, kind },
});
}
renameLayout(projectId: string, layoutId: string, name: string): Promise<void> {
return invoke<void>("rename_layout", {
request: { projectId, layoutId, name },
});
}
deleteLayout(projectId: string, layoutId: string): Promise<{ activeId: string }> {
return invoke<{ activeId: string }>("delete_layout", {
request: { projectId, layoutId },
});
}
setActiveLayout(projectId: string, layoutId: string): Promise<{ activeId: string }> {
return invoke<{ activeId: string }>("set_active_layout", {
request: { projectId, layoutId },
});
}
}