Skip to main content

Mountain/Environment/StatusBarProvider/
Tooltip.rs

1//! # StatusBarProvider - Tooltip Resolution
2//!
3//! Implementation of dynamic tooltip resolution for
4//! [`MountainEnvironment`]
5
6use std::sync::Arc;
7
8use CommonLibrary::{Error::CommonError::CommonError, IPC::DTO::ProxyTarget::ProxyTarget};
9use tauri::Manager;
10use serde_json::{Value, json};
11
12use super::super::MountainEnvironment::MountainEnvironment;
13use crate::{
14	RunTime::ApplicationRunTime::ApplicationRunTime,
15	Track::Effect::CreateEffectForRequest::Utilities::Proxy::proxy_cocoon,
16	dev_log,
17};
18
19/// Tooltip resolution operations implementation for MountainEnvironment
20pub(super) async fn provide_tooltip_impl(
21	env:&MountainEnvironment,
22
23	entry_identifier:String,
24) -> Result<Option<Value>, CommonError> {
25	dev_log!(
26		"lifecycle",
27		"[StatusBarProvider] Providing dynamic tooltip for entry: {}",
28		entry_identifier
29	);
30
31	let run_time:Arc<ApplicationRunTime> = env.ApplicationHandle.state::<Arc<ApplicationRunTime>>().inner().clone();
32
33	// This is a "reverse" call, where the host needs data from the sidecar.
34	let rpc_response = proxy_cocoon(
35		&run_time,
36		ProxyTarget::ExtHostStatusBar,
37		"ProvideStatusbarTooltip",
38		json!([entry_identifier]),
39		5000,
40	)
41	.await
42	.map_err(|e| CommonError::IPCError { Description:e })?;
43
44	// If the response is null or fails to parse, we gracefully return None.
45	Ok(serde_json::from_value(rpc_response).unwrap_or(None))
46}