breadhelp/src/services/breadd.rs
Breadway d9012c8e72
All checks were successful
dev release / build (push) Successful in 39s
Honor bread.command.help.open via breadhelp listen
2026-08-15 23:11:28 +08:00

33 lines
1.1 KiB
Rust

//! Bread bus integration. `--suggest` banners stay local; `bread.help.*`
//! emits are optional and fail-silent. See `EVENTS.md`.
//!
//! `BreadClient::emit` never blocks or errors this process — a missing or
//! restarting breadd must not affect the help center itself.
use bread_utils::bread_client::BreadClient;
/// Sibling-app id in `bread_shared::apps::KNOWN_APPS`. Events publish as
/// `bread.help.*`. Command verbs are handled by `breadhelp listen`.
pub const APP_ID: &str = "help";
/// Fire-and-forget `bread.help.opened` after the main window is actually
/// shown. Silent autostart (window built, not presented) does not call this.
pub fn emit_opened(autostart: bool) {
BreadClient::connect(APP_ID).emit(
"bread.help.opened",
serde_json::json!({ "autostart": autostart }),
);
}
pub struct Suggestion {
pub text: String,
}
pub fn resolve(id: &str) -> Option<Suggestion> {
match id {
"monitor-setup" => Some(Suggestion {
text: "New monitor detected — want to set up your display layout?".to_string(),
}),
_ => None,
}
}