pub(crate) async fn restore_workspace(
state: &AppState,
snapshot: &Value,
) -> Result<Option<(String, Vec<Event>)>, String>Expand description
Attempt to replay the durable “last session” snapshot (if any) into a
fresh workspace: CreateWorkspace → per-tab CreateTab + per-block
CreateBlock (reusing each block’s saved meta, so a restored agent pane
relaunches the same way opening a fresh one does) → LayoutSetTree with
the saved split tree (block ids remapped from placeholders to the newly
created ones).
Returns Ok(None) when there’s nothing to restore (no snapshot, or every
tab in it failed to recreate) — the caller falls back to the hardcoded
default seed exactly as it did before this feature existed. Returns
Err only for a failure in the very first step (creating the workspace
itself); per-tab/per-block failures during replay are logged and skipped
rather than aborting the whole restore, so a partially-stale snapshot
(e.g. one tab’s block meta no longer makes sense) still restores
everything else instead of failing shut.