@@ -18,6 +18,7 @@ import (
1818 "github.com/charmbracelet/crush/internal/session"
1919 "github.com/charmbracelet/crush/internal/tui/components/chat"
2020 "github.com/charmbracelet/crush/internal/tui/components/completions"
21+ "github.com/charmbracelet/crush/internal/tui/components/dialogs/filepicker"
2122 "github.com/charmbracelet/crush/internal/tui/layout"
2223 "github.com/charmbracelet/crush/internal/tui/styles"
2324 "github.com/charmbracelet/crush/internal/tui/util"
@@ -141,13 +142,13 @@ func (m *editorCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
141142 m.session = msg
142143 }
143144 return m, nil
144− // case dialog.AttachmentAddedMsg:
145− // if len(m.attachments) >= maxAttachments {
146− // logging.ErrorPersist(fmt.Sprintf("cannot add more than %d images", maxAttachments))
147− // return m, cmd
148− // }
149− // m.attachments = append(m.attachments, msg.Attachment)
150− // return m, nil
145+ case filepicker.FilePickedMsg:
146+ if len(m.attachments) >= maxAttachments {
147+ logging.ErrorPersist(fmt.Sprintf("cannot add more than %d images", maxAttachments))
148+ return m, cmd
149+ }
150+ m.attachments = append(m.attachments, msg.Attachment)
151+ return m, nil
151152 case completions.CompletionsClosedMsg:
152153 m.isCompletionsOpen = false
153154 m.currentQuery = ""
@@ -351,7 +352,24 @@ func (m *editorCmp) startCompletions() tea.Msg {
351352 }
352353}
353354
354−func CreateTextArea(existing *textarea.Model) textarea.Model {
355+// Blur implements Container.
356+func (c *editorCmp) Blur() tea.Cmd {
357+ c.textarea.Blur()
358+ return nil
359+}
360+
361+// Focus implements Container.
362+func (c *editorCmp) Focus() tea.Cmd {
363+ logging.Info("Focusing editor textarea")
364+ return c.textarea.Focus()
365+}
366+
367+// IsFocused implements Container.
368+func (c *editorCmp) IsFocused() bool {
369+ return c.textarea.Focused()
370+}
371+
372+func NewEditorCmp(app *app.App) util.Model {
355373 t := styles.CurrentTheme()
356374 ta := textarea.New()
357375 ta.SetStyles(t.S().TextArea)
@@ -369,36 +387,8 @@ func CreateTextArea(existing *textarea.Model) textarea.Model {
369387 ta.CharLimit = -1
370388 ta.Placeholder = "Tell me more about this project..."
371389 ta.SetVirtualCursor(false)
372−
373− if existing != nil {
374− ta.SetValue(existing.Value())
375− ta.SetWidth(existing.Width())
376− ta.SetHeight(existing.Height())
377− }
378−
379390 ta.Focus()
380− return ta
381−}
382391
383−// Blur implements Container.
384−func (c *editorCmp) Blur() tea.Cmd {
385− c.textarea.Blur()
386− return nil
387−}
388−
389−// Focus implements Container.
390−func (c *editorCmp) Focus() tea.Cmd {
391− logging.Info("Focusing editor textarea")
392− return c.textarea.Focus()
393−}
394−
395−// IsFocused implements Container.
396−func (c *editorCmp) IsFocused() bool {
397− return c.textarea.Focused()
398−}
399−
400−func NewEditorCmp(app *app.App) util.Model {
401− ta := CreateTextArea(nil)
402392 return &editorCmp{
403393 app: app,
404394 textarea: ta,