Skip to content

Commit c33ba0e

Browse files
chore(format)
Signed-off-by: Nikola Hristov <Nikola@PlayForm.Cloud>
1 parent d6b2821 commit c33ba0e

188 files changed

Lines changed: 7598 additions & 8540 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.

Source/Air/AirClient.rs

Lines changed: 1046 additions & 1231 deletions
Large diffs are not rendered by default.

Source/Air/AirServiceProvider.rs

Lines changed: 611 additions & 677 deletions
Large diffs are not rendered by default.

Source/Air/mod.rs

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@
1515
//! - Used by multiple Mountain components:
1616
//! - [`UpdateService`](crate::Update::UpdateService) for self-updates
1717
//! - [`SearchProvider`](crate::Environment::SearchProvider) for file search
18-
//! - [`SecretProvider`](crate::Environment::SecretProvider) for secret storage
19-
//! - Connection is optional; Mountain can function without Air (graceful degradation)
18+
//! - [`SecretProvider`](crate::Environment::SecretProvider) for secret
19+
//! storage
20+
//! - Connection is optional; Mountain can function without Air (graceful
21+
//! degradation)
2022
//! - Service discovery and health checking via gRPC
2123
//!
2224
//! MODULE STRUCTURE:
2325
//! - `AirClient` - gRPC client wrapper with connection management
24-
//! - `AirServiceProvider` - high-level provider with automatic request ID generation
25-
//! - `AirServiceTypesStub` - stub types for when Air library is unavailable (legacy)
26+
//! - `AirServiceProvider` - high-level provider with automatic request ID
27+
//! generation
28+
//! - `AirServiceTypesStub` - stub types for when Air library is unavailable
29+
//! (legacy)
2630
//!
2731
//! CONNECTION PATTERNS:
2832
//! - Uses tonic gRPC client for transport
@@ -31,25 +35,30 @@
3135
//! - Thread-safe operations via Arc<AirClient>
3236
//!
3337
//! ERROR HANDLING:
34-
//! - All gRPC errors translated to [`CommonError::IPCError`](CommonLibrary::Error::CommonError)
38+
//! - All gRPC errors translated to
39+
//! [`CommonError::IPCError`](CommonLibrary::Error::CommonError)
3540
//! - Connection failures logged and return error
36-
//! - Service unavailability handled gracefully (return error, caller decides fallback)
41+
//! - Service unavailability handled gracefully (return error, caller decides
42+
//! fallback)
3743
//!
3844
//! PERFORMANCE:
3945
//! - gRPC channels are expensive; reuse via Arc<AirClient>
4046
//! - Non-blocking async operations via tokio
4147
//! - Request ID generation for tracing
4248
//!
4349
//! VS CODE REFERENCE:
44-
//! - `vs/platform/telemetry/common/telemetry.ts` - telemetry/analytics service pattern
50+
//! - `vs/platform/telemetry/common/telemetry.ts` - telemetry/analytics service
51+
//! pattern
4552
//! - `vs/platform/update/common/update.ts` - update service integration
46-
//! - `vs/workbench/services/search/common/search.ts` - search service architecture
53+
//! - `vs/workbench/services/search/common/search.ts` - search service
54+
//! architecture
4755
//!
4856
//! TODO:
4957
//! - Implement connection retry with exponential backoff
5058
//! - Add connection pooling for multiple concurrent requests
5159
//! - Implement request caching for frequently accessed data (auth tokens, etc.)
52-
//! - Add metrics collection for Air service calls (latency, success rate, errors)
60+
//! - Add metrics collection for Air service calls (latency, success rate,
61+
//! errors)
5362
//! - Implement fallback strategies when Air unavailable (local search, etc.)
5463
//! - Support for multiple Air daemons (load balancing/failover)
5564
//! - Add request timeout configuration (configurable per operation type)
@@ -58,23 +67,35 @@
5867
//! - Implement bidirectional streaming for real-time updates
5968
//!
6069
//! MODULE CONTENTS:
61-
//! - Re-exports: `AirClient`, `AirServiceProvider`, response types, and helper functions
70+
//! - Re-exports: `AirClient`, `AirServiceProvider`, response types, and helper
71+
//! functions
6272
6373
// Module sub-modules
6474
pub mod AirClient;
6575
pub mod AirServiceProvider;
6676

6777
// Access AirClient struct as: crate::Air::AirClient::AirClient
6878
pub use AirClient::{
69-
AirMetrics, AirStatus, DownloadStream, DownloadStreamChunk, ExtendedFileInfo,
70-
FileInfo, FileResult, IndexInfo, ResourceUsage, UpdateInfo, DEFAULT_AIR_SERVER_ADDRESS,
79+
AirClient,
80+
AirMetrics,
81+
AirStatus,
82+
DEFAULT_AIR_SERVER_ADDRESS,
83+
DownloadStream,
84+
DownloadStreamChunk,
85+
ExtendedFileInfo,
86+
FileInfo,
87+
FileResult,
88+
IndexInfo,
89+
ResourceUsage,
90+
UpdateInfo,
7191
};
72-
pub use AirClient::AirClient;
7392
pub use AirServiceProvider::generate_request_id;
7493

75-
// Note: AirServiceProvider struct is available via crate::Air::AirServiceProvider::AirServiceProvider
94+
// Note: AirServiceProvider struct is available via
95+
// crate::Air::AirServiceProvider::AirServiceProvider
7696

7797
// Stub types for Air integration when AirLibrary is not available (legacy)
78-
// Note: These are kept for backward compatibility but should not be used in new code
98+
// Note: These are kept for backward compatibility but should not be used in new
99+
// code
79100
#[deprecated(note = "Use AirClient and AirServiceProvider instead")]
80101
pub mod AirServiceTypesStub;

Source/ApplicationState/DTO/CustomDocumentStateDTO.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use std::collections::HashMap;
1717

1818
use serde::{Deserialize, Serialize};
1919
use url::Url;
20-
2120
use CommonLibrary::Utility::Serialization::URLSerializationHelper;
2221

2322
/// Maximum length for ViewType string to prevent allocation attacks

Source/ApplicationState/DTO/DocumentStateDTO.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020
//! to Air. For now, Mountain handles this synchronously to ensure UI
2121
//! responsiveness.
2222
23-
use CommonLibrary::Error::CommonError::CommonError;
23+
use CommonLibrary::{Error::CommonError::CommonError, Utility::Serialization::URLSerializationHelper};
2424
use serde::{Deserialize, Serialize};
2525
use serde_json::Value;
2626
use url::Url;
2727

28-
use super::{RPCRangeDTO::RPCRangeDTO, RPCModelContentChangeDTO::RPCModelContentChangeDTO};
28+
use super::{RPCModelContentChangeDTO::RPCModelContentChangeDTO, RPCRangeDTO::RPCRangeDTO};
2929
use crate::ApplicationState::Internal::AnalyzeTextLinesAndEOL;
30-
use CommonLibrary::Utility::Serialization::URLSerializationHelper;
3130

3231
/// Maximum line count for a document to prevent memory exhaustion
3332
const MAX_DOCUMENT_LINES:usize = 1_000_000;
@@ -238,7 +237,6 @@ impl DocumentStateDTO {
238237
/// # Returns
239238
/// Updated lines vector after applying all changes
240239
fn ApplyDeltaChanges(Lines:&[String], EOL:&str, RPCChange:&[RPCModelContentChangeDTO]) -> Vec<String> {
241-
242240
// Join lines into full text for offset-based manipulation
243241
let mut ResultText = Lines.join(EOL);
244242

Source/ApplicationState/DTO/MarkerDataDTO.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
//! - RelatedInformation: Related diagnostic information
1717
//! - Tags: Additional marker tags (deprecated, unnecessary)
1818
19-
use super::MarkerSeverity::MarkerSeverity;
2019
use serde::{Deserialize, Serialize};
2120
use serde_json::Value;
2221

22+
use super::MarkerSeverity::MarkerSeverity;
23+
2324
/// Maximum message length for a marker
2425
const MAX_MARKER_MESSAGE_LENGTH:usize = 10_000;
2526

Source/ApplicationState/DTO/RPCModelContentChangeDTO.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
//! - Range: The range of text to replace
1111
//! - Text: The new text to insert
1212
13-
use super::RPCRangeDTO::RPCRangeDTO;
1413
use serde::Deserialize;
1514

15+
use super::RPCRangeDTO::RPCRangeDTO;
16+
1617
/// Represents a single text change operation, including the range to be
1718
/// replaced and the new text to insert. This is part of a collection sent when
1819
/// a document is edited.

Source/ApplicationState/DTO/WorkspaceFolderStateDTO.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! - Index: Zero-based position in workspace
1212
use serde::{Deserialize, Serialize};
1313
use url::Url;
14-
1514
use CommonLibrary::Utility::Serialization::URLSerializationHelper;
1615

1716
/// Maximum folder name length

Source/ApplicationState/Internal/ExtensionScanner/ScanAndPopulateExtensions.rs

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,14 @@
3030
//! - [ ] Implement extension caching
3131
//! - [ ] Add extension validation rules
3232
33-
use std::collections::HashMap;
34-
use std::path::PathBuf;
33+
use std::{collections::HashMap, path::PathBuf};
3534

3635
use CommonLibrary::Error::CommonError::CommonError;
3736
use log::{debug, error, info, trace, warn};
3837
use serde_json::Value;
3938
use tauri::AppHandle;
4039

41-
use crate::{
42-
ApplicationState::DTO::ExtensionDescriptionStateDTO::ExtensionDescriptionStateDTO,
43-
ExtensionManagement,
44-
};
40+
use crate::{ApplicationState::DTO::ExtensionDescriptionStateDTO::ExtensionDescriptionStateDTO, ExtensionManagement};
4541

4642
/// Scans all registered extension paths for valid extensions and populates the
4743
/// state.
@@ -59,16 +55,16 @@ use crate::{
5955
/// - Returns comprehensive scan statistics
6056
/// - Handles partial failures gracefully
6157
pub async fn ScanAndPopulateExtensions(
62-
ApplicationHandle: AppHandle,
63-
_State: &crate::ApplicationState::ExtensionState::State::State,
58+
ApplicationHandle:AppHandle,
59+
_State:&crate::ApplicationState::ExtensionState::State::State,
6460
) -> Result<(), CommonError> {
6561
info!("[ExtensionScanner] Starting extension scan...");
6662

67-
let mut all_found_extensions: HashMap<String, ExtensionDescriptionStateDTO> = HashMap::new();
63+
let mut all_found_extensions:HashMap<String, ExtensionDescriptionStateDTO> = HashMap::new();
6864

6965
// Note: This would need to be adapted to the new state structure
7066
// For now, this is a placeholder showing the structure
71-
let scan_paths: Vec<PathBuf> = Vec::new(); // Would get from State.Registry.Extension.Registry.ExtensionScanPaths
67+
let scan_paths:Vec<PathBuf> = Vec::new(); // Would get from State.Registry.Extension.Registry.ExtensionScanPaths
7268

7369
trace!("[ExtensionScanner] Scanning paths: {:?}", scan_paths);
7470

@@ -77,12 +73,7 @@ pub async fn ScanAndPopulateExtensions(
7773

7874
for path in scan_paths {
7975
let path_clone = path.clone();
80-
match ExtensionManagement::Scanner::ScanDirectoryForExtensions(
81-
ApplicationHandle.clone(),
82-
path_clone,
83-
)
84-
.await
85-
{
76+
match ExtensionManagement::Scanner::ScanDirectoryForExtensions(ApplicationHandle.clone(), path_clone).await {
8677
Ok(found_in_path) => {
8778
successful_scans += 1;
8879
for extension in found_in_path {
@@ -109,7 +100,8 @@ pub async fn ScanAndPopulateExtensions(
109100
}
110101
}
111102

112-
// Note: Would populate State.Extension.ScannedExtensions.Extension.ScannedExtensions
103+
// Note: Would populate
104+
// State.Extension.ScannedExtensions.Extension.ScannedExtensions
113105
debug!(
114106
"[ExtensionScanner] Extension scan complete. Found {} extensions ({} successful scans, {} failed scans).",
115107
all_found_extensions.len(),
@@ -118,10 +110,7 @@ pub async fn ScanAndPopulateExtensions(
118110
);
119111

120112
if failed_scans > 0 {
121-
warn!(
122-
"[ExtensionScanner] {} extension paths failed to scan",
123-
failed_scans
124-
);
113+
warn!("[ExtensionScanner] {} extension paths failed to scan", failed_scans);
125114
}
126115

127116
Ok(())
@@ -142,20 +131,19 @@ pub async fn ScanAndPopulateExtensions(
142131
/// - Retries once on failure
143132
/// - Comprehensive error logging
144133
pub async fn ScanExtensionsWithRecovery(
145-
ApplicationHandle: AppHandle,
146-
State: &crate::ApplicationState::ExtensionState::State::State,
134+
ApplicationHandle:AppHandle,
135+
State:&crate::ApplicationState::ExtensionState::State::State,
147136
) -> Result<(), CommonError> {
148137
info!("[ExtensionScanner] Starting robust extension scan with recovery...");
149138

150139
// Clear potentially corrupted extension state first
151-
// Note: Would clear State.Extension.ScannedExtensions.Extension.ScannedExtensions
140+
// Note: Would clear
141+
// State.Extension.ScannedExtensions.Extension.ScannedExtensions
152142

153143
// Perform the scan
154144
match ScanAndPopulateExtensions(ApplicationHandle.clone(), State).await {
155145
Ok(()) => {
156-
info!(
157-
"[ExtensionScanner] Robust extension scan completed successfully"
158-
);
146+
info!("[ExtensionScanner] Robust extension scan completed successfully");
159147
Ok(())
160148
},
161149
Err(error) => {
@@ -164,7 +152,8 @@ pub async fn ScanExtensionsWithRecovery(
164152
warn!("[ExtensionScanner] Attempting recovery from extension scan failure...");
165153

166154
// Clear state again
167-
// Note: Would clear State.Extension.ScannedExtensions.Extension.ScannedExtensions
155+
// Note: Would clear
156+
// State.Extension.ScannedExtensions.Extension.ScannedExtensions
168157

169158
// Retry the scan with a cloned handle
170159
ScanAndPopulateExtensions(ApplicationHandle.clone(), State).await

Source/ApplicationState/Internal/PathResolution/ResolveMementoStorageFilePath.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
//! - [ ] Add cross-platform path handling
3030
3131
use std::path::Path;
32+
3233
use log::debug;
3334

3435
/// Resolves the absolute path for a Memento storage file based on scope.
@@ -43,12 +44,13 @@ use log::debug;
4344
///
4445
/// # Behavior
4546
/// - Global scope: `{AppData}/User/globalStorage.json`
46-
/// - Workspace scope: `{AppData}/User/workspaceStorage/{sanitized-id}/storage.json`
47+
/// - Workspace scope:
48+
/// `{AppData}/User/workspaceStorage/{sanitized-id}/storage.json`
4749
/// - Sanitizes workspace identifier (alphanumeric, hyphens, underscores only)
4850
pub fn ResolveMementoStorageFilePath(
49-
ApplicationDataDirectory: &Path,
50-
IsGlobalScope: bool,
51-
WorkspaceIdentifier: &str,
51+
ApplicationDataDirectory:&Path,
52+
IsGlobalScope:bool,
53+
WorkspaceIdentifier:&str,
5254
) -> std::path::PathBuf {
5355
let user_storage_base_path = ApplicationDataDirectory.join("User");
5456

@@ -61,8 +63,7 @@ pub fn ResolveMementoStorageFilePath(
6163
path
6264
} else {
6365
// Sanitize the workspace identifier to be a safe directory name
64-
let segment =
65-
WorkspaceIdentifier.replace(|c: char| !c.is_alphanumeric() && c != '-' && c != '_', "_");
66+
let segment = WorkspaceIdentifier.replace(|c:char| !c.is_alphanumeric() && c != '-' && c != '_', "_");
6667

6768
let path = user_storage_base_path
6869
.join("workspaceStorage")

0 commit comments

Comments
 (0)