Skip to content

Commit 6e34ae4

Browse files
author
Mohammod Al Amin Ashik
committed
docs: Clarify tray update logic and success conditions
- Add comments explaining tray updates only happen after successful operations - Add success logging for create_space, delete_space, and set_active_space - Clarify that active space checkmark (\u2713) is updated in tray - Fix ownership issue by cloning space name before move Improves code maintainability and debugging visibility.
1 parent 7c24f61 commit 6e34ae4

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

  • apps/desktop/src-tauri/src/commands

apps/desktop/src-tauri/src/commands/space.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,14 @@ pub async fn create_space(
111111
});
112112
}
113113

114-
// Update system tray menu
114+
// Update system tray menu to show the new space
115+
// Only reached if both space creation and config file writing succeeded
115116
if let Err(e) = tray::update_tray_spaces(&app, &state).await {
116117
warn!("Failed to update tray menu: {}", e);
117118
}
118119

120+
info!("[create_space] Space '{}' created successfully", space.name);
121+
119122
Ok(space)
120123
}
121124

@@ -142,11 +145,14 @@ pub async fn delete_space(
142145
gw.emit_domain_event(mcpmux_core::DomainEvent::SpaceDeleted { space_id: uuid });
143146
}
144147

145-
// Update system tray menu
148+
// Update system tray menu to remove the deleted space
149+
// Only reached if space deletion from DB succeeded
146150
if let Err(e) = tray::update_tray_spaces(&app, &state).await {
147151
warn!("Failed to update tray menu: {}", e);
148152
}
149153

154+
info!("[delete_space] Space '{}' deleted successfully", uuid);
155+
150156
Ok(())
151157
}
152158

@@ -238,7 +244,7 @@ pub async fn set_active_space<R: tauri::Runtime>(
238244
let event = SpaceChangeEvent {
239245
from_space_id: old_space.map(|s| s.id.to_string()),
240246
to_space_id: new_space.id.to_string(),
241-
to_space_name: new_space.name,
247+
to_space_name: new_space.name.clone(),
242248
clients_needing_confirmation: clients_needing_confirmation.clone(),
243249
};
244250

@@ -255,11 +261,14 @@ pub async fn set_active_space<R: tauri::Runtime>(
255261
// will be emitted by the gateway when they make their next request
256262
// and the SpaceResolver returns the new active space.
257263

258-
// Update system tray menu to reflect new active space
264+
// Update system tray menu to show checkmark (✓) on the newly active space
265+
// Only reached if set_active operation succeeded in DB
259266
if let Err(e) = tray::update_tray_spaces(&app_handle, &state).await {
260267
warn!("Failed to update tray menu: {}", e);
261268
}
262269

270+
info!("[set_active_space] Switched to space '{}'", new_space.name);
271+
263272
Ok(())
264273
}
265274

0 commit comments

Comments
 (0)