Skip to content

Commit b10f9c0

Browse files
chore(Mountain): standardize naming conventions and directory structure
- Rename `AppState` to `ApplicationState` across Mountain component to align with Land's architectural documentation - Refactor `handlers` directory to `Handler` following project's PascalCase convention for core modules - Update `runtime` references to `RunTime` matching updated terminology in README.md - Normalize gRPC-related abbreviations (e.g. `VineGRPC` -> `VinegRPC`) per style guidelines - Reorganize environment provider implementations to match `Common` trait definitions - Adjust module declarations to use consistent naming for Effect-TS alignment This restructuring improves codebase consistency with Land's final architecture while maintaining all existing functionality for Cocoon integration and gRPC communication.
1 parent 814b8d2 commit b10f9c0

95 files changed

Lines changed: 1557 additions & 1642 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ frontend and the `Cocoon` extension host.
4040

4141
- **Declarative Effect System:** Built on a custom Rust `ActionEffect` system
4242
defined in the `Common` crate. All business logic is described as declarative,
43-
composable effects, which are executed by a central `AppRuntime`.
43+
composable effects, which are executed by a central `ApplicationRunTime`.
4444
- **gRPC-Powered IPC:** Hosts a `tonic`-based gRPC server (`Vine`) to provide a
4545
strongly-typed, high-performance communication channel for the `Cocoon`
4646
extension host.
4747
- **Centralized State Management:** Utilizes a thread-safe, Tauri-managed
48-
`AppState` to act as the single source of truth for the entire application's
49-
state, from open documents to provider registrations.
48+
`ApplicationState` to act as the single source of truth for the entire
49+
application's state, from open documents to provider registrations.
5050
- **Native PTY Management:** Implements a full-featured integrated terminal
5151
service by spawning and managing native pseudo-terminals (`PTY`) using the
5252
`portable-pty` crate.
5353
- **Secure Storage Integration:** Leverages the native OS keychain via the
5454
`keyring` crate to securely store sensitive data like authentication tokens.
5555
- **Robust Command Dispatching:** A central `Track` dispatcher intelligently
5656
routes all incoming requests from the UI (`Wind`) and extensions (`Cocoon`) to
57-
the appropriate native handlers or effects.
57+
the appropriate native Handler or effects.
5858

5959
---
6060

@@ -63,11 +63,11 @@ frontend and the `Cocoon` extension host.
6363
| Principle | Description | Key Components Involved |
6464
| :------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------- |
6565
| **Implementation of Contracts** | Faithfully implement the abstract service `trait`s defined in the `Common` crate, providing the concrete logic for the application's architecture. | `environment/*` providers |
66-
| **Separation of Concerns** | Isolate business logic in `handlers` modules, keeping the `environment` provider implementations clean and focused on delegation. | `environment/*`, `handlers/*` |
67-
| **Declarative Logic** | Express all operations as `ActionEffect`s, which are executed by the `AppRuntime`. This makes logic composable, testable, and robust. | `runtime/*`, `track/*`, `Common::effect` |
68-
| **Centralized State** | Maintain a single, thread-safe `AppState` struct managed by Tauri to ensure data consistency across the entire application. | `app_state/*` |
66+
| **Separation of Concerns** | Isolate business logic in `Handler` modules, keeping the `environment` provider implementations clean and focused on delegation. | `environment/*`, `Handler/*` |
67+
| **Declarative Logic** | Express all operations as `ActionEffect`s, which are executed by the `ApplicationRunTime`. This makes logic composable, testable, and robust. | `RunTime/*`, `track/*`, `Common::effect` |
68+
| **Centralized State** | Maintain a single, thread-safe `ApplicationState` struct managed by Tauri to ensure data consistency across the entire application. | `app_state/*` |
6969
| **Secure & Performant IPC** | Utilize gRPC for all communication with the `Cocoon` sidecar, ensuring a well-defined and high-performance API boundary. | `vine/*` |
70-
| **UI-Backend Decoupling** | Interact with the `Wind` frontend exclusively through asynchronous Tauri commands and events, ensuring the backend is UI-agnostic. | `main.rs` (invoke handler), `handlers/*` (emitters) |
70+
| **UI-Backend Decoupling** | Interact with the `Wind` frontend exclusively through asynchronous Tauri commands and events, ensuring the backend is UI-agnostic. | `main.rs` (invoke handler), `Handler/*` (emitters) |
7171

7272
---
7373

@@ -76,8 +76,8 @@ frontend and the `Cocoon` extension host.
7676
To understand how `Mountain`'s internal components are structured and how they
7777
implement the application's core logic, please refer to the detailed technical
7878
breakdown in [`docs/Deep Dive.md`](docs/Deep%20Dive.md). This document explains
79-
the roles of the `AppRuntime`, `AppState`, `handlers`, `environment`, and the
80-
`Vine` gRPC layer.
79+
the roles of the `ApplicationRunTime`, `ApplicationState`, `Handler`, `environment`,
80+
and the `Vine` gRPC layer.
8181

8282
---
8383

@@ -96,17 +96,17 @@ graph LR
9696
9797
subgraph "Mountain (Native Rust/Tauri Backend)"
9898
TauriRuntime[Tauri App & Window]:::mountain
99-
AppRuntime[AppRuntime Engine]:::mountain
100-
AppState["AppState (Shared State)"]:::mountain
99+
ApplicationRunTime[ApplicationRunTime Engine]:::mountain
100+
ApplicationState["ApplicationState (Shared State)"]:::mountain
101101
TrackDispatcher[Track Dispatcher]:::mountain
102-
VineGRPC[Vine gRPC Server]:::ipc
102+
VinegRPC[Vine gRPC Server]:::ipc
103103
NativeHandlers[Native Logic Handlers]:::mountain
104104
CommonCrate["Common Crate (Traits & DTOs)"]:::common
105105
106-
TauriRuntime -- Manages --> AppState
107-
TauriRuntime -- Manages --> AppRuntime
108-
AppRuntime -- Executes effects via --> NativeHandlers
109-
TrackDispatcher -- Routes requests to --> AppRuntime
106+
TauriRuntime -- Manages --> ApplicationState
107+
TauriRuntime -- Manages --> ApplicationRunTime
108+
ApplicationRunTime -- Executes effects via --> NativeHandlers
109+
TrackDispatcher -- Routes requests to --> ApplicationRunTime
110110
end
111111
112112
subgraph "Clients"
@@ -118,8 +118,8 @@ graph LR
118118
WindUI -- Tauri Commands --> TrackDispatcher
119119
TrackDispatcher -- Tauri Events --> WindUI
120120
121-
VineGRPC -- gRPC Protocol <--> CocoonSidecar; class VineGRPC,CocoonSidecar ipc
122-
VineGRPC -- Forwards requests to --> TrackDispatcher
121+
VinegRPC -- gRPC Protocol <--> CocoonSidecar; class VinegRPC,CocoonSidecar ipc
122+
VinegRPC -- Forwards requests to --> TrackDispatcher
123123
124124
NativeHandlers -- Implements traits from --> CommonCrate
125125
```
@@ -134,13 +134,13 @@ the architectural patterns defined in `Common`.
134134
```
135135
Mountain/
136136
├── Source/
137-
│ ├── main.rs # Tauri application entry point and setup.
138-
│ ├── app_state/ # The central, thread-safe state store for the application.
139-
│ ├── environment/ # Concrete implementations of the `Common` provider traits.
140-
│ ├── handlers/ # The detailed business logic for each service domain.
141-
│ ├── runtime/ # The `AppRuntime` engine that executes effects.
142-
│ ├── track/ # The central request dispatcher.
143-
│ └── vine/ # The gRPC server implementation (using `tonic`).
137+
│ ├── Binary.rs # Tauri application entry point and setup.
138+
│ ├── ApplicationState/ # The central, thread-safe state store for the application.
139+
│ ├── Environment/ # Concrete implementations of the `Common` provider traits.
140+
│ ├── Handlers/ # The detailed business logic for each service domain.
141+
│ ├── Runtime/ # The `ApplicationRunTime` engine that executes effects.
142+
│ ├── Track/ # The central request dispatcher.
143+
│ └── Vine/ # The gRPC server implementation (using `tonic`).
144144
├── proto/
145145
│ └── vine.proto # The gRPC contract definition file.
146146
└── build.rs # Build script to compile the .proto file into Rust code.
@@ -158,7 +158,7 @@ set up, build, and run the entire application.
158158
**Key Dependencies:**
159159

160160
- `tauri`: `^2.x`
161-
- `tokio`: For the asynchronous runtime.
161+
- `tokio`: For the asynchronous RunTime.
162162
- `tonic`: For the gRPC server implementation.
163163
- `serde` & `serde_json`: For serialization.
164164
- `log` & `env_logger`: For logging.

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ not limited to):**
5959
- **Denial of Service (DoS):** If an Element can be made unresponsive or crash
6060
due to specially crafted input or excessive resource consumption.
6161
- **Path Traversal/Arbitrary File Access:** For Elements interacting with the
62-
filesystem (like `River`, `Sun`, or `Mountain`'s FS handlers), ensuring that
62+
filesystem (like `River`, `Sun`, or `Mountain`'s FS Handler), ensuring that
6363
path inputs are properly sanitized.
6464
- **Insecure IPC/Communication:** For Elements involved in inter-process
6565
communication (`Vine`, `Track`, `Echo`, `Mist`), vulnerabilities in the

Source/ApplicationState/ApplicationState.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ use std::{
99
};
1010

1111
use log::{error, info, warn};
12-
use tauri::{AppHandle, Manager, Wry};
12+
use tauri::{ApplicationHandle, Manager, Wry};
1313

14-
/// @module AppState
15-
/// @description Defines the main `AppState` struct, which is the central,
16-
/// shared, thread-safe state for the entire Mountain application. It is managed
17-
/// by Tauri and accessible to all commands and environment providers.
18-
use super::{Dto::*, Internal};
19-
use crate::handlers::commands::CommandHandler;
14+
// @module ApplicationState
15+
// @description Defines the main `ApplicationState` struct, which is the central,
16+
// shared, thread-safe state for the entire Mountain application. It is managed
17+
// by Tauri and accessible to all commands and environment providers.
18+
use super::{DTO::*, Internal};
19+
use crate::Handler::commands::CommandHandler;
2020

21-
/// The central, shared, thread-safe state for the entire Mountain application.
21+
// The central, shared, thread-safe state for the entire Mountain application.
2222
#[derive(Clone)]
23-
pub struct AppState {
23+
pub struct ApplicationState {
2424
// Workspace State
2525
pub WorkspaceFolders:Arc<StdMutex<Vec<WorkspaceFolderStateDto>>>,
2626
pub WorkspaceConfigurationPath:Arc<StdMutex<Option<PathBuf>>>,
@@ -59,21 +59,21 @@ pub struct AppState {
5959
>,
6060
}
6161

62-
impl Default for AppState {
62+
impl Default for ApplicationState {
6363
fn default() -> Self {
64-
info!("[AppState] Initializing default application state...");
64+
info!("[ApplicationState] Initializing default application state...");
6565
let AppNameForPaths = env!("CARGO_PKG_NAME");
6666
let AppDataDirectoryPath = dirs::config_dir().map(|p| p.join(AppNameForPaths)).unwrap_or_else(|| {
67-
warn!("[AppState] Could not get config dir. Using relative path.");
67+
warn!("[ApplicationState] Could not get config dir. Using relative path.");
6868
PathBuf::from(format!(".{}-appdata", AppNameForPaths))
6969
});
7070
Internal::EnsureDirectoryExists(&AppDataDirectoryPath);
7171

7272
let GlobalMementoFilePath = Internal::ResolveMementoStorageFilePath(&AppDataDirectoryPath, true, "");
7373
let InitialGlobalMementoMap = Internal::LoadInitialMementoFromDisk(&GlobalMementoFilePath);
74-
let InitialCommandRegistryMap = crate::handlers::commands::RegisterNativeCommands();
74+
let InitialCommandRegistryMap = crate::Handler::commands::RegisterNativeCommands();
7575

76-
info!("[AppState] Default state initialization complete.");
76+
info!("[ApplicationState] Default state initialization complete.");
7777
Self {
7878
WorkspaceFolders:Arc::new(StdMutex::new(Vec::new())),
7979
WorkspaceConfigurationPath:Arc::new(StdMutex::new(None)),
@@ -104,7 +104,7 @@ impl Default for AppState {
104104
}
105105
}
106106

107-
impl AppState {
107+
impl ApplicationState {
108108
// All helper methods from the provided source are preserved here...
109109
pub fn GetWorkspaceIdentifier(&self) -> Result<String, String> {
110110
// ...
@@ -120,7 +120,7 @@ impl AppState {
120120

121121
pub fn GetNextTerminalIdentifier(&self) -> u64 { self.NextTerminalIdentifier.fetch_add(1, AtomicOrdering::Relaxed) }
122122

123-
pub async fn ScanExtensions(&self, AppHandle:&AppHandle<Wry>) { /* ... */
123+
pub async fn ScanExtensions(&self, ApplicationHandle:&ApplicationHandle<Wry>) { /* ...//
124124
}
125125

126126
pub fn UpdateWorkspaceMementoPathAndReload(&self, AppDataDirectory:&Path) -> Result<(), String> {
Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
1-
2-
3-
/**
4-
* @module CustomDocumentStateDto
5-
* @description Defines the Data Transfer Object for storing the state of a single
6-
* custom editor document.
7-
*/
1+
// @module CustomDocumentStateDto
2+
// @description Defines the Data Transfer Object for storing the state of a
3+
// single custom editor document.
4+
//
85

96
#![allow(non_snake_case, non_camel_case_types)]
107

11-
use super::super::Internal::UrlSerdeHelper;
12-
use serde::{Deserialize, Serialize};
138
use std::collections::HashMap;
9+
10+
use serde::{Deserialize, Serialize};
1411
use url::Url;
1512

16-
/**
17-
* A struct that holds the state for a document being handled by a custom editor.
18-
* This is stored in `AppState` to track the lifecycle of custom documents.
19-
*/
13+
use super::super::Internal::UrlSerdeHelper;
14+
15+
// A struct that holds the state for a document being handled by a custom
16+
// editor. This is stored in `ApplicationState` to track the lifecycle of custom
17+
// documents.
18+
//
2019
#[derive(Serialize, Deserialize, Debug, Clone)]
2120
#[serde(rename_all = "PascalCase")]
2221
pub struct CustomDocumentStateDto {
23-
/// The URI of the document resource being edited.
24-
#[serde(with = "UrlSerdeHelper")]
25-
pub Uri: Url,
22+
// The URI of the document resource being edited.
23+
#[serde(with = "UrlSerdeHelper")]
24+
pub Uri:Url,
2625

27-
/// The view type of the custom editor responsible for this document.
28-
pub ViewType: String,
26+
// The view type of the custom editor responsible for this document.
27+
pub ViewType:String,
2928

30-
/// The identifier of the sidecar process where the custom editor provider lives.
31-
pub SidecarIdentifier: String,
29+
// The identifier of the sidecar process where the custom editor provider lives.
30+
pub SidecarIdentifier:String,
3231

33-
/// A flag indicating if the document is currently editable by the user.
34-
pub IsEditable: bool,
32+
// A flag indicating if the document is currently editable by the user.
33+
pub IsEditable:bool,
3534

36-
/// An optional identifier for a backup copy of the file's content.
37-
#[serde(skip_serializing_if = "Option::is_none")]
38-
pub BackupId: Option<String>,
35+
// An optional identifier for a backup copy of the file's content.
36+
#[serde(skip_serializing_if = "Option::is_none")]
37+
pub BackupId:Option<String>,
3938

40-
/// A map to store edit history or other versioning information.
41-
/// In a real implementation, this might hold a more structured edit type.
42-
pub Edits: HashMap<u32, serde_json::Value>,
39+
// A map to store edit history or other versioning information.
40+
// In a real implementation, this might hold a more structured edit type.
41+
pub Edits:HashMap<u32, serde_json::Value>,
4342
}
Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,44 @@
1-
2-
3-
/**
4-
* @module WebviewStateDto
5-
* @description Defines the Data Transfer Object for storing the state of a single
6-
* active webview panel.
7-
*/
1+
// @module WebviewStateDto
2+
// @description Defines the Data Transfer Object for storing the state of a
3+
// single active webview panel.
4+
//
85

96
#![allow(non_snake_case, non_camel_case_types)]
107

118
use Common::webview::dto::{WebviewContentOptionsDto, WebviewPanelOptionsDto};
129
use serde::{Deserialize, Serialize};
1310

14-
/**
15-
* A struct that holds the complete state for a single webview panel instance.
16-
* This is stored in `AppState` to track all active webviews managed by the host.
17-
*/
11+
// A struct that holds the complete state for a single webview panel instance.
12+
// This is stored in `ApplicationState` to track all active webviews managed by
13+
// the host.
14+
//
1815
#[derive(Serialize, Deserialize, Debug, Clone)]
1916
#[serde(rename_all = "PascalCase")]
2017
pub struct WebviewStateDto {
21-
/// A unique UUID handle for this webview instance.
22-
pub Handle: String,
18+
// A unique UUID handle for this webview instance.
19+
pub Handle:String,
2320

24-
/// The view type of this webview panel, as defined by the extension.
25-
pub ViewType: String,
21+
// The view type of this webview panel, as defined by the extension.
22+
pub ViewType:String,
2623

27-
/// The current title of the webview panel.
28-
pub Title: String,
24+
// The current title of the webview panel.
25+
pub Title:String,
2926

30-
/// The content and security options for the webview's content.
31-
pub ContentOptions: WebviewContentOptionsDto,
27+
// The content and security options for the webview's content.
28+
pub ContentOptions:WebviewContentOptionsDto,
3229

33-
/// The options controlling the behavior of the webview panel itself.
34-
pub PanelOptions: WebviewPanelOptionsDto,
30+
// The options controlling the behavior of the webview panel itself.
31+
pub PanelOptions:WebviewPanelOptionsDto,
3532

36-
/// The identifier of the sidecar process that owns this webview.
37-
pub SidecarIdentifier: String,
33+
// The identifier of the sidecar process that owns this webview.
34+
pub SidecarIdentifier:String,
3835

39-
/// The identifier of the extension that owns this webview.
40-
pub ExtensionId: String,
36+
// The identifier of the extension that owns this webview.
37+
pub ExtensionId:String,
4138

42-
/// A flag indicating if the webview panel currently has focus.
43-
pub IsActive: bool,
39+
// A flag indicating if the webview panel currently has focus.
40+
pub IsActive:bool,
4441

45-
/// A flag indicating if the webview panel is currently visible in the UI.
46-
pub IsVisible: bool,
42+
// A flag indicating if the webview panel is currently visible in the UI.
43+
pub IsVisible:bool,
4744
}

Source/ApplicationState/DTO/mod.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
2-
3-
/**
4-
* @module Dto (AppState)
5-
* @description This module aggregates and re-exports all Data Transfer Objects (DTOs)
6-
* that are used to represent the various components of the application's central state.
7-
*/
1+
// @module DTO (ApplicationState)
2+
// @description This module aggregates and re-exports all Data Transfer Objects
3+
// (DTOs) that are used to represent the various components of the application's
4+
// central state.
5+
//
86

97
#![allow(non_snake_case, non_camel_case_types)]
108

@@ -25,17 +23,19 @@ mod WindowStateDto;
2523
mod WorkspaceFolderStateDto;
2624

2725
// --- Public Re-exports (alphabetical) ---
28-
pub use self::ConfigurationStateDto::MergedConfigurationStateDto;
29-
pub use self::CustomDocumentStateDto::CustomDocumentStateDto;
30-
pub use self::DocumentStateDto::DocumentStateDto;
31-
pub use self::ExtensionDescriptionStateDto::ExtensionDescriptionStateDto;
32-
pub use self::HierarchySessionContextDto::HierarchySessionContextDto;
33-
pub use self::MarkerDataDto::MarkerDataDto;
34-
pub use self::OutputChannelStateDto::OutputChannelStateDto;
35-
pub use self::ProviderRegistrationDto::ProviderRegistrationDto;
36-
pub use self::RpcModelContentChangeDto::{RpcModelContentChangeDto, RpcRangeDto};
37-
pub use self::TerminalStateDto::TerminalStateDto;
38-
pub use self::TreeViewStateDto::TreeViewStateDto;
39-
pub use self::WebviewStateDto::WebviewStateDto;
40-
pub use self::WindowStateDto::WindowStateDto;
41-
pub use self::WorkspaceFolderStateDto::WorkspaceFolderStateDto;
26+
pub use self::{
27+
ConfigurationStateDto::MergedConfigurationStateDto,
28+
CustomDocumentStateDto::CustomDocumentStateDto,
29+
DocumentStateDto::DocumentStateDto,
30+
ExtensionDescriptionStateDto::ExtensionDescriptionStateDto,
31+
HierarchySessionContextDto::HierarchySessionContextDto,
32+
MarkerDataDto::MarkerDataDto,
33+
OutputChannelStateDto::OutputChannelStateDto,
34+
ProviderRegistrationDto::ProviderRegistrationDto,
35+
RpcModelContentChangeDto::{RpcModelContentChangeDto, RpcRangeDto},
36+
TerminalStateDto::TerminalStateDto,
37+
TreeViewStateDto::TreeViewStateDto,
38+
WebviewStateDto::WebviewStateDto,
39+
WindowStateDto::WindowStateDto,
40+
WorkspaceFolderStateDto::WorkspaceFolderStateDto,
41+
};

0 commit comments

Comments
 (0)