From 0151d4ad02edbfed7a1dc6ccb78c50fd06537fff Mon Sep 17 00:00:00 2001 From: James Brechtel Date: Mon, 15 Jun 2026 11:01:26 -0400 Subject: [PATCH] UI updates --- noise-chat-list.el | 35 +++++++++++++++++++++++++---------- noise-conversation.el | 6 +++++- test/noise-chat-list-test.el | 4 ++-- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/noise-chat-list.el b/noise-chat-list.el index 2f9d575..9fcc472 100644 --- a/noise-chat-list.el +++ b/noise-chat-list.el @@ -32,9 +32,13 @@ (setq buffer-read-only t) (setq-local header-line-format (concat " U " - (format "%-20s" "Name") - (format "%-40s" "Last message") - "When"))) + (format "%-18s" "Name") + (format "%-42s" "Last message") + "When")) + (when (bound-and-true-p evil-mode) + (let ((m (make-sparse-keymap))) + (define-key m (kbd "RET") #'noise-chat-list-open) + (setq-local evil-normal-state-local-map m)))) ;;;###autoload (defun noise-chat-list () @@ -50,10 +54,21 @@ (let ((inhibit-read-only t) (conversations (noise-db-get-all-conversations))) (erase-buffer) + ;; Clear old fringe overlays + (remove-overlays (point-min) (point-max) 'noise-fringe t) (if (null conversations) (insert "No conversations. Sync from signal-cli with `g`.\n") (dolist (conv conversations) - (insert (noise-chat-list--format-row conv) "\n"))) + (let ((unread (or (gethash "unread_count" conv) 0)) + (row (noise-chat-list--format-row conv))) + (insert row "\n") + (when (> unread 0) + (let ((ov (make-overlay (line-beginning-position 0) + (line-beginning-position 0)))) + (overlay-put ov 'noise-fringe t) + (overlay-put ov 'before-string + (propertize " " 'display + '(left-fringe filled-rectangle warning)))))))) (noise-chat-list--update-modeline conversations) (goto-char (point-min)) (set-buffer-modified-p nil))) @@ -93,13 +108,13 @@ Today: HH:MM, this week: Ddd, older: Mon DD." (defun noise-chat-list--format-row (conv) "Format a single conversation row for display. -CONV is a hash table with string keys from noise-db." +CONV is a hash table with string keys from noise-db. +The unread dot is rendered in the Emacs fringe, not inline." (let* ((unread (or (gethash "unread_count" conv) 0)) (name (or (gethash "name" conv) "Unknown")) (preview (or (gethash "last_message_preview" conv) "")) (sender (or (gethash "last_message_sender" conv) "")) (timestamp (or (gethash "last_message_time" conv) 0)) - (fringe (if (> unread 0) "●" " ")) (unread-str (if (> unread 0) (format "%3d" unread) " ")) (name-str (truncate-string-to-width name 18 nil nil "…")) (preview-prefix @@ -107,11 +122,11 @@ CONV is a hash table with string keys from noise-db." ((string= sender "") preview) ((string= sender "me") (concat "me: " preview)) (t (concat sender ": " preview)))) - (preview-str (truncate-string-to-width preview-prefix 36 nil nil "…")) + (preview-str (truncate-string-to-width preview-prefix 42 nil nil "…")) (time-str (noise-chat-list--format-time timestamp))) - (concat (propertize fringe 'face 'warning) " " unread-str " " - (propertize (format "%-18s" name-str) 'face 'bold) " " - preview-str " " + (concat unread-str " " + (propertize (format "%-18s" name-str) 'face 'bold) + (propertize (format "%-42s" preview-str) 'face 'shadow) (propertize time-str 'face 'shadow)))) (defun noise-chat-list--conversation-at-point () diff --git a/noise-conversation.el b/noise-conversation.el index 1d9336d..dea630f 100644 --- a/noise-conversation.el +++ b/noise-conversation.el @@ -47,7 +47,11 @@ "Major mode for a Noise Signal conversation buffer. \\{noise-conversation-mode-map}" :group 'noise - (setq-local header-line-format noise-conversation--mode-header)) + (setq-local header-line-format noise-conversation--mode-header) + (when (bound-and-true-p evil-mode) + (let ((m (make-sparse-keymap))) + (define-key m (kbd "RET") #'noise-conversation-send) + (setq-local evil-normal-state-local-map m)))) ;;;###autoload (defun noise-conversation-open (conversation-id) diff --git a/test/noise-chat-list-test.el b/test/noise-chat-list-test.el index 17c87e4..ae398c0 100644 --- a/test/noise-chat-list-test.el +++ b/test/noise-chat-list-test.el @@ -39,7 +39,7 @@ (noise-chat-list-test--make-row "conv-1" "Sarah" 3 "are you taking the girls?" "Sarah" (float-time))))) - (should (string-match "●" row)) + (should (string-match " 3" row)) (should (string-match "Sarah" row)) (should (string-match "are you taking" row)))) @@ -49,4 +49,4 @@ (noise-chat-list-test--make-row "conv-2" "Mark Okafor" 0 "merged" "me" (float-time))))) (should (string-match "Mark Okafor" row)) - (should-not (string-match "●" row)))) + (should (string-match "^ " row))))