on main help sign in
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.

commit806d21ec7132d9e63cb7896c8cc63b2224b17677 authorAyman Bagabas <ayman.bagabas@gmail.com> dateTue 15 Jul 2025, 16:31 (1 year ago) parent5389513
1 file changed+12−8
internal/tui/page/chat/chat.go+12−8
internal/tui/page/chat/chat.go+12−8
@@ -273,7 +273,7 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
273273 return p, p.cancel()
274274 }
275275 case key.Matches(msg, p.keyMap.Details):
276− p.showDetails()
276+ p.toggleDetails()
277277 return p, nil
278278 }
279279
@@ -415,12 +415,9 @@ func (p *chatPage) setCompactMode(compact bool) {
415415 }
416416 p.compact = compact
417417 if compact {
418− p.compact = true
419418 p.sidebar.SetCompactMode(true)
420419 } else {
421− p.compact = false
422− p.showingDetails = false
423− p.sidebar.SetCompactMode(false)
420+ p.setShowDetails(false)
424421 }
425422}
426423
@@ -525,12 +522,19 @@ func (p *chatPage) cancel() tea.Cmd {
525522 return cancelTimerCmd()
526523}
527524
528−func (p *chatPage) showDetails() {
525+func (p *chatPage) setShowDetails(show bool) {
526+ p.showingDetails = show
527+ p.header.SetDetailsOpen(p.showingDetails)
528+ if !p.compact {
529+ p.sidebar.SetCompactMode(false)
530+ }
531+}
532+
533+func (p *chatPage) toggleDetails() {
529534 if p.session.ID == "" || !p.compact {
530535 return
531536 }
532− p.showingDetails = !p.showingDetails
533− p.header.SetDetailsOpen(p.showingDetails)
537+ p.setShowDetails(!p.showingDetails)
534538}
535539
536540func (p *chatPage) sendMessage(text string, attachments []message.Attachment) tea.Cmd {