remote-cli-agent 0.7.0 → 0.7.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/dist/index.js +4 -1
- package/dist/terminal.d.ts +1 -0
- package/dist/terminal.js +20 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { connect, disconnect, notifySessionsUpdate } from './connection.js';
|
|
4
|
-
import { listTmuxSessions, attachTmuxSession, createTmuxSession, spawnSession, cleanupAll, getSessionList } from './terminal.js';
|
|
4
|
+
import { listTmuxSessions, attachTmuxSession, createTmuxSession, spawnSession, cleanupAll, getSessionList, removeSessionsByTmux } from './terminal.js';
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import os from 'os';
|
|
@@ -117,7 +117,10 @@ program
|
|
|
117
117
|
}
|
|
118
118
|
for (const name of knownTmux) {
|
|
119
119
|
if (!current.includes(name)) {
|
|
120
|
+
console.log(`Tmux session gone: ${name}`);
|
|
121
|
+
removeSessionsByTmux(name);
|
|
120
122
|
knownTmux.delete(name);
|
|
123
|
+
changed = true;
|
|
121
124
|
}
|
|
122
125
|
}
|
|
123
126
|
if (changed) {
|
package/dist/terminal.d.ts
CHANGED
|
@@ -19,4 +19,5 @@ export declare function spawnSession(command?: string): TerminalSession;
|
|
|
19
19
|
export declare function writeToSession(sessionId: string, data: string): boolean;
|
|
20
20
|
export declare function resizeSession(sessionId: string, cols: number, rows: number): boolean;
|
|
21
21
|
export declare function attachSession(sessionId: string): boolean;
|
|
22
|
+
export declare function removeSessionsByTmux(tmuxName: string): boolean;
|
|
22
23
|
export declare function cleanupAll(): void;
|
package/dist/terminal.js
CHANGED
|
@@ -207,6 +207,26 @@ export function resizeSession(sessionId, cols, rows) {
|
|
|
207
207
|
export function attachSession(sessionId) {
|
|
208
208
|
return sessions.has(sessionId);
|
|
209
209
|
}
|
|
210
|
+
// Remove sessions attached to a specific tmux session
|
|
211
|
+
export function removeSessionsByTmux(tmuxName) {
|
|
212
|
+
let removed = false;
|
|
213
|
+
for (const [id, session] of sessions.entries()) {
|
|
214
|
+
if (session.tmuxSession === tmuxName) {
|
|
215
|
+
if (session.pty) {
|
|
216
|
+
try {
|
|
217
|
+
session.pty.kill();
|
|
218
|
+
}
|
|
219
|
+
catch { }
|
|
220
|
+
}
|
|
221
|
+
sessions.delete(id);
|
|
222
|
+
removed = true;
|
|
223
|
+
console.log(`Removed stale session "${session.name}" (${id})`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (removed)
|
|
227
|
+
onSessionsChange?.();
|
|
228
|
+
return removed;
|
|
229
|
+
}
|
|
210
230
|
// Cleanup all sessions
|
|
211
231
|
export function cleanupAll() {
|
|
212
232
|
for (const session of sessions.values()) {
|