diff --git a/desktop/src-tauri/src/kernel_commands/mod.rs b/desktop/src-tauri/src/kernel_commands/mod.rs index 2034661..15350b7 100644 --- a/desktop/src-tauri/src/kernel_commands/mod.rs +++ b/desktop/src-tauri/src/kernel_commands/mod.rs @@ -34,12 +34,28 @@ pub type SchedulerState = Arc>>; +/// +/// Newtype wrapper is required because Tauri state management uses the Rust type +/// system to distinguish states — two `type` aliases to the same underlying type +/// would cause a runtime panic ("state already being managed"). +#[derive(Clone, Default)] +pub struct SessionStreamGuard(pub Arc>>); /// Per-session stream cancellation flags. /// When a user cancels a stream, the flag for that session_id is set to `true`. /// The spawned `agent_chat_stream` task checks this flag each iteration. -pub type StreamCancelFlags = Arc>>; +#[derive(Clone, Default)] +pub struct StreamCancelFlags(pub Arc>>); + +impl std::ops::Deref for SessionStreamGuard { + type Target = Arc>>; + fn deref(&self) -> &Self::Target { &self.0 } +} + +impl std::ops::Deref for StreamCancelFlags { + type Target = Arc>>; + fn deref(&self) -> &Self::Target { &self.0 } +} // --------------------------------------------------------------------------- // Shared validation helpers