@@ -16,9 +16,25 @@ use std::{
1616} ;
1717
1818use 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+ } ;
2238use 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 ) ]
3046pub 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 {
131151impl 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 }
0 commit comments