From 642518696fdbef26f8726b035c013b4dfd4b702c Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Wed, 29 Jul 2026 23:01:28 +0800 Subject: [PATCH] refactor(ui): a local daemon restart rebuilds from the tree too The tree file survives the restart and the fresh daemon force-clears every pane's live flag, so the resync path already expresses exactly what the hand-rolled saved-session rebuild did: every leaf revives as a fresh shell in its recorded cwd with its agent resumed. The pull waits out the local link reconnecting to the fresh daemon. --- src/ui/app.rs | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/ui/app.rs b/src/ui/app.rs index c180d2e0..d2a0b5cd 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -2017,27 +2017,17 @@ impl Tty7App { // layout returns exactly as it was. let _ = this.update_in(cx, |this, window, cx| { match &restarted { + // Rebuild from the machine's tree, which survived the + // restart on disk: the fresh daemon force-cleared every + // pane's live flag, so the resync revives each leaf as a + // fresh shell in its recorded cwd (agents resumed) — + // exactly the semantics the old saved-session rebuild + // hand-rolled. The pull waits out the local link coming + // back up to the fresh daemon. Ok(()) => { - let font_size = this.font_size; - // This window's own workspace only — the other windows - // rebuild themselves from theirs. - let saved = WorkspaceStore::all(cx) - .get(this.workspace) - .map(|w| w.session.clone()); - let pane_ws = this.window_workspace(cx); - let (tabs, active) = tabs_from_session( - pane_ws.as_ref(), - this.workspace, - saved, - font_size, - window, - cx, - ); - this.tabs = tabs; - this.active = active; + crate::ui::tree_sync::resync_window_from_tree(cx, this.workspace); } - // The fresh daemon never came up; rebuilding would panic in - // `new_terminal`'s connect `.expect`. Stay on the home page and + // The fresh daemon never came up. Stay on the home page and // leave a breadcrumb rather than crash — the user can retry. Err(e) => { log::error!("restart background service failed, staying on home page: {e}");