@@ -18,6 +18,7 @@ import (
18 "github.com/charmbracelet/crush/internal/session"
18 "github.com/charmbracelet/crush/internal/session"
19 "github.com/charmbracelet/crush/internal/tui/components/chat"
19 "github.com/charmbracelet/crush/internal/tui/components/chat"
20 "github.com/charmbracelet/crush/internal/tui/components/completions"
20 "github.com/charmbracelet/crush/internal/tui/components/completions"
21+ "github.com/charmbracelet/crush/internal/tui/components/dialogs/filepicker"
21 "github.com/charmbracelet/crush/internal/tui/layout"
22 "github.com/charmbracelet/crush/internal/tui/layout"
22 "github.com/charmbracelet/crush/internal/tui/styles"
23 "github.com/charmbracelet/crush/internal/tui/styles"
23 "github.com/charmbracelet/crush/internal/tui/util"
24 "github.com/charmbracelet/crush/internal/tui/util"
@@ -141,13 +142,13 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
141 m.session = msg
142 m.session = msg
143 return m, nil
144 return m, nil
144− // case dialog.AttachmentAddedMsg:
145+ case filepicker.FilePickedMsg:
145− // if len(m.attachments) >= maxAttachments {
146+ if len(m.attachments) >= maxAttachments {
146− // logging.ErrorPersist(fmt.Sprintf("cannot add more than %d images", maxAttachments))
147+ logging.ErrorPersist(fmt.Sprintf("cannot add more than %d images", maxAttachments))
147− // return m, cmd
148+ return m, cmd
149− // m.attachments = append(m.attachments, msg.Attachment)
150+ m.attachments = append(m.attachments, msg.Attachment)
150− // return m, nil
151+ return m, nil
151 case completions.CompletionsClosedMsg:
152 case completions.CompletionsClosedMsg:
152 m.isCompletionsOpen = false
153 m.isCompletionsOpen = false
153 m.currentQuery = ""
154 m.currentQuery = ""
@@ -351,7 +352,24 @@ func (m *editorCmp) startCompletions() tea.Msg {
354−func CreateTextArea(existing *textarea.Model) textarea.Model {
355+// Blur implements Container.
356+func (c *editorCmp) Blur() tea.Cmd {
361+// Focus implements Container.
362+func (c *editorCmp) Focus() tea.Cmd {
363+ logging.Info("Focusing editor textarea")
364+ return c.textarea.Focus()
367+// IsFocused implements Container.
368+func (c *editorCmp) IsFocused() bool {
369+ return c.textarea.Focused()
372+func NewEditorCmp(app *app.App) util.Model {
355 t := styles.CurrentTheme()
373 t := styles.CurrentTheme()
356 ta := textarea.New()
374 ta := textarea.New()
357 ta.SetStyles(t.S().TextArea)
375 ta.SetStyles(t.S().TextArea)
@@ -369,36 +387,8 @@ func CreateTextArea(existing *textarea.Model) textarea.Model {
369 ta.CharLimit = -1
387 ta.CharLimit = -1
370 ta.Placeholder = "Tell me more about this project..."
388 ta.Placeholder = "Tell me more about this project..."
371 ta.SetVirtualCursor(false)
389 ta.SetVirtualCursor(false)
373− if existing != nil {
374− ta.SetValue(existing.Value())
375− ta.SetWidth(existing.Width())
376− ta.SetHeight(existing.Height())
379 ta.Focus()
390 ta.Focus()
383−// Blur implements Container.
384−func (c *editorCmp) Blur() tea.Cmd {
389−// Focus implements Container.
390−func (c *editorCmp) Focus() tea.Cmd {
391− logging.Info("Focusing editor textarea")
392− return c.textarea.Focus()
395−// IsFocused implements Container.
396−func (c *editorCmp) IsFocused() bool {
397− return c.textarea.Focused()
400−func NewEditorCmp(app *app.App) util.Model {
401− ta := CreateTextArea(nil)
402 return &editorCmp{
392 return &editorCmp{
403 app: app,
393 app: app,
404 textarea: ta,
394 textarea: ta,