agentmux_srv/server/prep/
meta.rs1use serde_json::{json, Value};
8
9use crate::backend::blockcontroller;
10use crate::backend::obj;
11use crate::server::AppState;
12
13pub(crate) fn set_block_meta(state: &AppState, block_ids: &[&str], updates: &[(&str, Value)]) {
16 let mut update = obj::MetaMapType::new();
17 for (key, value) in updates {
18 update.insert((*key).to_string(), value.clone());
19 }
20 for oid in block_ids {
21 match crate::server::service::update_object_meta(&state.mstore, &format!("block:{oid}"), &update) {
22 Ok(()) => blockcontroller::core::broadcast_block_update(&state.mstore, &state.event_bus, oid),
23 Err(e) => tracing::warn!(block_id = %oid, error = %e, "prep: the pane's meta was not updated"),
24 }
25 }
26}
27
28pub(super) fn prep_value(id: &str, action: &str, until_ms: u64, extended: bool, why: Option<&str>) -> Value {
30 json!({ "id": id, "action": action, "until_ms": until_ms, "extended": extended, "why": why })
31}