Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
launch: allow usage credits without upgrading (#18985)
Parth Sareen45e6011815c7
diff --git a/cmd/cmd.go b/cmd/cmd.goindex 8660c7f71..aeeab5f8e 100644--- a/cmd/cmd.go+++ b/cmd/cmd.go@@ -85,14 +85,6 @@ func init() {return userName, err}- launch.DefaultUpgrade = func(modelName, requiredPlan string) (string, error) {- plan, err := tui.RunUpgrade(modelName, requiredPlan)- if errors.Is(err, tui.ErrCancelled) {- return "", launch.ErrCancelled- }- return plan, err- }-launch.DefaultConfirmPrompt = tui.RunConfirmWithOptionslaunch.DefaultSpinner = tui.RunSpinnerdiff --git a/cmd/launch/account.go b/cmd/launch/account.goindex 9de432d0c..9ad2113fe 100644--- a/cmd/launch/account.go+++ b/cmd/launch/account.go@@ -5,7 +5,6 @@ import ("errors""fmt""net/http"- "os""strings""time"@@ -13,16 +12,13 @@ import ()const (- // DefaultUpgradeURL is the fixed destination for subscription upgrades.- DefaultUpgradeURL = "https://ollama.com/upgrade"+ modelUpgradeURL = "https://ollama.com/upgrade"+ modelCreditsURL = "https://ollama.com/settings"accountCheckTimeout = 3 * time.Second)-var (- ErrPlanVerificationUnavailable = errors.New("Could not verify Ollama plan. Try again in a moment or use a local model.")- errUpgradeCancelled = errors.New("upgrade cancelled")-)+var errModelPaymentDeclined = errors.New("model payment declined")type accountStateStatus int@@ -226,7 +222,7 @@ func availabilityBadge(item ModelItem, state AccountState) string {}case accountStateSignedIn:if item.RequiredPlan != "" && !PlanSatisfies(state.Plan, item.RequiredPlan) {- return "Upgrade required"+ return "Use usage credits or upgrade your plan"}}return ""@@ -236,7 +232,10 @@ func itemHasRecommendationMetadata(item ModelItem) bool {return item.Recommended || strings.TrimSpace(item.RequiredPlan) != ""}-func (c *launcherClient) ensureCloudModelAccess(ctx context.Context, model string) error {+func (c *launcherClient) confirmCloudModelPayment(ctx context.Context, model string) error {+ if !isCloudModelName(model) {+ return nil+ }item, ok := c.modelRecommendationItem(ctx, model)if !ok || strings.TrimSpace(item.RequiredPlan) == "" {return nil@@ -267,17 +266,13 @@ func (c *launcherClient) ensureCloudModelAccess(ctx context.Context, model strinreturn nil}- if err := c.runUpgradeFlow(ctx, item); err != nil {- return err- }- state = launchAccountState(ctx, c.apiClient)- if state.Status == accountStateUnknown {- return ErrPlanVerificationUnavailable- }- if state.Status != accountStateSignedIn || !PlanSatisfies(state.Plan, item.RequiredPlan) {- return errUpgradeCancelled+ restore := withLaunchConfirmPolicy(c.policy.confirmPolicy())+ defer restore()+ proceed, err := confirmModelPayment(model)+ if errors.Is(err, ErrCancelled) || (err == nil && !proceed) {+ return errModelPaymentDeclined}- return nil+ return err}func (c *launcherClient) modelRecommendationItem(ctx context.Context, model string) (ModelItem, bool) {@@ -289,74 +284,18 @@ func (c *launcherClient) modelRecommendationItem(ctx context.Context, model strireturn ModelItem{}, false}-func (c *launcherClient) runUpgradeFlow(ctx context.Context, item ModelItem) error {- if DefaultUpgrade != nil {- if _, err := DefaultUpgrade(item.Name, item.RequiredPlan); err != nil {- if errors.Is(err, ErrCancelled) {- return errUpgradeCancelled- }- return err- }- return nil- }-- yes, err := ConfirmPrompt(fmt.Sprintf("Upgrade to use %s?", item.Name))- if errors.Is(err, ErrCancelled) {- return errUpgradeCancelled- }- if err != nil {- return err- }- if !yes {- return errUpgradeCancelled- }-- fmt.Fprintf(os.Stderr, "\nTo upgrade, navigate to:\n %s\n\n", DefaultUpgradeURL)- openNow, err := ConfirmPrompt("Open now?")- if errors.Is(err, ErrCancelled) {- return errUpgradeCancelled- }- if err != nil {- return err- }- if openNow {- OpenBrowser(DefaultUpgradeURL)- } else {- return errUpgradeCancelled- }-- spinnerFrames := []string{"|", "/", "-", "\\"}- frame := 0- fmt.Fprintf(os.Stderr, "\033[90mwaiting for upgrade to complete... %s\033[0m", spinnerFrames[0])-- ticker := time.NewTicker(200 * time.Millisecond)- defer ticker.Stop()-- for {- select {- case <-ctx.Done():- fmt.Fprintf(os.Stderr, "\r\033[K")- return ctx.Err()- case <-ticker.C:- frame++- fmt.Fprintf(os.Stderr, "\r\033[90mwaiting for upgrade to complete... %s\033[0m", spinnerFrames[frame%len(spinnerFrames)])- if frame%10 != 0 {- continue- }- state := launchAccountState(ctx, c.apiClient)- if state.Status == accountStateUnknown {- fmt.Fprintf(os.Stderr, "\r\033[K")- return ErrPlanVerificationUnavailable- }- if state.Status == accountStateSignedIn && PlanSatisfies(state.Plan, item.RequiredPlan) {- fmt.Fprintf(os.Stderr, "\r\033[K\033[A\r\033[K\033[1mplan updated\033[0m\n")- return nil- }- }- }+// confirmModelPayment shows advisory payment guidance without checking credit availability.+func confirmModelPayment(modelName string) (bool, error) {+ prompt := fmt.Sprintf("%s\n\nThis model requires usage credits or a paid plan.\n\nAdd credits: %s\nUpgrade: %s\n\nContinue with %s?", modelName, modelCreditsURL, modelUpgradeURL, modelName)+ return ConfirmPromptWithOptions(prompt, ConfirmOptions{+ YesLabel: "Continue",+ NoLabel: "Choose another model",+ Default: ConfirmDefaultYes,+ })}-// PlanSatisfies reports whether currentPlan can use a model that has a requiredPlan.+// PlanSatisfies compares the subscription hints in recommendation metadata.+// Inference authorization also accounts for usage credits and other server policy.func PlanSatisfies(currentPlan, requiredPlan string) bool {required := normalizePlan(requiredPlan)if required == "" || required == "free" {diff --git a/cmd/launch/integrations_test.go b/cmd/launch/integrations_test.goindex 01662afb2..833e1d79c 100644--- a/cmd/launch/integrations_test.go+++ b/cmd/launch/integrations_test.go@@ -1537,7 +1537,7 @@ func TestApplyAccountStateToSelectionItems_BadgesOnlyWhenActionRequired(t *testiif freeUser[0].AvailabilityBadge != "" {t.Fatalf("signed-in account model should not be badged, got %q", freeUser[0].AvailabilityBadge)}- if freeUser[1].AvailabilityBadge != "Upgrade required" {+ if freeUser[1].AvailabilityBadge != "Use usage credits or upgrade your plan" {t.Fatalf("subscription cloud free-plan badge = %q", freeUser[1].AvailabilityBadge)}if freeUser[4].AvailabilityBadge != "" {diff --git a/cmd/launch/launch.go b/cmd/launch/launch.goindex 65af0bc50..ece39f8c6 100644--- a/cmd/launch/launch.go+++ b/cmd/launch/launch.go@@ -742,10 +742,20 @@ func (c *launcherClient) launchSingleIntegration(ctx context.Context, name strin}func (c *launcherClient) launchEditorIntegration(ctx context.Context, name string, runner Runner, editor Editor, saved *config.IntegrationConfig, req IntegrationLaunchRequest) error {+ previous := editorPreCheckedModels(saved, "")models, needsConfigure := c.resolveEditorLaunchModels(ctx, saved, req)+ if !needsConfigure && req.ModelOverride != "" && !slices.Contains(previous, req.ModelOverride) {+ if err := c.confirmCloudModelPayment(ctx, req.ModelOverride); err != nil {+ if !errors.Is(err, errModelPaymentDeclined) {+ return err+ }+ models = previous+ needsConfigure = true+ }+ }if needsConfigure {- selected, err := c.selectMultiModelsForIntegration(ctx, name, runner, models)+ selected, err := c.selectMultiModelsForIntegration(ctx, name, runner, models, previous)if err != nil {return err}@@ -755,7 +765,7 @@ func (c *launcherClient) launchEditorIntegration(ctx context.Context, name strinif !errors.Is(err, errDeprecatedLaunchModelDeclined) || req.ModelOverride != "" {return err}- selected, err := c.selectMultiModelsForIntegration(ctx, name, runner, models)+ selected, err := c.selectMultiModelsForIntegration(ctx, name, runner, models, previous)if err != nil {return err}@@ -973,6 +983,16 @@ func (c *launcherClient) resolveSingleIntegrationTarget(ctx context.Context, namif skipper, ok := runner.(ManagedModelReadinessSkipper); ok {skipReadiness = skipper.SkipModelReadiness()}+ if !skipReadiness && req.ModelOverride != "" && target != current {+ if err := c.confirmCloudModelPayment(ctx, target); err != nil {+ if !errors.Is(err, errModelPaymentDeclined) {+ return "", false, err+ }+ req.ModelOverride = ""+ target = current+ needsConfigure = true+ }+ }if target == "" {target = current@@ -1065,6 +1085,7 @@ func (c *launcherClient) selectSingleModelWithSelectorReady(ctx context.Context,return "", err}+ previous := currentfor {accountState := c.latestAccountState()selectionItems := SelectionItemsWithAccountState(items, accountState)@@ -1080,11 +1101,16 @@ func (c *launcherClient) selectSingleModelWithSelectorReady(ctx context.Context,return "", ErrCancelled}if ensureReady {- if err := c.ensureModelsReadyFor(ctx, []string{selected}, label, commandName); err != nil {- if errors.Is(err, errUpgradeCancelled) {- current = selected- continue+ if selected != previous {+ if err := c.confirmCloudModelPayment(ctx, selected); err != nil {+ if errors.Is(err, errModelPaymentDeclined) {+ current = selected+ continue+ }+ return "", err}+ }+ if err := c.ensureModelsReadyFor(ctx, []string{selected}, label, commandName); err != nil {if errors.Is(err, errDeprecatedLaunchModelDeclined) {current = selectedcontinue@@ -1096,7 +1122,7 @@ func (c *launcherClient) selectSingleModelWithSelectorReady(ctx context.Context,}}-func (c *launcherClient) selectMultiModelsForIntegration(ctx context.Context, name string, runner Runner, preChecked []string) ([]string, error) {+func (c *launcherClient) selectMultiModelsForIntegration(ctx context.Context, name string, runner Runner, preChecked, previous []string) ([]string, error) {if DefaultMultiSelector == nil && DefaultMultiSelectorWithUpdates == nil {return nil, fmt.Errorf("no selector configured")}@@ -1118,9 +1144,9 @@ func (c *launcherClient) selectMultiModelsForIntegration(ctx context.Context, naif err != nil {return nil, err}- accepted, skipped, err := c.selectReadyModelsForSave(ctx, selected, runner.String(), name)+ accepted, skipped, err := c.selectReadyModelsForSave(ctx, selected, previous, runner.String(), name)if err != nil {- if errors.Is(err, errUpgradeCancelled) {+ if errors.Is(err, errModelPaymentDeclined) {orderedChecked = append([]string(nil), selected...)continue}@@ -1273,9 +1299,6 @@ func (c *launcherClient) ensureModelsReadyFor(ctx context.Context, models []striisCloudModel := isCloudModelName(model)if isCloudModel {cloudModels[model] = true- if err := c.ensureCloudModelAccess(ctx, model); err != nil {- return err- }}if err := showOrPullWithPolicy(ctx, c.apiClient, model, c.policy.missingModelPolicy(), isCloudModel); err != nil {return err@@ -1323,16 +1346,23 @@ type skippedModel struct {reason string}-func (c *launcherClient) selectReadyModelsForSave(ctx context.Context, selected []string, label, commandName string) ([]string, []skippedModel, error) {+func (c *launcherClient) selectReadyModelsForSave(ctx context.Context, selected, previous []string, label, commandName string) ([]string, []skippedModel, error) {selected = dedupeModelList(selected)accepted := make([]string, 0, len(selected))skipped := make([]skippedModel, 0, len(selected))for _, model := range selected {- if err := c.ensureModelsReadyFor(ctx, []string{model}, label, commandName); err != nil {- if errors.Is(err, errUpgradeCancelled) {+ var err error+ if !slices.Contains(previous, model) {+ err = c.confirmCloudModelPayment(ctx, model)+ if errors.Is(err, errModelPaymentDeclined) {return nil, nil, err}+ }+ if err == nil {+ err = c.ensureModelsReadyFor(ctx, []string{model}, label, commandName)+ }+ if err != nil {if errors.Is(err, errDeprecatedLaunchModelDeclined) {return nil, nil, err}@@ -1352,9 +1382,6 @@ func (c *launcherClient) selectReadyModelsForSave(ctx context.Context, selected}func skippedModelReason(model string, err error) string {- if errors.Is(err, errUpgradeCancelled) {- return "upgrade was cancelled"- }if errors.Is(err, ErrCancelled) {if isCloudModelName(model) {return "sign in was cancelled"diff --git a/cmd/launch/launch_test.go b/cmd/launch/launch_test.goindex 65db6af58..621414bd5 100644--- a/cmd/launch/launch_test.go+++ b/cmd/launch/launch_test.go@@ -397,7 +397,6 @@ func withLauncherHooks(t *testing.T) {oldMultiWithUpdates := DefaultMultiSelectorWithUpdatesoldConfirm := DefaultConfirmPromptoldSignIn := DefaultSignIn- oldUpgrade := DefaultUpgradet.Cleanup(func() {DefaultSingleSelector = oldSingleDefaultSingleSelectorWithUpdates = oldSingleWithUpdates@@ -405,7 +404,6 @@ func withLauncherHooks(t *testing.T) {DefaultMultiSelectorWithUpdates = oldMultiWithUpdatesDefaultConfirmPrompt = oldConfirmDefaultSignIn = oldSignIn- DefaultUpgrade = oldUpgrade})}@@ -2406,7 +2404,7 @@ func TestResolveRunModel_MetadataSignedOutUsesSignInHook(t *testing.T) {}}-func TestResolveRunModel_SubscriptionModelUsesUpgradeHook(t *testing.T) {+func TestResolveRunModel_PaidModelContinuesWithoutPlanChange(t *testing.T) {tmpDir := t.TempDir()setLaunchTestHome(t, tmpDir)withLauncherHooks(t)@@ -2424,8 +2422,8 @@ func TestResolveRunModel_SubscriptionModelUsesUpgradeHook(t *testing.T) {}for _, item := range items {if item.Name == "kimi-k2.6:cloud" {- if item.AvailabilityBadge != "Upgrade required" {- t.Fatalf("availability badge = %q, want Upgrade required", item.AvailabilityBadge)+ if item.AvailabilityBadge != "Use usage credits or upgrade your plan" {+ t.Fatalf("availability badge = %q, want Use usage credits or upgrade your plan", item.AvailabilityBadge)}return "kimi-k2.6:cloud", nil}@@ -2438,18 +2436,17 @@ func TestResolveRunModel_SubscriptionModelUsesUpgradeHook(t *testing.T) {return "", nil}- plan := "free"- upgradeCalled := false- DefaultUpgrade = func(modelName, requiredPlan string) (string, error) {- upgradeCalled = true- if modelName != "kimi-k2.6:cloud" {- t.Fatalf("unexpected model passed to upgrade: %q", modelName)+ withInteractiveSession(t, true)+ paymentConfirmed := false+ DefaultConfirmPrompt = func(prompt string, options ConfirmOptions) (bool, error) {+ paymentConfirmed = true+ if !strings.Contains(prompt, "This model requires usage credits or a paid plan.") || !strings.Contains(prompt, "kimi-k2.6:cloud") {+ t.Fatalf("unexpected payment prompt: %q", prompt)}- if requiredPlan != "pro" {- t.Fatalf("unexpected required plan: %q", requiredPlan)+ if options.YesLabel != "Continue" || options.NoLabel != "Choose another model" || options.Default != ConfirmDefaultYes {+ t.Fatalf("unexpected payment actions: %+v", options)}- plan = "max"- return plan, nil+ return true, nil}srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {@@ -2464,7 +2461,7 @@ func TestResolveRunModel_SubscriptionModelUsesUpgradeHook(t *testing.T) {case "/api/show":fmt.Fprint(w, `{"remote_model":"kimi-k2.6"}`)case "/api/me":- fmt.Fprintf(w, `{"name":"test-user","plan":%q}`, plan)+ fmt.Fprint(w, `{"name":"test-user","plan":"free"}`)default:http.NotFound(w, r)}@@ -2479,12 +2476,12 @@ func TestResolveRunModel_SubscriptionModelUsesUpgradeHook(t *testing.T) {if model != "kimi-k2.6:cloud" {t.Fatalf("expected selected cloud model, got %q", model)}- if !upgradeCalled {- t.Fatal("expected upgrade hook to be used for subscription-gated cloud model")+ if !paymentConfirmed {+ t.Fatal("expected payment guidance before continuing with the free account")}}-func TestResolveRunModel_UpgradeCancelledReturnsToModelSelector(t *testing.T) {+func TestResolveRunModel_PaymentDeclinedReturnsToModelSelector(t *testing.T) {tmpDir := t.TempDir()setLaunchTestHome(t, tmpDir)withLauncherHooks(t)@@ -2502,8 +2499,9 @@ func TestResolveRunModel_UpgradeCancelledReturnsToModelSelector(t *testing.T) {return "", nil}}- DefaultUpgrade = func(modelName, requiredPlan string) (string, error) {- return "", ErrCancelled+ withInteractiveSession(t, true)+ DefaultConfirmPrompt = func(prompt string, options ConfirmOptions) (bool, error) {+ return false, nil}srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {@@ -2548,9 +2546,9 @@ func TestResolveRunModel_SubscriptionModelUnavailableWhoamiAllowsSelection(t *teDefaultSingleSelector = func(title string, items []SelectionItem, current string) (string, error) {return "kimi-k2.6:cloud", nil}- DefaultUpgrade = func(modelName, requiredPlan string) (string, error) {- t.Fatalf("did not expect upgrade hook when plan could not be verified")- return "", nil+ DefaultConfirmPrompt = func(prompt string, options ConfirmOptions) (bool, error) {+ t.Fatalf("did not expect payment guidance when account could not be verified")+ return false, nil}srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {@@ -2996,14 +2994,16 @@ func TestLaunchIntegration_EditorConfigureMultiSkipsUnauthedCloudAndPersistsAccet.Fatalf("unexpected prompt: %q", prompt)return false, nil}+ signInCalls := 0DefaultSignIn = func(modelName, signInURL string) (string, error) {+ signInCalls++return "", ErrCancelled}srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {switch r.URL.Path {case "/api/experimental/model-recommendations":- fmt.Fprint(w, `{"recommendations":[]}`)+ fmt.Fprint(w, `{"recommendations":[{"model":"glm-5:cloud","context_length":262144,"max_output_tokens":32768,"required_plan":"pro"}]}`)case "/api/tags":fmt.Fprint(w, `{"models":[{"name":"sample-model"},{"name":"glm-5:cloud","remote_model":"glm-5"}]}`)case "/api/status":@@ -3040,6 +3040,9 @@ func TestLaunchIntegration_EditorConfigureMultiSkipsUnauthedCloudAndPersistsAcceif launchErr != nil {t.Fatalf("LaunchIntegration returned error: %v", launchErr)}+ if signInCalls != 1 {+ t.Fatalf("sign-in calls = %d, want 1", signInCalls)+ }if editor.ranModel != "sample-model" {t.Fatalf("expected launch to use local primary, got %q", editor.ranModel)}@@ -3058,7 +3061,7 @@ func TestLaunchIntegration_EditorConfigureMultiSkipsUnauthedCloudAndPersistsAcce}}-func TestLaunchIntegration_EditorConfigureUpgradeCancelledReturnsToModelSelector(t *testing.T) {+func TestLaunchIntegration_EditorConfigurePaymentDeclinedReturnsToModelSelector(t *testing.T) {tmpDir := t.TempDir()setLaunchTestHome(t, tmpDir)withLauncherHooks(t)@@ -3086,13 +3089,14 @@ func TestLaunchIntegration_EditorConfigureUpgradeCancelledReturnsToModelSelectorreturn nil, nil}}- DefaultUpgrade = func(modelName, requiredPlan string) (string, error) {- return "", ErrCancelled- }+ withInteractiveSession(t, true)DefaultConfirmPrompt = func(prompt string, options ConfirmOptions) (bool, error) {if prompt == "Proceed?" {return true, nil}+ if options.NoLabel == "Choose another model" {+ return false, ErrCancelled+ }t.Fatalf("unexpected prompt: %q", prompt)return false, nil}@@ -4463,3 +4467,63 @@ func compareStringSlices(got, want [][]string) string {}return ""}++func TestResolveSingleIntegrationTargetPaymentGuidance(t *testing.T) {+ for _, tt := range []struct {+ name string+ current string+ mode LaunchConfirmMode+ proceed bool+ wantModel string+ wantPrompts int+ wantError string+ }{+ {name: "new selection continues with free plan", mode: LaunchConfirmPrompt, proceed: true, wantModel: "paid:cloud", wantPrompts: 1},+ {name: "saved selection skips payment prompt", current: "paid:cloud", mode: LaunchConfirmPrompt, wantModel: "paid:cloud"},+ {name: "yes approves payment guidance", mode: LaunchConfirmAutoApprove, wantModel: "paid:cloud"},+ {name: "headless requires yes", mode: LaunchConfirmRequireYes, wantError: "Continue with paid:cloud? requires confirmation; re-run with --yes to continue"},+ {name: "decline returns to picker", mode: LaunchConfirmPrompt, wantModel: "local-model", wantPrompts: 1},+ } {+ t.Run(tt.name, func(t *testing.T) {+ withLauncherHooks(t)+ DefaultSingleSelectorWithUpdates = nil+ DefaultSingleSelector = func(string, []SelectionItem, string) (string, error) { return "local-model", nil }+ prompts := 0+ DefaultConfirmPrompt = func(string, ConfirmOptions) (bool, error) {+ prompts+++ return tt.proceed, nil+ }+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ switch r.URL.Path {+ case "/api/me":+ fmt.Fprint(w, `{"name":"test-user","plan":"free"}`)+ case "/api/tags":+ fmt.Fprint(w, `{"models":[{"name":"local-model"}]}`)+ case "/api/show":+ fmt.Fprint(w, `{"remote_model":"paid"}`)+ default:+ http.NotFound(w, r)+ }+ }))+ defer srv.Close()+ t.Setenv("OLLAMA_HOST", srv.URL)+ client, err := newLauncherClient(LaunchPolicy{Confirm: tt.mode})+ if err != nil {+ t.Fatal(err)+ }+ client.recommendationsLoaded = true+ client.recommendationItems = []ModelItem{{Name: "paid:cloud", RequiredPlan: "pro"}}+ model, _, err := client.resolveSingleIntegrationTarget(context.Background(), "claude", &Claude{}, tt.current, IntegrationLaunchRequest{ModelOverride: "paid:cloud"})+ if tt.wantError != "" {+ if err == nil || !strings.Contains(err.Error(), tt.wantError) {+ t.Fatalf("error = %v, want %q", err, tt.wantError)+ }+ } else if err != nil || model != tt.wantModel {+ t.Fatalf("model = %q, error = %v; want %q", model, err, tt.wantModel)+ }+ if prompts != tt.wantPrompts {+ t.Fatalf("payment prompts = %d, want %d", prompts, tt.wantPrompts)+ }+ })+ }+}diff --git a/cmd/launch/selector_hooks.go b/cmd/launch/selector_hooks.goindex 49b13f43b..38292d5f1 100644--- a/cmd/launch/selector_hooks.go+++ b/cmd/launch/selector_hooks.go@@ -71,10 +71,6 @@ var DefaultMultiSelectorWithUpdates MultiSelectorWithUpdates// Returns the signed-in username or an error.var DefaultSignIn func(modelName, signInURL string) (string, error)-// DefaultUpgrade provides a TUI-based upgrade flow.-// Returns the updated plan or an error.-var DefaultUpgrade func(modelName, requiredPlan string) (string, error)-type launchConfirmPolicy struct {yes boolrequireYesMessage booldiff --git a/cmd/launch/spinner.go b/cmd/launch/spinner.goindex d962ba79b..4687e42f6 100644--- a/cmd/launch/spinner.go+++ b/cmd/launch/spinner.go@@ -8,7 +8,7 @@ import ()// SpinnerFrames are the braille spinner frames used by the bubbletea TUIs in-// this codebase (sign-in, upgrade). StartSpinner uses the same frames for its+// this codebase (sign-in). StartSpinner uses the same frames for its// fallback so the restart spinner matches the look of those flows.var SpinnerFrames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}diff --git a/cmd/tui/selector_test.go b/cmd/tui/selector_test.goindex ad6182134..b45061912 100644--- a/cmd/tui/selector_test.go+++ b/cmd/tui/selector_test.go@@ -315,7 +315,7 @@ func TestRenderContent_AvailabilityBadgeOnlyOnCursor(t *testing.T) {m := selectorModel{title: "Pick:",items: []SelectItem{- {Name: "kimi-k2.6:cloud", AvailabilityBadge: "Upgrade required"},+ {Name: "kimi-k2.6:cloud", AvailabilityBadge: "Use usage credits or upgrade your plan"},{Name: "qwen3.5:cloud", AvailabilityBadge: "Sign in required"},{Name: "glm-5:cloud", AvailabilityBadge: "Included"},},@@ -323,7 +323,7 @@ func TestRenderContent_AvailabilityBadgeOnlyOnCursor(t *testing.T) {}content := m.renderContent()- if !strings.Contains(content, "(Upgrade required)") {+ if !strings.Contains(content, "(Use usage credits or upgrade your plan)") {t.Fatalf("cursor badge missing:\n%s", content)}if strings.Contains(content, "(Sign in required)") {@@ -341,7 +341,7 @@ func TestSelectorModel_ItemsUpdatedPreservesCursorAndRendersBadge(t *testing.T)}, "kimi-k2.6:cloud")updated, _ := m.Update(selectorItemsUpdatedMsg{items: []SelectItem{- {Name: "kimi-k2.6:cloud", Recommended: true, AvailabilityBadge: "Upgrade required"},+ {Name: "kimi-k2.6:cloud", Recommended: true, AvailabilityBadge: "Use usage credits or upgrade your plan"},{Name: "llama3.2"},}})fm := updated.(selectorModel)@@ -349,21 +349,21 @@ func TestSelectorModel_ItemsUpdatedPreservesCursorAndRendersBadge(t *testing.T)t.Fatalf("cursor = %d, want 0", fm.cursor)}content := fm.renderContent()- if !strings.Contains(content, "(Upgrade required)") {+ if !strings.Contains(content, "(Use usage credits or upgrade your plan)") {t.Fatalf("updated badge missing:\n%s", content)}}func TestMultiSelector_AvailabilityBadgePreservesDefaultSuffix(t *testing.T) {m := newMultiSelectorModel("Pick:", []SelectItem{- {Name: "kimi-k2.6:cloud", AvailabilityBadge: "Upgrade required"},+ {Name: "kimi-k2.6:cloud", AvailabilityBadge: "Use usage credits or upgrade your plan"},{Name: "qwen3.5:cloud"},}, []string{"kimi-k2.6:cloud"})m.multi = truem.cursor = 0content := m.View()- if !strings.Contains(content, "(Upgrade required)") {+ if !strings.Contains(content, "(Use usage credits or upgrade your plan)") {t.Fatalf("cursor badge missing:\n%s", content)}if !strings.Contains(content, "(default)") {@@ -379,7 +379,7 @@ func TestMultiSelector_ItemsUpdatedPreservesCheckedStateAndRendersBadge(t *testim.multi = trueupdated, _ := m.Update(selectorItemsUpdatedMsg{items: []SelectItem{- {Name: "kimi-k2.6:cloud", Recommended: true, AvailabilityBadge: "Upgrade required"},+ {Name: "kimi-k2.6:cloud", Recommended: true, AvailabilityBadge: "Use usage credits or upgrade your plan"},{Name: "llama3.2"},}})fm := updated.(multiSelectorModel)@@ -388,7 +388,7 @@ func TestMultiSelector_ItemsUpdatedPreservesCheckedStateAndRendersBadge(t *testit.Fatalf("checked state was not preserved: %#v", fm.checked)}content := fm.View()- if !strings.Contains(content, "(Upgrade required)") {+ if !strings.Contains(content, "(Use usage credits or upgrade your plan)") {t.Fatalf("updated badge missing:\n%s", content)}if !strings.Contains(content, "(default)") {diff --git a/cmd/tui/signin.go b/cmd/tui/signin.goindex f8a512fb4..b6b1437e2 100644--- a/cmd/tui/signin.go+++ b/cmd/tui/signin.go@@ -19,14 +19,6 @@ type signInCheckMsg struct {userName string}-type upgradeTickMsg struct{}--type upgradeCheckMsg struct {- upgraded bool- plan string- err error-}-type signInModel struct {modelName stringsignInURL string@@ -36,18 +28,6 @@ type signInModel struct {cancelled bool}-type upgradeModel struct {- modelName string- requiredPlan string- spinner int- width int- openNow bool- polling bool- plan string- cancelled bool- err error-}-func (m signInModel) Init() tea.Cmd {return tea.Tick(200*time.Millisecond, func(t time.Time) tea.Msg {return signInTickMsg{}@@ -102,85 +82,6 @@ func (m signInModel) View() string {return renderSignIn(m.modelName, m.signInURL, m.spinner, m.width)}-func (m upgradeModel) Init() tea.Cmd {- if m.polling {- return upgradeTickCmd()- }- return nil-}--func (m upgradeModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {- switch msg := msg.(type) {- case tea.WindowSizeMsg:- wasSet := m.width > 0- m.width = msg.Width- if wasSet {- return m, tea.ClearScreen- }- return m, nil-- case tea.KeyMsg:- switch msg.Type {- case tea.KeyCtrlC, tea.KeyEsc:- m.cancelled = true- return m, tea.Quit- case tea.KeyLeft:- if !m.polling {- m.openNow = true- }- case tea.KeyRight:- if !m.polling {- m.openNow = false- }- case tea.KeyEnter:- if !m.polling {- if !m.openNow {- m.cancelled = true- return m, tea.Quit- }- launch.OpenBrowser(launch.DefaultUpgradeURL)- m.polling = true- return m, upgradeTickCmd()- }- }-- case upgradeTickMsg:- if !m.polling {- return m, nil- }- m.spinner++- if m.spinner%5 == 0 {- return m, tea.Batch(- upgradeTickCmd(),- checkUpgrade(m.requiredPlan),- )- }- return m, upgradeTickCmd()-- case upgradeCheckMsg:- if msg.err != nil {- m.err = msg.err- return m, tea.Quit- }- if msg.upgraded {- m.plan = msg.plan- return m, tea.Quit- }- }-- return m, nil-}--func (m upgradeModel) View() string {- if m.plan != "" {- return ""- }- if m.err != nil {- return ""- }- return renderUpgrade(m.modelName, m.spinner, m.width, m.polling, m.openNow)-}-func renderSignIn(modelName, signInURL string, spinner, width int) string {spinnerFrames := []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}frame := spinnerFrames[spinner%len(spinnerFrames)]@@ -209,55 +110,6 @@ func renderSignIn(modelName, signInURL string, spinner, width int) string {return lipgloss.NewStyle().PaddingLeft(2).Render(s.String())}-func upgradeTickCmd() tea.Cmd {- return tea.Tick(200*time.Millisecond, func(t time.Time) tea.Msg {- return upgradeTickMsg{}- })-}--func renderUpgrade(modelName string, spinner, width int, polling, openNow bool) string {- spinnerFrames := []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}- frame := spinnerFrames[spinner%len(spinnerFrames)]-- urlColor := lipgloss.NewStyle().- Foreground(lipgloss.Color("117"))- urlWrap := lipgloss.NewStyle().PaddingLeft(2)- if width > 4 {- urlWrap = urlWrap.Width(width - 4)- }-- var s strings.Builder-- fmt.Fprintf(&s, "To use %s, upgrade your Ollama plan.\n\n", selectorSelectedItemStyle.Render(modelName))-- s.WriteString("Navigate to:\n")- s.WriteString(urlWrap.Render(urlColor.Render(launch.DefaultUpgradeURL)))- s.WriteString("\n\n")-- if !polling {- var yesBtn, noBtn string- if openNow {- yesBtn = confirmActiveStyle.Render(" Yes ")- noBtn = confirmInactiveStyle.Render(" No ")- } else {- yesBtn = confirmInactiveStyle.Render(" Yes ")- noBtn = confirmActiveStyle.Render(" No ")- }-- s.WriteString("Open now?\n")- s.WriteString(" " + yesBtn + " " + noBtn)- s.WriteString("\n\n")- s.WriteString(selectorHelpStyle.Render("←/→ navigate • enter confirm • esc cancel"))- } else {- s.WriteString(lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "242", Dark: "246"}).Render(- frame + " Waiting for upgrade to complete..."))- s.WriteString("\n\n")- s.WriteString(selectorHelpStyle.Render("esc cancel"))- }-- return lipgloss.NewStyle().PaddingLeft(2).Render(s.String())-}-func checkSignIn() tea.Msg {client, err := api.ClientFromEnvironment()if err != nil {@@ -272,25 +124,6 @@ func checkSignIn() tea.Msg {return signInCheckMsg{signedIn: false}}-func checkUpgrade(requiredPlan string) tea.Cmd {- return func() tea.Msg {- client, err := api.ClientFromEnvironment()- if err != nil {- return upgradeCheckMsg{err: launch.ErrPlanVerificationUnavailable}- }- ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)- defer cancel()- user, err := client.Whoami(ctx)- if err != nil {- return upgradeCheckMsg{err: launch.ErrPlanVerificationUnavailable}- }- if err == nil && user != nil && user.Name != "" && launch.PlanSatisfies(user.Plan, requiredPlan) {- return upgradeCheckMsg{upgraded: true, plan: user.Plan}- }- return upgradeCheckMsg{upgraded: false}- }-}-// RunSignIn shows a bubbletea sign-in dialog and polls until the user signs in or cancels.func RunSignIn(modelName, signInURL string) (string, error) {launch.OpenBrowser(signInURL)@@ -313,28 +146,3 @@ func RunSignIn(modelName, signInURL string) (string, error) {return fm.userName, nil}--// RunUpgrade shows a bubbletea upgrade dialog and polls until the user's plan is updated or cancelled.-func RunUpgrade(modelName, requiredPlan string) (string, error) {- m := upgradeModel{- modelName: modelName,- requiredPlan: requiredPlan,- openNow: true,- }-- p := tea.NewProgram(m)- finalModel, err := p.Run()- if err != nil {- return "", fmt.Errorf("error running upgrade: %w", err)- }-- fm := finalModel.(upgradeModel)- if fm.cancelled {- return "", ErrCancelled- }- if fm.err != nil {- return "", fm.err- }-- return fm.plan, nil-}diff --git a/cmd/tui/signin_test.go b/cmd/tui/signin_test.goindex ced5c53a9..430b4f7b3 100644--- a/cmd/tui/signin_test.go+++ b/cmd/tui/signin_test.go@@ -5,7 +5,6 @@ import ("testing"tea "github.com/charmbracelet/bubbletea"- "github.com/ollama/ollama/cmd/launch")func TestRenderSignIn_ContainsModelName(t *testing.T) {@@ -51,35 +50,6 @@ func TestRenderSignIn_ContainsEscHelp(t *testing.T) {}}-func TestRenderUpgrade_AsksBeforeOpening(t *testing.T) {- got := renderUpgrade("kimi-k2.6:cloud", 0, 80, false, true)- if !strings.Contains(got, "kimi-k2.6:cloud") {- t.Error("should contain model name")- }- if !strings.Contains(got, launch.DefaultUpgradeURL) {- t.Error("should contain upgrade URL")- }- if !strings.Contains(got, "Open now?") {- t.Error("should ask before opening")- }- if !strings.Contains(got, "Yes") || !strings.Contains(got, "No") {- t.Error("should show yes/no selector")- }- if strings.Contains(got, "Waiting for upgrade to complete") {- t.Error("should not start waiting before open choice is confirmed")- }-}--func TestRenderUpgrade_PollingShowsWaiting(t *testing.T) {- got := renderUpgrade("kimi-k2.6:cloud", 0, 80, true, true)- if !strings.Contains(got, "Waiting for upgrade to complete") {- t.Error("should contain waiting message")- }- if strings.Contains(got, "Open now?") {- t.Error("should not show open prompt while polling")- }-}-func TestSignInModel_EscCancels(t *testing.T) {m := signInModel{modelName: "test:cloud",@@ -96,35 +66,6 @@ func TestSignInModel_EscCancels(t *testing.T) {}}-func TestUpgradeModel_NoCancelsWithoutPolling(t *testing.T) {- m := upgradeModel{- modelName: "kimi-k2.6:cloud",- requiredPlan: "pro",- openNow: true,- }-- updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRight})- fm := updated.(upgradeModel)- if fm.openNow {- t.Error("right should select no")- }- if fm.polling {- t.Error("right should not start polling")- }-- updated, cmd := fm.Update(tea.KeyMsg{Type: tea.KeyEnter})- fm = updated.(upgradeModel)- if !fm.cancelled {- t.Error("enter on no should cancel")- }- if fm.polling {- t.Error("enter on no should not start polling")- }- if cmd == nil {- t.Error("enter on no should quit")- }-}-func TestSignInModel_CtrlCCancels(t *testing.T) {m := signInModel{modelName: "test:cloud",diff --git a/cmd/tui/spinner.go b/cmd/tui/spinner.goindex 5d0f26133..178fdc687 100644--- a/cmd/tui/spinner.go+++ b/cmd/tui/spinner.go@@ -12,7 +12,7 @@ import ()// spinnerStyle dims the spinner so it reads as ancillary status text, matching-// the sign-in/upgrade spinners in signin.go.+// the sign-in spinner in signin.go.var spinnerStyle = lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "242", Dark: "246"})