fix(application,frontend): restauration correcte d'une cellule agent en CLI custom après changement de projet — #322 (QA verte)

Symptôme: après changement de projet puis retour, une cellule en CLI
custom retombait en TUI native et un nouveau switch CLI custom repartait
à neuf (aucune conversation reprenable) car le mode préféré de la
cellule n'était pas persisté dans l'arbre de layout.

- domaine frontend: type PreferredView (tui | chat) et champ
  preferredView optionnel sur LeafCell; opération de layout
  setCellPreferredView persistant la surface préférée (tui = défaut,
  champ omis pour garder les arbres existants compacts)
- LayoutGrid: le mode de présentation d'une cellule agent dérive de
  preferredView persisté; le cache localStorage du mode custom n'est
  plus qu'un cache de migration secondaire; remount par clé
  projectId:layoutId:nodeId à chaque changement de projet pour éviter
  tout état résiduel inter-projets; la conversation/engine session/
  session/agentWasRunning de la cellule sont préservés par les
  bascules chat <-> TUI
- useLayout: setCellPreferredView exposé au view model
- tests: layout_usecases (persistance chat puis retour TUI en
  conservant session/conversation/engine/running), layout.test
  (setCellPreferredView chat persiste, tui omet le champ),
  LayoutGrid.chat et cellControlsLayering alignés

QA verte sur fix/batch-322-323-session-restore-prompt-history. Aucun push.
This commit is contained in:
2026-09-11 18:22:57 +02:00
parent 791e068d2e
commit b0d68c2d14
8 changed files with 322 additions and 134 deletions

View File

@ -1050,6 +1050,9 @@ export interface ProjectMcpToolPermissions {
/** Split direction: `row` = columns (left→right), `column` = rows (top→bottom). */
export type Direction = "row" | "column";
/** Preferred live surface persisted on an agent layout cell. */
export type PreferredView = "tui" | "chat";
/** A terminal-hosting leaf cell. `session` is the hosted SessionId, if any.
* `agent` is the agent id if an agent is pinned to this cell (absent = plain terminal).
* `conversationId` is the persistent CLI conversation id (survives PTY close/reopen,
@ -1062,6 +1065,7 @@ export interface LeafCell {
agent?: string;
conversationId?: string;
agentWasRunning?: boolean;
preferredView?: PreferredView;
}
/** A weighted child of a split. `weight` is a relative (`> 0`) share. */
@ -1133,6 +1137,7 @@ export type LayoutOperation =
| { type: "setSession"; target: string; session?: string | null }
| { type: "setCellAgent"; target: string; agent: string | null }
| { type: "setCellConversation"; target: string; conversationId: string | null }
| { type: "setCellPreferredView"; target: string; preferredView: PreferredView }
| { type: "setAgentRunning"; target: string; running: boolean }
| { type: "setPluginLayoutState"; target: string; state: unknown };