feat(model-server): frontend modèles locaux — badge de statut & CRUD serveurs (#35) et wizard multi-profils OpenCode (#36)

Sprint « Modeles locaux », couche frontend.

#35 :
- F35.1 badge de statut de lancement du serveur local
  (ModelServerLaunchBadge + useAgentsModelServer).
- F35.2 feature model-servers : CRUD (ModelServersPanel / useModelServers /
  gateway modelServer) et ModelServerSelect.

#36 :
- Liste multi-profils OpenCode dans le wizard de premier lancement,
  gateway de clonage (clone_opencode_profile_from_seed).

Tests verts (exécution réelle) : tsc propre, vitest 608/608.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-11 15:50:18 +02:00
parent b82ac76f8b
commit 72476a650a
23 changed files with 1893 additions and 15 deletions

View File

@ -0,0 +1,100 @@
/**
* F35.1 — presentational tests for {@link ModelServerLaunchBadge}. Pure render
* of the folded launch state: lifecycle labels, the reused/fresh distinction,
* the actionable failure (with a details toggle that hides the code by default),
* and the "render nothing" cases for unmanaged rows.
*/
import { describe, it, expect } from "vitest";
import { render, screen, fireEvent } from "@testing-library/react";
import { ModelServerLaunchBadge } from "./ModelServerLaunchBadge";
describe("ModelServerLaunchBadge (F35.1)", () => {
it("renders nothing without a status or a failure", () => {
const { container } = render(<ModelServerLaunchBadge />);
expect(container.firstChild).toBeNull();
});
it("renders nothing for a notConfigured status (unmanaged endpoint)", () => {
const { container } = render(
<ModelServerLaunchBadge status={{ state: "notConfigured" }} />,
);
expect(container.firstChild).toBeNull();
});
it("shows the probing and starting lifecycle labels", () => {
const { rerender } = render(
<ModelServerLaunchBadge status={{ state: "probing" }} />,
);
expect(screen.getByLabelText("model server status").textContent).toMatch(
/vérification/i,
);
rerender(<ModelServerLaunchBadge status={{ state: "starting" }} />);
expect(screen.getByLabelText("model server status").textContent).toMatch(
/démarrage/i,
);
});
it("distinguishes a reused server from a freshly started one", () => {
const { rerender } = render(
<ModelServerLaunchBadge status={{ state: "ready", reused: true }} />,
);
expect(screen.getByLabelText("model server status").textContent).toMatch(
/réutilisé/i,
);
rerender(
<ModelServerLaunchBadge status={{ state: "ready", reused: false }} />,
);
const label = screen.getByLabelText("model server status").textContent ?? "";
expect(label).toMatch(/prêt/i);
expect(label).not.toMatch(/réutilisé/i);
});
it("shows an actionable failure message, not a bare 'agent failed'", () => {
render(
<ModelServerLaunchBadge
failure={{
cause: "model_server",
code: "SERVER_UNREACHABLE",
message: "llama-server did not become ready on :8080",
}}
/>,
);
const alert = screen.getByRole("alert");
expect(alert.textContent).toMatch(/did not become ready on :8080/);
// The code is not exposed by default (logs/detail stay hidden).
expect(screen.queryByLabelText("launch failure detail")).toBeNull();
});
it("reveals the stable code/cause only when Détails is toggled", () => {
render(
<ModelServerLaunchBadge
failure={{ cause: "model_server", code: "SPAWN", message: "boom" }}
/>,
);
fireEvent.click(screen.getByLabelText("toggle launch failure detail"));
const detail = screen.getByLabelText("launch failure detail");
expect(detail.textContent).toMatch(/SPAWN/);
expect(detail.textContent).toMatch(/model_server/);
});
it("prefers the agent-scoped failure over a failed status", () => {
render(
<ModelServerLaunchBadge
status={{ state: "failed", code: "S1", message: "status-level" }}
failure={{ cause: "model_server", code: "A1", message: "agent-level" }}
/>,
);
expect(screen.getByRole("alert").textContent).toMatch(/agent-level/);
});
it("falls back to a failed status when there is no agent failure", () => {
render(
<ModelServerLaunchBadge
status={{ state: "failed", code: "S1", message: "status-level boom" }}
/>,
);
expect(screen.getByRole("alert").textContent).toMatch(/status-level boom/);
});
});