Skip to content

Commit 8568caa

Browse files
authored
auth: search-as-you-type picker and visual distinction for action items (#5222)
Stacked on top of #5218. ## Why Two follow-up refinements after the picker rework in #5218: 1. The picker only entered search mode automatically when there were more than 5 profiles. For smaller lists the user had to press `/` to type-to-filter, which most people don't know. 2. The action entries (`Create a new profile`, `Enter a host URL manually`) sat in the list visually identical to real profiles, even though they're functionally different. ## Changes **Before:** Typing in the picker only filtered the list when `len(profiles) > 5`. Action items rendered the same as profiles. **Now:** - Picker always starts in search mode, so typing immediately filters the list. The cursor stays on the top remaining match — Enter takes that one. This is the "type, options shrink, top match is the suggestion" UX. - Action items render as faint text with `+` / `→` prefixes and no host/account suffix, so the list visually reads "profiles above, actions below" without needing a literal separator. - The searcher always returns true for action entries, so they stay visible no matter what the user types. If the typed query matches nothing, the user can still pick `+ Create a new profile` or `→ Enter a host URL manually` from the same screen. ## Test plan - [x] Existing unit tests for `buildPickerItems` and acceptance tests for `auth switch` / `auth logout` / `auth token` / `auth login` continue to pass. - [x] `./task checks`, `./task fmt-q`, `./task lint-q` are clean. - [x] Built locally and exercised the picker manually with 1, 3, and 8 profiles to confirm the search field is always visible and the action entries always appear in the filtered list. This pull request and its description were written by Isaac.
1 parent 4bba7bd commit 8568caa

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
* `databricks auth describe` now reports where U2M (`databricks-cli`) tokens are stored: `plaintext` (`~/.databricks/token-cache.json`) or `secure` (OS keyring), and the source of the choice (env var, config setting, or default).
88
* Marked the default profile in the interactive pickers shown by `databricks auth switch`, `databricks auth logout`, `databricks auth token`, and `databricks auth login`, and moved it to the top of the list. `databricks auth login` and `databricks auth logout` now offer the same selectors as `databricks auth token` and `databricks auth switch` respectively.
9+
* The interactive auth profile pickers now start in search mode so typing immediately filters the list, and the action entries (`+ Create a new profile`, `→ Enter a host URL manually`) are visually distinct from real profiles and stay visible regardless of the search query.
910

1011
### Bundles
1112
* Stop applying `presets.name_prefix` (and the dev-mode `[dev <user>]` rename) to `vector_search_endpoints` ([#5209](https://github.com/databricks/cli/pull/5209)).

cmd/auth/profile_picker.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const (
1919
)
2020

2121
const (
22-
profilePickerCreateNewLabel = "Create a new profile"
23-
profilePickerEnterHostLabel = "Enter a host URL manually"
22+
profilePickerCreateNewLabel = "+ Create a new profile"
23+
profilePickerEnterHostLabel = "Enter a host URL manually"
2424
)
2525

2626
// profilePickerOptions configures pickAuthProfile.
@@ -114,16 +114,22 @@ func pickAuthProfile(ctx context.Context, profiles profile.Profiles, opts profil
114114
idx, err := cmdio.RunSelect(ctx, cmdio.SelectOptions{
115115
Label: opts.Label,
116116
Items: items,
117-
StartInSearchMode: len(profiles) > 5,
117+
StartInSearchMode: true,
118118
Searcher: func(input string, index int) bool {
119+
// Action entries (Create new / Enter host) stay visible regardless
120+
// of the search query so the user can always reach them, including
121+
// when the typed query doesn't match any profile.
122+
if items[index].IsExtra {
123+
return true
124+
}
119125
input = strings.ToLower(input)
120126
return strings.Contains(strings.ToLower(items[index].Name), input) ||
121127
strings.Contains(strings.ToLower(items[index].Host), input) ||
122128
strings.Contains(strings.ToLower(items[index].AccountID), input)
123129
},
124130
LabelTemplate: "{{ . | faint }}",
125-
Active: `▸ {{.Name | bold}}{{if .IsDefault}} {{ "[default]" | green }}{{end}}{{if .AccountID}} (account: {{.AccountID|faint}}){{else if .Host}} ({{.Host|faint}}){{end}}`,
126-
Inactive: ` {{.Name}}{{if .IsDefault}} [default]{{end}}{{if .AccountID}} (account: {{.AccountID|faint}}){{else if .Host}} ({{.Host|faint}}){{end}}`,
131+
Active: `▸ {{if .IsExtra}}{{.Name | faint | bold}}{{else}}{{.Name | bold}}{{if .IsDefault}} {{ "[default]" | green }}{{end}}{{if .AccountID}} (account: {{.AccountID|faint}}){{else if .Host}} ({{.Host|faint}}){{end}}{{end}}`,
132+
Inactive: ` {{if .IsExtra}}{{.Name | faint}}{{else}}{{.Name}}{{if .IsDefault}} [default]{{end}}{{if .AccountID}} (account: {{.AccountID|faint}}){{else if .Host}} ({{.Host|faint}}){{end}}{{end}}`,
127133
Selected: `{{ "` + noun + `" | faint }}: {{ .Name | bold }}`,
128134
})
129135
if err != nil {

0 commit comments

Comments
 (0)