shell-mirror 1.5.105 → 1.5.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -976,6 +976,23 @@ function setupDataChannel(clientId) {
976
976
  }));
977
977
  logToFile(`[AGENT] ❌ Failed to create session for client ${clientId}`);
978
978
  }
979
+ } else if (message.type === 'close_session') {
980
+ // Handle session closure request from client
981
+ logToFile(`[AGENT] Client ${clientId} closing session ${message.sessionId}`);
982
+
983
+ sessionManager.terminateSession(message.sessionId);
984
+
985
+ // Send confirmation with updated session list
986
+ dataChannel.send(JSON.stringify({
987
+ type: 'session-closed',
988
+ sessionId: message.sessionId,
989
+ availableSessions: sessionManager.getAllSessions()
990
+ }));
991
+
992
+ // Send immediate heartbeat to update dashboard
993
+ sendHeartbeat();
994
+
995
+ logToFile(`[AGENT] ✅ Session closed: ${message.sessionId}`);
979
996
  }
980
997
  } catch (err) {
981
998
  logToFile(`[AGENT] Error parsing data channel message: ${err.message}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shell-mirror",
3
- "version": "1.5.105",
3
+ "version": "1.5.107",
4
4
  "description": "Access your Mac shell from any device securely. Perfect for mobile coding with Claude Code CLI, Gemini CLI, and any shell tool.",
5
5
  "main": "server.js",
6
6
  "bin": {
@@ -576,6 +576,6 @@
576
576
  }
577
577
  </script>
578
578
 
579
- <script src="/app/terminal.js?v=1.5.90"></script>
579
+ <script src="/app/terminal.js?v=1.5.91"></script>
580
580
  </body>
581
581
  </html>
@@ -1098,7 +1098,16 @@ function doCloseSession(sessionId) {
1098
1098
  // If closing current session, switch to another or show message
1099
1099
  if (currentSession && currentSession.id === sessionId) {
1100
1100
  if (availableSessions.length > 0) {
1101
- switchToSession(availableSessions[0].id);
1101
+ // Update currentSession IMMEDIATELY so renderTabs shows correct active tab
1102
+ const nextSession = availableSessions[0];
1103
+ currentSession = {
1104
+ id: nextSession.id,
1105
+ name: nextSession.name || 'Terminal Session'
1106
+ };
1107
+ // Tell agent to switch (will send session-switched confirmation)
1108
+ switchToSession(nextSession.id);
1109
+ // Update URL
1110
+ updateUrlWithSession(nextSession.id);
1102
1111
  } else {
1103
1112
  currentSession = null;
1104
1113
  term.clear();
@@ -1258,6 +1267,14 @@ function handleSessionMessage(message) {
1258
1267
  term.write(`\r\n\x1b[31m❌ Session terminated\x1b[0m\r\n`);
1259
1268
  term.write('🔄 Click Dashboard to start a new session\r\n');
1260
1269
  break;
1270
+ case 'session-closed':
1271
+ console.log('[CLIENT] ✅ Session closed confirmed:', message.sessionId);
1272
+ // Update available sessions from server response
1273
+ if (message.availableSessions) {
1274
+ availableSessions = message.availableSessions;
1275
+ renderTabs();
1276
+ }
1277
+ break;
1261
1278
  case 'error':
1262
1279
  term.write(`\r\n\x1b[31m❌ Error: ${message.message}\x1b[0m\r\n`);
1263
1280
  break;