fix: focus textarea on init, use shift+enter for newlines

This commit is contained in:
Rahul Bansal 2026-02-21 19:07:39 +05:30
parent e43f5e3cf8
commit 9068f8a329

View file

@ -76,14 +76,16 @@ type Model struct {
// NewModel creates a new TUI model wired to the given agent loop // NewModel creates a new TUI model wired to the given agent loop
func NewModel(agentLoop *agent.AgentLoop, sessionKey, modelName string) Model { func NewModel(agentLoop *agent.AgentLoop, sessionKey, modelName string) Model {
ta := textarea.New() ta := textarea.New()
ta.Placeholder = "Type a message... (Enter to send, Alt+Enter for newline)" ta.Placeholder = "Type a message... (Enter to send, Shift+Enter for newline)"
ta.Prompt = "│ " ta.Prompt = "│ "
ta.CharLimit = 0 // No limit ta.CharLimit = 0 // No limit
ta.SetHeight(textareaHeight) ta.SetHeight(textareaHeight)
ta.ShowLineNumbers = false ta.ShowLineNumbers = false
// Enter sends, Alt+Enter inserts newline // Enter sends, Shift+Enter inserts newline
ta.KeyMap.InsertNewline = key.NewBinding(key.WithKeys("alt+enter")) ta.KeyMap.InsertNewline = key.NewBinding(key.WithKeys("shift+enter"))
ta.Focus()
ta.FocusedStyle.CursorLine = lipgloss.NewStyle() ta.FocusedStyle.CursorLine = lipgloss.NewStyle()