Skip to content

Commit feb2658

Browse files
committed
feat: switch notification format to json lines
1 parent 07a2acf commit feb2658

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src-tauri/src/manager.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -737,36 +737,37 @@ fn start_notify_module_thread(
737737
})
738738
.expect("Failed to send module started message");
739739

740-
// Read output continuously and parse notifications
740+
// Read output continuously and parse notifications as JSON Lines
741741
let stdout = child.stdout.take().expect("Failed to get stdout");
742742
let reader = BufReader::new(stdout);
743743

744-
let mut in_notification = false;
745-
let mut notification_content = Vec::new();
746-
747744
for line in reader.lines() {
748745
match line {
749746
Ok(line_content) => {
750-
// Check for notification boundaries (exactly 50 dashes)
751-
if line_content == "-".repeat(50) {
752-
if in_notification {
753-
// End of notification - send it
754-
if !notification_content.is_empty() {
755-
let content = notification_content.join("\n");
756-
send_notification(&content);
757-
notification_content.clear();
758-
}
759-
in_notification = false;
747+
// Try to parse as JSON notification
748+
if let Ok(notification) =
749+
serde_json::from_str::<serde_json::Value>(&line_content)
750+
{
751+
// Extract title and message from JSON
752+
if let (Some(title), Some(message)) = (
753+
notification.get("title").and_then(|t| t.as_str()),
754+
notification.get("message").and_then(|m| m.as_str()),
755+
) {
756+
// Format notification: "title\nmessage"
757+
let content = format!("{}\n{}", title, message);
758+
send_notification(&content);
759+
debug!(
760+
"Parsed JSON notification: title='{}', message length={}",
761+
title,
762+
message.len()
763+
);
760764
} else {
761-
// Start of notification
762-
in_notification = true;
765+
debug!("JSON notification missing title or message fields");
763766
}
764-
} else if in_notification && !line_content.trim().is_empty() {
765-
// Collect notification content
766-
notification_content.push(line_content.clone());
767+
} else {
768+
// Not JSON - could be info logs or old format fallback
769+
debug!("aw-notify output (non-JSON): {}", line_content);
767770
}
768-
// Debug log aw-notify output (won't show at Info level)
769-
debug!("aw-notify output: {}", line_content);
770771
}
771772
Err(e) => {
772773
error!("Error reading aw-notify output: {}", e);

0 commit comments

Comments
 (0)