fix: handle new session when focused on the list

Kujtim Hoxha created

Change summary

internal/ui/model/keys.go |  4 ++--
internal/ui/model/ui.go   | 10 ++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)

Detailed changes

internal/ui/model/keys.go 🔗

@@ -166,11 +166,11 @@ func DefaultKeyMap() KeyMap {
 	)
 
 	km.Chat.Down = key.NewBinding(
-		key.WithKeys("down", "ctrl+j", "ctrl+n", "j"),
+		key.WithKeys("down", "ctrl+j", "j"),
 		key.WithHelp("↓", "down"),
 	)
 	km.Chat.Up = key.NewBinding(
-		key.WithKeys("up", "ctrl+k", "ctrl+p", "k"),
+		key.WithKeys("up", "ctrl+k", "k"),
 		key.WithHelp("↑", "up"),
 	)
 	km.Chat.UpDown = key.NewBinding(

internal/ui/model/ui.go 🔗

@@ -1511,6 +1511,16 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
 				m.focus = uiFocusEditor
 				cmds = append(cmds, m.textarea.Focus())
 				m.chat.Blur()
+			case key.Matches(msg, m.keyMap.Chat.NewSession):
+				if !m.hasSession() {
+					break
+				}
+				if m.isAgentBusy() {
+					cmds = append(cmds, uiutil.ReportWarn("Agent is busy, please wait before starting a new session..."))
+					break
+				}
+				m.focus = uiFocusEditor
+				m.newSession()
 			case key.Matches(msg, m.keyMap.Chat.Expand):
 				m.chat.ToggleExpandedSelectedItem()
 			case key.Matches(msg, m.keyMap.Chat.Up):