From bc564586d8d6445f903352ff795c31dd95297886 Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 17 Apr 2026 13:17:38 -0700 Subject: [PATCH] loosen up the requirements to show the File Browser in term context menu --- frontend/app/view/term/term-model.ts | 6 +++--- frontend/app/view/term/termutil.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/app/view/term/term-model.ts b/frontend/app/view/term/term-model.ts index 09ccce3e54..a256929e7d 100644 --- a/frontend/app/view/term/term-model.ts +++ b/frontend/app/view/term/term-model.ts @@ -40,7 +40,7 @@ import { boundNumber, fireAndForget, stringToBase64 } from "@/util/util"; import * as jotai from "jotai"; import * as React from "react"; import { getBlockingCommand } from "./shellblocking"; -import { computeTheme, DefaultTermTheme, trimTerminalSelection } from "./termutil"; +import { computeTheme, DefaultTermTheme, isLikelyOnSameHost, trimTerminalSelection } from "./termutil"; import { TermWrap, WebGLSupported } from "./termwrap"; export class TermViewModel implements ViewModel { @@ -958,9 +958,9 @@ export class TermViewModel implements ViewModel { }); fullMenu.push({ type: "separator" }); - const shellIntegrationStatus = globalStore.get(this.termRef?.current?.shellIntegrationStatusAtom); + const lastCommand = globalStore.get(this.termRef?.current?.lastCommandAtom); const cwd = blockData?.meta?.["cmd:cwd"]; - const canShowFileBrowser = shellIntegrationStatus === "ready" && cwd != null; + const canShowFileBrowser = cwd != null && isLikelyOnSameHost(lastCommand); if (canShowFileBrowser) { fullMenu.push({ diff --git a/frontend/app/view/term/termutil.ts b/frontend/app/view/term/termutil.ts index 838b8aaf92..add5e86e05 100644 --- a/frontend/app/view/term/termutil.ts +++ b/frontend/app/view/term/termutil.ts @@ -397,6 +397,14 @@ export function bufferLinesToText(buffer: TermTypes.IBuffer, startIndex: number, return lines; } +export function isLikelyOnSameHost(lastCommand: string): boolean { + if (lastCommand == null) { + return true; + } + const cmd = lastCommand.trimStart(); + return !cmd.startsWith("ssh "); +} + export function quoteForPosixShell(filePath: string): string { return "'" + filePath.replace(/'/g, "'\\''") + "'"; }