@lethevimlet/sshift 1.7.7 → 1.7.8

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.8",
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,21 @@ 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
+ // Keys-bar keys change the remote line/cursor in ways the hidden
4441
+ // textarea cannot model (Tab completes a word, arrows move the
4442
+ // cursor mid-line, Ctrl+C/U/D abort or clear the line, Esc aborts).
4443
+ // The textarea diff assumes the remote cursor sits at the END of
4444
+ // the sent baseline — that model is dead now. Reset the field and
4445
+ // baseline so typing continues from a clean slate: new input
4446
+ // appends at the remote cursor position, exactly like a real
4447
+ // keyboard. _resetInputTracking is composition-guarded, so an
4448
+ // in-flight Gboard composition is not corrupted mid-word (the
4449
+ // reset is deferred to compositionend).
4450
+ if (this.isMobile && session.mobileHandler && session.mobileHandler.hiddenTextarea) {
4451
+ session.mobileHandler._resetInputTracking();
4452
+ }
4453
+
4440
4454
  // Focus terminal after sending key
4441
4455
  if (this.isMobile && session.mobileHandler && session.mobileHandler.hiddenTextarea) {
4442
4456
  session.mobileHandler._focusHiddenTextarea();
@@ -4774,6 +4788,11 @@ const wheelHandler = (e) => {
4774
4788
  if (data.noTerminalState) {
4775
4789
  console.log('[SSHIFT] No terminal state on server, clearing syncing flag');
4776
4790
  session.syncing = false;
4791
+ // No serialized state is coming — the data buffered during the
4792
+ // sync window is the ONLY output this client has received.
4793
+ // Drain it or it stays stuck (permanently missing rows in
4794
+ // line-diff TUI screens — the stale/black-line bug).
4795
+ this._drainSyncBuffer(session);
4777
4796
  }
4778
4797
 
4779
4798
  // Handle controller status
@@ -9606,17 +9625,23 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
9606
9625
  // into the normal write path and schedule a flush. Called when a sync
9607
9626
  // completes (or is aborted) so no live output is lost.
9608
9627
  _drainSyncBuffer(session) {
9609
- if (!session || !session.terminal) { session.syncBuffer = []; return; }
9628
+ if (!session) return;
9610
9629
  const buffered = session.syncBuffer || [];
9611
9630
  session.syncBuffer = [];
9612
- if (buffered.length > 0) {
9631
+ if (buffered.length === 0) return;
9632
+ if (!session.terminal) {
9633
+ // Terminal not created yet — keep the data in the regular write
9634
+ // buffer; its terminal-not-ready retry path flushes it once the
9635
+ // terminal exists. Never discard live output.
9613
9636
  session.writeChunks.push(...buffered);
9614
- if (!session.writeRAF) {
9615
- const sessionId = session.id;
9616
- session.writeRAF = requestAnimationFrame(() => {
9617
- this._flushWriteChunks(sessionId);
9618
- });
9619
- }
9637
+ return;
9638
+ }
9639
+ session.writeChunks.push(...buffered);
9640
+ if (!session.writeRAF) {
9641
+ const sessionId = session.id;
9642
+ session.writeRAF = requestAnimationFrame(() => {
9643
+ this._flushWriteChunks(sessionId);
9644
+ });
9620
9645
  }
9621
9646
  }
9622
9647
 
@@ -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
  }