Workflow
Source Control Management (SCM)
Git extension in Cocoon uses Mountain to run native git commands and populate the SCM view in the UI.
Source Control Management (SCM)
Outlines how the built-in Git extension in Cocoon uses Mountain as a service to run native git commands and populate the SCM view in the UI.
Verify against Cocoon/Source/Services/Extension.ts for extension activation and Mountain’s Git provider implementation.
Data Flow
Phase 1: Registration and Discovery
Git Extension activate()
-> vscode.scm.createSourceControl('git', 'Git')
-> ScmProvider service in Cocoon sends $registerScmProvider gRPC to Mountain
-> vscode.workspace.workspaceFolders API to get root path
-> vscode.workspace.fs.stat(Uri.joinPath(root, '.git')) -- gRPC to Mountain
-> Mountain: tokio::fs::metadata -- .git directory confirmed
Phase 2: Populate SCM View
-> Git extension runs: git status --porcelain -z
-> $gitExec gRPC to Mountain
-> Mountain GitProvider spawns git process, captures stdout
-> Returns raw output to Cocoon
-> Git extension parses output, builds list of changed files
-> Creates SourceControlResourceState objects (URI + decorations)
-> Updates SourceControl resourceGroups
-> $updateScmGroup gRPC notification to Mountain
-> Mountain emits sky://scm/update-group Tauri event
Phase 3: UI Rendering
-> SCM View component receives update-group event
-> UI re-renders file list (e.g. "M src/main.ts")
Phase 4: Diff View
User clicks changed file
-> vscode.open with git: URI (e.g. git:/src/main.ts?{"ref":"HEAD"})
-> EditorService creates DiffEditorInput
-> Modified side: file:// URI, IFileService.read (standard read)
-> Original side: git: URI, Content Provider calls $gitExec
-> Mountain: git show HEAD:file
-> Returns original content to Wind
-> DiffEditor opens with both sides
-> User sees side-by-side diffPhase 1: Extension Registration and Repository Discovery (Cocoon)
- Cocoon activates the built-in Git extension.
- Git extension calls
vscode.scm.createSourceControl('git', 'Git').ScmProviderservice manages state and sends$registerScmProvidergRPC to Mountain. - Git extension uses
vscode.workspace.workspaceFoldersto get root path. Then checks for.gitdirectory viavscode.workspace.fs.stat(...), which routes through Cocoon’s FileSystemProvider over gRPC to Mountain’stokio::fs::metadata.
Phase 2: Populating the SCM View (Cocoon -> Mountain)
- Git extension needs file status. Uses a custom
vscode.gitAPI exposed by Mountain, which translates to a$gitExecgRPC request. - Mountain’s
GitProvidersafely spawns a nativegitchild process with the provided arguments, captures stdout, returns raw string. - Git extension parses
git statusoutput, createsSourceControlResourceStateobjects, updatesresourceGroups. ScmProviderin Cocoon serializes changes and sends$updateScmGroupgRPC notification to Mountain.- Mountain updates
AppState.ActiveScmProvidersand emitssky://scm/update-groupTauri event.
Phase 3: Rendering the SCM View (Wind/Sky)
- SCM View component in Wind receives the
sky://scm/update-groupevent and re-renders with the list of modified files.
Phase 4: Viewing a Diff
- User clicks a changed file in the SCM view.
vscode.openexecutes with agit:scheme URI. EditorServicecreates aDiffEditorInput:- Modified side: loads from workspace
file://URI viaIFileService(standard read). - Original side:
git:scheme Content Provider sends$gitExecto Mountain withgit show HEAD:path/to/file.
- Modified side: loads from workspace
- Mountain runs the command, returns original content. DiffEditor opens with both sides.
Key Source Files
Cocoon/Source/Services/Extension.ts— extension activationMountain/Source/Environment/SynchronizationProvider.rs— Git provider (verify)Mountain/Source/Environment/LanguageFeatureProvider/Registration.rs— provider registry
