feat(files): add delete action to file explorer#2691
Conversation
Greptile SummaryThis PR adds deleting files and folders from the file explorer. The main changes are:
Confidence Score: 4/5The SSH recursive delete path needs a containment fix before merging.
apps/emdash-desktop/src/main/core/fs/controller.ts and the SSH filesystem path resolver
|
| Filename | Overview |
|---|---|
| apps/emdash-desktop/src/main/core/fs/controller.ts | Forwards recursive delete options to the workspace filesystem, which exposes a remote SSH path-containment bug for crafted RPC paths. |
| apps/emdash-desktop/src/main/core/fs/impl/local-fs.test.ts | Adds coverage for recursive local directory deletion. |
| apps/emdash-desktop/src/renderer/features/tasks/editor/editor-file-tree.tsx | Adds the Delete context menu action, confirmation flow, RPC call, tab cleanup, and file tree update. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant UI as File explorer
participant RPC as removeFile RPC
participant FS as Workspace filesystem
participant Store as Tabs and file tree
User->>UI: Confirm Delete
UI->>RPC: removeFile(path, recursive)
RPC->>FS: remove(path, options)
FS-->>RPC: delete result
RPC-->>UI: result
UI->>Store: close deleted file tabs
UI->>Store: remove deleted node
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant UI as File explorer
participant RPC as removeFile RPC
participant FS as Workspace filesystem
participant Store as Tabs and file tree
User->>UI: Confirm Delete
UI->>RPC: removeFile(path, recursive)
RPC->>FS: remove(path, options)
FS-->>RPC: delete result
RPC-->>UI: result
UI->>Store: close deleted file tabs
UI->>Store: remove deleted node
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/emdash-desktop/src/main/core/fs/controller.ts:125
**Recursive SSH Path Traversal**
Forwarding `recursive` makes this RPC a recursive delete for SSH workspaces too. A crafted renderer RPC path like `subdir/../../../outside` can pass the SSH provider's string-prefix workspace check before the remote shell resolves `..`, so this changed call can turn the new folder-delete option into `rm -rf` outside the workspace.
Reviews (1): Last reviewed commit: "feat(files): add delete action to file e..." | Re-trigger Greptile
|
|
||
| try { | ||
| const result = await env.fs.remove(filePath); | ||
| const result = await env.fs.remove(filePath, options); |
There was a problem hiding this comment.
Forwarding recursive makes this RPC a recursive delete for SSH workspaces too. A crafted renderer RPC path like subdir/../../../outside can pass the SSH provider's string-prefix workspace check before the remote shell resolves .., so this changed call can turn the new folder-delete option into rm -rf outside the workspace.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/emdash-desktop/src/main/core/fs/controller.ts
Line: 125
Comment:
**Recursive SSH Path Traversal**
Forwarding `recursive` makes this RPC a recursive delete for SSH workspaces too. A crafted renderer RPC path like `subdir/../../../outside` can pass the SSH provider's string-prefix workspace check before the remote shell resolves `..`, so this changed call can turn the new folder-delete option into `rm -rf` outside the workspace.
How can I resolve this? If you propose a fix, please make it concise.e6467d3 to
64fb860
Compare
Summary
Impact
Users can remove files or whole folders directly from the file explorer. Folder deletion removes the selected folder and its contents, updates the tree, and closes deleted file tabs across split panes.
Validation
corepack pnpm exec oxfmt --check src/main/core/fs/controller.ts src/main/core/fs/impl/local-fs.test.ts src/renderer/features/tasks/editor/editor-file-tree.tsxcorepack pnpm exec oxlint src/main/core/fs/controller.ts src/main/core/fs/impl/local-fs.test.ts src/renderer/features/tasks/editor/editor-file-tree.tsxcorepack pnpm exec vitest run --project node src/main/core/fs/impl/local-fs.test.tscorepack pnpm run typecheck