@lethevimlet/sshift 1.7.1 → 1.7.3

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.
@@ -125,15 +125,30 @@
125
125
  <div class="terminal-color-options" id="terminalColorOptions">
126
126
  <div class="terminal-color-option">
127
127
  <label for="terminalBgColor">Background</label>
128
- <input type="color" id="terminalBgColor" class="color-input" value="#0d1117">
128
+ <div class="color-input-group">
129
+ <input type="color" id="terminalBgColor" class="color-input" value="#0d1117">
130
+ <button type="button" class="color-reset-btn" data-color-target="bg" title="Restore default background">
131
+ <i class="fas fa-rotate-left"></i>
132
+ </button>
133
+ </div>
129
134
  </div>
130
135
  <div class="terminal-color-option">
131
136
  <label for="terminalFgColor">Foreground</label>
132
- <input type="color" id="terminalFgColor" class="color-input" value="#e6edf3">
137
+ <div class="color-input-group">
138
+ <input type="color" id="terminalFgColor" class="color-input" value="#e6edf3">
139
+ <button type="button" class="color-reset-btn" data-color-target="fg" title="Restore default foreground">
140
+ <i class="fas fa-rotate-left"></i>
141
+ </button>
142
+ </div>
133
143
  </div>
134
144
  <div class="terminal-color-option">
135
145
  <label for="terminalSelectionColor">Selection</label>
136
- <input type="color" id="terminalSelectionColor" class="color-input" value="#264f78">
146
+ <div class="color-input-group">
147
+ <input type="color" id="terminalSelectionColor" class="color-input" value="#264f78">
148
+ <button type="button" class="color-reset-btn" data-color-target="selection" title="Restore default selection color">
149
+ <i class="fas fa-rotate-left"></i>
150
+ </button>
151
+ </div>
137
152
  </div>
138
153
  </div>
139
154
  </div>
@@ -219,15 +234,30 @@
219
234
  <div class="terminal-color-options" id="mobileTerminalColorOptions">
220
235
  <div class="terminal-color-option">
221
236
  <label for="mobileTerminalBgColor">Background</label>
222
- <input type="color" id="mobileTerminalBgColor" class="color-input" value="#0d1117">
237
+ <div class="color-input-group">
238
+ <input type="color" id="mobileTerminalBgColor" class="color-input" value="#0d1117">
239
+ <button type="button" class="color-reset-btn" data-color-target="bg" title="Restore default background">
240
+ <i class="fas fa-rotate-left"></i>
241
+ </button>
242
+ </div>
223
243
  </div>
224
244
  <div class="terminal-color-option">
225
245
  <label for="mobileTerminalFgColor">Foreground</label>
226
- <input type="color" id="mobileTerminalFgColor" class="color-input" value="#e6edf3">
246
+ <div class="color-input-group">
247
+ <input type="color" id="mobileTerminalFgColor" class="color-input" value="#e6edf3">
248
+ <button type="button" class="color-reset-btn" data-color-target="fg" title="Restore default foreground">
249
+ <i class="fas fa-rotate-left"></i>
250
+ </button>
251
+ </div>
227
252
  </div>
228
253
  <div class="terminal-color-option">
229
254
  <label for="mobileTerminalSelectionColor">Selection</label>
230
- <input type="color" id="mobileTerminalSelectionColor" class="color-input" value="#264f78">
255
+ <div class="color-input-group">
256
+ <input type="color" id="mobileTerminalSelectionColor" class="color-input" value="#264f78">
257
+ <button type="button" class="color-reset-btn" data-color-target="selection" title="Restore default selection color">
258
+ <i class="fas fa-rotate-left"></i>
259
+ </button>
260
+ </div>
231
261
  </div>
232
262
  </div>
233
263
  </div>
@@ -1858,6 +1858,27 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
1858
1858
  this.updateTerminalThemes(currentTheme);
1859
1859
  }
1860
1860
 
1861
+ // Restore a single terminal color to its per-theme default (the defaults
1862
+ // differ between the dark and light themes — see _terminalColorDefaults).
1863
+ // Used by the reset buttons next to each color picker in the terminal
1864
+ // colors dropdown (desktop) and mobile overflow submenu.
1865
+ resetTerminalColorToDefault(target) {
1866
+ const themeKey = (this.theme === 'dark' || this.theme === 'light') ? this.theme : 'dark';
1867
+ const defaults = this._terminalColorDefaults(themeKey);
1868
+ if (target === 'bg') {
1869
+ this.setTerminalBgColor(defaults.bg);
1870
+ } else if (target === 'fg') {
1871
+ this.setTerminalFgColor(defaults.fg);
1872
+ } else if (target === 'selection') {
1873
+ this.setTerminalSelectionColor(defaults.selection);
1874
+ } else {
1875
+ return;
1876
+ }
1877
+ // Sync both desktop and mobile pickers to the restored value.
1878
+ this.updateTerminalColorOverrideUI();
1879
+ console.log('[SSHIFT] Terminal color reset to default:', target, 'theme:', themeKey);
1880
+ }
1881
+
1861
1882
  updateTerminalColorOverrideUI() {
1862
1883
  // Desktop elements
1863
1884
  const checkbox = document.getElementById('terminalColorOverride');
@@ -5546,6 +5567,18 @@ const wheelHandler = (e) => {
5546
5567
  this.setTerminalSelectionColor(e.target.value);
5547
5568
  });
5548
5569
  }
5570
+
5571
+ // Per-picker "restore default" buttons (desktop dropdown + mobile
5572
+ // overflow submenu share the same class + data attribute). Defaults
5573
+ // are per theme (dark/light). stopPropagation keeps the dropdown/
5574
+ // submenu open so the user sees the picker snap back.
5575
+ document.querySelectorAll('.color-reset-btn').forEach(btn => {
5576
+ btn.addEventListener('click', (e) => {
5577
+ e.preventDefault();
5578
+ e.stopPropagation();
5579
+ this.resetTerminalColorToDefault(btn.dataset.colorTarget);
5580
+ });
5581
+ });
5549
5582
 
5550
5583
  // Initialize terminal color override UI state
5551
5584
  this.updateTerminalColorOverrideUI();
@@ -8036,6 +8069,7 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
8036
8069
  flushRemaining: null,
8037
8070
  originalScrollback: null,
8038
8071
  scrollbackRestoreTimer: null,
8072
+ settleRefreshTimer: null,
8039
8073
  // Per-session buffer for OSC 52 / DCS sequences that arrive split
8040
8074
  // across two write-chunk frames (see _handleOsc52).
8041
8075
  pendingOsc52: null
@@ -9471,6 +9505,9 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
9471
9505
  if (session.terminal && session.originalScrollback) {
9472
9506
  session.terminal.options.scrollback = session.originalScrollback;
9473
9507
  session.originalScrollback = null;
9508
+ // The scrollback option change adjusts the buffer; repaint the
9509
+ // full viewport so no row is left showing pre-adjustment content.
9510
+ try { session.terminal.refresh(0, session.terminal.rows - 1); } catch (_) {}
9474
9511
  }
9475
9512
  session.scrollbackRestoreTimer = null;
9476
9513
  }, 3000);
@@ -9497,6 +9534,40 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
9497
9534
  } else {
9498
9535
  terminal.write(combined);
9499
9536
  }
9537
+
9538
+ // Guarantee the screen converges to the buffer once this output burst
9539
+ // settles (see _scheduleSettleRefresh for the full rationale).
9540
+ this._scheduleSettleRefresh(session);
9541
+ }
9542
+
9543
+ // Full-viewport repaint shortly after an output burst settles.
9544
+ //
9545
+ // Under heavy output floods (TUI streaming + per-line scrollback trims
9546
+ // while throttled + 32KB/frame capped writes) the WebGL renderer can
9547
+ // miss dirty-row updates: some rows keep showing STALE content (old
9548
+ // backgrounds / leftover fragments) even though the terminal BUFFER is
9549
+ // correct. Line-diff TUI renderers (OpenCode, Bubble Tea apps, ...)
9550
+ // never rewrite lines they consider unchanged, so those stale rows then
9551
+ // persist indefinitely — visible as "interlaced black lines between
9552
+ // text lines" where the app's painted background alternates with the
9553
+ // terminal's default background. A font-size change or window resize
9554
+ // "fixed" it because both force a full re-render from the buffer.
9555
+ //
9556
+ // This debounced refresh(0, rows-1) after the LAST write of a burst
9557
+ // provides that same guarantee automatically: within ~350ms of any
9558
+ // burst ending, every row is re-rendered from the (correct) buffer.
9559
+ // Cost: one extra full-viewport render per burst — negligible.
9560
+ _scheduleSettleRefresh(session) {
9561
+ if (!session || !session.terminal) return;
9562
+ if (session.settleRefreshTimer) {
9563
+ clearTimeout(session.settleRefreshTimer);
9564
+ }
9565
+ session.settleRefreshTimer = setTimeout(() => {
9566
+ session.settleRefreshTimer = null;
9567
+ const term = session.terminal;
9568
+ if (!term) return;
9569
+ try { term.refresh(0, term.rows - 1); } catch (_) {}
9570
+ }, 350);
9500
9571
  }
9501
9572
 
9502
9573
  // SFTP Session Management
@@ -10096,6 +10167,17 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
10096
10167
  // Tab Management
10097
10168
 
10098
10169
  startTabFlash(sessionId, options = {}) {
10170
+ // Don't flash a terminal the user is already looking at: its wrapper is
10171
+ // visible (active in some panel) AND this browser window is focused and
10172
+ // visible. Each client decides locally, so a background device still
10173
+ // flashes while the one you're staring at stays quiet.
10174
+ const wrapper = document.getElementById(`terminal-wrapper-${sessionId}`);
10175
+ if (wrapper && wrapper.classList.contains('active') &&
10176
+ document.hasFocus() && !document.hidden) {
10177
+ console.log('[SSHIFT] Suppressing tab flash for visible+focused session:', sessionId);
10178
+ return;
10179
+ }
10180
+
10099
10181
  const flashingSessions = this._flashingSessions || (this._flashingSessions = new Set());
10100
10182
  flashingSessions.add(sessionId);
10101
10183
 
@@ -10399,6 +10481,11 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
10399
10481
  clearTimeout(session.scrollbackRestoreTimer);
10400
10482
  session.scrollbackRestoreTimer = null;
10401
10483
  }
10484
+ // Clean up settle-refresh timer
10485
+ if (session.settleRefreshTimer) {
10486
+ clearTimeout(session.settleRefreshTimer);
10487
+ session.settleRefreshTimer = null;
10488
+ }
10402
10489
  // Restore scrollback if it was dynamically reduced
10403
10490
  if (session.originalScrollback && session.terminal) {
10404
10491
  session.terminal.options.scrollback = session.originalScrollback;
@@ -10498,6 +10585,7 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
10498
10585
  this.socket.emit('ssh-disconnect', { sessionId });
10499
10586
  if (session.writeRAF) cancelAnimationFrame(session.writeRAF);
10500
10587
  if (session.scrollbackRestoreTimer) clearTimeout(session.scrollbackRestoreTimer);
10588
+ if (session.settleRefreshTimer) clearTimeout(session.settleRefreshTimer);
10501
10589
  if (session.originalScrollback && session.terminal) {
10502
10590
  session.terminal.options.scrollback = session.originalScrollback;
10503
10591
  }