Skip to content

Commit 8f27b87

Browse files
refactor(Mountain): organize module structure and fix RPC error handling
- Uncommented and activated core Mountain modules in Library.rs including `app_state`, `environment`, handlers submodules, and IPC-related components to establish proper code structure for backend implementation - Fixed error handling in `track::map_common_error_to_rpc_error_string` to correctly reference `error_utils` module, ensuring proper error translation for IPC communication with Cocoon - Updated Vine IPC layer to use absolute `crate::track` path when dispatching sidecar requests, resolving potential module resolution issues - Removed redundant line breaks in documentation comments for better code readability - Activated handler modules for config management, diagnostics, and workspace operations as part of MVP architecture setup These changes improve code organization in the Mountain backend while strengthening RPC error handling reliability - critical for stable communication with the Cocoon extension host. The module activation aligns with Path A goals by enabling foundational components for extension interoperability and state management.
1 parent d29507c commit 8f27b87

4 files changed

Lines changed: 35 additions & 45 deletions

File tree

Source/Library.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,60 +8,60 @@ fn main() { Binary::Fn::Fn(); }
88
pub mod Binary;
99

1010
// NEW:
11-
// pub mod app_state;
11+
pub mod app_state;
1212

13-
// pub mod environment;
13+
pub mod environment;
1414

15-
// pub mod handlers {
16-
// pub mod commands;
15+
pub mod handlers {
16+
pub mod commands;
1717

18-
// pub mod config;
18+
pub mod config;
1919

20-
// pub mod diagnostics;
20+
pub mod diagnostics;
2121

22-
// pub mod documents;
22+
pub mod documents;
2323

24-
// pub mod enablement;
24+
pub mod enablement;
2525

26-
// pub mod native_fs;
26+
pub mod error_utils;
2727

28-
// pub mod output;
28+
pub mod extension_status;
2929

30-
// pub mod process_mgmt;
30+
pub mod native_fs;
3131

32-
// pub mod protocol;
32+
pub mod output;
3333

34-
// pub mod proxy;
34+
pub mod process_mgmt;
3535

36-
// pub mod registry;
36+
pub mod protocol;
3737

38-
// pub mod secrets;
38+
pub mod proxy;
3939

40-
// pub mod storage;
40+
pub mod registry;
4141

42-
// pub mod terminal;
42+
pub mod secrets;
4343

44-
// pub mod ui;
44+
pub mod sky_ui_responses;
4545

46-
// pub mod workspace;
46+
pub mod storage;
4747

48-
// pub mod workspace_fs_api;
48+
pub mod terminal;
4949

50-
// pub mod error_utils;
50+
pub mod ui;
5151

52-
// pub mod extension_status;
52+
pub mod workspace_fs_api;
5353

54-
// pub mod sky_ui_responses;
55-
// }
54+
pub mod workspace;
55+
}
5656

57-
// pub mod Entry;
57+
pub mod Entry;
5858

59-
// pub mod mist;
59+
pub mod mist;
6060

61-
// pub mod track;
61+
pub mod track;
6262

63-
// pub mod rpc;
63+
pub mod rpc;
6464

65-
// pub mod runtime;
65+
pub mod runtime;
6666

67-
// pub mod vine;
67+
pub mod vine;

Source/handlers/sky_ui_responses.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,8 @@ pub async fn sky_resolves_ui_request(
302302
Ok(successful_data)
303303
},
304304

305-
// Case 3: Success with no specific data (e.g., user cancellation of a dialog,
306-
307-
// simple ack for a message box), or data was explicitly `null`.
305+
// Case 3: Success with no specific data (e.g., user cancellation of a dialog, simple ack for a message
306+
// box), or data was explicitly `null`.
308307
(None, None) => {
309308
debug!(
310309
"[Sky UI Resp Handler] ReqID '{}' resolved by Sky with no data and no error. Interpreting as user \

Source/track.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ fn create_parameter_parse_error_string(
141141
}
142142

143143
/// Maps a `CommonError` (from effect execution) to a JSON-RPC error string.
144-
///
145144
/// Delegates to `error_utils::map_common_error_to_rpc_string`.
146145
fn map_common_error_to_rpc_error_string(e:CommonError, operation_context:&str) -> String {
147146
error_utils::map_common_error_to_rpc_string(e, operation_context)
@@ -161,14 +160,8 @@ fn map_common_error_to_rpc_error_string(e:CommonError, operation_context:&str) -
161160
/// * `window` - The Tauri `Window` context.
162161
/// * `runtime` - Managed `Arc<AppRuntime>` for executing effects.
163162
/// * `command` - The string identifier of the command to dispatch (e.g.,
164-
///
165-
///
166-
///
167163
/// `Land_Echo::REQUEST_READ_FILE`).
168164
/// * `args` - A `serde_json::Value` containing the arguments for the command,
169-
///
170-
///
171-
///
172165
/// typically an object.
173166
///
174167
/// # Returns
@@ -230,9 +223,6 @@ pub async fn dispatch_command<R:TauriRuntime>(
230223
// --- Sidecar Request/Notification Dispatcher (Called by Vine) ---
231224

232225
/// Dispatches requests and notifications received from a sidecar process (e.g.,
233-
///
234-
///
235-
///
236226
/// Cocoon) via the Vine IPC layer.
237227
///
238228
/// This function tries to:
@@ -700,6 +690,7 @@ pub async fn dispatch_sidecar_request<R:TauriRuntime>(
700690
///
701691
///
702692
///
693+
///
703694
/// `$dispose`.
704695
fn is_output_method_fallback_candidate(method_name:&str) -> bool {
705696
matches!(method_name, "$register" | "$append" | "$replace" | "$reveal" | "$close")

Source/vine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ use tokio::{
122122
};
123123

124124
// For dispatching incoming requests from sidecars
125-
use crate::{runtime::AppRuntime, track};
125+
use crate::runtime::AppRuntime;
126126

127127
// --- Vine Error Type ---
128128
/// Defines errors specific to the Vine IPC layer.
@@ -883,7 +883,7 @@ async fn process_incoming_line_from_sidecar<R:Runtime>(
883883
(Some(main_window), Some(app_runtime_state)) if app_runtime_state.inner().is_some() => {
884884

885885
// Dispatch the request to Track.
886-
match track::dispatch_sidecar_request(
886+
match crate::track::dispatch_sidecar_request(
887887
app_handle.clone(),
888888

889889
main_window,

0 commit comments

Comments
 (0)