fix: skip auto-open memory palace in tmux on macOS (#1069)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Kevin Lin
2026-02-20 15:53:05 -08:00
committed by GitHub
parent 4f8690f98d
commit 6b085ba791
2 changed files with 19 additions and 10 deletions

View File

@@ -113,7 +113,13 @@ export function MemfsTreeViewer({
if ((input === "o" || input === "O") && hasGitRepo) {
showStatus("Opening in browser...", 10000);
generateAndOpenMemoryViewer(agentId, { agentName })
.then(() => showStatus("Opened in browser", 3000))
.then((result) => {
if (result.opened) {
showStatus("Opened in browser", 3000);
} else {
showStatus(`Run: open ${result.filePath}`, 15000);
}
})
.catch((err: unknown) =>
showStatus(
err instanceof Error ? err.message : "Failed to open viewer",

View File

@@ -38,6 +38,7 @@ const RECORD_SEP = "\x1e";
export interface GenerateResult {
filePath: string;
opened: boolean;
}
// ---------------------------------------------------------------------------
@@ -444,15 +445,17 @@ export async function generateAndOpenMemoryViewer(
writeFileSync(filePath, html);
chmodSync(filePath, 0o600);
// 4. Open in browser
try {
const { default: openUrl } = await import("open");
await openUrl(filePath, { wait: false });
} catch (err) {
throw new Error(
`Failed to open browser. File saved to: ${filePath}${err instanceof Error ? ` (${err.message})` : ""}`,
);
// 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) {
try {
const { default: openUrl } = await import("open");
await openUrl(filePath, { wait: false });
} catch {
throw new Error(`Could not open browser. Run: open ${filePath}`);
}
}
return { filePath };
return { filePath, opened: !isTmux };
}