Skip to content

Conversation

@easymikey
Copy link
Contributor

Description

Fix file deletion if they have already been deleted

Checklist

@easymikey easymikey force-pushed the ext/disk-usage-handle-deleted-files branch from 0eee29f to d9638ec Compare January 12, 2026 18:11
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: disk-usage Issues related to the disk-usage extension platform: macOS labels Jan 12, 2026
@raycastbot raycastbot added the OP is author The OP of the PR is the author of the extension label Jan 12, 2026
@raycastbot
Copy link
Collaborator

raycastbot commented Jan 12, 2026

Thank you for your contribution! 🎉

🔔 @easymikey you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

📋 Quick checkout commands
BRANCH="ext/disk-usage-handle-deleted-files"
FORK_URL="https://github.com/easymikey/raycast-extensions.git"
EXTENSION_NAME="disk-usage"
REPO_NAME="raycast-extensions"

git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run dev

Due to our current reduced availability, the initial review may take up to 10-15 business days.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 12, 2026

Greptile Overview

Greptile Summary

This PR attempts to fix the ENOENT: no such file or directory error when files are deleted externally while displayed in the disk usage extension. It adds an ITEM_MISSING event type and handler to update the cache when files no longer exist.

Architecture: The PR introduces a useEffect hook in FileSection.tsx that checks file existence using existsSync() on every render and sends an ITEM_MISSING event to the state machine when files are missing. The state machine handler then removes the item from cache and updates parent directory sizes.

Critical Issues:

  • The useEffect implementation will cause an infinite render loop because send() triggers a refresh, which causes the component to re-render with new object references
  • Synchronous existsSync() calls on every render will severely degrade performance for directories with many files
  • The approach of proactively checking file existence during render is architecturally incorrect - errors should be handled reactively when operations fail

Unrelated Changes: The PR includes formatting changes to the brew extension and a committed .DS_Store file, both unrelated to the stated purpose.

Confidence Score: 0/5

  • Not safe to merge - contains critical bugs that will cause infinite loops and severe performance degradation
  • The useEffect implementation has two P0 blocking issues: (1) it creates an infinite render loop due to missing dependencies and refresh triggers, and (2) it performs synchronous filesystem operations on every render, blocking the UI thread. These issues will break the extension's functionality and user experience.
  • extensions/disk-usage/src/components/FileSection.tsx requires complete rework of the file existence checking logic

Important Files Changed

File Analysis

Filename Score Overview
extensions/disk-usage/CHANGELOG.md 5/5 Added changelog entry for bug fix handling deleted files
extensions/disk-usage/src/types.ts 5/5 Added ITEM_MISSING event type to DiskUsageEvent union
extensions/disk-usage/src/disk-usage.tsx 5/5 Added empty line (formatting only, no logic change)
extensions/brew/src/components/dependencies.tsx 5/5 Formatting change from spaces to tabs, import reordering (no logic change)
extensions/soundboard/.DS_Store 0/5 macOS system file committed (should not be in repository)
extensions/disk-usage/src/components/FileSection.tsx 2/5 Added useEffect to check if file exists and send ITEM_MISSING event; potential infinite loop and missing dependency issues
extensions/disk-usage/src/machines/disk-usage-machine.ts 4/5 Added ITEM_MISSING handler to update cache when files are deleted; mostly correct but some formatting changes included

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, 5 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +23 to +27
useEffect(() => {
if (!isExists) {
send({ type: "ITEM_MISSING", path: node.path, bytes: node.bytes });
}
}, [node.path, isExists]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P0] This useEffect causes an infinite loop. When send({ type: "ITEM_MISSING" }) triggers refreshStore.triggerRefresh(), the component re-renders with a new node object, causing node.path to change reference and triggering the effect again. Additionally, send is missing from the dependency array, violating React's exhaustive-deps rule.

const selection = useSelection();
const isSelected = selection.has(node.path);
const isDeletingThis = isDeleting && isSelected;
const isExists = existsSync(node.path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P0] existsSync is called synchronously on every render. For a directory with hundreds of files, this will block the UI thread with hundreds of synchronous filesystem checks. This defeats the purpose of React's rendering model and will cause severe performance degradation.

Comment on lines +23 to +27
useEffect(() => {
if (!isExists) {
send({ type: "ITEM_MISSING", path: node.path, bytes: node.bytes });
}
}, [node.path, isExists]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] The approach of checking file existence on every render is architecturally flawed. The ITEM_MISSING event should be sent only when an actual deletion attempt fails (catching ENOENT errors in the trash operation), not proactively checked during render.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 12, 2026

Additional Comments (2)

extensions/soundboard/.DS_Store
[P1] .DS_Store is a macOS system file that should not be committed to the repository. This file is unrelated to the PR's stated purpose of handling deleted files in the disk-usage extension.


extensions/brew/src/components/dependencies.tsx
[P2] This formatting change (spaces to tabs) is unrelated to the PR's purpose of fixing deleted file handling in the disk-usage extension. Consider removing this from the PR to keep changes focused.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@pernielsentikaer
Copy link
Collaborator

Thanks for your update @easymikey 🔥

Can you see feedback from Greptile?

I converted this PR into a draft until it's ready for the review, please press the button Ready for review when it's ready and we'll have a look 😊

@pernielsentikaer pernielsentikaer marked this pull request as draft January 12, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension: disk-usage Issues related to the disk-usage extension extension fix / improvement Label for PRs with extension's fix improvements OP is author The OP of the PR is the author of the extension platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants