Skip to main content

Mountain/Vine/Server/Notification/
OutputReplace.rs

1#![allow(non_snake_case)]
2//! Cocoon → Mountain `output.replace` notification.
3//! Emitted when an extension calls `LogOutputChannel.replace(value)` to
4//! swap the channel's entire contents. Sky doesn't yet have a dedicated
5//! `sky://output/replace` listener, so this atom maps replace → (clear +
6//! append) on the existing channels. That preserves semantics without
7//! requiring a coordinated Sky-side change.
8
9use serde_json::{Value, json};
10use tauri::Emitter;
11
12use crate::{Vine::Server::MountainVinegRPCService::MountainVinegRPCService, dev_log};
13
14pub async fn OutputReplace(Service:&MountainVinegRPCService, Parameter:&Value) {
15	let Channel = Parameter.get("channel").and_then(Value::as_str).unwrap_or("");
16	let Text = Parameter.get("text").and_then(Value::as_str).unwrap_or("");
17	let Handle = Service.ApplicationHandle();
18	let _ = Handle.emit("sky://output/clear", json!({ "channel": Channel }));
19	let _ = Handle.emit("sky://output/append", json!({ "channel": Channel, "text": Text }));
20	dev_log!("grpc", "[Output] replace channel={} bytes={}", Channel, Text.len());
21}