@lethevimlet/sshift 1.7.3 → 1.7.5
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 +1 -1
- package/plugins/claude-attention/index.js +181 -50
- package/plugins/claude-attention/package.json +1 -1
- package/plugins/opencode-attention/index.js +191 -64
- package/plugins/opencode-attention/package.json +1 -1
- package/src/server/endpoints/ws/ssh.js +9 -0
- package/src/server/plugins/plugin-manager.js +24 -1
- package/src/server/services/ssh-manager.js +31 -0
- package/src/webapp/css/style.css +16 -12
- package/src/webapp/js/app.js +142 -13
- package/src/webapp/js/mobile-terminal.js +8 -2
package/src/webapp/js/app.js
CHANGED
|
@@ -1190,8 +1190,10 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1190
1190
|
if (session.terminal && !session.webglAddon && (session.webglContextLossCount || 0) < 3) {
|
|
1191
1191
|
console.log('[SSHIFT] Attempting WebGL addon recreation after context loss');
|
|
1192
1192
|
this._initWebGLAddon(session, false);
|
|
1193
|
-
if (
|
|
1194
|
-
|
|
1193
|
+
if (!document.hidden) {
|
|
1194
|
+
// Guarded refit — see _refreshAllWebGLSessions for why a bare
|
|
1195
|
+
// fitAddon.fit() on a hidden container is destructive.
|
|
1196
|
+
this._fitTerminal(session);
|
|
1195
1197
|
}
|
|
1196
1198
|
// After context loss the local terminal's rasterised
|
|
1197
1199
|
// cells may have been cleared; reconcile with the
|
|
@@ -1245,9 +1247,9 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1245
1247
|
} else {
|
|
1246
1248
|
try { webglAddon.clearTextureAtlas(); } catch (_) {}
|
|
1247
1249
|
session.terminal.refresh(0, session.terminal.rows - 1);
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1250
|
+
// Guarded refit — a bare fitAddon.fit() here would resize a hidden
|
|
1251
|
+
// session to 10x5 (see _refreshAllWebGLSessions).
|
|
1252
|
+
this._fitTerminal(session);
|
|
1251
1253
|
}
|
|
1252
1254
|
|
|
1253
1255
|
return true;
|
|
@@ -1276,9 +1278,14 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1276
1278
|
session.terminal.refresh(0, session.terminal.rows - 1);
|
|
1277
1279
|
} else if ((session.webglContextLossCount || 0) < 3 && typeof window.WebglAddon === 'function') {
|
|
1278
1280
|
this._initWebGLAddon(session, false);
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1281
|
+
// Refit through _fitTerminal, never fitAddon.fit() directly: a raw
|
|
1282
|
+
// fit() on a session whose wrapper is hidden reads the *computed*
|
|
1283
|
+
// (not used) style of the container, so `height: 100%` parses as
|
|
1284
|
+
// 100px and the terminal is resized to a bogus 10x5 — which the
|
|
1285
|
+
// controller then pushes to the remote PTY, wrecking whatever is
|
|
1286
|
+
// running in that background tab. _fitTerminal refuses to fit a
|
|
1287
|
+
// hidden or not-yet-laid-out container.
|
|
1288
|
+
this._fitTerminal(session);
|
|
1282
1289
|
}
|
|
1283
1290
|
};
|
|
1284
1291
|
this.sessions.forEach(refresh);
|
|
@@ -1333,6 +1340,14 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1333
1340
|
_fitTerminal(session, retryCount = 0) {
|
|
1334
1341
|
if (!session || !session.fitAddon || !session.terminal) return false;
|
|
1335
1342
|
|
|
1343
|
+
// Non-controllers must mirror the server's dimensions (they receive them
|
|
1344
|
+
// via ssh-resize-sync); fitting them to the local container makes the
|
|
1345
|
+
// shared session diverge and can start a resize war between clients.
|
|
1346
|
+
if (session.isController === false) {
|
|
1347
|
+
session.needsResize = true;
|
|
1348
|
+
return false;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1336
1351
|
const wrapper = document.getElementById(`terminal-wrapper-${session.id}`);
|
|
1337
1352
|
const container = document.getElementById(`terminal-${session.id}`);
|
|
1338
1353
|
if (!wrapper || !container) return false;
|
|
@@ -1407,9 +1422,44 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1407
1422
|
// bottom-row garbage and garbled status lines after resize.
|
|
1408
1423
|
this._forceRendererDimensionRecompute(session);
|
|
1409
1424
|
|
|
1425
|
+
// Make sure the remote PTY actually learns about this size. See
|
|
1426
|
+
// syncRemoteTerminalSize — xterm only fires onResize when cols/rows
|
|
1427
|
+
// change, so a fit that lands back on the dimensions the client already
|
|
1428
|
+
// had never notifies the server, even when the server is still on the
|
|
1429
|
+
// size it was given for the previous layout.
|
|
1430
|
+
this.syncRemoteTerminalSize(session);
|
|
1431
|
+
|
|
1410
1432
|
return true;
|
|
1411
1433
|
}
|
|
1412
1434
|
|
|
1435
|
+
// Push the terminal's current dimensions to the remote PTY when the server
|
|
1436
|
+
// is not already known to be at that size.
|
|
1437
|
+
//
|
|
1438
|
+
// The only automatic notification path is xterm's onResize event, which
|
|
1439
|
+
// fires ONLY when cols/rows actually change. That is not enough:
|
|
1440
|
+
// - a refit after a layout change can land on the same cols/rows the
|
|
1441
|
+
// client already had while the server is still sized for the previous
|
|
1442
|
+
// layout (nothing is emitted, the remote program keeps its old shape);
|
|
1443
|
+
// - the onResize emit is debounced and can be lost if another resize
|
|
1444
|
+
// event cancels the timer before it fires.
|
|
1445
|
+
// `remoteCols`/`remoteRows` track the last size the server is known to
|
|
1446
|
+
// have, so this is a no-op in the common case and cheap when it is not.
|
|
1447
|
+
syncRemoteTerminalSize(session) {
|
|
1448
|
+
if (!session || !session.terminal || !session.connected) return;
|
|
1449
|
+
if (!session.isController || session.isResyncing) return;
|
|
1450
|
+
if (!this.socket || !this.socket.connected) return;
|
|
1451
|
+
|
|
1452
|
+
const cols = session.terminal.cols;
|
|
1453
|
+
const rows = session.terminal.rows;
|
|
1454
|
+
if (!cols || !rows) return;
|
|
1455
|
+
if (session.remoteCols === cols && session.remoteRows === rows) return;
|
|
1456
|
+
|
|
1457
|
+
session.remoteCols = cols;
|
|
1458
|
+
session.remoteRows = rows;
|
|
1459
|
+
this.socket.emit('ssh-resize', { sessionId: session.id, cols, rows });
|
|
1460
|
+
console.log('[SSHIFT] Synced remote PTY size for', session.id, `${cols}x${rows}`);
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1413
1463
|
forceResizeTerminal(sessionId) {
|
|
1414
1464
|
if (!sessionId) return;
|
|
1415
1465
|
const session = this.sessions.get(sessionId) || this.sftpSessions.get(sessionId);
|
|
@@ -1471,6 +1521,19 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1471
1521
|
void container.offsetWidth;
|
|
1472
1522
|
void container.offsetHeight;
|
|
1473
1523
|
|
|
1524
|
+
// Same guard as _fitTerminal: a hidden pane reports its percentage CSS
|
|
1525
|
+
// verbatim ("100%" → 100px) and a fit against it produces a ~10x5
|
|
1526
|
+
// terminal that would be pushed straight to the remote PTY.
|
|
1527
|
+
if (!wrapper.classList.contains('active')) {
|
|
1528
|
+
session.needsResize = true;
|
|
1529
|
+
return false;
|
|
1530
|
+
}
|
|
1531
|
+
const rect = container.getBoundingClientRect();
|
|
1532
|
+
if (rect.width < 50 || rect.height < 50) {
|
|
1533
|
+
session.needsResize = true;
|
|
1534
|
+
return false;
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1474
1537
|
// (b) Commit the renderer's cell metrics before fit reads them.
|
|
1475
1538
|
this._syncCharSizeThenClearAtlas(session);
|
|
1476
1539
|
|
|
@@ -1509,6 +1572,8 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1509
1572
|
}
|
|
1510
1573
|
// Emit synchronously (we already debounced upstream by only calling
|
|
1511
1574
|
// this on discrete events: take-control / panel grab settlement).
|
|
1575
|
+
session.remoteCols = cols;
|
|
1576
|
+
session.remoteRows = rows;
|
|
1512
1577
|
this.socket.emit('ssh-resize', { sessionId: sid, cols, rows });
|
|
1513
1578
|
} catch (_) {}
|
|
1514
1579
|
}
|
|
@@ -2183,7 +2248,12 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
2183
2248
|
this.currentLayout = layout;
|
|
2184
2249
|
// Pass syncedTabs to applyLayout which will handle distribution
|
|
2185
2250
|
this.applyLayout(layout, syncedTabs);
|
|
2186
|
-
|
|
2251
|
+
|
|
2252
|
+
// Same staggered refit the local (dropdown) path gets — a client that
|
|
2253
|
+
// receives the layout from another browser tab has to re-measure its
|
|
2254
|
+
// panes just as thoroughly, or its terminals keep the previous shape.
|
|
2255
|
+
this.refitAllTerminals();
|
|
2256
|
+
|
|
2187
2257
|
setTimeout(() => this.handleResize(), 50);
|
|
2188
2258
|
}
|
|
2189
2259
|
}
|
|
@@ -4428,12 +4498,20 @@ const wheelHandler = (e) => {
|
|
|
4428
4498
|
console.log('[SSHIFT] Tab visible and socket disconnected, triggering reconnect');
|
|
4429
4499
|
this.socket.connect();
|
|
4430
4500
|
}
|
|
4501
|
+
this.clearFlashesForVisibleSessions();
|
|
4431
4502
|
this._refreshAllWebGLSessions();
|
|
4432
4503
|
// Refit visible terminals after tab becomes visible — the container
|
|
4433
4504
|
// may have had zero dimensions while hidden (Bugs 1 & 2).
|
|
4434
4505
|
requestAnimationFrame(() => this.handleResize());
|
|
4435
4506
|
});
|
|
4436
4507
|
|
|
4508
|
+
// A window can stay "visible" while unfocused (second monitor, desktop
|
|
4509
|
+
// app behind another window), so focus is its own signal that the user
|
|
4510
|
+
// has now seen whatever tab is on screen.
|
|
4511
|
+
window.addEventListener('focus', () => {
|
|
4512
|
+
this.clearFlashesForVisibleSessions();
|
|
4513
|
+
});
|
|
4514
|
+
|
|
4437
4515
|
this.socket.on('connect_error', (error) => {
|
|
4438
4516
|
console.error('[SSHIFT] Connection error:', error);
|
|
4439
4517
|
if (error.message === 'Authentication required') {
|
|
@@ -4868,6 +4946,10 @@ const wheelHandler = (e) => {
|
|
|
4868
4946
|
// 3. This can cause resize feedback loops between clients
|
|
4869
4947
|
// The controller is responsible for determining terminal dimensions
|
|
4870
4948
|
session.terminal.resize(data.cols, data.rows);
|
|
4949
|
+
// The server just told us the size it applied — remember it so we
|
|
4950
|
+
// don't bounce it straight back via syncRemoteTerminalSize.
|
|
4951
|
+
session.remoteCols = data.cols;
|
|
4952
|
+
session.remoteRows = data.rows;
|
|
4871
4953
|
console.log('[SSHIFT] Terminal resized to match server dimensions');
|
|
4872
4954
|
|
|
4873
4955
|
// Clear the syncing flag after a delay to ensure resize events settle
|
|
@@ -8807,6 +8889,8 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
8807
8889
|
clearTimeout(sess.resizeTimeout);
|
|
8808
8890
|
}
|
|
8809
8891
|
sess.resizeTimeout = setTimeout(() => {
|
|
8892
|
+
sess.remoteCols = cols;
|
|
8893
|
+
sess.remoteRows = rows;
|
|
8810
8894
|
this.socket.emit('ssh-resize', { sessionId, cols, rows });
|
|
8811
8895
|
}, 100); // 100ms debounce
|
|
8812
8896
|
}
|
|
@@ -9039,14 +9123,23 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
9039
9123
|
// Setup ResizeObserver to handle container size changes
|
|
9040
9124
|
// This ensures the terminal is refitted when the container is resized
|
|
9041
9125
|
// We observe the wrapper (parent) because it persists across layout changes
|
|
9126
|
+
//
|
|
9127
|
+
// NOTE: this debounce MUST use its own timer field. It used to share
|
|
9128
|
+
// `session.resizeTimeout` with the onResize handler above, which
|
|
9129
|
+
// schedules the `ssh-resize` emit that tells the remote PTY about the
|
|
9130
|
+
// new size. fit() changes the wrapper's inner geometry, so it
|
|
9131
|
+
// re-triggers this observer, which then cleared the *pending emit* and
|
|
9132
|
+
// replaced it with another (no-op) fit — the server never learned the
|
|
9133
|
+
// new size and the remote program kept drawing at the old width. That
|
|
9134
|
+
// is the "layout changed but the terminal keeps its previous shape" bug.
|
|
9042
9135
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
9043
9136
|
// Only fit if this is the controller and terminal is visible
|
|
9044
9137
|
if (session.isController && session.terminal && wrapper.classList.contains('active')) {
|
|
9045
9138
|
try {
|
|
9046
|
-
if (session.
|
|
9047
|
-
clearTimeout(session.
|
|
9139
|
+
if (session.roFitTimeout) {
|
|
9140
|
+
clearTimeout(session.roFitTimeout);
|
|
9048
9141
|
}
|
|
9049
|
-
session.
|
|
9142
|
+
session.roFitTimeout = setTimeout(() => {
|
|
9050
9143
|
try {
|
|
9051
9144
|
if (session.fitAddon && session.terminal && wrapper.classList.contains('active')) {
|
|
9052
9145
|
this._fitTerminal(session);
|
|
@@ -10175,6 +10268,10 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
10175
10268
|
if (wrapper && wrapper.classList.contains('active') &&
|
|
10176
10269
|
document.hasFocus() && !document.hidden) {
|
|
10177
10270
|
console.log('[SSHIFT] Suppressing tab flash for visible+focused session:', sessionId);
|
|
10271
|
+
// Tell the server the flash was seen, otherwise it keeps this session
|
|
10272
|
+
// marked as "flashing" forever and swallows every later attention
|
|
10273
|
+
// event as a duplicate.
|
|
10274
|
+
this.notifyTabSeen(sessionId);
|
|
10178
10275
|
return;
|
|
10179
10276
|
}
|
|
10180
10277
|
|
|
@@ -10209,6 +10306,29 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
10209
10306
|
this._flashApplyTimer = setTimeout(() => this.applyFlashStates(), 150);
|
|
10210
10307
|
}
|
|
10211
10308
|
|
|
10309
|
+
// Coming back to the window: any flashing tab that is actually on screen
|
|
10310
|
+
// has now been seen — clear it here and on the server.
|
|
10311
|
+
clearFlashesForVisibleSessions() {
|
|
10312
|
+
const flashingSessions = this._flashingSessions;
|
|
10313
|
+
if (!flashingSessions || flashingSessions.size === 0) return;
|
|
10314
|
+
if (document.hidden) return;
|
|
10315
|
+
for (const sessionId of Array.from(flashingSessions)) {
|
|
10316
|
+
const wrapper = document.getElementById(`terminal-wrapper-${sessionId}`);
|
|
10317
|
+
if (wrapper && wrapper.classList.contains('active')) {
|
|
10318
|
+
this.stopTabFlash(sessionId);
|
|
10319
|
+
this.notifyTabSeen(sessionId);
|
|
10320
|
+
}
|
|
10321
|
+
}
|
|
10322
|
+
}
|
|
10323
|
+
|
|
10324
|
+
// Let the server (and its attention plugins) know the user has seen this
|
|
10325
|
+
// tab. Clearing a flash only in the browser leaves the server-side plugin
|
|
10326
|
+
// stuck in "already flashing" state.
|
|
10327
|
+
notifyTabSeen(sessionId) {
|
|
10328
|
+
if (!sessionId || !this.socket || !this.socket.connected) return;
|
|
10329
|
+
this.socket.emit('tab-seen', { sessionId });
|
|
10330
|
+
}
|
|
10331
|
+
|
|
10212
10332
|
stopTabFlash(sessionId) {
|
|
10213
10333
|
const flashingSessions = this._flashingSessions;
|
|
10214
10334
|
if (flashingSessions) {
|
|
@@ -10275,6 +10395,7 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
10275
10395
|
|
|
10276
10396
|
// Stop any active flash on this tab since user is viewing it
|
|
10277
10397
|
this.stopTabFlash(sessionId);
|
|
10398
|
+
this.notifyTabSeen(sessionId);
|
|
10278
10399
|
|
|
10279
10400
|
// Determine which panel this session belongs to
|
|
10280
10401
|
if (!panelId) {
|
|
@@ -10461,11 +10582,15 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
10461
10582
|
session.resizeObserver.disconnect();
|
|
10462
10583
|
session.resizeObserver = null;
|
|
10463
10584
|
}
|
|
10464
|
-
// Clean up resize
|
|
10585
|
+
// Clean up resize timeouts (emit debounce + ResizeObserver fit debounce)
|
|
10465
10586
|
if (session.resizeTimeout) {
|
|
10466
10587
|
clearTimeout(session.resizeTimeout);
|
|
10467
10588
|
session.resizeTimeout = null;
|
|
10468
10589
|
}
|
|
10590
|
+
if (session.roFitTimeout) {
|
|
10591
|
+
clearTimeout(session.roFitTimeout);
|
|
10592
|
+
session.roFitTimeout = null;
|
|
10593
|
+
}
|
|
10469
10594
|
// Clean up scrollbar MutationObserver (mobile-only)
|
|
10470
10595
|
if (session._scrollbarObserver) {
|
|
10471
10596
|
session._scrollbarObserver.disconnect();
|
|
@@ -10597,6 +10722,10 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
10597
10722
|
clearTimeout(session.resizeTimeout);
|
|
10598
10723
|
session.resizeTimeout = null;
|
|
10599
10724
|
}
|
|
10725
|
+
if (session.roFitTimeout) {
|
|
10726
|
+
clearTimeout(session.roFitTimeout);
|
|
10727
|
+
session.roFitTimeout = null;
|
|
10728
|
+
}
|
|
10600
10729
|
if (session.wheelHandler && session.wheelElement) {
|
|
10601
10730
|
session.wheelElement.removeEventListener('wheel', session.wheelHandler);
|
|
10602
10731
|
}
|
|
@@ -1618,11 +1618,17 @@ class MobileTerminalHandler {
|
|
|
1618
1618
|
this.terminalElement.style.height = '';
|
|
1619
1619
|
}
|
|
1620
1620
|
|
|
1621
|
-
// Refit terminal
|
|
1621
|
+
// Refit terminal. Prefer the app's guarded refit (it refuses to fit a
|
|
1622
|
+
// hidden/unlaid-out container, which a bare fit() would resize to a
|
|
1623
|
+
// bogus 10x5) and falls back to fit() when the app isn't reachable.
|
|
1622
1624
|
if (this.session.fitAddon) {
|
|
1623
1625
|
requestAnimationFrame(() => {
|
|
1624
1626
|
try {
|
|
1625
|
-
this.
|
|
1627
|
+
if (this.app && typeof this.app._fitTerminal === 'function') {
|
|
1628
|
+
this.app._fitTerminal(this.session);
|
|
1629
|
+
} else {
|
|
1630
|
+
this.session.fitAddon.fit();
|
|
1631
|
+
}
|
|
1626
1632
|
} catch (err) {
|
|
1627
1633
|
console.warn('[MobileTerminal] Failed to fit terminal:', err);
|
|
1628
1634
|
}
|