Skip to content

Conversation

@ShivamB25
Copy link
Contributor

This is a critical safety improvement to prevent accidental data loss. Previously, the 'yes' button was selected by default in confirmation dialogs for delete and empty operations, making it extremely easy to accidentally destroy data by pressing 'e' followed by Enter.

Problem

Users have reported significant data loss (up to 150GB) due to accidentally pressing 'e' followed by Enter, which would immediately confirm deletion with the dangerous 'yes' default. This creates an extremely high risk of accidental data loss with just two quick keypresses.

Changes

  • Reorder confirmation dialog buttons from ['yes', 'no', 'don't ask me again'] to ['no', 'yes', 'don't ask me again'] making 'no' the default
  • Update button index mapping in confirmDeletionSelected() and confirmDeletionMarked() to handle the new button order
  • Add comprehensive tests to verify safer confirmation behavior
  • Replace deprecated strings.Title with golang.org/x/text/cases.Title
  • Maintain backward compatibility for all other functionality

Impact

This addresses a known usability issue in the gdu community where users have reported significant data loss due to the dangerous default behavior. The fix aligns gdu with ncdu's safer approach of defaulting to 'no'.

Testing

  • Added 7 new comprehensive tests to verify the safer confirmation behavior
  • All existing tests continue to pass
  • Full test suite passes with race condition testing

Fixes the critical safety issue mentioned in community discussions where users have experienced data loss due to accidental confirmation of destructive actions.

This is a critical safety improvement to prevent accidental data loss. Previously,
the 'yes' button was selected by default in confirmation dialogs for delete and
empty operations, making it extremely easy to accidentally destroy data by
pressing 'e' followed by Enter.

Changes:
- Reorder confirmation dialog buttons from ['yes', 'no', 'don't ask me again']
  to ['no', 'yes', 'don't ask me again'] making 'no' the default
- Update button index mapping in confirmDeletionSelected() and
  confirmDeletionMarked() to handle the new button order
- Add comprehensive tests to verify safer confirmation behavior
- Replace deprecated strings.Title with golang.org/x/text/cases.Title
- Maintain backward compatibility for all other functionality

This addresses a known usability issue in the gdu community where users
have reported significant data loss due to the dangerous default behavior.
The fix aligns gdu with ncdu's safer approach of defaulting to 'no'.
@ShivamB25
Copy link
Contributor Author

#140

#123

these are all here

@codecov
Copy link

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.49%. Comparing base (df73872) to head (5d0f0d3).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
tui/marked.go 66.66% 1 Missing ⚠️
tui/tui.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #437      +/-   ##
==========================================
- Coverage   83.50%   83.49%   -0.01%     
==========================================
  Files          46       46              
  Lines        4414     4412       -2     
==========================================
- Hits         3686     3684       -2     
  Misses        656      656              
  Partials       72       72              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ShivamB25
Copy link
Contributor Author

image looks bit awkward but we will get used to it

- Add TestConfirmDeletionSelectedCase1 to cover the 'yes' button logic
- Add TestConfirmDeletionMarkedCase1 to cover marked deletion 'yes' logic
- Improves test coverage to address Codecov report issues
- Ensures safety fix button reordering is properly tested
@ShivamB25
Copy link
Contributor Author

@dundee might be a good time to review and fix for all (really dangerous to have yes selected)

@dundee dundee merged commit f2f31ea into dundee:master Sep 22, 2025
10 checks passed
@dundee
Copy link
Owner

dundee commented Sep 22, 2025

Thank you!

@dundee dundee added this to the 5.32 milestone Sep 23, 2025
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.

2 participants