shell-mirror 1.5.124 → 1.5.125

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.124",
3
+ "version": "1.5.125",
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": {
@@ -56,6 +56,10 @@ let currentSession = null;
56
56
  let availableSessions = [];
57
57
  let requestedSessionId = null; // For connecting to specific session from URL
58
58
 
59
+ // Connection status messaging
60
+ let connectionStatusMessage = 'Connecting to agent...';
61
+ let connectionTimeoutWarning = null;
62
+
59
63
  // Chunk reassembly for large messages
60
64
  const chunkAssembler = {
61
65
  activeChunks: new Map(),
@@ -166,6 +170,30 @@ function updateConnectionStatus(status) {
166
170
  // else: disconnected (default red)
167
171
  }
168
172
 
173
+ // Set connection status message (shown in tab bar when no sessions)
174
+ function setConnectionMessage(message, writeToTerminal = true) {
175
+ connectionStatusMessage = message;
176
+ console.log('[CLIENT] 📢 Connection message:', message);
177
+
178
+ // Update the tab bar display
179
+ updateSessionDisplay();
180
+
181
+ // Optionally write to terminal for visibility
182
+ if (writeToTerminal && term) {
183
+ term.write(`\r\n\x1b[36m${message}\x1b[0m\r\n`); // Cyan color
184
+ }
185
+ }
186
+
187
+ // Clear connection timeout warnings (called when connection succeeds)
188
+ function clearConnectionTimeouts() {
189
+ if (connectionTimeoutWarning) {
190
+ clearTimeout(connectionTimeoutWarning.timeout10s);
191
+ clearTimeout(connectionTimeoutWarning.timeout30s);
192
+ connectionTimeoutWarning = null;
193
+ console.log('[CLIENT] ✅ Connection timeout warnings cleared');
194
+ }
195
+ }
196
+
169
197
  // Cleanup timer for chunk assembler
170
198
  setInterval(() => {
171
199
  chunkAssembler.cleanup();
@@ -244,6 +272,9 @@ function startConnection() {
244
272
  terminalContainer.classList.add('show');
245
273
  term.open(document.getElementById('terminal'));
246
274
 
275
+ // Show initial connection message
276
+ setConnectionMessage('🔗 Connecting to agent...', true);
277
+
247
278
  // Initialize session display (shows header with connection status even before session exists)
248
279
  updateSessionDisplay();
249
280
 
@@ -262,6 +293,26 @@ function startConnection() {
262
293
  fitAddon.fit();
263
294
  term.focus(); // Ensure cursor is visible even before connection
264
295
  }, 100);
296
+
297
+ // Set up connection timeout warnings
298
+ const timeout10s = setTimeout(() => {
299
+ if (!currentSession) {
300
+ setConnectionMessage('⏱️ Taking longer than usual... Please wait', true);
301
+ term.write('\r\n\x1b[33m⏱️ Connection is taking longer than expected...\x1b[0m\r\n');
302
+ }
303
+ }, 10000);
304
+
305
+ const timeout30s = setTimeout(() => {
306
+ if (!currentSession) {
307
+ setConnectionMessage('⚠️ Connection very slow - Agent may be offline', true);
308
+ term.write('\x1b[33m⚠️ Still trying to connect. The agent may be offline or unreachable.\x1b[0m\r\n');
309
+ term.write('\x1b[36m💡 Tip: Check the agent status on the Dashboard\x1b[0m\r\n');
310
+ }
311
+ }, 30000);
312
+
313
+ // Store timeout IDs so they can be cleared on successful connection
314
+ connectionTimeoutWarning = { timeout10s, timeout30s };
315
+
265
316
  initialize();
266
317
  }
267
318
 
@@ -275,17 +326,20 @@ async function initialize() {
275
326
 
276
327
  if (directConnectionSuccess) {
277
328
  console.log('[CLIENT] ✅ Direct connection established - no server needed!');
329
+ setConnectionMessage('✅ Connected via local network!', true);
278
330
  return;
279
331
  }
280
-
332
+
281
333
  console.log('[CLIENT] ⚠️ Direct connection failed, falling back to WebRTC signaling...');
334
+ setConnectionMessage('🌐 Attempting WebRTC connection...', true);
282
335
  await initializeWebRTCSignaling();
283
336
  }
284
337
 
285
338
  async function tryDirectConnection() {
286
339
  console.log('[CLIENT] 🔗 Attempting direct connection to agent...');
287
340
  updateConnectionStatus('connecting');
288
-
341
+ setConnectionMessage('🔍 Trying direct connection to local network...', true);
342
+
289
343
  // Get agent data from API to find local connection details
290
344
  try {
291
345
  const response = await fetch('/php-backend/api/agents-list.php', {
@@ -394,6 +448,10 @@ function setupDirectConnection(directWs) {
394
448
  case 'session_created':
395
449
  console.log('[CLIENT] ✅ Direct session created:', data.sessionId);
396
450
 
451
+ // Clear connection timeout warnings
452
+ clearConnectionTimeouts();
453
+ setConnectionMessage('✅ Session created successfully!', false);
454
+
397
455
  // Update current session
398
456
  currentSession = {
399
457
  id: data.sessionId,
@@ -570,6 +628,10 @@ async function initializeWebRTCSignaling() {
570
628
 
571
629
  // Handle session assignment from agent
572
630
  if (nextData.sessionId) {
631
+ // Clear connection timeout warnings
632
+ clearConnectionTimeouts();
633
+ setConnectionMessage('✅ Session connected!', false);
634
+
573
635
  currentSession = {
574
636
  id: nextData.sessionId,
575
637
  name: nextData.sessionName || 'Terminal Session',
@@ -577,7 +639,7 @@ async function initializeWebRTCSignaling() {
577
639
  };
578
640
  console.log('[CLIENT] 📋 Session assigned:', currentSession);
579
641
  console.log('[CLIENT] 🔍 Agent ID for storage:', AGENT_ID);
580
-
642
+
581
643
  // Update UI to show session info
582
644
  updateSessionDisplay();
583
645
 
@@ -793,6 +855,7 @@ async function createPeerConnection() {
793
855
  console.log('[CLIENT] ❌ ICE connection failed - no viable candidates');
794
856
  console.log('[CLIENT] 💡 Troubleshooting: This may be due to firewall/NAT issues or blocked STUN servers');
795
857
  updateConnectionStatus('disconnected');
858
+ setConnectionMessage('❌ Unable to connect - Agent may be offline', false);
796
859
  term.write('\r\n\r\n❌ Connection failed: Network connectivity issues\r\n');
797
860
  term.write('💡 This may be due to:\r\n');
798
861
  term.write(' • Firewall blocking WebRTC traffic\r\n');
@@ -1043,8 +1106,8 @@ function renderTabs() {
1043
1106
  // Add new session button only when we have sessions
1044
1107
  tabsHTML += '<button class="session-tab-new" onclick="createNewSession()" title="New Session">+</button>';
1045
1108
  } else {
1046
- // No sessions available - show status message
1047
- tabsHTML = '<div style="color: #888; font-size: 0.85rem; padding: 6px 12px;">No sessions available</div>';
1109
+ // No sessions - show connection status message
1110
+ tabsHTML = `<div style="color: #888; font-size: 0.85rem; padding: 6px 12px;">${connectionStatusMessage}</div>`;
1048
1111
  }
1049
1112
 
1050
1113
  tabBar.innerHTML = tabsHTML;