fix: listSessions filters to @pi-remote-managed sessions only — excludes pi-sidecar and other unrelated tmux sessions

This commit is contained in:
jay 2026-05-16 03:51:27 +02:00
parent 4b428df0a4
commit 2e44a7f286
1 changed files with 25 additions and 0 deletions

View File

@ -82,6 +82,17 @@ export async function spawnSession(opts: {
if (command) args.push(command);
await execFileAsync("tmux", args);
// Mark as sidecar-managed so listSessions() can filter out unrelated
// tmux sessions (e.g. the pi-sidecar launcher session itself).
await execFileAsync("tmux", [
"set-option",
"-t",
name,
"@pi-remote-managed",
"1",
]).catch(() => {});
return name;
}
@ -144,6 +155,20 @@ export async function listSessions(): Promise<TmuxSession[]> {
if (!line) continue;
const [id, createdAt, lastActivityAt, w, h] = line.split(SEP);
// Only include sessions created by the sidecar.
try {
const r = await execFileAsync("tmux", [
"show-options",
"-t",
id,
"-qv",
"@pi-remote-managed",
]);
if (!r.stdout.trim()) continue; // unmanaged session — skip
} catch {
continue; // can't read options → skip
}
// Fetch @description option separately (may not be set)
let description: string | undefined;
try {