fix: start filepicker in cwd instead of os.Homedir

This commit is contained in:
Tai Groot
2025-07-16 08:01:49 -07:00
parent acf354ec9d
commit 4937409a45
3 changed files with 19 additions and 3 deletions

View File

@@ -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")

View File

@@ -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

View File

@@ -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]: