fix(web): capability-gate folder reveal

This commit is contained in:
t3-code[bot] committed 2026-08-15 02:51:33 +00:00
1 parent d9e7c7f156
commit 39788e86e9
6 files changed
+71 -12

No files matched your search

@@ -93,6 +93,7 @@ it.layer(NodeServices.layer)("ServerEnvironmentLive", (it) => {
expect(second.capabilities.pullRequests).toBe(true);
expect(second.capabilities.threadTitleRegeneration).toBe(true);
expect(second.capabilities.agentActivityPublishing).toBe(false);
expect(second.capabilities.fileManagerReveal).toBe(true);
}),
);
@@ -152,6 +152,7 @@ export const make = Effect.gen(function* () {
threadPinning: true,
threadPinReorder: true,
threadTitleRegeneration: true,
fileManagerReveal: true,
...(serverSelfUpdate === null ? {} : { serverSelfUpdate }),
...(serverSelfUpdate === "boot-service" ? { serverSelfUpdateProgress: true } : {}),
},
+8 -12
View File
@@ -51,6 +51,7 @@ import {
resolveExternalWebLinkHost,
showExternalLinkContextMenu,
} from "./chat/externalLinkContextMenu";
import { buildFileLinkContextMenuItems } from "./chat/fileLinkContextMenu";
import { hasSpecificPierreIconForFileName, syntheticFileNameForLanguageId } from "../pierre-icons";
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
import { Button } from "./ui/button";
@@ -1268,17 +1269,10 @@ const MarkdownFileLink = memo(function MarkdownFileLink({
try {
const clicked = await api.contextMenu.show(
[
...(canRevealInFileManager
? ([{ id: "open-in-folder", label: "Open in folder" }] as const)
: []),
{ id: "open", label: "Open in editor" },
...(onOpenInBrowser
? ([{ id: "open-in-browser", label: "Open in integrated browser" }] as const)
: []),
{ id: "copy-relative", label: "Copy relative path" },
{ id: "copy-full", label: "Copy full path" },
] as const,
buildFileLinkContextMenuItems({
canRevealInFileManager,
canOpenInBrowser: onOpenInBrowser !== undefined,
}),
{ x: event.clientX, y: event.clientY },
);
@@ -1406,7 +1400,9 @@ function ChatMarkdown({
const availableEditors = serverConfig?.availableEditors ?? [];
const openInPreferredEditor = useOpenInPreferredEditor(environmentId, availableEditors);
const canRevealInFileManager =
preparedConnection._tag === "Some" && availableEditors.includes("file-manager");
preparedConnection._tag === "Some" &&
serverConfig?.environment.capabilities.fileManagerReveal === true &&
availableEditors.includes("file-manager");
const diffThemeName = resolveDiffThemeName(resolvedTheme);
const markdownFileLinkMetaByHref = useMemo(() => {
const metaByHref = new Map<
@@ -0,0 +1,33 @@
import { describe, expect, it } from "vite-plus/test";
import { buildFileLinkContextMenuItems } from "./fileLinkContextMenu";
describe("chat file link context menu", () => {
it("puts Open in folder first when the environment supports it", () => {
expect(
buildFileLinkContextMenuItems({
canRevealInFileManager: true,
canOpenInBrowser: false,
}),
).toEqual([
{ id: "open-in-folder", label: "Open in folder" },
{ id: "open", label: "Open in editor" },
{ id: "copy-relative", label: "Copy relative path" },
{ id: "copy-full", label: "Copy full path" },
]);
});
it("hides Open in folder when the environment does not support it", () => {
expect(
buildFileLinkContextMenuItems({
canRevealInFileManager: false,
canOpenInBrowser: true,
}),
).toEqual([
{ id: "open", label: "Open in editor" },
{ id: "open-in-browser", label: "Open in integrated browser" },
{ id: "copy-relative", label: "Copy relative path" },
{ id: "copy-full", label: "Copy full path" },
]);
});
});
@@ -0,0 +1,25 @@
import type { ContextMenuItem } from "@t3tools/contracts";
export type FileLinkContextMenuAction =
| "open-in-folder"
| "open"
| "open-in-browser"
| "copy-relative"
| "copy-full";
export function buildFileLinkContextMenuItems(input: {
readonly canRevealInFileManager: boolean;
readonly canOpenInBrowser: boolean;
}): readonly ContextMenuItem<FileLinkContextMenuAction>[] {
return [
...(input.canRevealInFileManager
? ([{ id: "open-in-folder", label: "Open in folder" }] as const)
: []),
{ id: "open", label: "Open in editor" },
...(input.canOpenInBrowser
? ([{ id: "open-in-browser", label: "Open in integrated browser" }] as const)
: []),
{ id: "copy-relative", label: "Copy relative path" },
{ id: "copy-full", label: "Copy full path" },
];
}
+3
View File
@@ -67,6 +67,9 @@ export const ExecutionEnvironmentCapabilities = Schema.Struct({
/** Server understands regenerateTitle on thread.meta.update. Absent on
older servers, so clients hide the action instead of sending it. */
threadTitleRegeneration: Schema.optionalKey(Schema.Boolean),
/** Server understands shell.revealInFileManager. Absent on older servers,
so clients hide the action instead of sending an unsupported RPC. */
fileManagerReveal: Schema.optionalKey(Schema.Boolean),
/** The update path clients should offer for this server. Absent on
servers that must be relaunched manually (dev checkouts, Windows
foreground runs, pre-update servers). */