Skip to content

feat: calculate real-time directory size in spotter#2695

Merged
sxyazi merged 1 commit intomainfrom
pr-11998dfa
Apr 29, 2025
Merged

feat: calculate real-time directory size in spotter#2695
sxyazi merged 1 commit intomainfrom
pr-11998dfa

Conversation

@sxyazi
Copy link
Owner

@sxyazi sxyazi commented Apr 29, 2025

Follow up to #2683, #2691

An implementation of the feature request: #842, #2649

Closes #842
Closes #2649


This PR adds directory sizes to the folder spotter, the size is computed dynamically in real time and asynchronously, which means:

  • Every time a user clicks <Tab> on a directory, the latest size is calculated.
  • For large directories, real-time changes in size are reported to the user, with "(?)" appended at the end to indicate that the calculation is in progress.
  • If the user closes the spotter or switches directories with the left/right arrow keys, any ongoing calculations will be canceled to avoid wasting resources.

Also, the computed directory size will be updated to the file list:

  • If the user sets linemode = size, the latest size will be shown on the right of the file line.
  • If the user sets sort_by = size, the file list will be sorted with the latest sizes (if necessary).
screenshot-002318.mp4

@sxyazi sxyazi requested a review from Copilot April 29, 2025 14:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a real-time directory size calculation feature in the spotter, including dynamic updates and cancellation of ongoing calculations.

  • Integrates asynchronous size calculation and cancellation in the spotter workflow.
  • Extends data structures and bindings to support a new Urn type with serialization and error handling.
  • Updates related files (FilesOp, update_spotted, and update_size) to incorporate the new functionality.

Reviewed Changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
yazi-shared/src/url/urn.rs Added Serialize derive to UrnBuf for better integration.
yazi-shared/src/event/data.rs Updated Data and DataKey enums to include the new Urn variant.
yazi-plugin/src/utils/spot.rs Added a new id field to SpotLock and updated conversion logic.
yazi-plugin/src/isolate/spot.rs Introduced a static Ids generator for job creation.
yazi-plugin/src/fs/op.rs Added support for a new "size" FilesOp using Urn as a key.
yazi-fs/src/files.rs Modified update_size with filtering logic using a threshold.
yazi-dds/src/sendable.rs Extended Sendable conversions to include Urn support.
yazi-core/src/tab/commands/update_spotted.rs Updated spotted handling to use new reset logic.
yazi-core/src/spot/spot.rs Added a reset method that aborts ongoing tasks and updates UI.
yazi-core/src/spot/commands/close.rs Simplified close command by invoking the new reset method.
yazi-core/src/mgr/commands/update_mimes.rs Minor improvements in error handling while parsing options.
yazi-binding/src/urn.rs Introduced a new Urn binding with FromLua and UserData trait.
yazi-binding/src/url.rs Modified Url struct & caching to support the new Urn field.
yazi-binding/src/lib.rs Updated module inclusion to add the Urn module.
Files not reviewed (2)
  • yazi-plugin/preset/plugins/folder.lua: Language not supported
  • yazi-plugin/preset/ya.lua: Language not supported

@sxyazi sxyazi merged commit eba9f1e into main Apr 29, 2025
6 checks passed
@sxyazi sxyazi deleted the pr-11998dfa branch April 29, 2025 14:17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show file/dir size when tab Reevaluate size of hovered folder on keypress

2 participants