@lethevimlet/sshift 1.7.5 → 1.7.7

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.5",
3
+ "version": "1.7.7",
4
4
  "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
5
  "main": "src/server/index.js",
6
6
  "bin": {
@@ -1,7 +1,11 @@
1
1
  /**
2
2
  * Layout management WebSocket handlers
3
+ *
4
+ * The layout-change broadcast handler was removed: the preferred layout
5
+ * is a per-device preference stored in each browser's localStorage (it
6
+ * survives server restarts and can differ between devices). Only the
7
+ * per-tab panel ASSIGNMENTS are still synced (see tabs.js tabs-save).
3
8
  */
4
-
5
9
  let currentLayout = 'default';
6
10
 
7
11
  /**
@@ -26,14 +30,7 @@ function setCurrentLayout(layoutId) {
26
30
  * @param {Object} io - Socket.IO instance
27
31
  */
28
32
  function registerLayoutHandlers(socket, io) {
29
- // Layout change - sync across all sessions
30
- socket.on('layout-change', (data) => {
31
- console.log('[LAYOUT] Layout change:', data.layoutId);
32
- currentLayout = data.layoutId;
33
-
34
- // Broadcast to all other clients
35
- socket.broadcast.emit('layout-changed', { layoutId: data.layoutId });
36
- });
33
+ // No handlers: layout preference is per-device (client localStorage).
37
34
  }
38
35
 
39
36
  module.exports = {
@@ -15,11 +15,7 @@ const {
15
15
  updateTabName,
16
16
  updateTabPanel,
17
17
  setActiveTab,
18
- getOpenTabs,
19
- getCurrentTheme,
20
- setCurrentTheme,
21
- getCurrentAccent,
22
- setCurrentAccent
18
+ getOpenTabs
23
19
  } = require('../../utils/tab-manager');
24
20
  const { sshManager, sftpManager } = require('../../services');
25
21
 
@@ -169,31 +165,9 @@ function registerTabHandlers(socket, io) {
169
165
  });
170
166
  });
171
167
 
172
- // Theme change - sync across all clients
173
- socket.on('theme-change', (data) => {
174
- console.log('[TAB] Theme change:', data.theme);
175
-
176
- // Update server-side theme
177
- setCurrentTheme(data.theme);
178
-
179
- // Broadcast to all other clients
180
- socket.broadcast.emit('theme-changed', {
181
- theme: data.theme
182
- });
183
- });
184
-
185
- // Accent change - sync across all clients
186
- socket.on('accent-change', (data) => {
187
- console.log('[TAB] Accent change:', data.accent);
188
-
189
- // Update server-side accent
190
- setCurrentAccent(data.accent);
191
-
192
- // Broadcast to all other clients
193
- socket.broadcast.emit('accent-changed', {
194
- accent: data.accent
195
- });
196
- });
168
+ // theme-change / accent-change handlers removed: theme and accent are
169
+ // per-device preferences kept in each browser's localStorage and are
170
+ // no longer synced through the server.
197
171
  }
198
172
 
199
173
  /**
@@ -25,7 +25,7 @@ const selfsigned = require('selfsigned');
25
25
  const httpolyglot = require('httpolyglot');
26
26
 
27
27
  // Import utilities
28
- const { ensureConfig, loadConfig, getPort, getBindAddress, getEnableHttps, getHttpRedirect, getCertPath, getKeyPath, getDataDir, getLegacyDataDir, isPasswordSet, USER_INSTALL_DIR } = require('./utils/config');
28
+ const { ensureConfig, loadConfig, getPort, getBindAddress, getEnableHttps, getHttpRedirect, getCertPath, getKeyPath, getDataDir, getLegacyDataDir, isPasswordSet, USER_INSTALL_DIR, migrateLegacyPackageConfig } = require('./utils/config');
29
29
 
30
30
  // Import services
31
31
  const { sshManager, sftpManager } = require('./services');
@@ -214,6 +214,11 @@ let actuallyHttps = false;
214
214
 
215
215
  // Async initialization function
216
216
  async function initializeServer() {
217
+ // Rescue legacy package-directory configs BEFORE anything else: they
218
+ // are destroyed by the next `npm install -g` (GUI update). Must run
219
+ // before ensureConfig(), which would otherwise consider the package-
220
+ // dir config "existing" and skip creating the durable user-space one.
221
+ migrateLegacyPackageConfig();
217
222
  ensureConfig();
218
223
 
219
224
  if (enableHttps) {
@@ -385,15 +390,16 @@ async function initializeServer() {
385
390
  io.on('connection', (socket) => {
386
391
  console.log('Client connected:', socket.id);
387
392
 
388
- // Send current open tabs to new client
389
- const { getOpenTabs, getTabOrder, getCurrentTheme, getCurrentAccent, getActiveTabsByPanel } = require('./utils/tab-manager');
390
- const { getCurrentLayout } = require('./endpoints/ws/layout');
393
+ // Send current open tabs to new client.
394
+ // NOTE: theme, accent and layout are deliberately NOT included —
395
+ // they are per-device preferences stored in each browser's
396
+ // localStorage (they survive server restarts and can differ per
397
+ // device). Broadcasting them here used to clobber every new client's
398
+ // own preference with the server's in-memory copy.
399
+ const { getOpenTabs, getTabOrder, getActiveTabsByPanel } = require('./utils/tab-manager');
391
400
 
392
401
  const openTabs = getOpenTabs();
393
402
  const tabOrder = getTabOrder();
394
- const currentLayout = getCurrentLayout();
395
- const currentTheme = getCurrentTheme();
396
- const currentAccent = getCurrentAccent();
397
403
  const activeTabsByPanelMap = getActiveTabsByPanel();
398
404
  const activeTabsByPanel = Object.fromEntries(activeTabsByPanelMap);
399
405
 
@@ -438,10 +444,7 @@ async function initializeServer() {
438
444
 
439
445
  socket.emit('open-tabs', {
440
446
  tabs: orderedTabs,
441
- layout: currentLayout,
442
- activeTabsByPanel,
443
- theme: currentTheme,
444
- accent: currentAccent
447
+ activeTabsByPanel
445
448
  });
446
449
 
447
450
  // Sync flash state for tabs that need attention
@@ -11,8 +11,16 @@ const crypto = require('crypto');
11
11
  // Get user's home directory
12
12
  const HOME_DIR = os.homedir();
13
13
 
14
- // User install directory for config
15
- const USER_INSTALL_DIR = path.join(HOME_DIR, '.local', 'share', 'sshift');
14
+ // User install directory for config. SSHIFT_DATA_DIR overrides it — used
15
+ // by the Docker image to point the app at a mounted volume so that
16
+ // config.json (bookmarks, folders, settings) and the self-signed
17
+ // certificates survive container recreation on image updates. Without
18
+ // it, a Docker install writes to $HOME/.local/share/sshift inside the
19
+ // container's ephemeral writable layer and loses everything whenever the
20
+ // container is recreated (docker compose pull && up -d).
21
+ const USER_INSTALL_DIR = process.env.SSHIFT_DATA_DIR
22
+ ? path.resolve(process.env.SSHIFT_DATA_DIR)
23
+ : path.join(HOME_DIR, '.local', 'share', 'sshift');
16
24
 
17
25
  // Config paths - prioritize package directory, then user install directory
18
26
  const PACKAGE_DIR = path.join(__dirname, '..', '..', '..');
@@ -302,7 +310,55 @@ function getDataDir() {
302
310
  }
303
311
 
304
312
  /**
305
- * Get the legacy data directory (package directory) used before
313
+ * Legacy package-directory config migration.
314
+ *
315
+ * Versions before ~v1.3.x (pre May 2026) created config.json INSIDE the
316
+ * npm package directory (<npm-global>/node_modules/@lethevimlet/sshift/).
317
+ * The search order still prefers those paths, so legacy installs keep
318
+ * working — but they are a time bomb: `npm install -g` (used by the GUI
319
+ * update and manual updates) replaces the package directory wholesale
320
+ * and DESTROYS such configs (verified: bookmarks vanish on update).
321
+ *
322
+ * This copies a legacy package-dir config to the user install directory
323
+ * (which survives npm updates) BEFORE an update can delete it. The
324
+ * package-dir file is left in place (it still wins the search order),
325
+ * but once an update removes it the user-space copy takes over
326
+ * seamlessly with all bookmarks/folders/settings intact.
327
+ *
328
+ * No-op when a user-space config already exists or when no package-dir
329
+ * config is present.
330
+ *
331
+ * @returns {string|null} Path the config was migrated to, or null
332
+ */
333
+ function migrateLegacyPackageConfig() {
334
+ const userConfigPath = path.join(USER_INSTALL_DIR, '.env', 'config.json');
335
+ if (fs.existsSync(userConfigPath)) return null;
336
+
337
+ const legacyPaths = [
338
+ path.join(PACKAGE_DIR, '.env', 'config.json'),
339
+ path.join(PACKAGE_DIR, 'config.json'),
340
+ ];
341
+
342
+ for (const legacyPath of legacyPaths) {
343
+ if (fs.existsSync(legacyPath)) {
344
+ try {
345
+ fs.mkdirSync(path.dirname(userConfigPath), { recursive: true });
346
+ fs.copyFileSync(legacyPath, userConfigPath);
347
+ console.log('[CONFIG] Legacy package-directory config detected — copied to', userConfigPath);
348
+ console.log('[CONFIG] The package-dir copy is left in place; the user-space copy now');
349
+ console.log('[CONFIG] guarantees settings/bookmarks survive the next npm update.');
350
+ return userConfigPath;
351
+ } catch (e) {
352
+ console.warn('[CONFIG] Failed to migrate package-directory config:', e.message);
353
+ return null;
354
+ }
355
+ }
356
+ }
357
+ return null;
358
+ }
359
+
360
+ /**
361
+ * Get legacy data directory (package directory) used before
306
362
  * certs were moved to user space. Used for migration only.
307
363
  * @returns {string|null} Path to legacy data directory, or null if N/A
308
364
  */
@@ -476,6 +532,7 @@ module.exports = {
476
532
  getConfigPath,
477
533
  loadConfig,
478
534
  saveConfig,
535
+ migrateLegacyPackageConfig,
479
536
  getPort,
480
537
  getBindAddress,
481
538
  getSSHKeepaliveSettings,
@@ -18,7 +18,10 @@
18
18
  <link rel="stylesheet" href="/libs/xterm/xterm.css?v=__VERSION__">
19
19
  <link rel="stylesheet" href="/libs/font-awesome/css/all.min.css?v=__VERSION__">
20
20
  <link rel="stylesheet" href="/css/style.css?v=__VERSION__">
21
- <script src="/libs/lucide/lucide.min.js?v=__VERSION__"></script>
21
+ <!-- defer: 397KB icon library must not block first paint on slow mobile
22
+ connections. lucide.createIcons() only runs at DOMContentLoaded
23
+ (app.js), which fires after deferred scripts execute. -->
24
+ <script defer src="/libs/lucide/lucide.min.js?v=__VERSION__"></script>
22
25
  </head>
23
26
  <body>
24
27
  <!-- Lock Screen Overlay (shown by default, hidden by JS if no password) -->