feat(web): open diff files from a right-click context menu #11842
Mergedsaphid(GitHub profile, opens in a new tab)merged 2 commits into
main fromrefs/pull/11842/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/web/src/fileContextMenu.ts line 102Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +71,21 @@71+}): readonly ContextMenuItem<FileContextMenuAction>[] {72+ // Without a resolvable absolute path nothing here can act on the file.73+ if (!input.hasAbsolutePath) return [];74+ const items: ContextMenuItem<FileContextMenuAction>[] = [];75+ if (input.capabilities.canOpenDefault) {76+ items.push({ id: "open", label: "Open", icon: "pencil" });77+ }78+ if (input.capabilities.revealLabel !== undefined) {79+ items.push({80+ id: "reveal-in-folder",81+ label: input.capabilities.revealLabel,82+ icon: "folder-tree",83+ });84+ }85+ const editorIds = input.capabilities.editorIds.filter((id) => id !== "file-manager");86+ if (editorIds.length > 0) {87+ items.push({88+ id: "open-with",89+ label: "Open with",90+ children: editorIds.map((editorId) => ({91+ id: `editor:${editorId}` as FileContextMenuAction,
- apps/web/src/components/files/FileBrowserPanel.tsx lines 194 to 197OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -174,11 +179,19 @@174179 const position = pointerIsFresh175180 ? { x: pointer.x, y: pointer.y }176181 : { x: anchorRect.left, y: anchorRect.bottom };182+ const fileTarget = { environmentId, filePath: relativePath, workspaceRoot: cwd };183+ const fileMenuItems = fileContextMenu.buildItems(fileTarget);177184 try {178185 const clicked = await api.contextMenu.show(179186 [187+ ...fileMenuItems,180188 { id: "copy-mention", label: "Copy mention" },181189 { id: "add-to-chat", label: "Add to chat" },182190 ],183191 position,184192 );193+ if (clicked === null) return;194+ if (fileMenuItems.some((entry) => entry.id === clicked)) {195+ await fileContextMenu.activate(clicked as FileContextMenuAction, fileTarget);196+ return;197+ }
juliusmarminge merged this9051ed9
juliusmarminge closed this
Sign in to join this conversation.



macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed