Order wizard region picker by caller's jurisdiction · Entire
Order wizard region picker by caller's jurisdiction
37fa329→main·
toothbrush·3w ago·2 files·+28 added/-11 removed
The region multi-select already lists every cluster, but on a short terminal huh's scrollable viewport shows only the top rows — so the pre-checked default the caller's jurisdiction could sit below the fold, making it look like one unrelated option. List the caller's-jurisdiction clusters first so the visible top row is the relevant, pre-selected default; trim the description to reclaim a row. Other jurisdictions remain selectable by scrolling.
Sessions
27ad338c331dView transcript
[?
Interactive Repo Mirror Onboarding WizardClaude Code·1 step](/content/gh/entireio/cli/session/b1f77cad-1b19-4ba8-bc01-a412c9c54e2a#timeline-27ad338c331d/index.html)
Changes
2
cmd/entire/cli
Mrepo_mirror_create_wizard.go+14/-3
- Mrepo_mirror_create_wizard_test.go+14/-8
141 unmodified lines
// per-jurisdiction, so pre-selecting only the caller's avoids defaulting a repo
// into every jurisdiction. With no jurisdiction nothing is pre-checked (the user
// picks). All clusters stay selectable regardless.
//
// The caller's-jurisdiction clusters are listed first so that on a short
// terminal — where huh's option viewport shows only the top rows — the visible,
// pre-checked default is the relevant one, not some other jurisdiction's.
func clusterChoices(regions []regionChoice, jurisdiction string) (opts []huh.Option[string], defaults []string) {
opts = make([]huh.Option[string], 0, len(regions))
for _, r := range regions {
ordered := make([]regionChoice, len(regions))
copy(ordered, regions)
if jurisdiction != "" {
sort.SliceStable(ordered, func(i, j int) bool {
return ordered[i].jurisdiction == jurisdiction && ordered[j].jurisdiction != jurisdiction
})
}
opts = make([]huh.Option[string], 0, len(ordered))
for _, r := range ordered {
opts = append(opts, huh.NewOption(regionLabel(r), r.host))
if jurisdiction != "" && r.isDefault && r.jurisdiction == jurisdiction {
defaults = append(defaults, r.host)
}
}
}
}
Mcmd/entire/cli/repo_mirror_create_wizard.go+14/-3
71 unmodified lines
// Caller is in "eu": every cluster is listed, but only the eu default
// pre-selects (is_default is per-jurisdiction, so the us default must not).
// Caller is in "eu": every cluster is listed, the eu cluster is ordered
// first (so it's visible+checked on a short terminal), and only the eu
// default pre-selects (is_default is per-jurisdiction, so us must not).
opts, defaults := clusterChoices(regions, "eu")
require.Len(t, opts, 3)
require.Equal(t, "us-east (us)", opts[0].Key)
require.Equal(t, "aws-us-east-2.entire.io", opts[0].Value)
require.Equal(t, "eu-west (eu)", opts[1].Key)
require.Equal(t, "bare.entire.io", opts[2].Key) // falls back to host
require.Equal(t, "eu-west (eu)", opts[0].Key, "caller's jurisdiction listed first")
require.Equal(t, "eu-west-1.entire.io", opts[0].Value)
require.Equal(t, []string{"eu-west-1.entire.io"}, defaults)
// The other jurisdictions are still present, in their original relative order.
var keys []string
for _, o := range opts {
keys = append(keys, o.Key)
}
require.ElementsMatch(t, []string{"us-east (us)", "eu-west (eu)", "bare.entire.io"}, keys)
// Unknown jurisdiction: all still listed, nothing pre-selected.
_, noneDefault := clusterChoices(regions, "")
// Unknown jurisdiction: all still listed, original order, nothing pre-selected.
noOpts, noneDefault := clusterChoices(regions, "")
require.Empty(t, noneDefault)
require.Equal(t, "us-east (us)", noOpts[0].Key)
}
func TestRegionLabel(t *testing.T) {