Skip to content

Conversation

@PrayagCodes
Copy link

Summary

Adds cumulative file size display to the explorer footer when files are selected. Users can now see at a glance how much storage space their selected files occupy, improving the file management experience.

Problem

The explorer footer currently shows only the count of selected items (e.g., "3 items selected") but provides no information about the total size of those files. Users need to:

  • Open Properties for each file individually
  • Perform mental math to calculate total size
  • Make educated guesses about storage impact

This makes it difficult to quickly assess disk space usage when managing multiple files, especially when deciding what to delete, move, or download.

User Impact

Without size information, users cannot easily:

  • Determine if selected files will fit on a target drive
  • Understand the storage impact of bulk operations
  • Quickly identify large file selections

Solution

Enhanced the update_explorer_footer_selected_items_count() function to calculate and display the total size of selected files alongside the item count.

Changes Made

File: src/gui/src/UI/UIWindow.js

  • Added size calculation loop that iterates through all selected items
  • Reads data-size attribute from each item element
  • Accumulates total size in bytes with safe parsing (parseInt() with fallback to 0)
  • Formats size using existing window.byte_format() utility
  • Appends formatted size to display text with bullet separator
  • Only displays size when total_size > 0 (gracefully handles folders)

File: src/gui/dist/bundle.min.js

  • Rebuilt GUI bundle to include the changes

Implementation Details

The solution leverages existing infrastructure:

  • Items already store size in data-size attributes (in bytes)
  • window.byte_format() utility handles human-readable formatting (B, KB, MB, GB, TB)
  • All selection mechanisms already call update_explorer_footer_selected_items_count()

Display format: "X items selected • YY.YY MB"

Testing

Manual Testing Completed

Verified functionality across all selection methods:

  1. Single file selection: Click a file - Shows "1 item selected • {size}"
  2. Multiple file selection: Ctrl+Click multiple files - Shows correct total size
  3. Drag selection: Select files by dragging - Size updates correctly
  4. Keyboard selection: Shift+Arrow keys - Size updates dynamically
  5. Select All (Ctrl+A): Selects all items - Shows sum of all file sizes
  6. Mixed selection: Files and folders together - Folders count as items but size is 0
  7. Deselection: Click empty space - Footer hides correctly
  8. Keyboard search: Type letters to find files - Size displays for matched selection

Edge Cases Tested

  • Empty folders: Counted as items but contribute 0 to size
  • Folders with no size data: Handled gracefully with || 0 fallback
  • Large files: Correctly formats GB and TB sizes
  • Single byte files: Shows "Bytes" unit correctly
  • Zero-byte files: Contributes 0 to total

Acceptance Criteria

  • Footer displays total size when one or more files are selected
  • Size is shown in human-readable format (B, KB, MB, GB, TB) with appropriate precision
  • Format is clear and consistent: "X items selected • YY.YY MB"
  • Size updates dynamically as files are selected/deselected
  • Folders count toward item count but not toward size calculation
  • Works across all selection methods (click, drag, keyboard, Ctrl+A)

Add cumulative file size calculation and display in the explorer footer
when files are selected. The footer now shows 'X items selected • Y.YY MB'
format to help users understand storage impact of selections.

- Calculate total size by summing data-size attributes from selected items
- Format size using existing byte_format() helper for human-readable display
- Only show size when total_size > 0 (handles folders gracefully)
- Size updates dynamically across all selection methods: click, drag,
  keyboard navigation, and Ctrl+A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant