@termly-dev/cli-dev
Advanced tools
@@ -266,2 +266,7 @@ const path = require('path'); | ||
| // Handle restore resize (after mobile disconnect) | ||
| wsManager.onRestoreResize(() => { | ||
| ptyManager.restoreLocalSize(); | ||
| }); | ||
| // Handle mobile connected | ||
@@ -271,2 +276,5 @@ wsManager.onMobileConnected(() => { | ||
| // Update PTY manager state | ||
| ptyManager.setMobileConnected(true); | ||
| // If demo mode, send special command to trigger screen redraw | ||
@@ -281,2 +289,5 @@ if (selectedTool.key === 'demo') { | ||
| updateSession(session.sessionId, { mobileConnected: false }); | ||
| // Update PTY manager state | ||
| ptyManager.setMobileConnected(false); | ||
| }); | ||
@@ -283,0 +294,0 @@ |
@@ -17,2 +17,3 @@ const WebSocket = require('ws'); | ||
| this.shouldReconnect = true; | ||
| this.restoreResizeTimer = null; | ||
@@ -25,2 +26,3 @@ // Callbacks | ||
| this.onPairedCallback = null; | ||
| this.onRestoreResizeCallback = null; | ||
| } | ||
@@ -115,2 +117,5 @@ | ||
| // Cancel restore resize timer if mobile reconnected | ||
| this.cancelRestoreResizeTimer(); | ||
| if (this.onMobileConnectedCallback) { | ||
@@ -126,2 +131,5 @@ this.onMobileConnectedCallback(); | ||
| // Start timer to restore terminal size after delay | ||
| this.startRestoreResizeTimer(); | ||
| if (this.onMobileDisconnectedCallback) { | ||
@@ -138,2 +146,5 @@ this.onMobileDisconnectedCallback(); | ||
| // Cancel restore resize timer if mobile reconnected | ||
| this.cancelRestoreResizeTimer(); | ||
| // Get missed messages | ||
@@ -288,2 +299,35 @@ const missedMessages = this.buffer.getAfter(message.lastSeq); | ||
| onRestoreResize(callback) { | ||
| this.onRestoreResizeCallback = callback; | ||
| } | ||
| // Start timer to restore terminal size after mobile disconnect | ||
| startRestoreResizeTimer() { | ||
| const { RESTORE_RESIZE_DELAY } = require('../session/pty-manager'); | ||
| // Clear any existing timer | ||
| this.cancelRestoreResizeTimer(); | ||
| logger.debug(`Starting restore resize timer (${RESTORE_RESIZE_DELAY}ms)`); | ||
| this.restoreResizeTimer = setTimeout(() => { | ||
| logger.debug('Restore resize timer expired, restoring terminal size'); | ||
| if (this.onRestoreResizeCallback) { | ||
| this.onRestoreResizeCallback(); | ||
| } | ||
| this.restoreResizeTimer = null; | ||
| }, RESTORE_RESIZE_DELAY); | ||
| } | ||
| // Cancel restore resize timer | ||
| cancelRestoreResizeTimer() { | ||
| if (this.restoreResizeTimer) { | ||
| logger.debug('Cancelling restore resize timer (mobile reconnected)'); | ||
| clearTimeout(this.restoreResizeTimer); | ||
| this.restoreResizeTimer = null; | ||
| } | ||
| } | ||
| // Close WebSocket | ||
@@ -294,2 +338,5 @@ close() { | ||
| // Cancel restore resize timer | ||
| this.cancelRestoreResizeTimer(); | ||
| if (this.ws) { | ||
@@ -296,0 +343,0 @@ this.ws.close(1000, 'Client closed'); |
@@ -5,2 +5,5 @@ const pty = require('node-pty'); | ||
| // Delay before restoring terminal size after mobile disconnect (ms) | ||
| const RESTORE_RESIZE_DELAY = 2000; | ||
| class PTYManager { | ||
@@ -14,2 +17,4 @@ constructor(tool, workingDir, buffer) { | ||
| this.onExitCallback = null; | ||
| this.mobileConnected = false; | ||
| this.localResizeListener = null; | ||
| } | ||
@@ -74,2 +79,5 @@ | ||
| // Setup local terminal resize listener | ||
| this.setupLocalResizeListener(); | ||
| return true; | ||
@@ -131,2 +139,42 @@ } catch (err) { | ||
| // Restore PTY size to match local terminal | ||
| restoreLocalSize() { | ||
| const cols = process.stdout.columns || 80; | ||
| const rows = process.stdout.rows || 24; | ||
| logger.info(`Terminal size restored to ${cols}x${rows}`); | ||
| this.resize(cols, rows); | ||
| } | ||
| // Setup listener for local terminal resize events | ||
| setupLocalResizeListener() { | ||
| if (!process.stdout.isTTY) { | ||
| return; | ||
| } | ||
| this.localResizeListener = () => { | ||
| // Only resize PTY if mobile is NOT connected | ||
| // When mobile is connected, PTY follows mobile screen size | ||
| if (!this.mobileConnected) { | ||
| const cols = process.stdout.columns || 80; | ||
| const rows = process.stdout.rows || 24; | ||
| logger.debug(`Local terminal resized to ${cols}x${rows}, updating PTY`); | ||
| this.resize(cols, rows); | ||
| } else { | ||
| logger.debug('Local terminal resized, but mobile is connected - ignoring'); | ||
| } | ||
| }; | ||
| // Listen for terminal resize events (SIGWINCH) | ||
| process.stdout.on('resize', this.localResizeListener); | ||
| logger.debug('Local terminal resize listener installed'); | ||
| } | ||
| // Set mobile connection state | ||
| setMobileConnected(connected) { | ||
| this.mobileConnected = connected; | ||
| logger.debug(`Mobile connection state: ${connected ? 'connected' : 'disconnected'}`); | ||
| } | ||
| // Set data callback (for sending to WebSocket) | ||
@@ -150,2 +198,9 @@ onData(callback) { | ||
| // Remove local resize listener | ||
| if (this.localResizeListener && process.stdout.off) { | ||
| process.stdout.off('resize', this.localResizeListener); | ||
| this.localResizeListener = null; | ||
| logger.debug('Local terminal resize listener removed'); | ||
| } | ||
| // Restore stdin | ||
@@ -169,1 +224,2 @@ if (process.stdin.isTTY && process.stdin.setRawMode) { | ||
| module.exports = PTYManager; | ||
| module.exports.RESTORE_RESIZE_DELAY = RESTORE_RESIZE_DELAY; |
+1
-1
| { | ||
| "name": "@termly-dev/cli-dev", | ||
| "version": "0.9.1", | ||
| "version": "0.9.2", | ||
| "description": "Universal terminal access for AI coding assistants (Development version)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
151902
2.41%3740
2.44%