on main help sign in
fix: fix sidebar init, fix focus
commitb78bf052b4e49929a675c451e8f109240b5ce6ad authorKujtim Hoxha <kujtimii.h@gmail.com> dateMon 23 Jun 2025, 11:13 (1 year ago) parent1631766
2 files changed+20−9
internal/tui/components/chat/sidebar/sidebar.go+8−4 internal/tui/page/chat/chat.go+12−5
internal/tui/components/chat/sidebar/sidebar.go+8−4
@@ -52,6 +52,7 @@ type SessionFilesMsg struct {
5252type Sidebar interface {
5353 util.Model
5454 layout.Sizeable
55+ SetSession(session session.Session) tea.Cmd
5556}
5657
5758type sidebarCmp struct {
@@ -83,10 +84,7 @@ func (m *sidebarCmp) Init() tea.Cmd {
8384func (m *sidebarCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
8485 switch msg := msg.(type) {
8586 case chat.SessionSelectedMsg:
86− if msg.ID != m.session.ID {
87− m.session = msg
88− }
89− return m, m.loadSessionFiles
87+ return m, m.SetSession(msg)
9088 case SessionFilesMsg:
9189 m.files = sync.Map{}
9290 for _, file := range msg.Files {
@@ -506,6 +504,12 @@ func (s *sidebarCmp) currentModelBlock() string {
506504 )
507505}
508506
507+// SetSession implements Sidebar.
508+func (m *sidebarCmp) SetSession(session session.Session) tea.Cmd {
509+ m.session = session
510+ return m.loadSessionFiles
511+}
512+
509513func cwd() string {
510514 cwd := config.WorkingDirectory()
511515 t := styles.CurrentTheme()
internal/tui/page/chat/chat.go+12−5
@@ -167,6 +167,8 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
167167 p.clearMessages(),
168168 util.CmdHandler(chat.SessionClearedMsg{}),
169169 p.setCompactMode(false),
170+ p.layout.FocusPanel(layout.BottomPanel),
171+ util.CmdHandler(ChatFocusedMsg{Focused: false}),
170172 )
171173 case key.Matches(msg, p.keyMap.AddAttachment):
172174 cfg := config.Get()
@@ -238,7 +240,7 @@ func (p *chatPage) setMessages() tea.Cmd {
238240}
239241
240242func (p *chatPage) setSidebar() tea.Cmd {
241− sidebarContainer := sidebarCmp(p.app, false)
243+ sidebarContainer := sidebarCmp(p.app, false, p.session)
242244 sidebarContainer.Init()
243245 return p.layout.SetRightPanel(sidebarContainer)
244246}
@@ -378,13 +380,18 @@ func (p *chatPage) Bindings() []key.Binding {
378380 return bindings
379381}
380382
381−func sidebarCmp(app *app.App, compact bool) layout.Container {
383+func sidebarCmp(app *app.App, compact bool, session session.Session) layout.Container {
382384 padding := layout.WithPadding(1, 1, 1, 1)
383385 if compact {
384386 padding = layout.WithPadding(0, 1, 1, 1)
385387 }
388+ sidebar := sidebar.NewSidebarCmp(app.History, app.LSPClients, compact)
389+ if session.ID != "" {
390+ sidebar.SetSession(session)
391+ }
392+
386393 return layout.NewContainer(
387− sidebar.NewSidebarCmp(app.History, app.LSPClients, compact),
394+ sidebar,
388395 padding,
389396 )
390397}
@@ -396,12 +403,12 @@ func NewChatPage(app *app.App) ChatPage {
396403 return &chatPage{
397404 app: app,
398405 layout: layout.NewSplitPane(
399− layout.WithRightPanel(sidebarCmp(app, false)),
406+ layout.WithRightPanel(sidebarCmp(app, false, session.Session{})),
400407 layout.WithBottomPanel(editorContainer),
401408 layout.WithFixedBottomHeight(5),
402409 layout.WithFixedRightWidth(31),
403410 ),
404− compactSidebar: sidebarCmp(app, true),
411+ compactSidebar: sidebarCmp(app, true, session.Session{}),
405412 keyMap: DefaultKeyMap(),
406413 header: header.New(app.LSPClients),
407414 }