@@ -52,6 +52,7 @@ type SessionFilesMsg struct {
type Sidebar interface {
util.Model
layout.Sizeable
+ SetSession(session session.Session) tea.Cmd
}
type sidebarCmp struct {
@@ -83,10 +84,7 @@ func (m *sidebarCmp) Init() tea.Cmd {
func (m *sidebarCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case chat.SessionSelectedMsg:
- if msg.ID != m.session.ID {
- m.session = msg
- }
- return m, m.loadSessionFiles
+ return m, m.SetSession(msg)
case SessionFilesMsg:
m.files = sync.Map{}
for _, file := range msg.Files {
@@ -506,6 +504,12 @@ func (s *sidebarCmp) currentModelBlock() string {
)
}
+// SetSession implements Sidebar.
+func (m *sidebarCmp) SetSession(session session.Session) tea.Cmd {
+ m.session = session
+ return m.loadSessionFiles
+}
+
func cwd() string {
cwd := config.WorkingDirectory()
t := styles.CurrentTheme()
@@ -167,6 +167,8 @@ func (p *chatPage) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
p.clearMessages(),
util.CmdHandler(chat.SessionClearedMsg{}),
p.setCompactMode(false),
+ p.layout.FocusPanel(layout.BottomPanel),
+ util.CmdHandler(ChatFocusedMsg{Focused: false}),
)
case key.Matches(msg, p.keyMap.AddAttachment):
cfg := config.Get()
@@ -238,7 +240,7 @@ func (p *chatPage) setMessages() tea.Cmd {
}
func (p *chatPage) setSidebar() tea.Cmd {
- sidebarContainer := sidebarCmp(p.app, false)
+ sidebarContainer := sidebarCmp(p.app, false, p.session)
sidebarContainer.Init()
return p.layout.SetRightPanel(sidebarContainer)
}
@@ -378,13 +380,18 @@ func (p *chatPage) Bindings() []key.Binding {
return bindings
}
-func sidebarCmp(app *app.App, compact bool) layout.Container {
+func sidebarCmp(app *app.App, compact bool, session session.Session) layout.Container {
padding := layout.WithPadding(1, 1, 1, 1)
if compact {
padding = layout.WithPadding(0, 1, 1, 1)
}
+ sidebar := sidebar.NewSidebarCmp(app.History, app.LSPClients, compact)
+ if session.ID != "" {
+ sidebar.SetSession(session)
+ }
+
return layout.NewContainer(
- sidebar.NewSidebarCmp(app.History, app.LSPClients, compact),
+ sidebar,
padding,
)
}
@@ -396,12 +403,12 @@ func NewChatPage(app *app.App) ChatPage {
return &chatPage{
app: app,
layout: layout.NewSplitPane(
- layout.WithRightPanel(sidebarCmp(app, false)),
+ layout.WithRightPanel(sidebarCmp(app, false, session.Session{})),
layout.WithBottomPanel(editorContainer),
layout.WithFixedBottomHeight(5),
layout.WithFixedRightWidth(31),
),
- compactSidebar: sidebarCmp(app, true),
+ compactSidebar: sidebarCmp(app, true, session.Session{}),
keyMap: DefaultKeyMap(),
header: header.New(app.LSPClients),
}