feat(ui): working vertical slice — dashboard, channel view, send
- mattermost-dashboard-mode: list channels from bridge - mattermost-channel-mode: view history and send messages - Interactive connection prompt (password in memory only) - Fix JSON array parsing (vectors → lists) in protocol layer - Add mattermost-reset-state for clean reconnects - Add dev-check.sh for quick Rust validation - Verified end-to-end: Emacs → Bridge → Mattermost → back
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
(require 'mattermost-custom)
|
||||
(require 'mattermost-protocol)
|
||||
(require 'mattermost-channel)
|
||||
|
||||
(defvar mattermost--current-server-id nil
|
||||
"Current server ID for the dashboard buffer.")
|
||||
@@ -19,9 +20,18 @@
|
||||
(setq buffer-read-only t)
|
||||
(setq truncate-lines t))
|
||||
|
||||
(defun mattermost-reset-state ()
|
||||
"Reset all connection state and clear pending requests."
|
||||
(interactive)
|
||||
(when (and (boundp 'mattermost--process) mattermost--process (process-live-p mattermost--process))
|
||||
(delete-process mattermost--process))
|
||||
(setq mattermost--process nil)
|
||||
(setq mattermost--pending-requests (make-hash-table :test 'equal))
|
||||
(setq mattermost--input-buffer "")
|
||||
(message "[MM] State reset complete. Ready to reconnect."))
|
||||
|
||||
(defun mattermost-ensure-connected (callback)
|
||||
"Ensure connection to the bridge, prompting for missing credentials.
|
||||
Calls CALLBACK with server-id on success. Password is never saved to disk."
|
||||
"Ensure connection to the bridge, prompting for missing credentials."
|
||||
(let* ((url (if (string= mattermost-server-url "")
|
||||
(read-string "Mattermost URL (e.g., https://mattermost.local): ")
|
||||
mattermost-server-url))
|
||||
@@ -31,12 +41,16 @@ Calls CALLBACK with server-id on success. Password is never saved to disk."
|
||||
(password (read-passwd "Password (or PAT token): "))
|
||||
(server-id mattermost-server-id))
|
||||
|
||||
;; Сохраняем только не-секретные настройки, если они были пустыми
|
||||
(when (string= mattermost-server-url "")
|
||||
(customize-save-variable 'mattermost-server-url url))
|
||||
(when (string= mattermost-login-id "")
|
||||
(customize-save-variable 'mattermost-login-id login))
|
||||
|
||||
(unless (and (boundp 'mattermost--process)
|
||||
mattermost--process
|
||||
(process-live-p mattermost--process))
|
||||
(mattermost-connect-to-bridge))
|
||||
|
||||
(message "[MM-DEBUG] Connecting to %s as %s (password masked)" url login)
|
||||
(mattermost--send-request
|
||||
"connect"
|
||||
@@ -70,21 +84,22 @@ Calls CALLBACK with server-id on success. Password is never saved to disk."
|
||||
"Render CHANNELS in a new Mattermost Dashboard buffer."
|
||||
(let ((buf (get-buffer-create "*Mattermost Dashboard*")))
|
||||
(with-current-buffer buf
|
||||
(erase-buffer)
|
||||
(mattermost-dashboard-mode)
|
||||
(setq-local mattermost--current-server-id server-id)
|
||||
(setq-local mattermost--channels channels)
|
||||
|
||||
(insert "Mattermost Channels\n")
|
||||
(insert "==================\n\n")
|
||||
|
||||
(dolist (ch channels)
|
||||
(let ((name (or (plist-get ch :display_name) "Unknown"))
|
||||
(type (or (plist-get ch :channel_type) "?"))
|
||||
(id (plist-get ch :id)))
|
||||
(insert (format "[%s] %s (ID: %s)\n" type name id))))
|
||||
|
||||
(goto-char (point-min)))
|
||||
(let ((inhibit-read-only t))
|
||||
(erase-buffer)
|
||||
(mattermost-dashboard-mode)
|
||||
(setq-local mattermost--current-server-id server-id)
|
||||
(setq-local mattermost--channels channels)
|
||||
|
||||
(insert "Mattermost Channels\n")
|
||||
(insert "==================\n\n")
|
||||
|
||||
(dolist (ch channels)
|
||||
(let ((name (or (plist-get ch :display_name) "Unknown"))
|
||||
(type (or (plist-get ch :channel_type) "?"))
|
||||
(id (plist-get ch :id)))
|
||||
(insert (format "[%s] %s (ID: %s)\n" type name id))))
|
||||
|
||||
(goto-char (point-min))))
|
||||
(switch-to-buffer buf)))
|
||||
|
||||
(defun mattermost-dashboard-refresh ()
|
||||
@@ -109,8 +124,14 @@ Calls CALLBACK with server-id on success. Password is never saved to disk."
|
||||
(interactive)
|
||||
(let ((line (thing-at-point 'line t)))
|
||||
(if (string-match "ID: \\([a-z0-9]+\\)" line)
|
||||
(let ((channel-id (match-string 1 line)))
|
||||
(message "[MM] Opening channel: %s (TODO: implement channel buffer)" channel-id))
|
||||
(let* ((channel-id (match-string 1 line))
|
||||
(server-id mattermost--current-server-id)
|
||||
(channel-name (if (string-match "\\] \\(.+\\) (ID:" line)
|
||||
(match-string 1 line)
|
||||
"Unknown")))
|
||||
(if server-id
|
||||
(mattermost-channel-open server-id channel-id channel-name)
|
||||
(error "No server ID associated with this dashboard")))
|
||||
(message "[MM] No channel ID found on this line."))))
|
||||
|
||||
(provide 'mattermost-dashboard)
|
||||
|
||||
Reference in New Issue
Block a user