feat(rust tui): add delete uri funciton with confirmation and refresh behaviour#696
Conversation
…h behavior This commit adds two key TUI features: 1. Delete functionality (d key): - Press 'd' to delete the selected file or directory - A confirmation prompt appears: "Delete [file/directory]? (y/n): [URI]" - Press 'y' to confirm deletion or 'n' to cancel - After deletion, the tree refreshes and cursor moves to the next or previous sibling 2. Refresh behavior (r key): - Press 'r' to refresh the entire tree - Loads the root node "viking://" - Restores the cursor to the originally selected node - Maintains user context after refresh
qin-ctx
left a comment
There was a problem hiding this comment.
Overall a well-structured PR that adds useful TUI features. One blocking bug found: the delete confirmation prompt can be prematurely cleared by the auto-clear timer from a previous status message. 4 additional non-blocking suggestions included.
Also note: no tests were added for the new functionality (delete confirmation state machine, status message auto-clear, tree refresh with state restoration). Consider adding unit tests for at least the timer logic and confirmation flow.
| } | ||
| } | ||
|
|
||
| pub async fn reload_entire_tree(&mut self) { |
There was a problem hiding this comment.
[Design] (non-blocking) reload_entire_tree() and delete_uri() share ~40 lines of nearly identical logic:
- Collecting expanded nodes from
self.tree.visible - Reloading root and restoring expanded state via
expand_node_by_uriloop - Walking parent paths to ensure target URI visibility
- Finding cursor position with parent-fallback closure
Consider extracting a shared helper (e.g., refresh_tree_and_restore(&mut self, target_uri: &str)) to reduce duplication and make future maintenance easier.
There was a problem hiding this comment.
extracted common code into small methods
Changes: - Replace delete_confirmation with generic confirmation system using callbacks - Add error message handling with dedicated display - Add status message locking during confirmations - Add delete_selected_uri method for cleaner deletion flow - Add deletion protection for root and scope directories - Update UI to show error messages and confirmation prompts - Rename update_status_message to update_messages - Add allow_deletion method to TreeState - Update key handling to prioritize error messages
|
I'll merge after some optimization |
Description
This commit adds two TUI features:
Delete functionality (d key):
Refresh behavior (r key):
Type of Change
Changes Made
Testing
Checklist
Screenshots