fix(view-windows): réconcilier l'état des fenêtres détachées au boot (#50)

Branche le consommateur frontend sur la commande backend
`list_open_view_windows` : le port window expose la liste des fenêtres
de panneaux détachées réellement ouvertes côté OS, l'adaptateur Tauri
(et son double mock) l'implémente, et `ProjectsView` réconcilie le
placement des vues au démarrage à partir de ce snapshot au lieu de
supposer un état. Couvre `viewPlacement` et la réconciliation par des
tests dédiés.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-13 18:14:45 +02:00
parent afbf315e97
commit b4a01e0ae9
7 changed files with 300 additions and 1 deletions

View File

@ -90,6 +90,7 @@ import type {
UpdateTicketInput,
UiPreferencesGateway,
ViewWindowClosed,
ViewWindowSnapshot,
WindowGateway,
FocusedProject,
FocusedProjectGateway,
@ -1118,6 +1119,16 @@ export class MockWindowGateway implements WindowGateway {
}
}
async listOpenViewWindows(): Promise<ViewWindowSnapshot[]> {
// Mirror the backend enumeration: every currently-open detached window is
// reported visible, with a stable label derived from its panel id.
return [...this.open].map((panel) => ({
panel,
label: panel,
visible: true,
}));
}
async onViewWindowClosed(
handler: (event: ViewWindowClosed) => void,
): Promise<Unsubscribe> {

View File

@ -14,7 +14,11 @@ import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
import type { Unsubscribe } from "@/domain";
import type { ViewWindowClosed, WindowGateway } from "@/ports";
import type {
ViewWindowClosed,
ViewWindowSnapshot,
WindowGateway,
} from "@/ports";
/** The single Tauri event carrying detached-window lifecycle transitions. */
const VIEW_WINDOW_LIFECYCLE = "view-window://lifecycle";
@ -41,6 +45,12 @@ export class TauriWindowGateway implements WindowGateway {
await invoke("close_view_window", { panel });
}
async listOpenViewWindows(): Promise<ViewWindowSnapshot[]> {
// Backend serialises the snapshots in camelCase (panel/label/visible), so the
// wire shape matches the port type directly.
return invoke<ViewWindowSnapshot[]>("list_open_view_windows");
}
async onViewWindowClosed(
handler: (event: ViewWindowClosed) => void,
): Promise<Unsubscribe> {