File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -116,16 +116,18 @@ const panelHeight = ref(props.initialTerminalHeight ?? 261);
116116
117117// --- Share mode: sync sessions from server's sharedTerminals ---
118118watch (isSharing , (sharing ) => {
119+ knownShareIds .clear ();
120+ sessions .value = [];
121+ splitId .value = null ;
122+ savedPairsMap .clear ();
123+ nextId = 1 ;
124+ epoch = Date .now ();
119125 if (sharing ) {
120- knownShareIds .clear ();
121- sessions .value = [];
122- splitId .value = null ;
123- savedPairsMap .clear ();
124- // Re-ensure a session in case the panel is already visible.
125- // sharedTerminals watcher (immediate) will populate sessions if there are existing
126- // terminals; ensureSession only creates a new local one if nothing else does.
126+ // Sharing started: sharedTerminals watcher (immediate) populates sessions if terminals
127+ // already exist; ensureSession creates a pending local one if needed.
127128 nextTick (() => ensureSession ());
128129 }
130+ // Sharing stopped: sessions cleared above. index.vue calls ensureSession() when terminal is open.
129131});
130132
131133watch (() => sharedTerminals .value , (list ) => {
Original file line number Diff line number Diff line change @@ -633,6 +633,10 @@ function onShareStopped() {
633633 // Host stopped sharing: close all relay terminals
634634 for (const handle of relayTerminals .values ()) handle .close ();
635635 relayTerminals .clear ();
636+ // Re-create terminal sessions now that we're back in normal mode
637+ if (terminalOpen .value ) {
638+ nextTick (() => terminalPanelRef .value ?.ensureSession ());
639+ }
636640}
637641
638642async function autoJoinShare(sid : string ) {
Original file line number Diff line number Diff line change @@ -158,8 +158,21 @@ function createWindow(rootPath) {
158158 } ) ;
159159
160160 win . on ( "closed" , ( ) => {
161- windows . delete ( win ) ;
162- if ( ! isQuitting ) saveSessions ( ) ;
161+ if ( ! isQuitting ) {
162+ const root = windows . get ( win ) ;
163+ windows . delete ( win ) ;
164+ if ( windows . size === 0 && root !== undefined ) {
165+ // Last window on Windows/Linux: before-quit fires AFTER this, map already empty.
166+ // Save the last root now so it's restored on next launch.
167+ try { fs . writeFileSync ( sessionsFile , JSON . stringify ( [ root || "" ] ) , "utf-8" ) ; } catch ( e ) {
168+ log ( `[session] save error: ${ e . message } ` ) ;
169+ }
170+ } else {
171+ saveSessions ( ) ;
172+ }
173+ } else {
174+ windows . delete ( win ) ;
175+ }
163176 } ) ;
164177
165178 return win ;
You can’t perform that action at this time.
0 commit comments