Expand description
§SourceControlManagement (Command)
RESPONSIBILITIES:
- Defines Tauri command handlers for Source Control Management (SCM) operations
- Exposes SCM functionality to the Sky frontend via IPC
- Aggregates SCM provider state, resources, and groups for UI rendering
- Routes SCM commands to appropriate providers (commit, push, pull, branch ops)
- Manages branch listing, checkout, and commit history retrieval
- Handles resource staging (git add equivalent)
ARCHITECTURAL ROLE:
- Command module that bridges Sky UI requests to
SourceControlManagementProviderimplementations in the Environment layer - Uses Tauri’s
#[command]attribute for IPC exposure - Reads from
ApplicationState.SourceControlManagement*fields to gather state - TODO: Should forward commands to provider methods via DI (Require trait)
COMMAND REFERENCE (Tauri IPC):
GetAllSourceControlManagementState: Returns complete snapshot of providers, groups, and resources for SCM viewGetSCMResourceChanges: Get file changes for a specific providerExecuteSCMCommand: Execute SCM operation (commit, push, pull, etc.)GetSCMBranches: List branches for providerCheckoutSCMBranch: Switch to a different branchGetSCMCommitHistory: Retrieve commit log with optional limitStageSCMResource: Stage or unstage a file resource
ERROR HANDLING:
- Returns
Result<Value, String>where error string is sent to frontend - Uses
MapLockErrorto convert Mutex poisoning to error strings - Provider identifier parsing may fail (unwrap_or(0) fallback)
- Unknown commands return error string
PERFORMANCE:
- State access uses RwLock reads; cloning entire state maps (may be heavy)
- TODO: Consider pagination for large commit histories and resource lists
VS CODE REFERENCE:
vs/workbench/contrib/scm/common/scm.ts- SCM model and state aggregationvs/workbench/contrib/scm/browser/scmView.ts- SCM UI panelvs/workbench/services/scm/common/scmService.ts- SCM service façade
TODO:
- Integrate with
SourceControlManagementProvidertrait methods - Implement actual SCM command execution (currently stubs with mock success)
- Add proper error handling for failed git operations
- Implement branch retrieval with remote tracking branches
- Add commit history with proper commit objects (author, message, hash)
- Implement resource staging with correct file paths and states
- Add support for stash operations, merging, rebasing
- Handle multiple SCM providers simultaneously (git, svn, etc.)
- Add cancellation tokens for long-running operations
- Implement diff viewing with proper unified diff format
- Add SCM resource decoration (git status icons, gutter marks)
- Support SCM workspace edit (apply changes from commit/rebase)
- Add SCM input box interactions (commit message, branch name)
MODULE CONTENTS:
- Tauri command functions (all
#[command]async):- State retrieval:
GetAllSourceControlManagementState,GetSCMResourceChanges - Operations:
ExecuteSCMCommand,StageSCMResource - Branch management:
GetSCMBranches,CheckoutSCMBranch - History:
GetSCMCommitHistory
- State retrieval:
- No data structures (uses DTOs from CommonLibrary)
Functions§
- CheckoutSCM
Branch - ExecuteSCM
Command - GetAll
Source Control Management State - Retrieves the complete state of all Source Control Management providers, groups, and resources for rendering in the UI.
- GetSCM
Branches - GetSCM
Commit History - GetSCM
Resource Changes - StageSCM
Resource