Skip to content

feat(rust tui): add delete uri funciton with confirmation and refresh behaviour#696

Merged
MaojiaSheng merged 4 commits intovolcengine:mainfrom
xiaobin83:feature/manage-record-tui
Apr 15, 2026
Merged

feat(rust tui): add delete uri funciton with confirmation and refresh behaviour#696
MaojiaSheng merged 4 commits intovolcengine:mainfrom
xiaobin83:feature/manage-record-tui

Conversation

@xiaobin83
Copy link
Copy Markdown
Contributor

@xiaobin83 xiaobin83 commented Mar 17, 2026

Description

This commit adds two 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

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • added delete_uri and reload_entire_tree in app.rs
  • added set_status_message for showing a status message on the bottom bar.
  • added update_status_message in mod.rs for making status message go away after 3 (hardcoded) seconds.
  • added expand_node_by_uri in tree
  • monitor key input 'd' for deletion (then 'y'/'n' for confirmation), and 'r' for refresh

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots

Screenshot 2026-03-17 at 17 33 53 Screenshot 2026-03-17 at 17 33 58

…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
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 17, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Collaborator

@qin-ctx qin-ctx left a comment

Choose a reason for hiding this comment

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

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.

Comment thread crates/ov_cli/src/tui/event.rs Outdated
Comment thread crates/ov_cli/src/tui/app.rs Outdated
}
}

pub async fn reload_entire_tree(&mut self) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[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_uri loop
  • 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

extracted common code into small methods

Comment thread crates/ov_cli/src/tui/event.rs
Comment thread crates/ov_cli/src/tui/ui.rs Outdated
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
@xiaobin83 xiaobin83 requested a review from qin-ctx March 18, 2026 03:13
@MaojiaSheng
Copy link
Copy Markdown
Collaborator

I'll merge after some optimization

@MaojiaSheng MaojiaSheng merged commit 58666ed into volcengine:main Apr 15, 2026
36 of 37 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants