fix(tui): chat: fix compact mode details toggle
Ayman Bagabas
created 4 months ago
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.
Change summary
internal/tui/page/chat/chat.go | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
Detailed changes
@@ -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 {