diff --git a/internal/app/app.go b/internal/app/app.go index f15b3361fb1d8117dc8cdac2a24ba66e1fcee69b..654cb87ca643530eb030195f5b45679ee18af8e6 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -92,6 +92,11 @@ func New(ctx context.Context, conn *sql.DB, cfg *config.Config) (*App, error) { return app, nil } +// Config returns the application configuration. +func (app *App) Config() *config.Config { + return app.config +} + // RunNonInteractive handles the execution flow when a prompt is provided via CLI flag. func (app *App) RunNonInteractive(ctx context.Context, prompt string, quiet bool) error { slog.Info("Running in non-interactive mode") diff --git a/internal/tui/components/chat/editor/editor.go b/internal/tui/components/chat/editor/editor.go index 51009536358cd849e28cd6c7550376340b58d530..242075d98e99da0117430a26df34357f58c18d10 100644 --- a/internal/tui/components/chat/editor/editor.go +++ b/internal/tui/components/chat/editor/editor.go @@ -72,7 +72,7 @@ var DeleteKeyMaps = DeleteAttachmentKeyMaps{ ), DeleteAllAttachments: key.NewBinding( key.WithKeys("r"), - key.WithHelp("ctrl+r+r", "delete all attchments"), + key.WithHelp("ctrl+r+r", "delete all attachments"), ), } diff --git a/internal/tui/components/chat/editor/keys.go b/internal/tui/components/chat/editor/keys.go index ef002436901ed0fbad3bcbd2da7cecc08ef255c1..2f464833bd67b81cd105aeddeb69d2e950971bbe 100644 --- a/internal/tui/components/chat/editor/keys.go +++ b/internal/tui/components/chat/editor/keys.go @@ -42,6 +42,9 @@ func (k EditorKeyMap) KeyBindings() []key.Binding { k.SendMessage, k.OpenEditor, k.Newline, + AttachmentsKeyMaps.AttachmentDeleteMode, + AttachmentsKeyMaps.DeleteAllAttachments, + AttachmentsKeyMaps.Escape, } } diff --git a/internal/tui/components/dialogs/filepicker/filepicker.go b/internal/tui/components/dialogs/filepicker/filepicker.go index aa8956fee9a184a906a4059080fc1557d13414e1..3944da7665b6d400c091f4a1282360ed2c638163 100644 --- a/internal/tui/components/dialogs/filepicker/filepicker.go +++ b/internal/tui/components/dialogs/filepicker/filepicker.go @@ -45,11 +45,22 @@ type model struct { help help.Model } -func NewFilePickerCmp() FilePicker { +func NewFilePickerCmp(workingDir string) FilePicker { t := styles.CurrentTheme() fp := filepicker.New() fp.AllowedTypes = []string{".jpg", ".jpeg", ".png"} - fp.CurrentDirectory, _ = os.UserHomeDir() + + if workingDir != "" { + fp.CurrentDirectory = workingDir + } else { + // Fallback to current working directory, then home directory + if cwd, err := os.Getwd(); err == nil { + fp.CurrentDirectory = cwd + } else { + fp.CurrentDirectory, _ = os.UserHomeDir() + } + } + fp.ShowPermissions = false fp.ShowSize = false fp.AutoHeight = false diff --git a/internal/tui/page/chat/chat.go b/internal/tui/page/chat/chat.go index c0af5252e7d44b2898cbd8be4ed1263877fdf583..e55e965df2cbe375143a2e9cdf0c2c3252338f95 100644 --- a/internal/tui/page/chat/chat.go +++ b/internal/tui/page/chat/chat.go @@ -838,6 +838,18 @@ func (p *chatPage) Help() help.KeyMap { key.WithKeys("ctrl+v"), key.WithHelp("ctrl+v", "open editor"), ), + key.NewBinding( + key.WithKeys("ctrl+r"), + key.WithHelp("ctrl+r+{i}", "delete attachment at index i"), + ), + key.NewBinding( + key.WithKeys("ctrl+r", "r"), + key.WithHelp("ctrl+r+r", "delete all attachments"), + ), + key.NewBinding( + key.WithKeys("esc"), + key.WithHelp("esc", "cancel delete mode"), + ), }) } shortList = append(shortList, diff --git a/internal/tui/tui.go b/internal/tui/tui.go index 811c18122687464d216e33f093aba60bbf5221c1..d7e9f6dbd2a1c9ff3391b7675494ec2c0e38da10 100644 --- a/internal/tui/tui.go +++ b/internal/tui/tui.go @@ -204,7 +204,7 @@ func (a *appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return a, util.CmdHandler(dialogs.CloseDialogMsg{}) } return a, util.CmdHandler(dialogs.OpenDialogMsg{ - Model: filepicker.NewFilePickerCmp(), + Model: filepicker.NewFilePickerCmp(a.app.Config().WorkingDir()), }) // Permissions case pubsub.Event[permission.PermissionRequest]: