Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions crates/openlogi-agent-core/src/orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1819,10 +1819,19 @@ impl Orchestrator {
) {
continue;
}
// The same precedence the tray and the GUI use: a user-assigned
// name, then the product name the settings app persisted, then the
// firmware codename.
let name = self
.config
.device_custom_name(&device.config_key)
.map(str::to_owned)
.or_else(|| {
self.config
.device_identity(&device.config_key)
.map(|identity| identity.display_name.trim().to_owned())
.filter(|name| !name.is_empty())
})
.or_else(|| device.codename.as_deref().map(prettify_codename));
info!(device = %device.config_key, ?battery, "announcing a low battery");
self.observable.notices().post(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,41 @@ async fn the_notice_names_the_device_as_the_user_does() {
);
}

#[tokio::test]
async fn the_notice_prefers_the_persisted_product_name() {
let mut config = Config::default();
config.set_device_identity(
KEY,
openlogi_core::config::DeviceIdentity {
display_name: "MX Master 3S".to_owned(),
model_info: None,
codename: Some("Synthetic Performance Mouse".to_owned()),
kind: DeviceKind::Mouse,
capabilities: openlogi_core::device::Capabilities::default(),
light_capabilities: None,
driver_id: None,
registry_model_id: None,
},
);
let (mut orch, observable) = wired(config);
refresh(
&mut orch,
discharging(10),
true,
"Synthetic Performance Mouse",
);
let posted = notices(&observable).await;
assert_eq!(posted.len(), 1);
assert_eq!(
posted[0].kind,
NoticeKind::LowBattery {
name: Some("MX Master 3S".to_owned()),
kind: DeviceKind::Mouse,
battery: discharging(10),
}
);
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
}

#[tokio::test]
async fn a_shouted_device_name_is_tidied() {
let (mut orch, observable) = wired(Config::default());
Expand Down