Module TreeView

Module TreeView 

Source
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 TreeViewProvider via DI with Require() trait from MountainEnvironment
  • Translates frontend requests to provider method calls with proper error mapping

COMMAND REFERENCE (Tauri IPC):

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 API
  • vs/workbench/api/common/extHostTreeViews.ts - extension host tree view API
  • vs/workbench/contrib/files/browser/explorerView.ts - file explorer tree view
  • vs/workbench/contrib/tree/browser/treeView.ts - generic tree view component

TODO:

  • Implement OnTreeNodeExpanded and OnTreeSelectionChanged in 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

Functions§

GetTreeViewChildren
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).
GetTreeViewItem
Gets the tree item for a given tree element handle.
OnTreeViewExpansionChanged
Handles tree node expansion/collapse events.
OnTreeViewSelectionChanged
Handles tree selection changes.
PersistTreeView
Persists tree view state.
RefreshTreeView
Refreshes a tree view.
RestoreTreeView
Restores tree view state.
RevealTreeViewItem
Reveals a specific tree item.