@lethevimlet/sshift 1.9.4 → 1.9.5
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
|
@@ -274,7 +274,7 @@ See [Configuration > Plugins](docs/configuration.md#plugins) for full details.
|
|
|
274
274
|
### Remote Control (local assistants)
|
|
275
275
|
|
|
276
276
|
The opt-in `remote-control` plugin exposes a **loopback-only, token-protected** HTTP API so a
|
|
277
|
-
local assistant (for example a voice assistant's MCP server) can list and
|
|
277
|
+
local assistant (for example a voice assistant's MCP server) can list, switch and rename tabs, open
|
|
278
278
|
bookmarks, read a terminal's screen as plain text, type text and press keys. Typing never
|
|
279
279
|
presses Enter; submitting is always a separate, explicit key request.
|
|
280
280
|
|
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* GET /v1/bookmarks → { bookmarks: [{ id, name, type, folder }] }
|
|
26
26
|
* GET /v1/screen?sessionId=&history=N
|
|
27
27
|
* POST /v1/switch { sessionId }
|
|
28
|
+
* POST /v1/rename { sessionId, name } → renames the tab on every browser
|
|
28
29
|
* POST /v1/open { bookmarkId } → opens it on ONE connected browser
|
|
29
30
|
* POST /v1/type { sessionId?, text }
|
|
30
31
|
* POST /v1/key { sessionId?, key, repeat? }
|
|
@@ -160,6 +161,7 @@ class RemoteControlPlugin {
|
|
|
160
161
|
case 'GET /v1/bookmarks': return send(200, { bookmarks: this.ctx.getBookmarks() });
|
|
161
162
|
case 'GET /v1/screen': return send(200, this.screen(url.searchParams.get('sessionId'), url.searchParams.get('history')));
|
|
162
163
|
case 'POST /v1/switch': return send(200, this.switchTab(body.sessionId));
|
|
164
|
+
case 'POST /v1/rename': return send(200, this.renameTab(body.sessionId, body.name));
|
|
163
165
|
case 'POST /v1/open': return send(200, await this.open(body.bookmarkId));
|
|
164
166
|
case 'POST /v1/type': return send(200, await this.type(body.sessionId, body.text));
|
|
165
167
|
case 'POST /v1/key': return send(200, await this.key(body.sessionId, body.key, body.repeat));
|
|
@@ -234,6 +236,14 @@ class RemoteControlPlugin {
|
|
|
234
236
|
return { switched: true, sessionId, name: tab?.name || null };
|
|
235
237
|
}
|
|
236
238
|
|
|
239
|
+
renameTab(sessionId, name) {
|
|
240
|
+
if (typeof sessionId !== 'string' || !sessionId) throw new HttpError(400, 'sessionId required');
|
|
241
|
+
const clean = typeof name === 'string' ? name.trim().replace(/\s+/g, ' ') : '';
|
|
242
|
+
if (!clean || clean.length > 40 || /[\x00-\x1f\x7f-\x9f]/.test(clean)) throw new HttpError(400, 'name must be 1-40 printable characters');
|
|
243
|
+
if (typeof this.ctx.renameTab !== 'function' || !this.ctx.renameTab(sessionId, clean)) throw new HttpError(404, 'Tab not found');
|
|
244
|
+
return { renamed: true, sessionId, name: clean };
|
|
245
|
+
}
|
|
246
|
+
|
|
237
247
|
async open(bookmarkId) {
|
|
238
248
|
const bookmark = this.ctx.getBookmarks().find(b => b.id === bookmarkId);
|
|
239
249
|
if (!bookmark) throw new HttpError(404, 'Bookmark not found');
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
* - ctx.getTerminalText(sessionId, options) - Plain-text screen (+ history) and input modes
|
|
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
|
+
* - ctx.renameTab(sessionId, name) - Rename a tab on the server and every client
|
|
29
30
|
* - ctx.getBookmarks() - Bookmark names/types (never credentials)
|
|
30
31
|
* - ctx.requestClientAction(event, data, opts) - Ask exactly ONE connected client to act
|
|
31
32
|
* - ctx.getDataDir() - User data directory (private plugin state)
|
|
@@ -300,6 +301,14 @@ class PluginManager {
|
|
|
300
301
|
return true;
|
|
301
302
|
},
|
|
302
303
|
|
|
304
|
+
renameTab(sessionId, name) {
|
|
305
|
+
const tm = self.tabManager;
|
|
306
|
+
if (!tm || !tm.getTab(sessionId)) return false;
|
|
307
|
+
tm.updateTabName(sessionId, name);
|
|
308
|
+
if (self.io) self.io.emit('tab-renamed', { sessionId, name });
|
|
309
|
+
return true;
|
|
310
|
+
},
|
|
311
|
+
|
|
303
312
|
getBookmarks() {
|
|
304
313
|
const { loadConfig } = require('../utils/config');
|
|
305
314
|
const config = loadConfig();
|
package/src/webapp/js/app.js
CHANGED
|
@@ -4873,7 +4873,7 @@ const wheelHandler = (e) => {
|
|
|
4873
4873
|
if (tab) {
|
|
4874
4874
|
const nameSpan = tab.querySelector('.tab-name');
|
|
4875
4875
|
if (nameSpan) {
|
|
4876
|
-
nameSpan.textContent =
|
|
4876
|
+
nameSpan.textContent = data.name; // textContent is already safe; escaping here showed "&"
|
|
4877
4877
|
}
|
|
4878
4878
|
}
|
|
4879
4879
|
|