From 806d21ec7132d9e63cb7896c8cc63b2224b17677 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Tue, 15 Jul 2025 16:31:40 -0400 Subject: [PATCH] fix(tui): chat: fix compact mode details toggle If the details are open, then the window gets wider, the sidebar state doesn't get reset. This commit fixes the issue by ensuring that the sidebar is reset when the compact mode is toggled off. --- internal/tui/page/chat/chat.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/internal/tui/page/chat/chat.go b/internal/tui/page/chat/chat.go index be7c0f2658202ea59e70778df1785b98310bc458..a76c3b2e9f0f81f862da221d4908d2e932380295 100644 --- a/internal/tui/page/chat/chat.go +++ b/internal/tui/page/chat/chat.go @@ -273,7 +273,7 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return p, p.cancel() } case key.Matches(msg, p.keyMap.Details): - p.showDetails() + p.toggleDetails() return p, nil } @@ -415,12 +415,9 @@ func (p *chatPage) setCompactMode(compact bool) { } p.compact = compact if compact { - p.compact = true p.sidebar.SetCompactMode(true) } else { - p.compact = false - p.showingDetails = false - p.sidebar.SetCompactMode(false) + p.setShowDetails(false) } } @@ -525,12 +522,19 @@ func (p *chatPage) cancel() tea.Cmd { return cancelTimerCmd() } -func (p *chatPage) showDetails() { +func (p *chatPage) setShowDetails(show bool) { + p.showingDetails = show + p.header.SetDetailsOpen(p.showingDetails) + if !p.compact { + p.sidebar.SetCompactMode(false) + } +} + +func (p *chatPage) toggleDetails() { if p.session.ID == "" || !p.compact { return } - p.showingDetails = !p.showingDetails - p.header.SetDetailsOpen(p.showingDetails) + p.setShowDetails(!p.showingDetails) } func (p *chatPage) sendMessage(text string, attachments []message.Attachment) tea.Cmd {