MCPcopy Create free account
hub / github.com/block/buzz / build_app_state

Function build_app_state

desktop/src-tauri/src/app_state.rs:73–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71}
72
73pub fn build_app_state() -> AppState {
74 // Env var takes precedence (dev/CI). If absent, resolve_persisted_identity()
75 // in setup() will replace the ephemeral placeholder with a persisted key.
76 let keys = match identity_from_env() {
77 Some(keys) => {
78 eprintln!(
79 "buzz-desktop: configured identity pubkey {}",
80 keys.public_key().to_hex()
81 );
82 keys
83 }
84 None => Keys::generate(),
85 };
86
87 AppState {
88 keys: Mutex::new(keys),
89 http_client: reqwest::Client::builder()
90 .resolve("localhost", std::net::SocketAddr::from(([127, 0, 0, 1], 0)))
91 .pool_idle_timeout(std::time::Duration::from_secs(10))
92 .pool_max_idle_per_host(1)
93 .build()
94 .unwrap_or_else(|_| reqwest::Client::new()),
95 relay_url_override: Mutex::new(None),
96 managed_agents_store_lock: Mutex::new(()),
97 channel_templates_store_lock: Mutex::new(()),
98 managed_agent_processes: Mutex::new(HashMap::new()),
99 session_config_cache: Mutex::new(HashMap::new()),
100 huddle_state: Mutex::new(HuddleState::default()),
101 app_handle: Mutex::new(None),
102 audio_output_device: Mutex::new(None),
103 media_proxy_port: AtomicU16::new(0),
104 prevent_sleep: Arc::new(Mutex::new(
105 crate::prevent_sleep::PreventSleepState::default(),
106 )),
107 #[cfg(feature = "mesh-llm")]
108 mesh_llm_runtime: AsyncMutex::new(None),
109 #[cfg(feature = "mesh-llm")]
110 mesh_coordinator: AsyncMutex::new(None),
111 }
112}
113
114impl AppState {
115 /// Lock the huddle state mutex, converting a poisoned-lock error to a String.

Calls 2

identity_from_envFunction · 0.85
buildMethod · 0.80

Tested by

no test coverage detected