diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-14 05:30:20 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-14 05:30:20 +0300 |
| commit | 226e87306deaba017d36583f51ae34e42b303aad (patch) | |
| tree | 2a1155689b75007c15d93735aedfa58db7a05edf /src/app/actions.rs | |
| parent | 17544c36ee397233e2f7b3319d86e3b517e3b5d0 (diff) | |
fix: preserve tab identity across restored sessions
Diffstat (limited to 'src/app/actions.rs')
| -rw-r--r-- | src/app/actions.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/app/actions.rs b/src/app/actions.rs index a7d99f35..99bd0ff6 100644 --- a/src/app/actions.rs +++ b/src/app/actions.rs @@ -31,6 +31,13 @@ fn is_completion_transition(change: &EffectiveStateChange) -> bool { ) } +fn public_tab_id_for_index(ws: &crate::workspace::Workspace, tab_idx: usize) -> Option<String> { + let tab_number = ws.public_tab_number(tab_idx)?; + Some(crate::workspace::public_tab_id_for_number( + &ws.id, tab_number, + )) +} + pub fn is_completion_transition_parts( previous_state: AgentState, state: AgentState, @@ -951,7 +958,8 @@ impl AppState { if let Some(ws) = self.workspaces.get_mut(idx) { let active_tab = ws.active_tab; ws.switch_tab(active_tab); - let tab_id = format!("{}:{}", workspace_id, active_tab + 1); + let tab_id = + public_tab_id_for_index(ws, active_tab).unwrap_or_else(|| workspace_id.clone()); crate::logging::tab_focused(&workspace_id, &tab_id); } self.tab_scroll_follow_active = true; @@ -994,7 +1002,8 @@ impl AppState { self.ensure_workspace_visible(ws_idx); if let Some(ws) = self.workspaces.get_mut(ws_idx) { ws.switch_tab(tab_idx); - let tab_id = format!("{}:{}", workspace_id, tab_idx + 1); + let tab_id = + public_tab_id_for_index(ws, tab_idx).unwrap_or_else(|| workspace_id.clone()); crate::logging::tab_focused(&workspace_id, &tab_id); } self.tab_scroll_follow_active = true; @@ -1092,7 +1101,7 @@ impl AppState { }; ws.switch_tab(idx); let workspace_id = ws.id.clone(); - let tab_id = format!("{}:{}", workspace_id, idx + 1); + let tab_id = public_tab_id_for_index(ws, idx).unwrap_or_else(|| workspace_id.clone()); crate::logging::tab_focused(&workspace_id, &tab_id); self.mark_session_dirty(); self.tab_scroll_follow_active = true; @@ -1853,7 +1862,8 @@ impl AppState { return false; }; let workspace_id = ws.id.clone(); - let closing_tab_id = format!("{}:{}", workspace_id, ws.active_tab + 1); + let closing_tab_id = + public_tab_id_for_index(ws, ws.active_tab).unwrap_or_else(|| workspace_id.clone()); ws.close_active_tab(); self.remove_plugin_pane_records(pane_ids); self.remove_unattached_terminal_ids(terminal_ids); |
