@@ -529,13 +529,18 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
529 m.dialog.Update(msg)
529 m.dialog.Update(msg)
530 return m, tea.Batch(cmds...)
530 return m, tea.Batch(cmds...)
533+ if cmd := m.handleClickFocus(msg); cmd != nil {
534+ cmds = append(cmds, cmd)
532 switch m.state {
537 switch m.state {
533 case uiChat:
538 case uiChat:
534 x, y := msg.X, msg.Y
539 x, y := msg.X, msg.Y
535 // Adjust for chat area position
540 // Adjust for chat area position
536 x -= m.layout.main.Min.X
541 x -= m.layout.main.Min.X
537 y -= m.layout.main.Min.Y
542 y -= m.layout.main.Min.Y
538− if m.chat.HandleMouseDown(x, y) {
543+ if !image.Pt(msg.X, msg.Y).In(m.layout.sidebar) && m.chat.HandleMouseDown(x, y) {
539 m.lastClickTime = time.Now()
544 m.lastClickTime = time.Now()
@@ -897,6 +902,24 @@ func (m *UI) appendSessionMessage(msg message.Message) tea.Cmd {
897 return tea.Batch(cmds...)
902 return tea.Batch(cmds...)
905+func (m *UI) handleClickFocus(msg tea.MouseClickMsg) (cmd tea.Cmd) {
907+ case m.state != uiChat:
909+ case image.Pt(msg.X, msg.Y).In(m.layout.sidebar):
911+ case m.focus != uiFocusEditor && image.Pt(msg.X, msg.Y).In(m.layout.editor):
912+ m.focus = uiFocusEditor
913+ cmd = m.textarea.Focus()
915+ case m.focus != uiFocusMain && image.Pt(msg.X, msg.Y).In(m.layout.main):
916+ m.focus = uiFocusMain
900// updateSessionMessage updates an existing message in the current session in the chat
923// updateSessionMessage updates an existing message in the current session in the chat
901// when an assistant message is updated it may include updated tool calls as well
924// when an assistant message is updated it may include updated tool calls as well
902// that is why we need to handle creating/updating each tool call message too
925// that is why we need to handle creating/updating each tool call message too