From 8f38996b8a0ff7b55e116098bd96d0eaf111de72 Mon Sep 17 00:00:00 2001 From: ayn2op Date: Wed, 2 Sep 2026 20:00:33 -0400 Subject: [PATCH] feat(chat): toggle reply mentions from composer --- internal/config/config.toml | 2 ++ internal/config/keybinds.go | 30 ++++++++++++++++-------------- internal/ui/chat/composer.go | 28 +++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 15 deletions(-) diff --git a/internal/config/config.toml b/internal/config/config.toml index 41d63a9..30f86f8 100644 --- a/internal/config/config.toml +++ b/internal/config/config.toml @@ -189,6 +189,8 @@ newline = "shift+enter" cancel = "esc" # Complete usernames when mentioning tab_complete = "tab" +# Toggle whether a reply mentions its author. +toggle_reply_mention = "shift+tab" undo = "ctrl+u" open_editor = "ctrl+e" diff --git a/internal/config/keybinds.go b/internal/config/keybinds.go index 1f75364..9d44eae 100644 --- a/internal/config/keybinds.go +++ b/internal/config/keybinds.go @@ -92,12 +92,13 @@ type MessagesListKeybinds struct { } type ComposerKeybinds struct { - Paste Keybind `toml:"paste"` - Send Keybind `toml:"send"` - Newline Keybind `toml:"newline"` - Cancel Keybind `toml:"cancel"` - TabComplete Keybind `toml:"tab_complete"` - Undo Keybind `toml:"undo"` + Paste Keybind `toml:"paste"` + Send Keybind `toml:"send"` + Newline Keybind `toml:"newline"` + Cancel Keybind `toml:"cancel"` + TabComplete Keybind `toml:"tab_complete"` + ToggleReplyMention Keybind `toml:"toggle_reply_mention"` + Undo Keybind `toml:"undo"` OpenEditor Keybind `toml:"open_editor"` OpenFilePicker Keybind `toml:"open_file_picker"` @@ -185,14 +186,15 @@ func defaultMessagesListKeybinds() MessagesListKeybinds { func defaultComposerKeybinds() ComposerKeybinds { return ComposerKeybinds{ - Paste: desc("paste"), - Send: desc("send"), - Newline: desc("nl"), - Cancel: desc("cancel"), - TabComplete: desc("complete"), - Undo: desc("undo"), - OpenEditor: desc("editor"), - OpenFilePicker: desc("attach"), + Paste: desc("paste"), + Send: desc("send"), + Newline: desc("nl"), + Cancel: desc("cancel"), + TabComplete: desc("complete"), + ToggleReplyMention: desc("toggle @reply"), + Undo: desc("undo"), + OpenEditor: desc("editor"), + OpenFilePicker: desc("attach"), } } diff --git a/internal/ui/chat/composer.go b/internal/ui/chat/composer.go index d85894e..1abab7c 100644 --- a/internal/ui/chat/composer.go +++ b/internal/ui/chat/composer.go @@ -204,6 +204,9 @@ func (c *composer) Update(msg tview.Msg) tview.Cmd { return c.tabComplete() } return c.forwardToTextArea(msg) + case keybind.Matches(msg, c.cfg.Keybinds.Composer.ToggleReplyMention.Keybind): + c.toggleReplyMention() + return nil case keybind.Matches(msg, c.cfg.Keybinds.Composer.Undo.Keybind): return c.forwardToTextArea(tcell.NewEventKey(tcell.KeyCtrlZ, "", tcell.ModNone)) } @@ -228,6 +231,21 @@ func (c *composer) Update(msg tview.Msg) tview.Cmd { return c.TextArea.Update(msg) } +func (c *composer) toggleReplyMention() { + data := c.sendMessageData + if data.Reference == nil || data.AllowedMentions == nil || data.AllowedMentions.RepliedUser == nil { + return + } + + mention := !*data.AllowedMentions.RepliedUser + data.AllowedMentions.RepliedUser = option.Some(mention) + title := strings.TrimPrefix(c.Title(), "[@] ") + if mention { + title = "[@] " + title + } + c.SetTitle(title) +} + type imagePastedMsg []byte func pasteImage() tview.Cmd { @@ -830,6 +848,9 @@ func (c *composer) ShortHelp() []keybind.Keybind { cfg := c.cfg.Keybinds.Composer short := []keybind.Keybind{cfg.Send.Keybind, cfg.Newline.Keybind, cfg.Cancel.Keybind, cfg.Paste.Keybind, cfg.OpenEditor.Keybind} + if c.sendMessageData.Reference != nil { + short = append(short, cfg.ToggleReplyMention.Keybind) + } if c.canAttachFiles() { short = append(short, cfg.OpenFilePicker.Keybind) } @@ -853,8 +874,13 @@ func (c *composer) FullHelp() [][]keybind.Keybind { openEditor = append(openEditor, cfg.OpenFilePicker.Keybind) } + compose := []keybind.Keybind{cfg.Send.Keybind, cfg.Newline.Keybind, cfg.Cancel.Keybind, cfg.Undo.Keybind} + if c.sendMessageData.Reference != nil { + compose = append(compose, cfg.ToggleReplyMention.Keybind) + } + return [][]keybind.Keybind{ - {cfg.Send.Keybind, cfg.Newline.Keybind, cfg.Cancel.Keybind, cfg.Undo.Keybind}, + compose, openEditor, } }