Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/tui/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ import (

// Session management handlers

func (a *appModel) applyKeyboardEnhancements() {
if a.keyboardEnhancements != nil {
updated, _ := a.chatPage.Update(*a.keyboardEnhancements)
a.chatPage = updated.(chat.Page)
}
}

func (a *appModel) handleNewSession() (tea.Model, tea.Cmd) {
// Theme is now global - no per-session theme reset needed
a.application.NewSession()
sess := a.application.Session()
a.sessionState = service.NewSessionState(sess)
a.chatPage = chat.New(a.application, a.sessionState)
a.dialog = dialog.New()
a.statusBar.SetHelp(a.chatPage)
a.applyKeyboardEnhancements()

return a, tea.Batch(
a.Init(),
Expand Down Expand Up @@ -82,7 +89,7 @@ func (a *appModel) handleLoadSession(sessionID string) (tea.Model, tea.Cmd) {
a.sessionState = service.NewSessionState(sess)
a.chatPage = chat.New(a.application, a.sessionState)
a.dialog = dialog.New()
a.statusBar.SetHelp(a.chatPage)
a.applyKeyboardEnhancements()

return a, tea.Batch(
a.Init(),
Expand Down
6 changes: 6 additions & 0 deletions pkg/tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ type appModel struct {
themeWatcherEventCh chan string // Channel for theme file change events (carries themeRef)
themeListenerStarted bool // Guard to prevent multiple listeners

// keyboardEnhancements stores the last keyboard enhancements message from the terminal.
// This is reapplied to new chat/editor instances when sessions are switched.
keyboardEnhancements *tea.KeyboardEnhancementsMsg

ready bool
err error
}
Expand Down Expand Up @@ -255,6 +259,8 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return a, cmd

case tea.KeyboardEnhancementsMsg:
// Store the keyboard enhancements message so we can reapply it to new chat pages
a.keyboardEnhancements = &msg
updated, cmd := a.chatPage.Update(msg)
a.chatPage = updated.(chat.Page)
return a, cmd
Expand Down