on main help sign in
Merge pull request #221 from charmbracelet/bugfix/filepicker-in-cwd
52346a2Kujtim Hoxha
internal/app/app.go+5
@@ -92,6 +92,11 @@ func New(ctx context.Context, conn *sql.DB, cfg *config.Config) (*App, error) {
92 return app, nil
92 return app, nil
93}
93}
94
94
95+// Config returns the application configuration.
96+func (app *App) Config() *config.Config {
97+ return app.config
98+}
99+
95// RunNonInteractive handles the execution flow when a prompt is provided via CLI flag.
100// RunNonInteractive handles the execution flow when a prompt is provided via CLI flag.
96func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool) error {
101func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool) error {
97 slog.Info("Running in non-interactive mode")
102 slog.Info("Running in non-interactive mode")
internal/tui/components/chat/editor/editor.go+1−1
@@ -72,7 +72,7 @@ var DeleteKeyMaps = DeleteAttachmentKeyMaps{
72 ),
72 ),
73 DeleteAllAttachments: key.NewBinding(
73 DeleteAllAttachments: key.NewBinding(
74 key.WithKeys("r"),
74 key.WithKeys("r"),
75− key.WithHelp("ctrl+r+r", "delete all attchments"),
75+ key.WithHelp("ctrl+r+r", "delete all attachments"),
76 ),
76 ),
77}
77}
78
78
internal/tui/components/chat/editor/keys.go+3
@@ -42,6 +42,9 @@ func (k EditorKeyMap) KeyBindings() []key.Binding {
42 k.SendMessage,
42 k.SendMessage,
43 k.OpenEditor,
43 k.OpenEditor,
44 k.Newline,
44 k.Newline,
45+ AttachmentsKeyMaps.AttachmentDeleteMode,
46+ AttachmentsKeyMaps.DeleteAllAttachments,
47+ AttachmentsKeyMaps.Escape,
45 }
48 }
46}
49}
47
50
internal/tui/components/dialogs/filepicker/filepicker.go+13−2
@@ -45,11 +45,22 @@ type model struct {
45 help help.Model
45 help help.Model
46}
46}
47
47
48−func NewFilePickerCmp() FilePicker {
48+func NewFilePickerCmp(workingDir string) FilePicker {
49 t := styles.CurrentTheme()
49 t := styles.CurrentTheme()
50 fp := filepicker.New()
50 fp := filepicker.New()
51 fp.AllowedTypes = []string{".jpg", ".jpeg", ".png"}
51 fp.AllowedTypes = []string{".jpg", ".jpeg", ".png"}
52+
53+ if workingDir != "" {
54+ fp.CurrentDirectory = workingDir
55+ } else {
56+ // Fallback to current working directory, then home directory
57+ if cwd, err := os.Getwd(); err == nil {
58+ fp.CurrentDirectory = cwd
59+ } else {
52− fp.CurrentDirectory, _ = os.UserHomeDir()
60+ fp.CurrentDirectory, _ = os.UserHomeDir()
61+ }
62+ }
63+
53 fp.ShowPermissions = false
64 fp.ShowPermissions = false
54 fp.ShowSize = false
65 fp.ShowSize = false
55 fp.AutoHeight = false
66 fp.AutoHeight = false
internal/tui/page/chat/chat.go+12
@@ -838,6 +838,18 @@ func (p *chatPage) Help() help.KeyMap {
838 key.WithKeys("ctrl+v"),
838 key.WithKeys("ctrl+v"),
839 key.WithHelp("ctrl+v", "open editor"),
839 key.WithHelp("ctrl+v", "open editor"),
840 ),
840 ),
841+ key.NewBinding(
842+ key.WithKeys("ctrl+r"),
843+ key.WithHelp("ctrl+r+{i}", "delete attachment at index i"),
844+ ),
845+ key.NewBinding(
846+ key.WithKeys("ctrl+r", "r"),
847+ key.WithHelp("ctrl+r+r", "delete all attachments"),
848+ ),
849+ key.NewBinding(
850+ key.WithKeys("esc"),
851+ key.WithHelp("esc", "cancel delete mode"),
852+ ),
841 })
853 })
842 }
854 }
843 shortList = append(shortList,
855 shortList = append(shortList,
internal/tui/tui.go+1−1
@@ -204,7 +204,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
204 return a, util.CmdHandler(dialogs.CloseDialogMsg{})
204 return a, util.CmdHandler(dialogs.CloseDialogMsg{})
205 }
205 }
206 return a, util.CmdHandler(dialogs.OpenDialogMsg{
206 return a, util.CmdHandler(dialogs.OpenDialogMsg{
207− Model: filepicker.NewFilePickerCmp(),
207+ Model: filepicker.NewFilePickerCmp(a.app.Config().WorkingDir()),
208 })
208 })
209 // Permissions
209 // Permissions
210 case pubsub.Event[permission.PermissionRequest]:
210 case pubsub.Event[permission.PermissionRequest]: