| 956 | }, |
| 957 | |
| 958 | installSession(session) { |
| 959 | const existingIndex = this.tabs.findIndex((tab) => ( |
| 960 | (session.file_id && tab.file_id === session.file_id) |
| 961 | || (session.path && tab.path === session.path) |
| 962 | )); |
| 963 | if (existingIndex >= 0) { |
| 964 | const tabId = this.tabs[existingIndex].tab_id; |
| 965 | const wasActive = this.activeTabId === tabId || this.session?.tab_id === tabId; |
| 966 | const merged = { ...this.tabs[existingIndex], ...session, tab_id: tabId }; |
| 967 | this.tabs.splice(existingIndex, 1, merged); |
| 968 | this.activeTabId = tabId; |
| 969 | if (wasActive) { |
| 970 | this.hydrateActiveSession(merged, { preservePage: true, focus: false }); |
| 971 | return; |
| 972 | } |
| 973 | } else { |
| 974 | this.tabs.push(session); |
| 975 | this.activeTabId = session.tab_id; |
| 976 | } |
| 977 | this.selectTab(this.activeTabId); |
| 978 | }, |
| 979 | |
| 980 | hydrateActiveSession(tab, options = {}) { |
| 981 | this.session = tab || null; |