feat(web): reveal files and worktrees in the system file manager #9373
main fromrefs/pull/9373/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/components/RightPanelTabs.tsx line 208OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -172,0 +188,21 @@188+ */189+export function fileTabContextMenuItems(190+ surface: RightPanelSurface,191+ revealLabel: string | null,192+): ReadonlyArray<ContextMenuItem<FileTabContextMenuAction>> {193+ if (surface.kind !== "file" || surface.attachment !== undefined) return [];194+ return [195+ { id: "copy-path", label: "Copy path" },196+ ...(revealLabel === null197+ ? []198+ : [{ id: "reveal-in-file-manager" as const, label: revealLabel }]),199+ ];200+}201+202+/** Resolves a workspace-relative file-tab path to the host path sent to the shell. */203+export function rightPanelFileTargetPath(204+ surface: RightPanelSurface,205+ workspaceRoot: string,206+): string | null {207+ if (surface.kind !== "file" || surface.attachment !== undefined) return null;208+ return resolvePathLinkTarget(surface.relativePath, workspaceRoot);
flamboh(GitHub profile, opens in a new tab) changed the title
flamboh(GitHub profile, opens in a new tab) changed the title
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XXL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) removed labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
- apps/web/src/fileManagerReveal.ts lines 85 to 85Resolvedby flamboh(GitHub profile, opens in a new tab)@@ -0,0 +65,21 @@65+ onFailure?.(cause);66+ toastManager.add(67+ stackedThreadToast({68+ type: "error",69+ title: failureTitle,70+ description: cause instanceof Error ? cause.message : "An error occurred.",71+ }),72+ );73+ }74+}75+76+export function openFileManagerPath(77+ action: FileManagerAction,78+ targetPath: string,79+ failureTitle: string,80+): Promise<void> {81+ return runFileManagerPath(action.open.run, targetPath, failureTitle);82+}83+84+function isAbsoluteFilePath(path: string): boolean {85+ return path.startsWith("/") || /^[A-Za-z]:[\\/]/.test(path) || path.startsWith("\\\\");
- apps/web/src/components/ThreadTerminalDrawer.tsx line 798Resolvedby flamboh(GitHub profile, opens in a new tab)@@ -676,3 +766,6 @@676766 if (requestId !== selectionActionRequestIdRef.current || clicked === null) {677767 return;678768 }769+ if (linkText !== null) {770+ switch (clicked) {771+ case "open-terminal-link-preview":apps/web/src/components/ThreadTerminalDrawer.tsx line 784OutdatedResolvedby flamboh(GitHub profile, opens in a new tab)@@ -676,3 +766,19 @@676766 if (requestId !== selectionActionRequestIdRef.current || clicked === null) {677767 return;678768 }769+ if (linkText !== null) {770+ switch (clicked) {771+ case "open-terminal-link-preview":772+ await openTerminalLinkInIntegratedBrowser({773+ url: linkText,774+ threadRef,775+ openPreview,776+ fallbackToBrowser: () => openTerminalUrl(linkText, { forceBrowser: true }),777+ });778+ return;779+ case "open-terminal-link-browser":780+ openTerminalUrl(linkText, { forceBrowser: true });781+ return;782+ case "add-terminal-link-to-chat":783+ case "add-terminal-path-to-chat":784+ if (canAddLinkToChat()) onAddTerminalLink?.(terminalLinkChatText(linkText, cwd));apps/web/src/components/ThreadTerminalDrawer.tsx lines 273 to 273OutdatedResolvedby flamboh(GitHub profile, opens in a new tab)@@ -247,4 +255,19 @@247255 };248256 }249257250-export type TerminalContextMenuAction = "add-to-chat" | "copy" | "paste";258+export type TerminalContextMenuAction =259+ | "add-to-chat"260+ | "copy"261+ | "paste"262+ | "open-terminal-link-preview"263+ | "open-terminal-link-browser"264+ | "add-terminal-link-to-chat"265+ | "copy-terminal-link"266+ | "open-terminal-path"267+ | "reveal-terminal-path"268+ | "add-terminal-path-to-chat"269+ | "copy-terminal-path";270+271+export function terminalLinkChatText(text: string, cwd: string): string {272+ if (isTerminalUrl(text)) return text;273+ const path = splitFilePathPosition(text).path.replace(/\/+$/, "") || "/";
- apps/web/src/fileManagerReveal.ts lines 102 to 102Resolvedby flamboh(GitHub profile, opens in a new tab)@@ -0,0 +82,21 @@82+}83+84+function isAbsoluteFilePath(path: string): boolean {85+ return path.startsWith("/") || /^[A-Za-z]:[\\/]/.test(path) || path.startsWith("\\\\");86+}87+88+function usesWindowsSeparators(path: string): boolean {89+ return /^[A-Za-z]:/.test(path) || path.startsWith("\\\\") || path.startsWith("//");90+}91+92+function trimTrailingSeparators(path: string, separator: "/" | "\\"): string {93+ const trimmed = separator === "/" ? path.replace(/\/+$/, "") : path.replace(/[\\/]+$/, "");94+ return trimmed || separator;95+}96+97+function windowsVolumeRootForWorkspaceRoot(workspaceRoot: string): string | null {98+ const normalizedRoot = workspaceRoot.replaceAll("/", "\\");99+ const drive = /^([A-Za-z]:)(?:\\|$)/.exec(normalizedRoot);100+ if (drive !== null) return drive[1] ?? null;101+102+ if (!normalizedRoot.startsWith("\\\\")) return null;
- apps/web/src/components/ThreadTerminalDrawer.tsx lines 276 to 289Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -250 +258,20 @@250-export type TerminalContextMenuAction = "add-to-chat" | "copy" | "paste";258+export type TerminalContextMenuAction =259+ | "add-to-chat"260+ | "copy"261+ | "paste"262+ | "open-terminal-link-preview"263+ | "open-terminal-link-browser"264+ | "add-terminal-link-to-chat"265+ | "copy-terminal-link"266+ | "open-terminal-path"267+ | "reveal-terminal-path"268+ | "add-terminal-path-to-chat"269+ | "copy-terminal-path";270+271+export function terminalLinkChatText(text: string, cwd: string): string {272+ if (isTerminalUrl(text)) return text;273+ // Trim trailing separators, but keep the one that makes `C:\` a volume root.274+ const path = splitFilePathPosition(text).path.replace(/(?<!^[A-Za-z]:)[\\/]+$/, "") || "/";275+ const target = resolvePathLinkTarget(path, cwd);276+ return target.endsWith("/") ? target : serializeComposerFileLink(target);277+}
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed