Skip to content

Commit 3818304

Browse files
1 parent 9cc4fed commit 3818304

5 files changed

Lines changed: 68 additions & 135 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[[bin]]
22
name = "Mountain"
3-
path = "Source/Library.rs"
3+
path = "Source/Binary.rs"
44

55
[build-dependencies]
66
json5 = { workspace = true }
@@ -68,14 +68,16 @@ flate2 = { workspace = true }
6868
ring = { workspace = true }
6969

7070
[features]
71-
default = ["ExtensionHostCocoon", "MistNative"]
71+
default = ["ExtensionHostCocoon", "MistNative", "AirIntegration"]
7272

7373
ExtensionHostCocoon = []
7474

7575
MistNative = []
7676

7777
Debug = []
7878

79+
AirIntegration = []
80+
7981
[lib]
8082
name = "Mountain"
8183
path = "Source/Library.rs"

Source/Air/AirClient.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ use tonic::transport::{Channel, Endpoint};
2121
// Placeholder authentication types
2222
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
2323
pub struct AuthenticationRequest {
24-
pub request_id: u64,
24+
pub request_id: String,
2525
pub username: String,
2626
pub password: String,
2727
pub provider: String,
2828
}
2929

3030
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
3131
pub struct AuthenticationResponse {
32-
pub request_id: u64,
32+
pub request_id: String,
3333
pub success: bool,
3434
pub token: String,
3535
pub error: String,
@@ -38,14 +38,14 @@ pub struct AuthenticationResponse {
3838
// Placeholder update types
3939
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
4040
pub struct UpdateCheckRequest {
41-
pub request_id: u64,
41+
pub request_id: String,
4242
pub current_version: String,
4343
pub channel: String,
4444
}
4545

4646
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
4747
pub struct UpdateCheckResponse {
48-
pub request_id: u64,
48+
pub request_id: String,
4949
pub update_available: bool,
5050
pub version: String,
5151
pub download_url: String,
@@ -55,22 +55,22 @@ pub struct UpdateCheckResponse {
5555

5656
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
5757
pub struct ApplyUpdateRequest {
58-
pub request_id: u64,
58+
pub request_id: String,
5959
pub version: String,
6060
pub update_path: String,
6161
}
6262

6363
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
6464
pub struct ApplyUpdateResponse {
65-
pub request_id: u64,
65+
pub request_id: String,
6666
pub success: bool,
6767
pub error: String,
6868
}
6969

7070
// Placeholder download types
7171
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
7272
pub struct DownloadRequest {
73-
pub request_id: u64,
73+
pub request_id: String,
7474
pub url: String,
7575
pub destination_path: String,
7676
pub checksum: String,
@@ -79,7 +79,7 @@ pub struct DownloadRequest {
7979

8080
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
8181
pub struct DownloadResponse {
82-
pub request_id: u64,
82+
pub request_id: String,
8383
pub success: bool,
8484
pub file_path: String,
8585
pub file_size: u64,
@@ -90,7 +90,7 @@ pub struct DownloadResponse {
9090
// Placeholder indexing types
9191
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
9292
pub struct IndexRequest {
93-
pub request_id: u64,
93+
pub request_id: String,
9494
pub path: String,
9595
pub patterns: Vec<String>,
9696
pub exclude_patterns: Vec<String>,
@@ -99,7 +99,7 @@ pub struct IndexRequest {
9999

100100
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
101101
pub struct IndexResponse {
102-
pub request_id: u64,
102+
pub request_id: String,
103103
pub success: bool,
104104
pub files_indexed: u32,
105105
pub total_size: u64,
@@ -108,7 +108,7 @@ pub struct IndexResponse {
108108

109109
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
110110
pub struct SearchRequest {
111-
pub request_id: u64,
111+
pub request_id: String,
112112
pub query: String,
113113
pub path: String,
114114
pub max_results: u32,
@@ -124,7 +124,7 @@ pub struct FileResult {
124124

125125
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
126126
pub struct SearchResponse {
127-
pub request_id: u64,
127+
pub request_id: String,
128128
pub results: Vec<FileResult>,
129129
pub total_results: u32,
130130
pub error: String,
@@ -133,7 +133,7 @@ pub struct SearchResponse {
133133
// Placeholder status types
134134
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
135135
pub struct StatusRequest {
136-
pub request_id: u64,
136+
pub request_id: String,
137137
}
138138

139139
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
@@ -151,13 +151,13 @@ pub struct StatusResponse {
151151

152152
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
153153
pub struct MetricsRequest {
154-
pub request_id: u64,
154+
pub request_id: String,
155155
pub metric_type: String,
156156
}
157157

158158
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
159159
pub struct MetricsResponse {
160-
pub request_id: u64,
160+
pub request_id: String,
161161
pub metrics: HashMap<String, String>,
162162
pub error: String,
163163
}

Source/Air/AirServiceProvider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl AirServiceProvider {
395395
/// Uses UUID v4 to generate a cryptographically random unique identifier.
396396
/// This is used to correlate requests with responses and for tracing.
397397
fn generate_request_id() -> String {
398-
Uuid::new_v4().to_simple().to_string()
398+
Uuid::new_v4().simple().to_string()
399399
}
400400

401401
/// Creates a new AirServiceProvider by attempting to connect to Air.

Source/IPC/WindAdvancedSync.rs

Lines changed: 26 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use log::{debug, error, info, trace, warn};
1919
use serde::{Deserialize, Serialize};
2020
use tokio::time::interval;
2121
use tauri::{AppHandle, Emitter, command, State, Manager};
22+
use crate::IPC::AdvancedFeatures::PerformanceStats;
23+
use Common::FileSystem::FileSystemReader::FileSystemReader;
2224

2325
use crate::RunTime::ApplicationRunTime::ApplicationRunTime;
2426
use Common::Environment::Requires::Requires;
@@ -33,49 +35,6 @@ pub struct WindAdvancedSync {
3335
}
3436

3537
impl WindAdvancedSync {
36-
/// Create a new WindAdvancedSync instance
37-
pub fn new(runtime: Arc<ApplicationRunTime>) -> Self {
38-
Self {
39-
runtime,
40-
document_sync: Arc::new(Mutex::new(DocumentSynchronization {
41-
synchronized_documents: HashMap::new(),
42-
pending_changes: HashMap::new(),
43-
last_sync_time: 0,
44-
sync_status: SyncStatus {
45-
total_documents: 0,
46-
synced_documents: 0,
47-
conflicted_documents: 0,
48-
offline_documents: 0,
49-
last_sync_duration_ms: 0,
50-
},
51-
})),
52-
ui_state_sync: Arc::new(Mutex::new(UIStateSynchronization {
53-
active_editor: None,
54-
cursor_positions: HashMap::new(),
55-
selection_ranges: HashMap::new(),
56-
view_state: ViewState {
57-
zoom_level: 1.0,
58-
sidebar_visible: true,
59-
panel_visible: true,
60-
status_bar_visible: true,
61-
},
62-
theme: "default".to_string(),
63-
layout: LayoutState {
64-
editor_groups: Vec::new(),
65-
active_group: 0,
66-
grid_layout: GridLayout {
67-
rows: 1,
68-
columns: 1,
69-
cell_width: 100,
70-
cell_height: 100,
71-
},
72-
},
73-
})),
74-
real_time_updates: Arc::new(Mutex::new(RealTimeUpdates {
75-
updates: Vec::new(),
76-
subscribers: HashMap::new(),
77-
})),
78-
performance_stats: Arc::new(Mutex::new(PerformanceStats {
7938
total_messages_sent: 0,
8039
total_messages_received: 0,
8140
average_processing_time_ms: 0.0,
@@ -107,7 +66,7 @@ impl WindAdvancedSync {
10766
let runtime = self.runtime.clone();
10867

10968
tokio::spawn(async move {
110-
let mut interval = interval(Duration::from_secs(5));
69+
let mut interval = tokio::time::interval(Duration::from_secs(5));
11170

11271
loop {
11372
interval.tick().await;
@@ -128,7 +87,7 @@ impl WindAdvancedSync {
12887
sync.sync_status = Self::calculate_sync_status(&sync.synchronized_documents);
12988

13089
// Emit sync event
131-
let _ = runtime.emit(
90+
let _ = runtime.Environment.ApplicationHandle.emit(
13291
"mountain_sync_status_update",
13392
sync.sync_status.clone()
13493
);
@@ -145,7 +104,7 @@ impl WindAdvancedSync {
145104
let runtime = self.runtime.clone();
146105

147106
tokio::spawn(async move {
148-
let mut interval = interval(Duration::from_secs(10));
107+
let mut interval = tokio::time::interval(Duration::from_secs(10));
149108

150109
loop {
151110
interval.tick().await;
@@ -158,7 +117,7 @@ impl WindAdvancedSync {
158117
stats.connection_uptime += 10;
159118

160119
// Emit performance update
161-
let _ = runtime.emit(
120+
let _ = runtime.Environment.ApplicationHandle.emit(
162121
"mountain_performance_update",
163122
stats.clone()
164123
);
@@ -234,7 +193,7 @@ pub enum ChangeType {
234193
}
235194

236195
/// Sync state
237-
#[derive(Debug, Clone, Serialize, Deserialize)]
196+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
238197
pub enum SyncState {
239198
Synced,
240199
Modified,
@@ -407,51 +366,22 @@ impl WindAdvancedSync {
407366
// ADVANCED PERFORMANCE TRACKING: Microsoft-inspired initialization metrics
408367
let sync_duration = sync_start.elapsed();
409368
info!("[WindAdvancedSync] Initialization completed in {:.2}ms", sync_duration.as_millis());
410-
411-
Self {
412-
runtime,
413-
document_sync: Arc::new(Mutex::new(DocumentSynchronization {
414-
synchronized_documents: HashMap::new(),
415-
pending_changes: HashMap::new(),
416-
last_sync_time: SystemTime::now()
417-
.duration_since(SystemTime::UNIX_EPOCH)
418-
.unwrap_or_default()
419-
.as_secs(),
420-
sync_status: SyncStatus {
421-
total_documents: 0,
422-
synced_documents: 0,
423-
conflicted_documents: 0,
424-
offline_documents: 0,
425-
last_sync_duration_ms: 0,
426-
},
427-
})),
428-
ui_state_sync: Arc::new(Mutex::new(UIStateSynchronization {
429-
active_editor: None,
430-
cursor_positions: HashMap::new(),
431-
selection_ranges: HashMap::new(),
432-
view_state: ViewState {
433-
zoom_level: 1.0,
434-
sidebar_visible: true,
435-
panel_visible: false,
436-
status_bar_visible: true,
437-
},
438-
theme: "dark".to_string(),
439-
layout: LayoutState {
440-
editor_groups: Vec::new(),
441-
active_group: 0,
442-
grid_layout: GridLayout {
443-
rows: 1,
444-
columns: 1,
445-
cell_width: 100,
446-
cell_height: 100,
447-
},
448-
},
449-
})),
450-
real_time_updates: Arc::new(Mutex::new(RealTimeUpdates {
451-
subscribers: HashMap::new(),
452369
last_broadcast: 0,
453370
update_queue: Vec::new(),
454371
})),
372+
performance_stats: Arc::new(Mutex::new(PerformanceStats {
373+
total_memory_bytes: 0,
374+
used_memory_bytes: 0,
375+
cpu_usage_percent: 0.0,
376+
network_bytes_sent: 0,
377+
network_bytes_received: 0,
378+
disk_read_bytes: 0,
379+
disk_write_bytes: 0,
380+
process_count: 0,
381+
thread_count: 0,
382+
uptime_seconds: 0,
383+
last_update_timestamp: 0,
384+
})),
455385
}
456386
}
457387

@@ -481,7 +411,7 @@ impl WindAdvancedSync {
481411

482412
/// Synchronize documents between Wind and Mountain
483413
async fn synchronize_documents(&self) {
484-
let mut interval = interval(Duration::from_secs(5));
414+
let mut interval = tokio::time::interval(Duration::from_secs(5));
485415
let mut consecutive_failures = 0;
486416
let max_consecutive_failures = 3;
487417

@@ -510,7 +440,7 @@ impl WindAdvancedSync {
510440
consecutive_failures += 1;
511441
if consecutive_failures >= max_consecutive_failures {
512442
warn!("[WindAdvancedSync] Too many consecutive failures, slowing sync interval");
513-
interval = interval(Duration::from_secs(30)); // Slow down
443+
interval = tokio::time::interval(Duration::from_secs(30)); // Slow down
514444
}
515445
}
516446
}
@@ -519,7 +449,7 @@ impl WindAdvancedSync {
519449
// Reset failure counter on successful operations
520450
if success_count > 0 {
521451
consecutive_failures = 0;
522-
interval = interval(Duration::from_secs(5)); // Reset to normal interval
452+
interval = tokio::time::interval(Duration::from_secs(5)); // Reset to normal interval
523453
}
524454

525455
// Update sync status
@@ -536,7 +466,7 @@ impl WindAdvancedSync {
536466

537467
/// Synchronize UI state
538468
async fn synchronize_ui_state(&self) {
539-
let mut interval = interval(Duration::from_secs(1));
469+
let mut interval = tokio::time::interval(Duration::from_secs(1));
540470

541471
loop {
542472
interval.tick().await;
@@ -555,7 +485,7 @@ impl WindAdvancedSync {
555485

556486
/// Broadcast real-time updates
557487
async fn broadcast_real_time_updates(&self) {
558-
let mut interval = interval(Duration::from_millis(100));
488+
let mut interval = tokio::time::interval(Duration::from_millis(100));
559489

560490
loop {
561491
interval.tick().await;
@@ -712,7 +642,7 @@ impl WindAdvancedSync {
712642
*sync = ui_state;
713643

714644
// Emit UI state update to Sky
715-
if let Err(e) = self.runtime.Environment.ApplicationHandle.emit("ui-state-update", &sync) {
645+
if let Err(e) = self.runtime.Environment.ApplicationHandle.emit("ui-state-update", *sync) {
716646
error!("[WindAdvancedSync] Failed to emit UI state update: {}", e);
717647
}
718648

0 commit comments

Comments
 (0)