@lethevimlet/sshift 0.9.0 → 0.9.1

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/README.md CHANGED
@@ -12,8 +12,12 @@ A modern, responsive web-based SSH and SFTP terminal client built with Node.js,
12
12
  ## 📸 Screenshots
13
13
 
14
14
  <div align="center">
15
- <img src="media/screenshot1.png" alt="SSH Terminal" width="45%">
16
- <img src="media/screenshot2.png" alt="SFTP Browser" width="45%">
15
+ <img src="media/desktop_light.png" alt="SSHIFT Desktop (Light)" width="45%">
16
+ <img src="media/desktop_dark.png" alt="SSHIFT Desktop (Dark)" width="45%">
17
+ </div>
18
+ <br>
19
+ <div align="center">
20
+ <img src="media/mobile.png" alt="SSHIFT Mobile" width="30%">
17
21
  </div>
18
22
 
19
23
  ## ✨ Features
@@ -109,12 +113,33 @@ npm start
109
113
 
110
114
  ## ⚙️ Configuration
111
115
 
112
- SSHIFT uses a priority-based configuration system:
116
+ SSHIFT uses a priority-based configuration system. Config files are searched in order; the first match wins.
117
+
118
+ ### Config File Search (first match wins)
119
+
120
+ | Priority | Path | Notes |
121
+ |----------|------|-------|
122
+ | 1 | `~/.local/share/sshift/.env/config.json` | Primary user install location |
123
+ | 2 | `~/.local/share/bin/.env/config.json` | Alternative install location |
124
+ | 3 | `~/.local/share/sshift/config.json` | User install (no `.env` subdir) |
125
+ | 4 | `~/.local/share/bin/config.json` | Alternative location (no `.env` subdir) |
126
+ | 5 | `<PACKAGE_DIR>/.env/config.json` | NPM package directory |
127
+ | 6 | `<PACKAGE_DIR>/config.json` | NPM package root (fallback) |
128
+
129
+ ### Port Priority
130
+
131
+ 1. `--port` CLI argument (highest priority)
132
+ 2. `PORT` environment variable
133
+ 3. `config.json` `devPort` (when `NODE_ENV=development` or `--dev`)
134
+ 4. `config.json` `port` (production)
135
+ 5. Default: 8022 (production), 3000 (development)
136
+
137
+ ### Bind Address Priority
113
138
 
114
- 1. Environment variables (`PORT`, `BIND`)
115
- 2. `.env/.env.local` - User-specific private config
116
- 3. `.env/config.json` - User-specific application config
117
- 4. `config.json` - Default application config
139
+ 1. `--bind` CLI argument
140
+ 2. `BIND` environment variable
141
+ 3. `config.json` `bind` setting
142
+ 4. Default: `0.0.0.0`
118
143
 
119
144
  See [Configuration](docs/configuration.md) for details.
120
145
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lethevimlet/sshift",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
5
  "main": "src/server/index.js",
6
6
  "bin": {
@@ -3434,39 +3434,70 @@ class SSHIFTClient {
3434
3434
  session.isController = data.controllerSocket === this.socket.id;
3435
3435
  session.controllerSocket = data.controllerSocket;
3436
3436
 
3437
+ if (session.isController && !wasController) {
3438
+ // We just became the controller — hide overlay immediately
3439
+ // to avoid measuring stale dimensions, then resize after layout settles
3440
+ const overlay = document.getElementById(`control-overlay-${data.sessionId}`);
3441
+ if (overlay) overlay.style.display = 'none';
3442
+ }
3443
+
3437
3444
  this.updateControlOverlay(data.sessionId);
3438
3445
 
3439
3446
  if (session.isController && !wasController) {
3440
- // We just became the controller — resize to our container
3447
+ // Resize to our container after browser finishes layout
3441
3448
  if (session.terminal && session.fitAddon) {
3442
- session.isResyncing = true;
3443
3449
  if (session.resizeTimeout) {
3444
3450
  clearTimeout(session.resizeTimeout);
3445
3451
  session.resizeTimeout = null;
3446
3452
  }
3447
- this._fitTerminal(session);
3448
- session.isResyncing = false;
3449
- this.socket.emit('ssh-resize', {
3450
- sessionId: data.sessionId,
3451
- cols: session.terminal.cols,
3452
- rows: session.terminal.rows
3453
- });
3454
- console.log('[SSHIFT] Resized terminal after becoming controller:', session.terminal.cols, 'x', session.terminal.rows);
3455
3453
 
3456
- // Delayed refit to handle viewport transitions (e.g. mobile -> desktop)
3457
- setTimeout(() => {
3458
- if (session.terminal && session.fitAddon && session.isController) {
3459
- session.isResyncing = true;
3460
- this._fitTerminal(session);
3461
- session.isResyncing = false;
3462
- this.socket.emit('ssh-resize', {
3463
- sessionId: data.sessionId,
3464
- cols: session.terminal.cols,
3465
- rows: session.terminal.rows
3466
- });
3467
- console.log('[SSHIFT] Delayed refit after becoming controller:', session.terminal.cols, 'x', session.terminal.rows);
3468
- }
3469
- }, 300);
3454
+ requestAnimationFrame(() => {
3455
+ requestAnimationFrame(() => {
3456
+ if (!session.terminal || !session.fitAddon || !session.isController) return;
3457
+ try {
3458
+ session.isResyncing = true;
3459
+ this._fitTerminal(session);
3460
+ session.isResyncing = false;
3461
+
3462
+ if (session.terminal && session.connected) {
3463
+ this.socket.emit('ssh-resize', {
3464
+ sessionId: data.sessionId,
3465
+ cols: session.terminal.cols,
3466
+ rows: session.terminal.rows
3467
+ });
3468
+ console.log('[SSHIFT] Resized terminal after becoming controller:', session.terminal.cols, 'x', session.terminal.rows);
3469
+ }
3470
+
3471
+ setTimeout(() => {
3472
+ if (session.terminal && session.fitAddon && session.isController) {
3473
+ session.isResyncing = true;
3474
+ const prevCols = session.terminal.cols;
3475
+ const prevRows = session.terminal.rows;
3476
+ this._fitTerminal(session);
3477
+ session.isResyncing = false;
3478
+ if (session.terminal.cols !== prevCols || session.terminal.rows !== prevRows) {
3479
+ this.socket.emit('ssh-resize', {
3480
+ sessionId: data.sessionId,
3481
+ cols: session.terminal.cols,
3482
+ rows: session.terminal.rows
3483
+ });
3484
+ console.log('[SSHIFT] Corrected dimensions after becoming controller:', session.terminal.cols, 'x', session.terminal.rows);
3485
+ }
3486
+ }
3487
+ }, 300);
3488
+
3489
+ setTimeout(() => {
3490
+ if (session.terminal && session.connected && session.isController) {
3491
+ console.log('[SSHIFT] Requesting screen sync after becoming controller to redraw at local dimensions');
3492
+ this.requestScreenSync(data.sessionId);
3493
+ }
3494
+ }, 500);
3495
+ } catch (e) {
3496
+ console.warn('[SSHIFT] Error resizing terminal after becoming controller:', e.message);
3497
+ session.isResyncing = false;
3498
+ }
3499
+ });
3500
+ });
3470
3501
  }
3471
3502
  this.showToast('You are now in control (previous controller left)', 'info');
3472
3503
  } else if (!session.isController) {
@@ -3494,57 +3525,71 @@ class SSHIFTClient {
3494
3525
  if (session) {
3495
3526
  session.isController = true;
3496
3527
  session.controllerSocket = this.socket.id;
3528
+
3529
+ // Immediately hide the overlay so the terminal container can recalculate
3530
+ // its dimensions before we fit. Skip the 50ms debounce in updateControlOverlay
3531
+ // to avoid measuring stale dimensions.
3532
+ const overlay = document.getElementById(`control-overlay-${data.sessionId}`);
3533
+ if (overlay) overlay.style.display = 'none';
3497
3534
  this.updateControlOverlay(data.sessionId);
3498
3535
 
3499
3536
  // Resize the SSH terminal to match our local terminal dimensions
3500
- // This ensures the terminal displays correctly for the new controller
3537
+ // Use double requestAnimationFrame to ensure the browser has finished
3538
+ // layout after hiding the overlay (same pattern as tab switching).
3501
3539
  if (session.terminal && session.fitAddon) {
3502
- try {
3503
- // Set resyncing flag to prevent onResize from emitting duplicate resize event
3504
- // fit() triggers onResize, but we want to control when the resize is sent
3505
- session.isResyncing = true;
3506
-
3507
- // Clear any pending resize timeout to prevent duplicate resize events
3508
- if (session.resizeTimeout) {
3509
- clearTimeout(session.resizeTimeout);
3510
- session.resizeTimeout = null;
3511
- }
3512
-
3513
- // Fit the terminal to our container first
3514
- session.isResyncing = true;
3515
- this._fitTerminal(session);
3516
-
3517
- // Clear the resyncing flag before emitting resize
3518
- session.isResyncing = false;
3519
-
3520
- // Now emit the resize event to update the SSH terminal and other clients
3521
- this.socket.emit('ssh-resize', {
3522
- sessionId: data.sessionId,
3523
- cols: session.terminal.cols,
3524
- rows: session.terminal.rows
3525
- });
3526
-
3527
- console.log('[SSHIFT] Resized SSH terminal after taking control:', session.terminal.cols, 'x', session.terminal.rows);
3528
-
3529
- // Delayed refit to handle viewport transitions (e.g. mobile -> desktop)
3530
- // The container dimensions may not be final when fit first runs
3531
- setTimeout(() => {
3532
- if (session.terminal && session.fitAddon && session.isController) {
3540
+ // Clear any pending resize timeout to prevent duplicate resize events
3541
+ if (session.resizeTimeout) {
3542
+ clearTimeout(session.resizeTimeout);
3543
+ session.resizeTimeout = null;
3544
+ }
3545
+
3546
+ requestAnimationFrame(() => {
3547
+ requestAnimationFrame(() => {
3548
+ if (!session.terminal || !session.fitAddon || !session.isController) return;
3549
+ try {
3533
3550
  session.isResyncing = true;
3534
3551
  this._fitTerminal(session);
3535
3552
  session.isResyncing = false;
3536
- this.socket.emit('ssh-resize', {
3537
- sessionId: data.sessionId,
3538
- cols: session.terminal.cols,
3539
- rows: session.terminal.rows
3540
- });
3541
- console.log('[SSHIFT] Delayed refit after take control:', session.terminal.cols, 'x', session.terminal.rows);
3553
+
3554
+ if (session.terminal && session.connected) {
3555
+ this.socket.emit('ssh-resize', {
3556
+ sessionId: data.sessionId,
3557
+ cols: session.terminal.cols,
3558
+ rows: session.terminal.rows
3559
+ });
3560
+ console.log('[SSHIFT] Resized SSH terminal after taking control:', session.terminal.cols, 'x', session.terminal.rows);
3561
+ }
3562
+
3563
+ setTimeout(() => {
3564
+ if (session.terminal && session.fitAddon && session.isController) {
3565
+ session.isResyncing = true;
3566
+ const prevCols = session.terminal.cols;
3567
+ const prevRows = session.terminal.rows;
3568
+ this._fitTerminal(session);
3569
+ session.isResyncing = false;
3570
+ if (session.terminal.cols !== prevCols || session.terminal.rows !== prevRows) {
3571
+ this.socket.emit('ssh-resize', {
3572
+ sessionId: data.sessionId,
3573
+ cols: session.terminal.cols,
3574
+ rows: session.terminal.rows
3575
+ });
3576
+ console.log('[SSHIFT] Corrected dimensions after take control:', session.terminal.cols, 'x', session.terminal.rows);
3577
+ }
3578
+ }
3579
+ }, 300);
3580
+
3581
+ setTimeout(() => {
3582
+ if (session.terminal && session.connected && session.isController) {
3583
+ console.log('[SSHIFT] Requesting screen sync after taking control to redraw at local dimensions');
3584
+ this.requestScreenSync(data.sessionId);
3585
+ }
3586
+ }, 500);
3587
+ } catch (e) {
3588
+ console.warn('[SSHIFT] Error resizing terminal after taking control:', e.message);
3589
+ session.isResyncing = false;
3542
3590
  }
3543
- }, 300);
3544
- } catch (e) {
3545
- console.warn('[SSHIFT] Error resizing terminal after taking control:', e.message);
3546
- session.isResyncing = false;
3547
- }
3591
+ });
3592
+ });
3548
3593
  }
3549
3594
 
3550
3595
  this.showToast('You are now in control', 'success');