fix: skip auto-open viewers in SSH sessions (#1184)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Devansh Jain
2026-02-26 18:34:38 -08:00
committed by GitHub
parent 986cb7dc79
commit 1ed619663a
2 changed files with 15 additions and 9 deletions

View File

@@ -445,10 +445,13 @@ export async function generateAndOpenMemoryViewer(
writeFileSync(filePath, html);
chmodSync(filePath, 0o600);
// 4. Open in browser (skip inside tmux — `open` launches a broken new
// browser instance instead of reusing the running one)
const isTmux = Boolean(process.env.TMUX);
if (!isTmux) {
// 4. Open in browser (skip inside tmux or SSH — `open` either launches a
// broken browser instance or fails entirely on remote machines)
const skipOpen =
Boolean(process.env.TMUX) ||
Boolean(process.env.SSH_CONNECTION) ||
Boolean(process.env.SSH_TTY);
if (!skipOpen) {
try {
const { default: openUrl } = await import("open");
await openUrl(filePath, { wait: false });
@@ -457,5 +460,5 @@ export async function generateAndOpenMemoryViewer(
}
}
return { filePath, opened: !isTmux };
return { filePath, opened: !skipOpen };
}

View File

@@ -50,9 +50,12 @@ export async function generateAndOpenPlanViewer(
writeFileSync(filePath, html);
chmodSync(filePath, 0o600);
// Open in browser (skip inside tmux)
const isTmux = Boolean(process.env.TMUX);
if (!isTmux) {
// Open in browser (skip inside tmux or SSH)
const skipOpen =
Boolean(process.env.TMUX) ||
Boolean(process.env.SSH_CONNECTION) ||
Boolean(process.env.SSH_TTY);
if (!skipOpen) {
try {
const { default: openUrl } = await import("open");
await openUrl(filePath, { wait: false });
@@ -61,5 +64,5 @@ export async function generateAndOpenPlanViewer(
}
}
return { filePath, opened: !isTmux };
return { filePath, opened: !skipOpen };
}