cli-tunnel 1.2.0 → 1.2.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/remote-ui/app.js +32 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-tunnel",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Tunnel any CLI app to your phone — PTY + devtunnel + xterm.js",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/remote-ui/app.js CHANGED
@@ -93,15 +93,24 @@
93
93
  fitAddon.fit();
94
94
 
95
95
  // Send terminal size to PTY so copilot renders correctly
96
+ var lastCols = 0, lastRows = 0;
97
+ var resizeTimer = null;
96
98
  function sendResize() {
97
99
  if (ws && ws.readyState === WebSocket.OPEN && xterm) {
98
- ws.send(JSON.stringify({ type: 'pty_resize', cols: xterm.cols, rows: xterm.rows }));
100
+ if (xterm.cols !== lastCols || xterm.rows !== lastRows) {
101
+ lastCols = xterm.cols;
102
+ lastRows = xterm.rows;
103
+ ws.send(JSON.stringify({ type: 'pty_resize', cols: xterm.cols, rows: xterm.rows }));
104
+ }
99
105
  }
100
106
  }
101
107
 
102
- // Handle resize
108
+ // Handle resize — debounced to avoid rapid PTY resizes (mobile keyboard, URL bar, etc.)
103
109
  window.addEventListener('resize', () => {
104
- if (fitAddon) { fitAddon.fit(); sendResize(); }
110
+ if (resizeTimer) clearTimeout(resizeTimer);
111
+ resizeTimer = setTimeout(() => {
112
+ if (fitAddon) { fitAddon.fit(); sendResize(); }
113
+ }, 150);
105
114
  });
106
115
 
107
116
  // Send initial size
@@ -568,18 +577,25 @@
568
577
  }, 100);
569
578
  }
570
579
 
580
+ var gridResizeTimer = null;
571
581
  function fitGridPanels() {
572
- gridTerminals.forEach(function(gt) {
573
- if (!document.contains(gt.panel)) return;
574
- if (gt.fitAddon) {
575
- try {
576
- gt.fitAddon.fit();
577
- if (gt.ws && gt.ws.readyState === WebSocket.OPEN && gt.xterm) {
578
- gt.ws.send(JSON.stringify({ type: 'pty_resize', cols: gt.xterm.cols, rows: gt.xterm.rows }));
579
- }
580
- } catch(e) {}
581
- }
582
- });
582
+ if (gridResizeTimer) clearTimeout(gridResizeTimer);
583
+ gridResizeTimer = setTimeout(function() {
584
+ gridTerminals.forEach(function(gt) {
585
+ if (!document.contains(gt.panel)) return;
586
+ if (gt.fitAddon) {
587
+ try {
588
+ var prevCols = gt.xterm ? gt.xterm.cols : 0;
589
+ var prevRows = gt.xterm ? gt.xterm.rows : 0;
590
+ gt.fitAddon.fit();
591
+ if (gt.ws && gt.ws.readyState === WebSocket.OPEN && gt.xterm &&
592
+ (gt.xterm.cols !== prevCols || gt.xterm.rows !== prevRows)) {
593
+ gt.ws.send(JSON.stringify({ type: 'pty_resize', cols: gt.xterm.cols, rows: gt.xterm.rows }));
594
+ }
595
+ } catch(e) {}
596
+ }
597
+ });
598
+ }, 150);
583
599
  }
584
600
 
585
601
  function destroyGrid() {
@@ -833,7 +849,8 @@
833
849
  ws.onopen = () => {
834
850
  connected = true;
835
851
  reconnectAttempt = 0;
836
- setTimeout(() => initializeACP(1), 1000);
852
+ setStatus('online', 'Connected');
853
+ // PTY mode: server sends pty data immediately, no ACP handshake needed
837
854
  };
838
855
  ws.onclose = () => {
839
856
  connected = false; acpReady = false; sessionId = null;