shell-mirror 1.5.85 → 1.5.86

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shell-mirror",
3
- "version": "1.5.85",
3
+ "version": "1.5.86",
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": {
@@ -469,6 +469,6 @@
469
469
  });
470
470
  </script>
471
471
 
472
- <script src="/app/terminal.js?v=chunked-20250820"></script>
472
+ <script src="/app/terminal.js?v=1.5.87"></script>
473
473
  </body>
474
474
  </html>
@@ -49,6 +49,7 @@ let user;
49
49
  let AGENT_ID;
50
50
  let CLIENT_ID;
51
51
  let SELECTED_AGENT; // Store full agent data including WebSocket URL
52
+ let usingDirectConnection = false; // Flag to prevent handler overwrite
52
53
 
53
54
  // Session management
54
55
  let currentSession = null;
@@ -361,10 +362,11 @@ async function tryDirectConnectionToIP(ip, port) {
361
362
 
362
363
  function setupDirectConnection(directWs) {
363
364
  console.log('[CLIENT] 🔧 Setting up direct connection handlers');
364
-
365
+
365
366
  // Store the WebSocket for global access
366
367
  ws = directWs;
367
-
368
+ usingDirectConnection = true; // Prevent signaling handler from overwriting
369
+
368
370
  // Set up message handlers
369
371
  directWs.onmessage = (event) => {
370
372
  const data = JSON.parse(event.data);
@@ -388,6 +390,8 @@ function setupDirectConnection(directWs) {
388
390
 
389
391
  case 'session_created':
390
392
  console.log('[CLIENT] ✅ Direct session created:', data.sessionId);
393
+
394
+ // Update current session
391
395
  currentSession = {
392
396
  id: data.sessionId,
393
397
  name: data.sessionName || 'Terminal Session'
@@ -396,8 +400,18 @@ function setupDirectConnection(directWs) {
396
400
  // Update available sessions
397
401
  if (data.availableSessions) {
398
402
  availableSessions = data.availableSessions;
403
+ } else {
404
+ // If agent doesn't provide session list, add this session manually
405
+ if (!availableSessions.find(s => s.id === currentSession.id)) {
406
+ availableSessions.push(currentSession);
407
+ }
399
408
  }
400
409
 
410
+ // Clear terminal and show success message
411
+ term.clear();
412
+ term.write(`\r\n\x1b[36m✨ New session created: ${currentSession.name}\x1b[0m\r\n\r\n`);
413
+
414
+ // Update UI
401
415
  updateSessionDisplay();
402
416
 
403
417
  // Save to localStorage
@@ -526,9 +540,11 @@ async function initializeWebRTCSignaling() {
526
540
  }
527
541
  }, 1000);
528
542
 
529
- // This is a bit of a hack for the message handler.
543
+ // This is a bit of a hack for the message handler.
530
544
  // We redefine it to handle the next phase of messages.
531
- ws.onmessage = async (nextMessage) => {
545
+ // Skip if using direct connection - don't overwrite its handler!
546
+ if (!usingDirectConnection) {
547
+ ws.onmessage = async (nextMessage) => {
532
548
  let messageData = nextMessage.data;
533
549
 
534
550
  // Handle Blob messages by converting to text first
@@ -615,6 +631,7 @@ async function initializeWebRTCSignaling() {
615
631
  console.error(`[CLIENT] ❌ Error processing WebRTC message:`, error);
616
632
  }
617
633
  };
634
+ } // End if (!usingDirectConnection)
618
635
  break;
619
636
  }
620
637
  };
@@ -1047,23 +1064,31 @@ function switchToSession(sessionId) {
1047
1064
 
1048
1065
  function createNewSession() {
1049
1066
  console.log('[CLIENT] 🆕 Creating new session...');
1067
+ console.log('[CLIENT] Debug - ws:', ws ? ws.readyState : 'null',
1068
+ 'dataChannel:', dataChannel ? dataChannel.readyState : 'null');
1050
1069
 
1051
1070
  if (ws && ws.readyState === WebSocket.OPEN) {
1052
- // Direct WebSocket connection - use underscore
1053
- ws.send(JSON.stringify({
1071
+ console.log('[CLIENT] 📤 Sending session create via Direct WebSocket');
1072
+ const message = {
1054
1073
  type: 'create_session',
1055
1074
  cols: term.cols,
1056
1075
  rows: term.rows
1057
- }));
1076
+ };
1077
+ console.log('[CLIENT] Message:', JSON.stringify(message));
1078
+ ws.send(JSON.stringify(message));
1058
1079
  } else if (dataChannel && dataChannel.readyState === 'open') {
1059
- // WebRTC data channel connection - use hyphen
1060
- dataChannel.send(JSON.stringify({
1080
+ console.log('[CLIENT] 📤 Sending session create via WebRTC data channel');
1081
+ const message = {
1061
1082
  type: 'session-create',
1062
1083
  cols: term.cols,
1063
1084
  rows: term.rows
1064
- }));
1085
+ };
1086
+ console.log('[CLIENT] Message:', JSON.stringify(message));
1087
+ dataChannel.send(JSON.stringify(message));
1065
1088
  } else {
1066
1089
  console.error('[CLIENT] ❌ Cannot create session - no active connection');
1090
+ console.error('[CLIENT] ws:', ws ? ws.readyState : 'null',
1091
+ 'dataChannel:', dataChannel ? dataChannel.readyState : 'null');
1067
1092
  term.write('\r\n\x1b[31m❌ Cannot create session - not connected\x1b[0m\r\n');
1068
1093
  }
1069
1094
  }