fix: show notifications and unread count for SSE messages arriving when chat closed
Three gaps caused messages received via SSE to be invisible when the conversation buffer wasn't already open: 1. Echo-area notification (noise-receive.el): when an SSE message arrives and the conversation buffer isn't in a visible window, show "[Noise] <name>" in the echo area. 2. Modeline unread counter (noise.el): the noise-mode lighter now shows Noise[N] for N unread messages via a lightweight SUM aggregation across all conversations. 3. Auto-refresh hook (noise-conversation.el): a window-buffer-change-functions hook re-renders *signal:* buffers when they become visible, covering direct C-x b switches. Also adds regression test: noise-receive-sse-stores-then-open-shows-message — store via SSE handler with no buffer open, then open and verify.
This commit is contained in:
+10
-1
@@ -44,13 +44,22 @@ Returns the number of new messages stored."
|
||||
(message "Received %d new message%s" new (if (= new 1) "" "s")))
|
||||
new))
|
||||
|
||||
(defun noise-receive--announce-message (conv-id)
|
||||
"Show a brief echo-area notification for a new message in CONV-ID."
|
||||
(let* ((conv (noise-db-get-conversation conv-id))
|
||||
(name (if conv (or (gethash "name" conv) conv-id) conv-id)))
|
||||
(message "[Noise] %s" name)))
|
||||
|
||||
(defun noise-receive--handle-sse-event (event)
|
||||
"Handle an SSE EVENT from signal-cli.
|
||||
Processes the envelope and updates UI."
|
||||
(noise-db-init)
|
||||
(when-let ((envelope (noise-receive--field event "envelope")))
|
||||
(when-let ((conv-id (noise-receive--process-envelope envelope)))
|
||||
(noise-conversation-refresh-for conv-id)
|
||||
(let ((buf (noise-conversation--buffer-for conv-id)))
|
||||
(if (and buf (get-buffer-window buf t))
|
||||
(noise-conversation-refresh-for conv-id)
|
||||
(noise-receive--announce-message conv-id)))
|
||||
(when-let ((buf (get-buffer "*signal*")))
|
||||
(with-current-buffer buf
|
||||
(noise-chat-list--render))))))
|
||||
|
||||
Reference in New Issue
Block a user