Skip to main content

Mountain/Vine/Server/Notification/
ProgressStart.rs

1//! Cocoon → Mountain `progress.start` notification.
2//! Fires at the top of every `vscode.window.withProgress(...)` call.
3//! Normalises onto `sky://notification/progress-begin` so Sky's progress
4//! indicator renders identically whether an extension or a Mountain
5//! handler triggered the progress.
6
7use serde_json::{Value, json};
8use tauri::Emitter;
9
10use crate::{Vine::Server::MountainVinegRPCService::MountainVinegRPCService, dev_log};
11
12pub async fn ProgressStart(Service:&MountainVinegRPCService, Parameter:&Value) {
13	let Handle = Parameter.get("handle").and_then(Value::as_str).unwrap_or("");
14
15	let Title = Parameter.get("title").and_then(Value::as_str).unwrap_or("");
16
17	let Cancellable = Parameter.get("cancellable").and_then(Value::as_bool).unwrap_or(false);
18
19	if let Err(Error) = Service.ApplicationHandle().emit(
20		"sky://notification/progress-begin",
21		json!({
22			"id": Handle,
23			"title": Title,
24			"cancellable": Cancellable,
25		}),
26	) {
27		dev_log!(
28			"grpc",
29			"warn: [MountainVinegRPCService] sky://notification/progress-begin emit failed: {}",
30			Error
31		);
32	}
33}