Skip to content

feat: make apps init interactive by default, simplify flow#5112

Open
jamesbroadhead wants to merge 2 commits intomainfrom
jb/apps-init-interactive-flow
Open

feat: make apps init interactive by default, simplify flow#5112
jamesbroadhead wants to merge 2 commits intomainfrom
jb/apps-init-interactive-flow

Conversation

@jamesbroadhead
Copy link
Copy Markdown

Replaces #4879 — re-opened from an upstream branch (was previously from a fork, which blocked CI from running properly).

Summary

  • Add --interactive flag (default true) replacing implicit flags-mode. --name and --deploy now pre-fill values while still showing prompts. Use --interactive=false for fully non-interactive mode.
  • Remove the description prompt from interactive flow (--description flag still works).
  • Auto-fill lakebase database branch with "production" instead of prompting.
  • Don't auto-run the app after creation; always print the next-steps command. Deprecate --run flag.
  • Generate a default project name (my-app, my-app-1, etc.) when --interactive=false and --name not provided.

Test plan

  • All existing tests pass (go test ./cmd/apps/ ./libs/apps/prompt/)
  • New tests for --interactive flag default, generateProjectName with suffix bumping
  • Manual test: databricks apps init shows interactive prompts
  • Manual test: databricks apps init --name foo shows interactive prompts with name pre-filled
  • Manual test: databricks apps init --interactive=false generates project with defaults

This pull request was AI-assisted by Isaac.

- Add --interactive flag (default true) replacing implicit flagsMode.
  Passing --name or --deploy now pre-fills values while still showing
  prompts. Use --interactive=false to skip all prompts.
- Remove the description prompt from the interactive flow (--description
  flag still works for explicit use).
- Auto-fill lakebase database branch with "production" instead of
  prompting.
- Don't auto-run the app after creation; always print the next-steps
  command instead.
- Generate a default project name ("my-app", "my-app-1", etc.) when
  --interactive=false and --name is not provided.

Co-authored-by: Isaac
@github-actions
Copy link
Copy Markdown

Approval status: pending

/cmd/apps/ - needs approval

Files: cmd/apps/init.go, cmd/apps/init_test.go
Suggested: @pkosiec
Also eligible: @MarioCadenas, @arsenyinfo, @keugenek, @calvarjorge, @fjakobs, @Shridhad, @atilafassina, @igrekun, @pffigueiredo, @ditadi

/libs/apps/ - needs approval

Files: libs/apps/prompt/prompt.go
Suggested: @pkosiec
Also eligible: @MarioCadenas, @arsenyinfo, @keugenek, @calvarjorge, @fjakobs, @Shridhad, @atilafassina, @igrekun, @pffigueiredo, @ditadi

Any maintainer (@andrewnester, @anton-107, @denik, @pietern, @shreyas-goenka, @simonfaltum, @renaudhartert-db) can approve all areas.
See OWNERS for ownership rules.

- Validate required resources in both interactive and non-interactive
  paths: in interactive mode, --plugins preselection skips the prompt
  step and previously also skipped validation, so apps could be
  scaffolded with no warehouse configured.
- Reject empty --set values: the prefix check accepted "p.r.id="
  as if a value had been supplied.
- Error when --interactive is true (default) but the terminal does not
  support prompts, instead of silently auto-generating "my-app" and
  using defaults for every other prompted field.
- generateProjectName now treats only os.ErrNotExist as "available";
  permission/IO errors no longer pick a name that may collide with an
  inaccessible directory. Bound the loop at 1000 to avoid pathological
  spins.

Co-authored-by: Isaac
Copy link
Copy Markdown
Member

@pkosiec pkosiec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments. Adding --interactive flag and removing app description prompt are good additions, same with generating the app name (I'd add it to the interactive flow too) 👍

@@ -182,56 +159,38 @@ func PromptForProjectName(ctx context.Context, outputDir string) (string, error)
return name, nil
}

// PromptForDeployAndRun prompts for post-creation deploy and run options.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this: on one hand you're right, it simplifies the flow, on the other, we make the remote bridge option almost impossible to find 🤔

Maybe let's remove the description as you did and keep the run options as they were before?

Comment thread cmd/apps/init.go
Comment on lines 175 to +174
@@ -180,8 +170,9 @@ Environment variables:
cmd.Flags().StringSliceVar(&pluginsFlag, "plugins", nil, "Alias for --features")
_ = cmd.Flags().MarkHidden("plugins")
cmd.Flags().BoolVar(&deploy, "deploy", false, "Deploy the app after creation")
cmd.Flags().StringVar(&run, "run", "", "Run the app after creation (none, dev, dev-remote)")
cmd.Flags().BoolVar(&autoApprove, "auto-approve", false, "Skip confirmation prompts for optional resources. Optional resources are only configured when their values are provided via --set.")
cmd.Flags().StringVar(&run, "run", "", "Deprecated: auto-run removed, use 'databricks apps dev' after init")
_ = cmd.Flags().MarkDeprecated("run", "auto-run has been removed; use 'databricks apps dev' after init")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As posted already, I'd revert this to keep the run options, mostly to promote the remote bridge option 👍

}

// defaultDatabaseBranch is the Lakebase branch used for all new apps.
const defaultDatabaseBranch = "production"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot do this, because not all projects have production branch. Brand-new ones - yes, older - not necessarily. Another reason I'd keep the branch selection as it is - an app might be initialized for a dev/preview environment, which could be a different branch but still the same project.


Also, as a side note, I don't think the changes was tested:

  1. The branch is a full path, not just a name (that's how the Lakebase API is designed)
  2. When I built the CLI and tried to select the Lakebase project, nothing shows up.

On this PR:

Image

On latest CLI:

Image

Comment thread cmd/apps/init.go
return err
if isInteractive {
// Prompt includes validation for name format AND directory existence
name, err := prompt.PromptForProjectName(ctx, opts.outputDir)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image Maybe we can go a step further and allow users to press "enter" and move past the "app name" step if nothing is provided?

So we could generate the name upfront, and user could accept it or put theirs own.
What do you think?

Comment thread cmd/apps/init.go
Comment on lines +657 to +658
// modes: interactive prompts may have been skipped (e.g. --plugins preselected
// without --features), and an empty --set value would otherwise pass the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is a --plugin flag?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants