-
-
Notifications
You must be signed in to change notification settings - Fork 359
Expand file tree
/
Copy pathlocal_thread_usage.rs
More file actions
33 lines (30 loc) · 954 Bytes
/
local_thread_usage.rs
File metadata and controls
33 lines (30 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use serde_json::json;
use tauri::{AppHandle, State};
use crate::remote_backend;
use crate::shared::thread_usage_core;
use crate::state::AppState;
use crate::types::LocalThreadUsageSnapshot;
#[tauri::command]
pub(crate) async fn local_thread_usage_snapshot(
thread_ids: Vec<String>,
workspace_path: Option<String>,
state: State<'_, AppState>,
app: AppHandle,
) -> Result<LocalThreadUsageSnapshot, String> {
if remote_backend::is_remote_mode(&*state).await {
let response = remote_backend::call_remote(
&*state,
app,
"local_thread_usage_snapshot",
json!({ "threadIds": thread_ids, "workspacePath": workspace_path }),
)
.await?;
return serde_json::from_value(response).map_err(|err| err.to_string());
}
thread_usage_core::local_thread_usage_snapshot_core(
&state.workspaces,
thread_ids,
workspace_path,
)
.await
}