Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

providers: a switched-off provider says how to turn it on, after a sign-in too

yetone5b2b3d3f5095
diff --git a/internal/cli/accounts_cli.go b/internal/cli/accounts_cli.go
index ee112ad58..ba4933cb6 100644
--- a/internal/cli/accounts_cli.go
+++ b/internal/cli/accounts_cli.go
@@ -505,6 +505,7 @@ func addAccount(agentID string) error {
}
switch st.State {
case "done":
+ defer sayStillOff(agentID)
if st.Again {
fmt.Println(green.Render("✓"), st.User, "is already listed — its sign-in was renewed")
} else if st.Using {
diff --git a/internal/cli/plugin_login_cli_test.go b/internal/cli/plugin_login_cli_test.go
index 941572311..1900431cb 100644
--- a/internal/cli/plugin_login_cli_test.go
+++ b/internal/cli/plugin_login_cli_test.go
@@ -6,6 +6,7 @@ import (
"net/http"
"net/http/httptest"
"path/filepath"
+ "strings"
"sync/atomic"
"testing"
"time"
@@ -184,3 +185,46 @@ func TestPluginLoginInstallsItsCLIFirst(t *testing.T) {
t.Fatalf("installed for a key: %v", installed)
}
}
+
+// A sign-in to a provider the user switched off keeps it off, and says so
+// with the command that turns it on (Atlas: WorkBuddy AI signed in, then
+// "○ switched off" with nothing saying why or how). One that is on says
+// nothing of it. magpie providers says the same command beside the row.
+func TestPluginLoginSaysItIsSwitchedOff(t *testing.T) {
+ fakeCoHome(t)
+ noBrowser(t)
+ login := func() string {
+ t.Helper()
+ piped(t, "1", "sk-one-key-1111")
+ out, err := said(t, func() error { return pluginCmd([]string{"plugin", "login", "fakeco"}) })
+ if err != nil {
+ t.Fatalf("%v: %s", err, out)
+ }
+ return out
+ }
+ if out := login(); strings.Contains(out, "switched off") {
+ t.Fatalf("a provider that is on said switched off:\n%s", out)
+ }
+ if err := provider.SetOff("fakeco", true); err != nil {
+ t.Fatal(err)
+ }
+ out := login()
+ if !strings.Contains(out, "switched off") || !strings.Contains(out, "magpie provider on fakeco") {
+ t.Fatalf("signed in to a switched-off provider, and nothing said how to turn it on:\n%s", out)
+ }
+ if p, err := provider.Find("fakeco"); err != nil || !p.Off {
+ t.Fatalf("the sign-in turned the user's switch over: %+v %v", p, err)
+ }
+ // magpie accounts add, the same sign-in, says it too
+ piped(t, "1", "sk-two-key-2222")
+ if out, err := said(t, func() error { return accountsCmd([]string{"accounts", "add", "fakeco"}) }); err != nil || !strings.Contains(out, "magpie provider on fakeco") {
+ t.Fatalf("accounts add: %v\n%s", err, out)
+ }
+ out, err := printed(t, providers)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if row := lineWith(out, "fakeco"); !strings.Contains(row, "switched off") || !strings.Contains(row, "magpie provider on fakeco") {
+ t.Errorf("magpie providers, off: %q", row)
+ }
+}
diff --git a/internal/cli/plugins_cli.go b/internal/cli/plugins_cli.go
index 6efe395c0..71274862d 100644
--- a/internal/cli/plugins_cli.go
+++ b/internal/cli/plugins_cli.go
@@ -535,9 +535,21 @@ func pluginLogin(ctx context.Context, name, method string) error {
// magpie, it comes back
id := provider.PluginSignedIn(saved)
fmt.Println(green.Render("✓"), "signed in to", pp.Name, muted.Render("· its models are "+id+"/<model>"))
+ sayStillOff(id)
return nil
}
+// sayStillOff tells, after a sign-in, that the provider it went to is
+// switched off. A sign-in keeps the user's own switch as it was, but
+// "signed in" and then "○ switched off" in magpie providers read as a bug
+// with nothing saying how to turn it on (Atlas, WorkBuddy AI). A provider
+// that can't be found says nothing: not known to be off.
+func sayStillOff(id string) {
+ if p, err := provider.Find(id); err == nil && p.Off {
+ fmt.Println(amber.Render("!"), p.Name, "is switched off in magpie, so agents aren't given its models · turn it on: magpie provider on "+p.ID)
+ }
+}
+
// keyPrompt asks an "api" method's key: its title, then the hint the
// plugin gives (its placeholder), as a question's is.
func keyPrompt(name string, m plugin.Method) string {
diff --git a/internal/cli/providers_cli.go b/internal/cli/providers_cli.go
index 70c9af151..680a9e866 100644
--- a/internal/cli/providers_cli.go
+++ b/internal/cli/providers_cli.go
@@ -207,6 +207,11 @@ func providers() error {
if u := uses[p.ID]; len(u) > 0 {
r.uses = green.Render("← " + strings.Join(u, ", "))
}
+ if p.Off {
+ // the user's own switch, kept as they set it: how to undo it
+ // is said beside it, never done for them
+ r.uses = strings.TrimSpace(muted.Render("magpie provider on "+p.ID) + " " + r.uses)
+ }
if e := p.ListError(); e != "" {
r.uses += amber.Render(" ! couldn't list its models: " + e)
}
diff --git a/internal/cli/providers_vertex_cli_test.go b/internal/cli/providers_vertex_cli_test.go
index 0b8541890..25ef5ad78 100644
--- a/internal/cli/providers_vertex_cli_test.go
+++ b/internal/cli/providers_vertex_cli_test.go
@@ -225,9 +225,12 @@ func TestProvidersShowVertexCredentials(t *testing.T) {
t.Fatal(err)
}
out, _ = printed(t, providers)
- if row := lineWith(out, "google-vertex"); !strings.Contains(row, "switched off") || strings.Contains(row, "Google credentials") {
+ if row := lineWith(out, "google-vertex"); !strings.Contains(row, "switched off") || strings.Contains(row, "Google credentials") || !strings.Contains(row, "magpie provider on google-vertex") {
t.Errorf("list, off: %q", row)
}
+ if row := lineWith(out, "vertex-sa"); strings.Contains(row, "magpie provider on") {
+ t.Errorf("list, on, says how to turn it on: %q", row)
+ }
}
// A Vertex AI provider with no project an address can be made of
diff --git a/internal/tui/pages.go b/internal/tui/pages.go
index 5dbda72ba..a2c24388f 100644
--- a/internal/tui/pages.go
+++ b/internal/tui/pages.go
@@ -777,6 +777,10 @@ func (m model) viewProviders() string {
}
r.models = fmt.Sprintf("%d models", len(p.Exposed()))
var notes []string
+ if p.Off {
+ // how to switch it on again, as magpie providers says it
+ notes = append(notes, "o switches it on")
+ }
if v, ok := m.bal[p.ID]; ok {
notes = append(notes, v)
}
diff --git a/internal/tui/vertex_test.go b/internal/tui/vertex_test.go
index 40ad060e4..77efca07f 100644
--- a/internal/tui/vertex_test.go
+++ b/internal/tui/vertex_test.go
@@ -80,10 +80,10 @@ func TestTUIAddsVertexWithItsProject(t *testing.T) {
if r := row("google-vertex"); !strings.Contains(r, "● Google credentials") || strings.Contains(r, " as ") || strings.Contains(r, "no key") {
t.Errorf("its row: %q", r)
}
- if r := row("vertex-sa"); !strings.Contains(r, "● Google credentials as [email protected]") {
+ if r := row("vertex-sa"); !strings.Contains(r, "● Google credentials as [email protected]") || strings.Contains(r, "switches it on") {
t.Errorf("a service account's row: %q", r)
}
- if r := row("vertex-off"); !strings.Contains(r, "○ switched off") || strings.Contains(r, "Google credentials") {
+ if r := row("vertex-off"); !strings.Contains(r, "○ switched off") || strings.Contains(r, "Google credentials") || !strings.Contains(r, "o switches it on") {
t.Errorf("a switched-off one's row: %q", r)
}