Commit f188a50
authored
feat: apps init speed improvements (#4678)
## Changes
Speed up `databricks apps init` by parallelizing three slow I/O
operations (template cloning, npm install, resource list fetching) that
previously ran sequentially, so they overlap with user interaction time.
### Main changes
**Background template cloning** (`cmd/apps/init.go`):
Template cloning now starts in a background goroutine immediately when
the command runs, while the user is typing the project name.
`resolveTemplateAsync` returns a channel; `awaitTemplate` either returns
instantly (if already done) or shows a spinner for the remaining wait.
This replaces the previous blocking `resolveTemplate` call that happened
after the name prompt.
**Background npm install** (`cmd/apps/init.go`):
For Node.js templates, `startBackgroundNpmInstall` copies
`package.json`/`package-lock.json` into the destination and kicks off
`npm ci` while the user answers plugin/resource prompts. The result is
awaited before template files are written to avoid concurrent writes.
The Node.js initializer now skips redundant installs when `node_modules`
already exists.
**Prefetched resource lists** (`libs/apps/prompt/prefetch.go`,
`libs/apps/prompt/prompt.go`):
`PrefetchResources` fires background goroutines to fetch the first page
of every resource type the manifest might need (warehouses, jobs,
endpoints, experiments, Genie spaces, etc.) before the user selects
plugins. A `ResourceCache` in the context stores `PagedFetcher`
instances, so pickers render instantly when reached. Resource prompts
now use `promptFromPagedFetcher` with "Load more..." and "Enter
manually" / server-side search fallbacks, replacing the old
`promptForResourceFromLister` that fetched everything in one blocking
call.
**Paged resource picker UX** (`libs/apps/prompt/prompt.go`,
`libs/apps/prompt/listers.go`):
All resource prompts switched from loading everything upfront to
incremental paging (200 items/page, 10,000 cap). When capped, users can
enter a name/ID manually or trigger a server-side search (currently
supported for Jobs). Prompt titles now include the plugin display name
for context (e.g. "Select SQL Warehouse for Analytics").
### Supporting infrastructure
- **`libs/apps/prompt/paged.go`** — `PagedFetcher` struct with
`WaitForFirstPage`, `LoadMore`, `IsDone`, and a generic `collectN`
helper for SDK iterators.
- **`libs/apps/prompt/cache.go`** — Thread-safe `ResourceCache` stored
in `context.Context` via `ContextWithCache`/`CacheFromContext`.
- **`libs/apps/prompt/prefetch.go`** — Maps resource types to paged
constructors and launches background prefetch goroutines for both
single-step and multi-step (catalog/instance/project) resources.
- **`libs/apps/prompt/listers.go`** — Added `NewPaged*` constructors for
all resource types and a `SearchJobs` server-side search function.
### Other changes
- Brand colors extracted into package-level
`colorRed`/`colorGray`/`colorYellow`/`colorOrange` variables for
consistency.
- Filter hint changed from "type to filter" to "/ to filter" and
explicit `.Filtering(true)` removed.
- Volume IDs changed from `catalog.schema.volume` to
`/Volumes/catalog/schema/volume`.
- `manifest.Resource` gained a `PluginDisplayName` field (JSON-excluded)
set during collection.
- `manifest.Manifest` gained a `GetPluginNames` helper.
- Checkmark output (`✔`/`✓`) consolidated into `prompt.PrintDone` across
`deploy_bundle.go`, `import.go`, and `init.go`.
- Existing `List*` functions now consistently apply `capResults` and use
`min(len, maxListResults)` for initial slice capacity.
## Why
<!-- Why are these changes needed? Provide the context that the reviewer
might be missing.
For example, were there any decisions behind the change that are not
reflected in the code itself? -->
## Tests
<!-- How have you tested the changes? -->
<!-- If your PR needs to be included in the release notes for next
release,
add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
---------
Co-authored-by: MarioCadenas <MarioCadenas@users.noreply.github.com>1 parent c5f4546 commit f188a50
File tree
14 files changed
+1414
-344
lines changed- cmd/apps
- libs/apps
- generator
- initializer
- manifest
- prompt
14 files changed
+1414
-344
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
156 | | - | |
| 157 | + | |
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
160 | | - | |
| 161 | + | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
205 | | - | |
| 206 | + | |
| 207 | + | |
206 | 208 | | |
207 | | - | |
| 209 | + | |
208 | 210 | | |
209 | 211 | | |
210 | 212 | | |
| |||
0 commit comments