@lethevimlet/sshift 1.4.6 → 1.4.7
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/src/webapp/js/app.js +62 -20
package/package.json
CHANGED
package/src/webapp/js/app.js
CHANGED
|
@@ -1200,27 +1200,33 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1200
1200
|
return false;
|
|
1201
1201
|
}
|
|
1202
1202
|
|
|
1203
|
-
// Guard: refuse to fit if the container
|
|
1204
|
-
// A zero
|
|
1205
|
-
//
|
|
1206
|
-
//
|
|
1207
|
-
//
|
|
1208
|
-
//
|
|
1203
|
+
// Guard: refuse to fit if the container hasn't reached a usable size.
|
|
1204
|
+
// A zero/very small container (e.g. a pane mid-layout-transition that
|
|
1205
|
+
// is briefly ~100x100px) produces bogus col/row counts. Those propagate
|
|
1206
|
+
// to the remote PTY and cause the "tiny ~10-column terminal" bug.
|
|
1207
|
+
//
|
|
1208
|
+
// 50px is below every real pane size (terms-container min-height 200px,
|
|
1209
|
+
// layout-panel min-width/height enforce 200px+ even on mobile) but above
|
|
1210
|
+
// transient collapsed states (display:none, mid-flex-grow). Retrying on
|
|
1211
|
+
// the next animation frame lets the browser finish laying out first.
|
|
1209
1212
|
const rect = container.getBoundingClientRect();
|
|
1210
|
-
if (rect.width <
|
|
1213
|
+
if (rect.width < 50 || rect.height < 50) {
|
|
1211
1214
|
session.needsResize = true;
|
|
1212
|
-
if (retryCount <
|
|
1215
|
+
if (retryCount < 5) {
|
|
1213
1216
|
requestAnimationFrame(() => this._fitTerminal(session, retryCount + 1));
|
|
1214
1217
|
}
|
|
1215
1218
|
return false;
|
|
1216
1219
|
}
|
|
1217
1220
|
|
|
1218
|
-
//
|
|
1219
|
-
//
|
|
1220
|
-
//
|
|
1221
|
+
// Note: do NOT mutate term.options.lineHeight / letterSpacing here.
|
|
1222
|
+
// Both options are set to their base values (1, 0) at Terminal construction
|
|
1223
|
+
// and nothing else modifies them, so a reset would be a no-op — except that
|
|
1224
|
+
// xterm.js's option setter invalidates _renderService.dimensions
|
|
1225
|
+
// asynchronously. Then fitAddon.fit() can read the stale (pre-invalidation)
|
|
1226
|
+
// cell height, computing cols/rows for one cell height while the renderer
|
|
1227
|
+
// paints at another. That mismatch shows every other row empty (the
|
|
1228
|
+
// "alternating black band" rendering bug).
|
|
1221
1229
|
const term = session.terminal;
|
|
1222
|
-
term.options.letterSpacing = 0;
|
|
1223
|
-
term.options.lineHeight = 1;
|
|
1224
1230
|
|
|
1225
1231
|
void container.offsetHeight;
|
|
1226
1232
|
void wrapper.offsetHeight;
|
|
@@ -1239,7 +1245,7 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
|
|
|
1239
1245
|
const containerWidth = container.getBoundingClientRect().width;
|
|
1240
1246
|
if (cellWidth > 0 && containerWidth > 80) {
|
|
1241
1247
|
const expectedCols = Math.floor(containerWidth / cellWidth);
|
|
1242
|
-
if (terminal.cols < expectedCols * 0.5 && retryCount <
|
|
1248
|
+
if (terminal.cols < expectedCols * 0.5 && retryCount < 5) {
|
|
1243
1249
|
console.warn(`[SSHIFT] Terminal fit seems incorrect (cols: ${terminal.cols}, expected: ~${expectedCols}, container: ${containerWidth}px), retrying (attempt ${retryCount + 1})...`);
|
|
1244
1250
|
requestAnimationFrame(() => {
|
|
1245
1251
|
this._fitTerminal(session, retryCount + 1);
|
|
@@ -7184,10 +7190,19 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
7184
7190
|
console.log('[SSHIFT] Container dimensions:', container.offsetWidth, 'x', container.offsetHeight);
|
|
7185
7191
|
console.log('[SSHIFT] Wrapper visible:', isVisible, 'Display:', wrapper ? getComputedStyle(wrapper).display : 'N/A');
|
|
7186
7192
|
|
|
7187
|
-
// Ensure container has dimensions
|
|
7188
|
-
|
|
7193
|
+
// Ensure container has dimensions large enough for a usable terminal
|
|
7194
|
+
// before opening it. A pane that is mid-layout-transition can briefly
|
|
7195
|
+
// measure ~100x100px; terminal.open() at that size computes bogus
|
|
7196
|
+
// cols/rows that get sent to the remote PTY, and the terminal stays
|
|
7197
|
+
// tiny from then on. See _fitTerminal's matching threshold comment.
|
|
7198
|
+
const rect = container.getBoundingClientRect();
|
|
7199
|
+
if (
|
|
7200
|
+
!isVisible ||
|
|
7201
|
+
rect.width < 50 || rect.height < 50 ||
|
|
7202
|
+
container.offsetWidth === 0 || container.offsetHeight === 0
|
|
7203
|
+
) {
|
|
7189
7204
|
if (retryCount < 10) {
|
|
7190
|
-
console.warn(`[SSHIFT] Container not ready (attempt ${retryCount + 1}/10), waiting...`);
|
|
7205
|
+
console.warn(`[SSHIFT] Container not ready (attempt ${retryCount + 1}/10, ${rect.width}x${rect.height}px), waiting...`);
|
|
7191
7206
|
setTimeout(() => this.initTerminal(sessionId, retryCount + 1), 100);
|
|
7192
7207
|
return;
|
|
7193
7208
|
} else {
|
|
@@ -7308,10 +7323,16 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
7308
7323
|
|
|
7309
7324
|
console.log('[SSHIFT] Opening terminal in container...');
|
|
7310
7325
|
|
|
7311
|
-
// Ensure container has valid dimensions before opening
|
|
7326
|
+
// Ensure container has valid dimensions before opening.
|
|
7327
|
+
// xterm.js's terminal.open() inlines a sized <div> based on whatever
|
|
7328
|
+
// cols/rows the Terminal was constructed with; if the container is
|
|
7329
|
+
// collapsed at open() time the inline styles get pinned to near-zero
|
|
7330
|
+
// pixels and subsequent fit()s can fail to recover from that state.
|
|
7331
|
+
// The matching load-time retry above already keeps us waiting until
|
|
7332
|
+
// the container is usable; re-check here as a hard invariant.
|
|
7312
7333
|
const rect = container.getBoundingClientRect();
|
|
7313
|
-
if (rect.width
|
|
7314
|
-
console.error('[SSHIFT] Container
|
|
7334
|
+
if (rect.width < 50 || rect.height < 50) {
|
|
7335
|
+
console.error('[SSHIFT] Container not usable before open():', rect.width, 'x', rect.height);
|
|
7315
7336
|
this.showToast('Terminal container has invalid dimensions', 'error');
|
|
7316
7337
|
return;
|
|
7317
7338
|
}
|
|
@@ -7452,6 +7473,27 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
|
|
|
7452
7473
|
// it will have set needsResize = true so switchTab() picks it up.
|
|
7453
7474
|
console.log('[SSHIFT] Could not fit after fonts ready — deferred to tab activation');
|
|
7454
7475
|
}
|
|
7476
|
+
|
|
7477
|
+
// Safety net: the first fit may have measured a pane mid-layout
|
|
7478
|
+
// (Browser is still committing display:none -> display:flex, or a
|
|
7479
|
+
// sidebar is collapsing/opening). Re-fit after layout settles so
|
|
7480
|
+
// a transient small pane size doesn't leave the terminal stuck in
|
|
7481
|
+
// a ~100x100px box (the "tiny terminal" bug). Mirrors the same
|
|
7482
|
+
// fix already used in switchTab().
|
|
7483
|
+
setTimeout(() => {
|
|
7484
|
+
if (!session.terminal || !session.fitAddon || !session.isController) return;
|
|
7485
|
+
const w = document.getElementById(`terminal-wrapper-${session.id}`);
|
|
7486
|
+
if (w && w.classList.contains('active')) {
|
|
7487
|
+
this._fitTerminal(session);
|
|
7488
|
+
}
|
|
7489
|
+
}, 250);
|
|
7490
|
+
setTimeout(() => {
|
|
7491
|
+
if (!session.terminal || !session.fitAddon || !session.isController) return;
|
|
7492
|
+
const w = document.getElementById(`terminal-wrapper-${session.id}`);
|
|
7493
|
+
if (w && w.classList.contains('active')) {
|
|
7494
|
+
this._fitTerminal(session);
|
|
7495
|
+
}
|
|
7496
|
+
}, 600);
|
|
7455
7497
|
});
|
|
7456
7498
|
});
|
|
7457
7499
|
|