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>
This commit is contained in:
2026-06-25 16:23:40 +02:00
parent 137620daa3
commit e916ecd95e
14 changed files with 372 additions and 51 deletions

View File

@ -169,7 +169,10 @@ impl LoadLayout {
pub async fn execute(&self, input: LoadLayoutInput) -> Result<LoadLayoutOutput, AppError> {
let project = self.store.load_project(input.project_id).await?;
let doc = resolve_doc(self.fs.as_ref(), &project).await?;
let id = doc.resolve_id(input.layout_id);
// Self-healing (I3): a stale requested id degrades to the valid active
// id instead of hard-erroring. `find` is now infallible in practice;
// the `ok_or` is kept as a purely defensive guard.
let id = doc.resolve_existing_id(input.layout_id);
let named = doc
.find(id)
.ok_or_else(|| AppError::NotFound(format!("layout {id}")))?;
@ -229,7 +232,10 @@ impl MutateLayout {
pub async fn execute(&self, input: MutateLayoutInput) -> Result<MutateLayoutOutput, AppError> {
let project = self.store.load_project(input.project_id).await?;
let mut doc = resolve_doc(self.fs.as_ref(), &project).await?;
let id = doc.resolve_id(input.layout_id);
// Self-healing (I3): a stale requested id degrades to the valid active
// id instead of hard-erroring. `find_mut` is now infallible in
// practice; the `ok_or` is kept as a purely defensive guard.
let id = doc.resolve_existing_id(input.layout_id);
let named = doc
.find_mut(id)