Expand description
§TreeView (Command)
RESPONSIBILITIES:
- Defines Tauri command handlers for TreeView operations from Sky frontend
- Bridges TreeView UI requests to
TreeViewProvider - Handles tree data fetching, expansion, selection, and refresh operations
- Manages tree view state persistence and restoration (stubs)
ARCHITECTURAL ROLE:
- Command module exposing TreeView functionality via Tauri IPC
(
#[command]) - Delegates to Environment’s
TreeViewProvidervia DI withRequire()trait fromMountainEnvironment - Translates frontend requests to provider method calls with proper error mapping
COMMAND REFERENCE (Tauri IPC):
GetTreeViewChildren: Fetch child items for a tree node (byElementHandle, null for root)GetTreeViewItem: Get tree item metadata (label, icon, description) by handleOnTreeViewExpansionChanged: Notify when user expands/collapses a node (stub - trait method missing)OnTreeViewSelectionChanged: Notify when user selects/deselects tree items (stub - trait method missing)RefreshTreeView: Request tree view to refresh its data, optionally specific itemsRevealTreeViewItem: Request to reveal/focus a specific tree item in the UIPersistTreeView: Save tree view state (scroll position, expansion) (stub)RestoreTreeView: Restore previously saved tree view state (stub)
ERROR HANDLING:
- Returns
Result<Value, String>with error strings sent to frontend - Provider errors are logged with context and converted to error strings
- Missing trait methods return structured error indicating not implemented
PERFORMANCE:
- All commands are async and non-blocking
- Tree data fetching should be efficient; provider may cache results
- Refresh can target specific items to avoid full tree rebuild
VS CODE REFERENCE:
vs/workbench/api/browser/mainThreadTreeViews.ts- main thread tree view APIvs/workbench/api/common/extHostTreeViews.ts- extension host tree view APIvs/workbench/contrib/files/browser/explorerView.ts- file explorer tree viewvs/workbench/contrib/tree/browser/treeView.ts- generic tree view component
TODO:
- Implement
OnTreeNodeExpandedandOnTreeSelectionChangedin TreeViewProvider trait - Add tree view state persistence to ApplicationState
- Implement drag and drop support for tree items
- Add tree item validation and disabled states
- Support tree item tooltips and description rendering
- Implement tree item icon theming (light/dark)
- Add tree view column support (multi-column tree views)
- Support tree view title and description updates
- Implement tree view badge (count overlay) functionality
- Add tree view message handling for dynamic updates
- Support tree item context menu contributions
- Implement tree item editing (inline rename)
- Add tree view accessibility (ARIA labels, keyboard navigation)
MODULE CONTENTS:
- Tauri command functions (all
#[command] pub async fn):- Data retrieval:
GetTreeViewChildren,GetTreeViewItem - UI events:
OnTreeViewExpansionChanged,OnTreeViewSelectionChanged - Management:
RefreshTreeView,RevealTreeViewItem - State:
PersistTreeView,RestoreTreeView
- Data retrieval:
Functions§
- GetTree
View Children - A specific Tauri command handler for the UI to fetch the children of a tree view node. This handler dispatches to the correct provider (native or proxied).
- GetTree
View Item - Gets the tree item for a given tree element handle.
- OnTree
View Expansion Changed - Handles tree node expansion/collapse events.
- OnTree
View Selection Changed - Handles tree selection changes.
- Persist
Tree View - Persists tree view state.
- Refresh
Tree View - Refreshes a tree view.
- Restore
Tree View - Restores tree view state.
- Reveal
Tree View Item - Reveals a specific tree item.