@lethevimlet/sshift 1.9.5 → 1.9.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.9.5",
3
+ "version": "1.9.7",
4
4
  "description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
5
5
  "main": "src/server/index.js",
6
6
  "bin": {
@@ -26,6 +26,7 @@
26
26
  * GET /v1/screen?sessionId=&history=N
27
27
  * POST /v1/switch { sessionId }
28
28
  * POST /v1/rename { sessionId, name } → renames the tab on every browser
29
+ * POST /v1/close { sessionId } → closes the tab (ends its SSH session) everywhere
29
30
  * POST /v1/open { bookmarkId } → opens it on ONE connected browser
30
31
  * POST /v1/type { sessionId?, text }
31
32
  * POST /v1/key { sessionId?, key, repeat? }
@@ -54,6 +55,8 @@ const KEYS = {
54
55
  'ctrl-c': '\x03',
55
56
  'ctrl-d': '\x04',
56
57
  'ctrl-e': '\x05',
58
+ // Newline inside Claude Code / opencode prompt boxes without submitting (Enter submits).
59
+ 'ctrl-j': '\n',
57
60
  'ctrl-k': '\x0b',
58
61
  'ctrl-l': '\x0c',
59
62
  'ctrl-r': '\x12',
@@ -162,6 +165,7 @@ class RemoteControlPlugin {
162
165
  case 'GET /v1/screen': return send(200, this.screen(url.searchParams.get('sessionId'), url.searchParams.get('history')));
163
166
  case 'POST /v1/switch': return send(200, this.switchTab(body.sessionId));
164
167
  case 'POST /v1/rename': return send(200, this.renameTab(body.sessionId, body.name));
168
+ case 'POST /v1/close': return send(200, this.closeTab(body.sessionId));
165
169
  case 'POST /v1/open': return send(200, await this.open(body.bookmarkId));
166
170
  case 'POST /v1/type': return send(200, await this.type(body.sessionId, body.text));
167
171
  case 'POST /v1/key': return send(200, await this.key(body.sessionId, body.key, body.repeat));
@@ -236,6 +240,14 @@ class RemoteControlPlugin {
236
240
  return { switched: true, sessionId, name: tab?.name || null };
237
241
  }
238
242
 
243
+ closeTab(sessionId) {
244
+ if (typeof sessionId !== 'string' || !sessionId) throw new HttpError(400, 'sessionId required');
245
+ const tab = this.ctx.getTabs().tabs.find(t => t.sessionId === sessionId);
246
+ if (!tab) throw new HttpError(404, 'Tab not found');
247
+ if (typeof this.ctx.closeTab !== 'function' || !this.ctx.closeTab(sessionId)) throw new HttpError(404, 'Tab not found');
248
+ return { closed: true, sessionId, name: tab.name, position: tab.position };
249
+ }
250
+
239
251
  renameTab(sessionId, name) {
240
252
  if (typeof sessionId !== 'string' || !sessionId) throw new HttpError(400, 'sessionId required');
241
253
  const clean = typeof name === 'string' ? name.trim().replace(/\s+/g, ' ') : '';
@@ -27,6 +27,7 @@
27
27
  * - ctx.getTabs() - Open tabs in order, with the focused session
28
28
  * - ctx.switchTab(sessionId) - Focus a tab on every connected client
29
29
  * - ctx.renameTab(sessionId, name) - Rename a tab on the server and every client
30
+ * - ctx.closeTab(sessionId) - Close a tab (ends its session) everywhere
30
31
  * - ctx.getBookmarks() - Bookmark names/types (never credentials)
31
32
  * - ctx.requestClientAction(event, data, opts) - Ask exactly ONE connected client to act
32
33
  * - ctx.getDataDir() - User data directory (private plugin state)
@@ -301,6 +302,21 @@ class PluginManager {
301
302
  return true;
302
303
  },
303
304
 
305
+ closeTab(sessionId) {
306
+ // Same as a user closing the tab: end the SSH/SFTP session and remove it everywhere.
307
+ const tm = self.tabManager;
308
+ const tab = tm && tm.getTab(sessionId);
309
+ if (!tab) return false;
310
+ tm.clearCloseTimer(sessionId);
311
+ tm.removeTab(sessionId);
312
+ if (tab.type === 'ssh' && self.sshManager) self.sshManager.disconnect(sessionId);
313
+ if (tab.type === 'sftp') {
314
+ try { require('../services').sftpManager.disconnect(sessionId); } catch (e) { /* ignore */ }
315
+ }
316
+ if (self.io) { self.io.emit('tab-closed', { sessionId }); self.io.emit('sessions-updated'); }
317
+ return true;
318
+ },
319
+
304
320
  renameTab(sessionId, name) {
305
321
  const tm = self.tabManager;
306
322
  if (!tm || !tm.getTab(sessionId)) return false;