PM: merge M1.12 notifications
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # docs/architecture.md # docs/gaps.md # docs/roadmap.md # docs/target-app-parity.md # docs/ui-parity.md
This commit is contained in:
commit
2f8fef876b
21 changed files with 1178 additions and 94 deletions
|
|
@ -156,6 +156,30 @@ impl Engine {
|
|||
self.state.take_events()
|
||||
}
|
||||
|
||||
/// Queues an [`crate::Event::Notification`] from the host, such as an
|
||||
/// error after the folder picker closed, with a fresh id from the same
|
||||
/// sequence as the engine's own notifications, and takes the queued
|
||||
/// events.
|
||||
///
|
||||
/// # Parameters
|
||||
/// - `level`: severity.
|
||||
/// - `message_key`: message-catalog key of the text.
|
||||
/// - `message`: English text, the fallback without a catalog entry.
|
||||
/// - `params`: interpolation params for the catalog text.
|
||||
///
|
||||
/// # Returns
|
||||
/// The queued events, oldest first, ending with the notification.
|
||||
pub fn notify(
|
||||
&mut self,
|
||||
level: NotificationLevel,
|
||||
message_key: Option<&str>,
|
||||
message: Option<String>,
|
||||
params: Option<serde_json::Map<String, Value>>,
|
||||
) -> Vec<crate::Event> {
|
||||
self.state.notify(level, message_key, message, params);
|
||||
self.state.take_events()
|
||||
}
|
||||
|
||||
/// Describes every command with its current enabled state. A command whose
|
||||
/// `enabled` check panics is listed as disabled.
|
||||
pub fn list_commands(&self) -> Vec<CommandInfo> {
|
||||
|
|
@ -222,6 +246,26 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_notifications_get_fresh_ids() {
|
||||
let mut engine = Engine::new().unwrap();
|
||||
let first = engine.notify(
|
||||
NotificationLevel::Error,
|
||||
Some("notification.project.openFailed"),
|
||||
Some("cannot open".into()),
|
||||
None,
|
||||
);
|
||||
let second = engine.notify(NotificationLevel::Info, None, Some("hi".into()), None);
|
||||
let id = |events: &[crate::Event]| match events.last() {
|
||||
Some(crate::Event::Notification { id, .. }) => id.clone(),
|
||||
other => panic!("not a notification: {other:?}"),
|
||||
};
|
||||
assert_eq!(first.len(), 1);
|
||||
assert_eq!(id(&first), "n1");
|
||||
assert_eq!(id(&second), "n2");
|
||||
assert!(engine.take_events().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn about_reports_product_information() {
|
||||
let mut engine = Engine::new().unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue