on main help sign in
fix: start filepicker in cwd instead of os.Homedir
4937409Tai Groot
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/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/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]: