Files
IdeA/frontend/src/adapters/modelServer.ts
Blomios 02603441c1 fix: livrable tickets #70 #100 #102 — UX surface scoping
- #70: implémentation suppression modèles locaux téléchargés
- #100: correction scroll OpenCode
- #102: correction fit TUI après switch/layout
- memory note scoping UX
2026-07-26 19:42:06 +02:00

49 lines
1.5 KiB
TypeScript

/**
* Tauri adapter for {@link ModelServerGateway} (F35). One of the only places that
* calls `invoke()`; features reach it exclusively through the port.
*
* Commands and payload keys are camelCase, matching the backend DTO convention.
* The flat `LocalModelServerConfig` wire shape is the DTO frozen by Architect —
* no nesting.
*/
import { invoke } from "@tauri-apps/api/core";
import type {
LocalModelServerConfig,
ModelServerCommandPreview,
} from "@/domain";
import type { ModelServerGateway } from "@/ports";
export class TauriModelServerGateway implements ModelServerGateway {
listModelServers(): Promise<LocalModelServerConfig[]> {
return invoke<LocalModelServerConfig[]>("list_model_servers");
}
saveModelServer(
config: LocalModelServerConfig,
): Promise<LocalModelServerConfig> {
return invoke<LocalModelServerConfig>("save_model_server", {
request: { config },
});
}
async deleteModelServer(serverId: string): Promise<void> {
await invoke("delete_model_server", { serverId });
}
async deleteModelArtifact(serverId: string): Promise<void> {
await invoke("delete_model_artifact", { serverId });
}
previewModelServerCommand(
config: LocalModelServerConfig,
): Promise<ModelServerCommandPreview> {
// `preview_model_server_command` takes the config directly (no `request`
// wrapper), unlike `save_model_server`.
return invoke<ModelServerCommandPreview>("preview_model_server_command", {
config,
});
}
}