@lethevimlet/sshift 1.7.7 → 1.7.9

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": "@lethevimlet/sshift",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
5
  "main": "src/server/index.js",
6
6
  "bin": {
@@ -4436,7 +4436,18 @@ const wheelHandler = (e) => {
4436
4436
  this.socket.emit('ssh-data', { sessionId: this.activeSessionId, data: keySequence });
4437
4437
  console.log('[SSHIFT] Sent mobile key:', keyName, 'sequence:', keySequence);
4438
4438
  }
4439
-
4439
+
4440
+ // NOTE: do NOT reset the mobile handler's input tracking here.
4441
+ // v1.7.8 did (to drop the textarea's stale model of the remote line
4442
+ // after Tab/arrows/Ctrl+C) and it reintroduced the Gboard duplication
4443
+ // family, WORSE: the keys-bar taps don't blur the hidden textarea, so
4444
+ // the clear happened under a LIVE IME session — invisible to Gboard,
4445
+ // whose stale field model then re-inserted text ("characters go
4446
+ // crazy"). With an active composition the deferred reset even
4447
+ // discarded the in-flight word. The staleness after line-clearing
4448
+ // keys is minor and mostly invisible (typing still appends at the
4449
+ // remote cursor); the reset was far worse.
4450
+
4440
4451
  // Focus terminal after sending key
4441
4452
  if (this.isMobile && session.mobileHandler && session.mobileHandler.hiddenTextarea) {
4442
4453
  session.mobileHandler._focusHiddenTextarea();
@@ -4774,6 +4785,11 @@ const wheelHandler = (e) => {
4774
4785
  if (data.noTerminalState) {
4775
4786
  console.log('[SSHIFT] No terminal state on server, clearing syncing flag');
4776
4787
  session.syncing = false;
4788
+ // No serialized state is coming — the data buffered during the
4789
+ // sync window is the ONLY output this client has received.
4790
+ // Drain it or it stays stuck (permanently missing rows in
4791
+ // line-diff TUI screens — the stale/black-line bug).
4792
+ this._drainSyncBuffer(session);
4777
4793
  }
4778
4794
 
4779
4795
  // Handle controller status
@@ -4845,6 +4861,14 @@ const wheelHandler = (e) => {
4845
4861
  session.flushRemaining = null;
4846
4862
  // Fresh buffer for live data arriving while the sync state is written
4847
4863
  session.syncBuffer = [];
4864
+ // A partial OSC 52 / DCS sequence stashed before the reset must
4865
+ // NOT survive into the post-sync stream: it was captured against
4866
+ // the pre-reset state, and _handleOsc52 would prepend it to the
4867
+ // next flush — the parser then eats real output into a bogus
4868
+ // clipboard sequence (garbled/missing characters right after
4869
+ // take-control / tab-switch syncs). It is already consumed
4870
+ // server-side (contained in the serialized state) — drop it.
4871
+ session.pendingOsc52 = null;
4848
4872
 
4849
4873
  // Clear the terminal completely before applying the serialized state
4850
4874
  // Use reset() to clear both the buffer and the scrollback
@@ -9606,17 +9630,23 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
9606
9630
  // into the normal write path and schedule a flush. Called when a sync
9607
9631
  // completes (or is aborted) so no live output is lost.
9608
9632
  _drainSyncBuffer(session) {
9609
- if (!session || !session.terminal) { session.syncBuffer = []; return; }
9633
+ if (!session) return;
9610
9634
  const buffered = session.syncBuffer || [];
9611
9635
  session.syncBuffer = [];
9612
- if (buffered.length > 0) {
9636
+ if (buffered.length === 0) return;
9637
+ if (!session.terminal) {
9638
+ // Terminal not created yet — keep the data in the regular write
9639
+ // buffer; its terminal-not-ready retry path flushes it once the
9640
+ // terminal exists. Never discard live output.
9613
9641
  session.writeChunks.push(...buffered);
9614
- if (!session.writeRAF) {
9615
- const sessionId = session.id;
9616
- session.writeRAF = requestAnimationFrame(() => {
9617
- this._flushWriteChunks(sessionId);
9618
- });
9619
- }
9642
+ return;
9643
+ }
9644
+ session.writeChunks.push(...buffered);
9645
+ if (!session.writeRAF) {
9646
+ const sessionId = session.id;
9647
+ session.writeRAF = requestAnimationFrame(() => {
9648
+ this._flushWriteChunks(sessionId);
9649
+ });
9620
9650
  }
9621
9651
  }
9622
9652
 
@@ -9787,24 +9817,43 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
9787
9817
  clearTimeout(session.settleRefreshMaxTimer);
9788
9818
  session.settleRefreshMaxTimer = null;
9789
9819
  }
9790
- const term = session.terminal;
9791
- if (!term) return;
9792
- try { term.refresh(0, term.rows - 1); } catch (_) {}
9820
+ if (!session.terminal) return;
9821
+ // Use the full dimension recompute (the exact path a font-size
9822
+ // change triggers), NOT a plain refresh(): a plain refresh
9823
+ // repaints at the CURRENT renderer cell pitch — if a pitch desync
9824
+ // formed during the flood (the "alternating black bands between
9825
+ // text lines" bug: rows painted empty at a mismatched pitch),
9826
+ // repainting at the same broken pitch reproduces the bands.
9827
+ // Users report a font/window resize reliably heals the artefact;
9828
+ // this is the programmatic equivalent, applied automatically
9829
+ // ~350ms after every output burst settles.
9830
+ if (session.syncing) return; // sync completion does its own recompute
9831
+ this._forceRendererDimensionRecompute(session);
9793
9832
  }, 350);
9794
9833
 
9795
9834
  // Safety net for continuous floods: guarantee a full dimension-
9796
9835
  // recompute repaint at least every 2s while writes keep arriving,
9797
9836
  // otherwise the trailing refresh above is postponed indefinitely.
9798
9837
  if (!session.settleRefreshMaxTimer) {
9799
- session.settleRefreshMaxTimer = setTimeout(() => {
9838
+ const runMaxWait = () => {
9800
9839
  session.settleRefreshMaxTimer = null;
9801
9840
  if (!session.terminal) return;
9841
+ // Never run the dimension recompute mid-screen-sync: the
9842
+ // serialized state is still being parsed (terminal.reset() has
9843
+ // run but the write hasn't completed), so a full repaint now
9844
+ // paints a half-applied state and an atlas rebuild races the
9845
+ // sync completion's own recompute. Retry later.
9846
+ if (session.syncing) {
9847
+ session.settleRefreshMaxTimer = setTimeout(runMaxWait, 2000);
9848
+ return;
9849
+ }
9802
9850
  if (session.settleRefreshTimer) {
9803
9851
  clearTimeout(session.settleRefreshTimer);
9804
9852
  session.settleRefreshTimer = null;
9805
9853
  }
9806
9854
  this._forceRendererDimensionRecompute(session);
9807
- }, 2000);
9855
+ };
9856
+ session.settleRefreshMaxTimer = setTimeout(runMaxWait, 2000);
9808
9857
  }
9809
9858
  }
9810
9859
 
@@ -1561,23 +1561,24 @@ class MobileTerminalHandler {
1561
1561
  // Do NOT clear the textarea on refocus. The diff baseline
1562
1562
  // (_sentValue) tracks exactly what was sent to the terminal, so
1563
1563
  // stale-looking content is NOT stale: textarea, baseline and the
1564
- // remote prompt line all agree, and Gboard's own model of the
1565
- // field (from its last focus query) agrees too.
1564
+ // remote prompt line all agree. Clearing here (v1.7.0 behaviour)
1565
+ // is a programmatic assignment INVISIBLE to Gboard, desyncing its
1566
+ // field model — the "hel" + autocomplete → "helhel" bug. Keeping
1567
+ // the text lets the IME operate on the real pending line so
1568
+ // suggestion taps send only the true delta.
1566
1569
  //
1567
- // Wiping the value here (the old behaviour) is a programmatic
1568
- // assignment that is INVISIBLE to Gboard: the keyboard keeps its
1569
- // cached model ("hel"), the field is now empty, and the next
1570
- // suggestion tap re-inserts text computed from the stale model.
1571
- // The diff then treats that fragment as brand-new text and sends
1572
- // it on top of what the terminal already echoed — the classic
1573
- // "hel" + autocomplete → "helhel" duplication. Keeping the
1574
- // textarea intact keeps the IME, the field and the baseline in
1575
- // sync; autocomplete diffs then send only the true delta.
1576
- //
1577
- // Genuine context switches (session teardown, Enter/newline,
1578
- // Tab key, selection start) still reset explicitly via
1579
- // _resetInputTracking().
1570
+ // CRITICAL: the diff is append-at-end semantics (longest common
1571
+ // prefix from the END of the sent baseline). After a programmatic
1572
+ // focus() the caret typically lands at position 0 (NOT at the end
1573
+ // of the text), so the next keystroke would be inserted at the
1574
+ // START of the field — the diff then sees total divergence and
1575
+ // re-sends the ENTIRE field, retyping already-echoed words on
1576
+ // every keystroke after a tap (the "repeats words without
1577
+ // autocomplete" regression). Force the caret to the end so typing
1578
+ // appends, matching both the diff and the remote prompt cursor.
1579
+ const len = this.hiddenTextarea.value.length;
1580
1580
  this.hiddenTextarea.focus();
1581
+ try { this.hiddenTextarea.setSelectionRange(len, len); } catch (_) {}
1581
1582
  this._keyboardCollapsed = false;
1582
1583
  }
1583
1584
  }