@lethevimlet/sshift 1.5.1 → 1.5.2

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.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
5
  "main": "src/server/index.js",
6
6
  "bin": {
@@ -2360,6 +2360,7 @@ body.dragging-tabs .tabs-container {
2360
2360
  pointer-events: auto !important;
2361
2361
  transition: none !important;
2362
2362
  background-color: var(--terminal-scrollbar-track, #151b23) !important;
2363
+ width: 8px !important;
2363
2364
  }
2364
2365
 
2365
2366
  .terminal-container .xterm-scrollable-element > .scrollbar.invisible {
@@ -2378,12 +2379,22 @@ body.dragging-tabs .tabs-container {
2378
2379
  .terminal-container .xterm-scrollable-element > .scrollbar > .slider {
2379
2380
  border-radius: 3px;
2380
2381
  background-color: var(--terminal-scrollbar-thumb, #3d444d) !important;
2382
+ width: 8px !important;
2383
+ min-width: 8px !important;
2384
+ max-width: 8px !important;
2381
2385
  }
2382
2386
 
2383
2387
  .terminal-container .xterm-scrollable-element > .shadow {
2384
2388
  display: none !important;
2385
2389
  }
2386
2390
 
2391
+ /* Hide the overview ruler canvas — it creates a visible white strip
2392
+ when the terminal has no scrollback or on blur. The custom scrollbar
2393
+ already shows scroll position. */
2394
+ .terminal-container .xterm-decoration-overview-ruler {
2395
+ display: none !important;
2396
+ }
2397
+
2387
2398
  /* Hide native viewport scrollbar (xterm v6 uses custom scrollbar) */
2388
2399
  .terminal-container .xterm-viewport::-webkit-scrollbar {
2389
2400
  width: 0;
@@ -3298,6 +3309,37 @@ body.dragging-tabs .tabs-container {
3298
3309
  --header-height: 43px;
3299
3310
  }
3300
3311
 
3312
+ /* Thinner xterm scrollbar on mobile */
3313
+ .terminal-container .xterm-scrollable-element > .scrollbar {
3314
+ width: 4px !important;
3315
+ min-width: 4px !important;
3316
+ max-width: 4px !important;
3317
+ }
3318
+ .terminal-container .xterm-scrollable-element > .scrollbar.vertical {
3319
+ width: 4px !important;
3320
+ min-width: 4px !important;
3321
+ max-width: 4px !important;
3322
+ }
3323
+ .terminal-container .xterm-scrollable-element > .scrollbar > .slider {
3324
+ width: 4px !important;
3325
+ min-width: 4px !important;
3326
+ max-width: 4px !important;
3327
+ border-radius: 2px !important;
3328
+ /* Match the track background so the scrollbar blend in and doesn't
3329
+ look like a white line against the dark terminal background. */
3330
+ background-color: var(--terminal-scrollbar-track, #151b23) !important;
3331
+ }
3332
+ /* Also hide the viewport scrollbar more aggressively on mobile */
3333
+ .terminal-container .xterm-viewport {
3334
+ scrollbar-width: none !important;
3335
+ -ms-overflow-style: none !important;
3336
+ }
3337
+ .terminal-container .xterm-viewport::-webkit-scrollbar {
3338
+ width: 0 !important;
3339
+ height: 0 !important;
3340
+ display: none !important;
3341
+ }
3342
+
3301
3343
  .header {
3302
3344
  padding: 0 6px;
3303
3345
  }
@@ -756,7 +756,7 @@ class SSHIFTClient {
756
756
  // Update active sessions:
757
757
  // 1. Make the moved tab active in the target panel
758
758
  this.switchTab(sessionId, targetPanelId);
759
-
759
+
760
760
  // 2. Activate the first remaining tab in the source panel (if any)
761
761
  if (sourceTabs.length > 0) {
762
762
  const firstRemainingSessionId = sourceTabs[0].dataset.sessionId;
@@ -770,6 +770,38 @@ class SSHIFTClient {
770
770
 
771
771
  // Update server panel map for mobile preservation
772
772
  this._serverPanelMap.set(sessionId, targetPanelId);
773
+
774
+ // After moving the terminal wrapper to a new container, the
775
+ // terminal's internal canvas/renderer dimensions are still tied
776
+ // to the old panel's size. The WebGL atlas has glyphs rasterised
777
+ // for the old cell size. If we fit() immediately the browser
778
+ // hasn't committed the new layout yet, so fit() measures stale
779
+ // dimensions — producing the interlaced/alternating-black-band
780
+ // rendering bug. Fix: double-RAF to let the browser commit the
781
+ // new layout, then fit + clear atlas + force refresh.
782
+ // Also refit ALL terminals (the source panel's remaining tab may
783
+ // have changed container size too).
784
+ const session = this.sessions.get(sessionId);
785
+ if (session && session.terminal && session.fitAddon && session.isController) {
786
+ requestAnimationFrame(() => {
787
+ requestAnimationFrame(() => {
788
+ if (!session.terminal || !session.fitAddon || !session.isController) return;
789
+ // Re-measure char size (font may have loaded differently in
790
+ // the new container) then fit, clear atlas, and refresh.
791
+ const core = session.terminal._core;
792
+ if (core && core._charSizeService && typeof core._charSizeService.measure === 'function') {
793
+ try { core._charSizeService.measure(); } catch (_) {}
794
+ }
795
+ this._fitTerminal(session);
796
+ this._resetWebGLAtlas(session);
797
+ });
798
+ });
799
+ }
800
+
801
+ // Refit ALL visible terminals — the source panel's remaining tab
802
+ // may have a different container width now that the moved tab is
803
+ // gone. Use the existing staggered refit helper.
804
+ this.refitAllTerminals();
773
805
  }
774
806
 
775
807
  // Hide empty state for a specific panel
@@ -2928,20 +2960,59 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
2928
2960
  element.addEventListener('touchmove', (e) => {
2929
2961
  if (e.touches.length === 1 && session.isScrolling) {
2930
2962
  e.preventDefault();
2931
-
2963
+
2932
2964
  const currentTouchY = e.touches[0].clientY;
2933
2965
  const touchDiff = session.lastTouchY - currentTouchY;
2934
2966
  session.lastTouchY = currentTouchY;
2935
2967
  session.touchAccumulator += touchDiff;
2936
-
2968
+
2937
2969
  const lineHeight = terminal._core?._renderService?.dimensions?.css?.cell?.height || 20;
2938
2970
  const lineH = Math.max(lineHeight, 14);
2939
-
2940
- const linesToScroll = Math.trunc(Math.abs(session.touchAccumulator) / lineH);
2941
- if (linesToScroll > 0) {
2942
- const direction = session.touchAccumulator > 0 ? 1 : -1;
2943
- terminal.scrollLines(direction * linesToScroll);
2944
- session.touchAccumulator -= direction * linesToScroll * lineH;
2971
+
2972
+ // When a TUI app has mouse tracking enabled (DECSET
2973
+ // 1000/1002/1003), scrolling should send mouse wheel
2974
+ // escape sequences directly to the PTY. Instead of
2975
+ // dispatching synthetic WheelEvents (which xterm's own
2976
+ // document-level touch handler can interfere with), we
2977
+ // generate the SGR mouse format ourselves and emit it via
2978
+ // ssh-data. SGR format: \x1b[<button;col;row;M
2979
+ // Wheel up = button 64, wheel down = button 65.
2980
+ const mouseProtocol = terminal._core?.coreMouseService?.activeProtocol;
2981
+ const tuiMouseActive = mouseProtocol && mouseProtocol !== 'NONE';
2982
+
2983
+ if (tuiMouseActive) {
2984
+ if (Math.abs(session.touchAccumulator) >= lineH) {
2985
+ // Compute the terminal cell under the touch point.
2986
+ const screenEl = terminal.element?.querySelector('.xterm-screen');
2987
+ if (screenEl) {
2988
+ const rect = screenEl.getBoundingClientRect();
2989
+ const cellW = terminal._core?._renderService?.dimensions?.css?.cell?.width || 8;
2990
+ const cellH = lineHeight;
2991
+ const touchX = e.touches[0].clientX - rect.left;
2992
+ const touchY = e.touches[0].clientY - rect.top;
2993
+ const col = Math.max(1, Math.min(terminal.cols, Math.floor(touchX / cellW) + 1));
2994
+ const row = Math.max(1, Math.min(terminal.rows, Math.floor(touchY / cellH) + 1));
2995
+
2996
+ const scrollLines = Math.trunc(Math.abs(session.touchAccumulator) / lineH);
2997
+ const direction = session.touchAccumulator > 0 ? 1 : -1; // 1 = scroll down, -1 = scroll up
2998
+ for (let i = 0; i < scrollLines; i++) {
2999
+ // button 64 = wheel up, 65 = wheel down
3000
+ const button = direction > 0 ? 65 : 64;
3001
+ const seq = `\x1b[<${button};${col};${row}M`;
3002
+ if (session.connected && session.isController) {
3003
+ this.socket.emit('ssh-data', { sessionId, data: seq });
3004
+ }
3005
+ }
3006
+ session.touchAccumulator = 0;
3007
+ }
3008
+ }
3009
+ } else {
3010
+ const linesToScroll = Math.trunc(Math.abs(session.touchAccumulator) / lineH);
3011
+ if (linesToScroll > 0) {
3012
+ const direction = session.touchAccumulator > 0 ? 1 : -1;
3013
+ terminal.scrollLines(direction * linesToScroll);
3014
+ session.touchAccumulator -= direction * linesToScroll * lineH;
3015
+ }
2945
3016
  }
2946
3017
  } else if (e.touches.length === 2 && session.isPinching) {
2947
3018
  e.preventDefault();
@@ -3026,16 +3097,24 @@ sendChunkedInput(sessionId, data, chunkSize = 2048) {
3026
3097
 
3027
3098
  const wheelHandler = (e) => {
3028
3099
  if (e.deltaY === 0) return;
3029
-
3100
+
3030
3101
  // If the event target is inside the custom scrollbar,
3031
3102
  // let xterm's ScrollableElement handle it to avoid double-scroll
3032
3103
  const target = e.target;
3033
3104
  if (target && target.closest && target.closest('.xterm-scrollable-element')) {
3034
3105
  return;
3035
3106
  }
3036
-
3107
+
3108
+ // When a TUI app has mouse tracking enabled, let xterm's own
3109
+ // wheel handler process the event so it translates to mouse
3110
+ // tracking escape sequences sent to the PTY. Don't intercept.
3111
+ const mouseProtocol = terminal._core?.coreMouseService?.activeProtocol;
3112
+ if (mouseProtocol && mouseProtocol !== 'NONE') {
3113
+ return;
3114
+ }
3115
+
3037
3116
  e.preventDefault();
3038
-
3117
+
3039
3118
  let lines = 1;
3040
3119
  if (e.deltaMode === 1) {
3041
3120
  lines = Math.abs(e.deltaY);
@@ -3045,14 +3124,14 @@ const wheelHandler = (e) => {
3045
3124
  } else {
3046
3125
  lines = Math.abs(e.deltaY) * terminal.rows;
3047
3126
  }
3048
-
3127
+
3049
3128
  const fastScrollModifier = terminal.options.fastScrollModifier;
3050
3129
  if (fastScrollModifier === 'alt' && e.altKey ||
3051
3130
  fastScrollModifier === 'ctrl' && e.ctrlKey ||
3052
3131
  fastScrollModifier === 'shift' && e.shiftKey) {
3053
3132
  lines *= (terminal.options.fastScrollSensitivity || 5);
3054
3133
  }
3055
-
3134
+
3056
3135
  terminal.scrollLines((e.deltaY > 0 ? 1 : -1) * lines);
3057
3136
  };
3058
3137
 
@@ -4474,11 +4553,11 @@ const wheelHandler = (e) => {
4474
4553
  }
4475
4554
  } else if (data.advisory) {
4476
4555
  // Advisory errors (rate-limit, invalid payload, bufferFull, etc.)
4477
- // are non-fatal — warn via toast but DO NOT close the tab. Closing
4478
- // the tab on every rate-limited ssh-request-sync would kill the
4479
- // very session the user was trying to refresh / switch to.
4556
+ // are operational warnings — log them but do NOT show a toast.
4557
+ // Showing toasts for every rate-limited sync or buffer-full event
4558
+ // is extremely annoying during normal usage like scrolling in a
4559
+ // TUI app.
4480
4560
  console.warn('[SSHIFT] Advisory ssh-error (tab kept open):', data.message);
4481
- this.showToast(data.message, 'warning');
4482
4561
  } else {
4483
4562
  this.showToast(data.message, 'error');
4484
4563
  }
@@ -7334,7 +7413,7 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
7334
7413
  fastScrollModifier: 'alt',
7335
7414
  fastScrollSensitivity: 5,
7336
7415
  smoothScrollDuration: 80,
7337
- overviewRuler: { width: 14 },
7416
+ overviewRuler: { width: 0 },
7338
7417
  customGlyphs: true
7339
7418
  });
7340
7419
 
@@ -7843,40 +7922,35 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
7843
7922
  }
7844
7923
  });
7845
7924
 
7846
- // Defensive activation on user interaction.
7925
+ // Defensive activation: clear stuck `isResyncing` on user interaction.
7847
7926
  // Backgrounded / throttled browser tabs can leave `isResyncing` set
7848
7927
  // (setTimeout was deferred by the browser's power saver) which
7849
- // suppresses onResize emits. Some browsers also move focus to the
7850
- // body when the tab is hidden, and xterm's mouse input + IME only
7851
- // fire while the terminal's element / hidden textarea has focus.
7852
- // Result: after a period of inactivity on a TUI app, mouse clicks
7853
- // and scroll stop working until the user refreshes. Fix: on every
7854
- // mouse / touch / wheel interaction with the terminal, re-focus
7855
- // xterm and clear any stuck isResyncing flag so subsequent resize
7856
- // events (and TUI mouse-tracking escape sequences) flow through.
7857
- const activateSession = () => {
7928
+ // suppresses onResize emits. After inactivity on a TUI app, mouse
7929
+ // clicks and scroll can stop working until the user refreshes.
7930
+ // Fix: on mouse/wheel interaction (desktop), clear the flag AND
7931
+ // re-focus the terminal so xterm's mouse-service fires.
7932
+ // On mobile touch, ONLY clear the flag — do NOT re-focus the
7933
+ // hidden textarea because that would pop the on-screen keyboard
7934
+ // on every scroll drag. The mobile handler manages keyboard
7935
+ // visibility separately.
7936
+ const clearResyncing = () => {
7858
7937
  if (!session) return;
7859
7938
  if (session.isResyncing) {
7860
- // setTimeout was probably deferred by background throttling.
7861
- // Releasing here lets the next user-initiated resize flow.
7862
7939
  session.isResyncing = false;
7863
7940
  }
7864
- // Re-focus the terminal so xterm's mouse-service fires. Use
7865
- // requestAnimationFrame to avoid stealing focus mid-click on
7866
- // the active selection.
7941
+ };
7942
+ const activateAndFocus = () => {
7943
+ clearResyncing();
7867
7944
  requestAnimationFrame(() => {
7868
- if (session.terminal) {
7869
- if (this.isMobile && session.mobileHandler && session.mobileHandler.hiddenTextarea) {
7870
- session.mobileHandler._focusHiddenTextarea();
7871
- } else {
7872
- try { session.terminal.focus(); } catch (_) {}
7873
- }
7945
+ if (session.terminal && !this.isMobile) {
7946
+ try { session.terminal.focus(); } catch (_) {}
7874
7947
  }
7875
7948
  });
7876
7949
  };
7877
- container.addEventListener('mousedown', activateSession, true);
7878
- container.addEventListener('touchstart', activateSession, true);
7879
- container.addEventListener('wheel', activateSession, true);
7950
+ container.addEventListener('mousedown', activateAndFocus, true);
7951
+ container.addEventListener('wheel', clearResyncing, true);
7952
+ // On mobile, only clear isResyncing on touchstart — do NOT focus.
7953
+ container.addEventListener('touchstart', clearResyncing, true);
7880
7954
 
7881
7955
  session.terminal = terminal;
7882
7956
  session.fitAddon = fitAddon;
@@ -7932,11 +8006,75 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
7932
8006
  resizeObserver.observe(wrapper);
7933
8007
  session.resizeObserver = resizeObserver;
7934
8008
 
8009
+ // Keep xterm's scrollbar dimensions + slider bg consistent.
8010
+ // xterm sets inline width: 14px and bg: rgb(73,77,83) on the
8011
+ // slider every time it re-renders; a MutationObserver catches
8012
+ // each change and overrides it back.
8013
+ {
8014
+ const targetW = this.isMobile ? '4px' : '8px';
8015
+ const fixScrollbar = () => {
8016
+ const sbs = wrapper.querySelectorAll('.xterm-scrollable-element > .scrollbar.vertical');
8017
+ sbs.forEach(sb => {
8018
+ if (sb.style.width !== targetW) {
8019
+ sb.style.width = targetW;
8020
+ sb.style.minWidth = targetW;
8021
+ sb.style.maxWidth = targetW;
8022
+ }
8023
+ const slider = sb.querySelector('.slider');
8024
+ if (slider) {
8025
+ if (slider.style.width !== targetW) {
8026
+ slider.style.width = targetW;
8027
+ slider.style.minWidth = targetW;
8028
+ slider.style.maxWidth = targetW;
8029
+ }
8030
+ // Override xterm's inline !important bg (lighter shade
8031
+ // that looks like a white line) with a dark thumb color.
8032
+ slider.style.setProperty('background-color', '#3d444d', 'important');
8033
+ }
8034
+ });
8035
+ };
8036
+ requestAnimationFrame(fixScrollbar);
8037
+ const mo = new MutationObserver(fixScrollbar);
8038
+ const scrollableEl = wrapper.querySelector('.xterm-scrollable-element');
8039
+ if (scrollableEl) {
8040
+ mo.observe(scrollableEl, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });
8041
+ }
8042
+ session._scrollbarObserver = mo;
8043
+ }
8044
+
7935
8045
  // Setup mobile scroll behavior after terminal is ready
7936
8046
  // Use requestAnimationFrame to ensure terminal.element is available
7937
8047
  requestAnimationFrame(() => {
7938
8048
  this.setupMobileScrollBehavior(sessionId);
7939
8049
  this.setupWheelScroll(sessionId);
8050
+
8051
+ // Force thinner scrollbar on mobile. xterm v6 sets an inline
8052
+ // width: 14px on the vertical scrollbar AND its slider — override
8053
+ // both via inline style since CSS !important on the slider doesn't
8054
+ // always survive against xterm's re-renders.
8055
+ // On desktop, override the slider bg color which xterm sets inline
8056
+ // to rgb(73,77,83) — a lighter shade that looks like a white line
8057
+ // against the dark terminal background.
8058
+ const targetWidth = this.isMobile ? '4px' : '8px';
8059
+ {
8060
+ const scrollbars = wrapper.querySelectorAll('.xterm-scrollable-element > .scrollbar');
8061
+ scrollbars.forEach(sb => {
8062
+ if (sb.classList.contains('vertical')) {
8063
+ sb.style.width = targetWidth;
8064
+ sb.style.minWidth = targetWidth;
8065
+ sb.style.maxWidth = targetWidth;
8066
+ const slider = sb.querySelector('.slider');
8067
+ if (slider) {
8068
+ slider.style.width = targetWidth;
8069
+ slider.style.minWidth = targetWidth;
8070
+ slider.style.maxWidth = targetWidth;
8071
+ // Override xterm's inline !important bg with a dark shade
8072
+ // that's visible but doesn't look like a white line.
8073
+ slider.style.setProperty('background-color', '#3d444d', 'important');
8074
+ }
8075
+ }
8076
+ });
8077
+ }
7940
8078
  });
7941
8079
 
7942
8080
  console.log('[SSHIFT] Terminal initialized for session:', sessionId);
@@ -9203,6 +9341,11 @@ if (keepaliveCountMaxInput && this.sshKeepaliveCountMax) {
9203
9341
  clearTimeout(session.resizeTimeout);
9204
9342
  session.resizeTimeout = null;
9205
9343
  }
9344
+ // Clean up scrollbar MutationObserver (mobile-only)
9345
+ if (session._scrollbarObserver) {
9346
+ session._scrollbarObserver.disconnect();
9347
+ session._scrollbarObserver = null;
9348
+ }
9206
9349
  // Clean up write buffer RAF
9207
9350
  if (session.writeRAF) {
9208
9351
  cancelAnimationFrame(session.writeRAF);