Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions cmd/antares/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ func cmdTUI() error {
}
rt.cfg = cfg
rt.agent.SetConfig(cfg)
// Setup (web or terminal) creates the chosen workspace; ensure it
// exists before the TUI starts in case the path was only written.
if err := os.MkdirAll(cfg.Agent.Workspace, 0o755); err != nil {
return fmt.Errorf("preparing workspace: %w", err)
}
}

return tui.New(rt.agent, rt.cfg, rt.db).Run(ctx)
Expand Down Expand Up @@ -201,8 +206,13 @@ func bootstrap(ctx context.Context) (*runtimeServices, error) {
if err := logx.Setup(cfg.Logging.Level, cfg.Logging.File, cfg.Logging.JSON); err != nil {
return nil, fmt.Errorf("setting up logging: %w", err)
}
if err := os.MkdirAll(cfg.Agent.Workspace, 0o755); err != nil {
return nil, fmt.Errorf("preparing workspace: %w", err)
// Defer workspace creation until setup finishes. Creating the default
// path here leaves a leftover ~/antares-workspace when the user picks a
// custom directory in the wizard.
if !needsSetup(cfg) {
if err := os.MkdirAll(cfg.Agent.Workspace, 0o755); err != nil {
return nil, fmt.Errorf("preparing workspace: %w", err)
}
}

db, err := store.Open(ctx, cfg.Database.Driver, cfg.Database.DSN,
Expand Down
9 changes: 5 additions & 4 deletions cmd/antares/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,11 @@ func runTerminalSetup(ctx context.Context, rt *runtimeServices) error {
}
cfg.Model.Default = model

// 5. Workspace
// 5. Workspace — only record the path here; create the directory after the
// full wizard finishes so a cancelled run does not leave an empty folder.
fmt.Println()
ws := promptLine(fmt.Sprintf(" Workspace directory (default %s): ", cfg.Agent.Workspace), cfg.Agent.Workspace)
cfg.Agent.Workspace = config.Expand(ws)
if err := os.MkdirAll(cfg.Agent.Workspace, 0o755); err != nil {
return fmt.Errorf("creating workspace: %w", err)
}

// 5b. Storage. SQLite is the default and needs nothing; Postgres asks for a
// DSN and is verified now so a bad string surfaces here, not on next start.
Expand Down Expand Up @@ -392,6 +390,9 @@ func runTerminalSetup(ctx context.Context, rt *runtimeServices) error {
if err := config.Save(cfg); err != nil {
return fmt.Errorf("saving configuration: %w", err)
}
if err := os.MkdirAll(cfg.Agent.Workspace, 0o755); err != nil {
return fmt.Errorf("creating workspace: %w", err)
}
rt.cfg = cfg
rt.agent.SetConfig(cfg)

Expand Down