Skip to content

Commit c1dcd82

Browse files
refactor(Mountain): Rename workspace to workSpace and add critical dependencies
- Renamed all `Workspace` references to `WorkSpace` in ApplicationState and Environment providers to align with architectural naming conventions - Added `parking_lot`, `lazy_static`, and `portable-pty` dependencies to support synchronization primitives and terminal functionality - Updated type references (e.g. `StatusBarEntryDTO`) to match Common crate definitions - Adjusted gRPC service method names to proper PascalCase convention - Fixed environment initialization with unsafe handling for logging setup - Temporarily disabled gRPC generated code inclusion during refactoring This refactor maintains existing functionality while ensuring consistency with Land's architecture and preparing for terminal and gRPC features. The changes impact core state management and environment providers but don't introduce behavioral changes.
1 parent ee16d80 commit c1dcd82

40 files changed

Lines changed: 250 additions & 218 deletions

Cargo.toml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,45 @@ tauri-build = { workspace = true, features = [] }
1111
toml = { workspace = true }
1212

1313
[dependencies]
14-
tokio = { workspace = true, features = ["full"] }
15-
async-trait = { workspace = true }
16-
futures-util = { workspace = true, features = ["sink", "std"] }
17-
once_cell = { workspace = true }
18-
tauri = { version = "2.5.1", features = [
14+
tauri = { version = "*", features = [
1915
"wry",
2016
"tray-icon",
2117
"devtools",
2218
"rustls-tls",
2319
"compression",
2420
], default-features = false }
25-
log = { workspace = true }
26-
env_logger = { workspace = true }
21+
22+
tauri-plugin-dialog = { workspace = true }
23+
24+
async-trait = { workspace = true }
25+
base64 = { workspace = true }
26+
chrono = { workspace = true, features = ["serde"] }
2727
colored = { workspace = true }
28-
tokio-tungstenite = { workspace = true, features = ["rustls-tls-native-roots"] }
28+
Common = { workspace = true }
2929
dirs = { workspace = true }
30-
ignore = { workspace = true }
30+
Echo = { workspace = true }
31+
env_logger = { workspace = true }
32+
futures-util = { workspace = true, features = ["sink", "std"] }
3133
globset = { workspace = true }
34+
ignore = { workspace = true }
3235
keyring = { workspace = true }
33-
base64 = { workspace = true }
34-
url = { workspace = true, features = ["serde"] }
35-
uuid = { workspace = true, features = ["v4", "serde"] }
36-
chrono = { workspace = true, features = ["serde"] }
37-
thiserror = { workspace = true }
38-
Echo = { workspace = true }
39-
Common = { workspace = true }
40-
serde_json = { workspace = true }
41-
serde = { workspace = true }
42-
toml = { workspace = true }
36+
log = { workspace = true }
4337
md5 = { workspace = true }
4438
num_cpus = { workspace = true }
39+
once_cell = { workspace = true }
4540
rand = { workspace = true }
46-
47-
tauri-plugin-dialog = { workspace = true }
41+
serde = { workspace = true }
42+
serde_json = { workspace = true }
43+
thiserror = { workspace = true }
44+
tokio = { workspace = true, features = ["full"] }
45+
tokio-tungstenite = { workspace = true, features = ["rustls-tls-native-roots"] }
46+
toml = { workspace = true }
47+
tonic = { workspace = true }
48+
url = { workspace = true, features = ["serde"] }
49+
uuid = { workspace = true, features = ["v4", "serde"] }
50+
parking_lot = { workspace = true }
51+
lazy_static = { workspace = true }
52+
portable-pty = { workspace = true }
4853

4954
# regex = { workspace = true }
5055
# unbug = { workspace = true }

Source/ApplicationState/ApplicationState.rs

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,25 @@ use std::{
1616
};
1717

1818
use log::{error, info, warn};
19-
use tauri::{AppHandle, Manager, Runtime};
20-
21-
use super::{DTO::*, Internal};
19+
use tauri::{Manager, Runtime};
20+
21+
use super::{
22+
DTO::{
23+
CustomDocumentStateDTO::CustomDocumentStateDTO,
24+
DocumentStateDTO::DocumentStateDTO,
25+
ExtensionDescriptionStateDTO::ExtensionDescriptionStateDTO,
26+
MarkerDataDTO::MarkerDataDTO,
27+
MergedConfigurationStateDTO::MergedConfigurationStateDTO,
28+
OutputChannelStateDTO::OutputChannelStateDTO,
29+
ProviderRegistrationDTO::ProviderRegistrationDTO,
30+
TerminalStateDTO::TerminalStateDTO,
31+
TreeViewStateDTO::TreeViewStateDTO,
32+
WebViewStateDTO::WebViewStateDTO,
33+
WindowStateDTO::WindowStateDTO,
34+
WorkSpaceFolderStateDTO::WorkSpaceFolderStateDTO,
35+
},
36+
Internal,
37+
};
2238
use crate::Environment::CommandProvider::CommandHandler; // TODO: Fix this path after refactor
2339

2440
/// The central, shared, thread-safe state for the entire Mountain application.
@@ -28,21 +44,21 @@ use crate::Environment::CommandProvider::CommandHandler; // TODO: Fix this path
2844
/// like terminals and WebViews.
2945
#[derive(Clone)]
3046
pub struct ApplicationState {
31-
// --- Workspace State ---
32-
pub WorkspaceFolders:Arc<StandardMutex<Vec<WorkspaceFolderStateDTO>>>,
33-
pub WorkspaceConfigurationPath:Arc<StandardMutex<Option<PathBuf>>>,
47+
// --- WorkSpace State ---
48+
pub WorkSpaceFolders:Arc<StandardMutex<Vec<WorkSpaceFolderStateDTO>>>,
49+
pub WorkSpaceConfigurationPath:Arc<StandardMutex<Option<PathBuf>>>,
3450
pub IsTrusted:Arc<AtomicBool>,
3551
pub WindowState:Arc<StandardMutex<WindowStateDTO>>,
3652

3753
// --- Configuration & Storage ---
3854
pub Configuration:Arc<StandardMutex<MergedConfigurationStateDTO>>,
3955
pub GlobalMemento:Arc<StandardMutex<HashMap<String, serde_json::Value>>>,
4056
pub GlobalMementoPath:PathBuf,
41-
pub WorkspaceMemento:Arc<StandardMutex<HashMap<String, serde_json::Value>>>,
42-
pub WorkspaceMementoPath:Arc<StandardMutex<Option<PathBuf>>>,
57+
pub WorkSpaceMemento:Arc<StandardMutex<HashMap<String, serde_json::Value>>>,
58+
pub WorkSpaceMementoPath:Arc<StandardMutex<Option<PathBuf>>>,
4359

4460
// --- Extension & Provider Management ---
45-
pub CommandRegistry:Arc<StandardMutex<HashMap<String, CommandHandler<Runtime>>>>,
61+
pub CommandRegistry:Arc<StandardMutex<HashMap<String, CommandHandler<dyn Runtime>>>>,
4662
pub LanguageProviders:Arc<StandardMutex<HashMap<u32, ProviderRegistrationDTO>>>,
4763
pub NextProviderHandle:Arc<AtomicU32>,
4864
pub ScannedExtensions:Arc<StandardMutex<HashMap<String, ExtensionDescriptionStateDTO>>>,
@@ -57,13 +73,17 @@ pub struct ApplicationState {
5773
pub NextTerminalIdentifier:Arc<AtomicU64>,
5874
pub ActiveWebViews:Arc<StandardMutex<HashMap<String, WebViewStateDTO>>>,
5975
pub ActiveCustomDocuments:Arc<StandardMutex<HashMap<String, CustomDocumentStateDTO>>>,
60-
pub ActiveStatusBarItems:Arc<StandardMutex<HashMap<String, Common::StatusBar::DTO::StatusBarEntryDTO>>>,
76+
pub ActiveStatusBarItems:
77+
Arc<StandardMutex<HashMap<String, Common::StatusBar::DTO::StatusBarEntryDTO::StatusBarEntryDTO>>>,
6178
pub ActiveTreeViews:Arc<StandardMutex<HashMap<String, TreeViewStateDTO>>>,
6279

6380
// --- IPC & User Interface State ---
6481
pub PendingUserInterfaceRequests: Arc<
6582
StandardMutex<
66-
HashMap<String, tokio::sync::oneshot::Sender<Result<serde_json::Value, Common::Error::CommonError>>>,
83+
HashMap<
84+
String,
85+
tokio::sync::oneshot::Sender<Result<serde_json::Value, Common::Error::CommonError::CommonError>>,
86+
>,
6787
>,
6888
>,
6989
}
@@ -99,15 +119,15 @@ impl Default for ApplicationState {
99119

100120
info!("[ApplicationState] Default state initialization complete.");
101121
Self {
102-
WorkspaceFolders:Arc::new(StandardMutex::new(Vec::new())),
103-
WorkspaceConfigurationPath:Arc::new(StandardMutex::new(None)),
122+
WorkSpaceFolders:Arc::new(StandardMutex::new(Vec::new())),
123+
WorkSpaceConfigurationPath:Arc::new(StandardMutex::new(None)),
104124
IsTrusted:Arc::new(AtomicBool::new(false)),
105125
WindowState:Arc::new(StandardMutex::new(Default::default())),
106126
Configuration:Arc::new(StandardMutex::new(MergedConfigurationStateDTO::default())),
107127
GlobalMemento:Arc::new(StandardMutex::new(InitialGlobalMementoMap)),
108128
GlobalMementoPath:GlobalMementoFilePath,
109-
WorkspaceMemento:Arc::new(StandardMutex::new(HashMap::new())),
110-
WorkspaceMementoPath:Arc::new(StandardMutex::new(None)),
129+
WorkSpaceMemento:Arc::new(StandardMutex::new(HashMap::new())),
130+
WorkSpaceMementoPath:Arc::new(StandardMutex::new(None)),
111131
CommandRegistry:Arc::new(StandardMutex::new(HashMap::new())), // TODO: Use InitialCommandRegistryMap
112132
DiagnosticsMap:Arc::new(StandardMutex::new(HashMap::new())),
113133
OpenDocuments:Arc::new(StandardMutex::new(HashMap::new())),
@@ -131,15 +151,15 @@ impl Default for ApplicationState {
131151
impl ApplicationState {
132152
/// Generates a unique, filesystem-safe identifier string for the current
133153
/// workspace.
134-
pub fn GetWorkspaceIdentifier(&self) -> Result<String, String> {
154+
pub fn GetWorkSpaceIdentifier(&self) -> Result<String, String> {
135155
let LockErrorMapper = |e| format!("[AppState] Lock error: {}", e);
136-
let ConfigurationPathGuard = self.WorkspaceConfigurationPath.lock().map_err(LockErrorMapper)?;
156+
let ConfigurationPathGuard = self.WorkSpaceConfigurationPath.lock().map_err(LockErrorMapper)?;
137157
if let Some(ConfigurationPath) = ConfigurationPathGuard.as_ref() {
138158
return Ok(ConfigurationPath.file_name().unwrap_or_default().to_string_lossy().into_owned());
139159
}
140160
drop(ConfigurationPathGuard);
141161

142-
let FoldersGuard = self.WorkspaceFolders.lock().map_err(LockErrorMapper)?;
162+
let FoldersGuard = self.WorkSpaceFolders.lock().map_err(LockErrorMapper)?;
143163
if let Some(FirstFolder) = FoldersGuard.first() {
144164
let PathString = FirstFolder.URI.path();
145165
// Create a more stable hash for the identifier.
@@ -163,21 +183,21 @@ impl ApplicationState {
163183

164184
/// Updates the path to the workspace memento file and reloads its content
165185
/// from disk.
166-
pub fn UpdateWorkspaceMementoPathAndReload(&self, ApplicationDataDirectory:&Path) -> Result<(), String> {
186+
pub fn UpdateWorkSpaceMementoPathAndReload(&self, ApplicationDataDirectory:&Path) -> Result<(), String> {
167187
let LockErrorMapper = |e| format!("[AppState] Lock error: {}", e);
168-
let WorkspaceIdentifier = self.GetWorkspaceIdentifier()?;
169-
let mut PathGuard = self.WorkspaceMementoPath.lock().map_err(LockErrorMapper)?;
188+
let WorkSpaceIdentifier = self.GetWorkSpaceIdentifier()?;
189+
let mut PathGuard = self.WorkSpaceMementoPath.lock().map_err(LockErrorMapper)?;
170190

171-
if WorkspaceIdentifier == "NO_WORKSPACE" {
191+
if WorkSpaceIdentifier == "NO_WORKSPACE" {
172192
if PathGuard.is_some() {
173193
*PathGuard = None;
174-
self.WorkspaceMemento.lock().map_err(LockErrorMapper)?.clear();
194+
self.WorkSpaceMemento.lock().map_err(LockErrorMapper)?.clear();
175195
}
176196
return Ok(());
177197
}
178198

179199
let NewMementoPath =
180-
Internal::ResolveMementoStorageFilePath(ApplicationDataDirectory, false, &WorkspaceIdentifier);
200+
Internal::ResolveMementoStorageFilePath(ApplicationDataDirectory, false, &WorkSpaceIdentifier);
181201
if PathGuard.as_ref() != Some(&NewMementoPath) {
182202
if let Some(Parent) = NewMementoPath.parent() {
183203
if !Parent.exists() {
@@ -186,7 +206,7 @@ impl ApplicationState {
186206
}
187207
*PathGuard = Some(NewMementoPath.clone());
188208
let NewMementoContent = Internal::LoadInitialMementoFromDisk(&NewMementoPath);
189-
*self.WorkspaceMemento.lock().map_err(LockErrorMapper)? = NewMementoContent;
209+
*self.WorkSpaceMemento.lock().map_err(LockErrorMapper)? = NewMementoContent;
190210
}
191211
Ok(())
192212
}

Source/ApplicationState/DTO/ProviderRegistrationDTO.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
#![allow(non_snake_case, non_camel_case_types)]
77

8-
use Common::LanguageFeature::DTO::ProviderType;
8+
use Common::LanguageFeature::DTO::ProviderType::ProviderType;
99
use serde::{Deserialize, Serialize};
1010
use serde_json::Value;
1111

Source/ApplicationState/DTO/TerminalStateDTO.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
66
#![allow(non_snake_case, non_camel_case_types)]
77

8-
use std::{
9-
collections::HashMap,
10-
path::PathBuf,
11-
sync::{Arc, Mutex as StandardMutex},
12-
};
8+
use std::{collections::HashMap, path::PathBuf, sync::Arc};
139

1410
use serde_json::Value;
1511
use tokio::{

Source/ApplicationState/DTO/WebViewStateDTO.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
#![allow(non_snake_case, non_camel_case_types)]
77

8-
use Common::WebView::DTO::WebViewContentOptionsDTO;
8+
use Common::WebView::DTO::WebViewContentOptionsDTO::WebViewContentOptionsDTO;
99
use serde::{Deserialize, Serialize};
1010
use serde_json::Value; // For PanelOptions, etc.
1111

Source/ApplicationState/DTO/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub mod TerminalStateDTO;
1919
pub mod TreeViewStateDTO;
2020
pub mod WebViewStateDTO;
2121
pub mod WindowStateDTO;
22-
pub mod WorkspaceFolderStateDTO;
22+
pub mod WorkSpaceFolderStateDTO;
2323

2424
// --- Public Re-exports (alphabetical) ---
2525
// pub use self::CustomDocumentStateDTO::CustomDocumentStateDTO;
@@ -34,4 +34,4 @@ pub mod WorkspaceFolderStateDTO;
3434
// pub use self::TreeViewStateDTO::TreeViewStateDTO;
3535
// pub use self::WebViewStateDTO::WebViewStateDTO;
3636
// pub use self::WindowStateDTO::WindowStateDTO;
37-
// pub use self::WorkspaceFolderStateDTO::WorkspaceFolderStateDTO;
37+
// pub use self::WorkSpaceFolderStateDTO::WorkSpaceFolderStateDTO;

Source/ApplicationState/Internal.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,25 @@ pub fn LoadInitialMementoFromDisk(StorageFilePath:&Path) -> HashMap<String, Valu
5555
pub fn ResolveMementoStorageFilePath(
5656
ApplicationDataDirectory:&Path,
5757
IsGlobalScope:bool,
58-
WorkspaceIdentifier:&str,
58+
WorkSpaceIdentifier:&str,
5959
) -> std::path::PathBuf {
6060
let UserStorageBasePath = ApplicationDataDirectory.join("User");
6161
if IsGlobalScope {
6262
UserStorageBasePath.join("globalStorage.json")
6363
} else {
6464
// Sanitize the workspace identifier to be a safe directory name.
65-
let Segment = WorkspaceIdentifier.replace(|c:char| !c.is_alphanumeric() && c != '-' && c != '_', "_");
65+
let Segment = WorkSpaceIdentifier.replace(|c:char| !c.is_alphanumeric() && c != '-' && c != '_', "_");
6666
UserStorageBasePath.join("workspaceStorage").join(Segment).join("storage.json")
6767
}
6868
}
6969

7070
/// A helper module for serializing and deserializing `url::Url` with `serde`.
7171
/// This is used in DTOs where a `Url` field needs to be serialized to a string.
7272
pub mod URLSerializationHelper {
73+
use serde::Deserialize;
74+
7375
use super::*;
76+
7477
pub fn serialize<S>(URLInstance:&Url, SerializerInstance:S) -> Result<S::Ok, S::Error>
7578
where
7679
S: Serializer, {

Source/Binary.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::{
2727
fn InitializeLogging() {
2828
let LogLevel = if cfg!(debug_assertions) { "debug" } else { "info" };
2929
if std::env::var("RUST_LOG").is_err() {
30-
std::env::set_var("RUST_LOG", LogLevel);
30+
unsafe { std::env::set_var("RUST_LOG", LogLevel) };
3131
}
3232
env_logger::init();
3333
}

Source/Environment/CommandProvider.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use Common::{Command::CommandExecutor, Error::CommonError, IPC::DTO::ProxyTarget
1111
use async_trait::async_trait;
1212
use log::{debug, error, info};
1313
use serde_json::{Value, json};
14-
use tauri::{AppHandle, Manager, Runtime, Window};
14+
use tauri::{Manager, Runtime, Window};
1515

16-
use super::MountainEnvironment;
16+
use super::MountainEnvironment::MountainEnvironment;
1717
use crate::{ApplicationState::ApplicationState::ApplicationState, RunTime::ApplicationRunTime, Vine::Client};
1818

1919
/// An enum representing the different ways a command can be handled.

Source/Environment/ConfigurationProvider.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ use Common::{
1313
ConfigurationProvider,
1414
DTO::{ConfigurationOverridesDTO, ConfigurationTarget, InspectResultDataDTO},
1515
},
16-
Error::CommonError,
16+
Error::CommonError::CommonError,
1717
FileSystem::{FileSystemReader, FileSystemWriter},
1818
};
1919
use async_trait::async_trait;
2020
use log::{debug, error, info, warn};
2121
use serde_json::{Map, Value};
2222

23-
use super::MountainEnvironment;
23+
use super::MountainEnvironment::MountainEnvironment;
2424
// TODO: Re-integrate IPC client for notifications
2525
// use crate::Vine::Client;
2626

@@ -60,9 +60,9 @@ impl ConfigurationProvider for MountainEnvironment {
6060
.app_config_dir()
6161
.map(|p| p.join("settings.json"))
6262
},
63-
ConfigurationTarget::Workspace => {
63+
ConfigurationTarget::WorkSpace => {
6464
self.ApplicationState
65-
.WorkspaceConfigurationPath
65+
.WorkSpaceConfigurationPath
6666
.lock()
6767
.map_err(super::Utility::MapApplicationStateLockErrorToCommonError)?
6868
.clone()
@@ -150,16 +150,16 @@ pub async fn InitializeAndMergeConfigurations(Environment:&MountainEnvironment)
150150
.app_config_dir()
151151
.map(|p| p.join("settings.json"));
152152

153-
let WorkspaceSettingsPath = Environment.ApplicationState.WorkspaceConfigurationPath.lock().unwrap().clone();
153+
let WorkSpaceSettingsPath = Environment.ApplicationState.WorkSpaceConfigurationPath.lock().unwrap().clone();
154154

155155
let UserConfig = ReadAndParseConfigurationFile(Environment, &UserSettingsPath).await;
156-
let WorkspaceConfig = ReadAndParseConfigurationFile(Environment, &WorkspaceSettingsPath).await;
156+
let WorkSpaceConfig = ReadAndParseConfigurationFile(Environment, &WorkSpaceSettingsPath).await;
157157

158158
// A real implementation would also load default and folder-level settings.
159159
// The merge order is critical: workspace settings override user settings.
160160
let mut Merged = UserConfig.as_object().cloned().unwrap_or_default();
161-
if let Some(WorkspaceMap) = WorkspaceConfig.as_object() {
162-
for (k, v) in WorkspaceMap {
161+
if let Some(WorkSpaceMap) = WorkSpaceConfig.as_object() {
162+
for (k, v) in WorkSpaceMap {
163163
Merged.insert(k.clone(), v.clone());
164164
}
165165
}

0 commit comments

Comments
 (0)