ReneXiong's account has two organizations: the personal one on
zed_student and a non-personal default with no plan. orgOf() always took
default_organization_id, minted the model token for it, and /models and
/completions answered 402 "Organization does not have an active
subscription". planOf() fell back to the account's plan_v3, so the card
said Student over an organization with none.
What Zed's editor does (zed-industries/zed 56934ec): user.rs
update_authenticated_user starts in the default organization, else the
first; the title bar's organization menu calls set_current_organization,
which the LLM token's auth context (language_models cloud.rs
ClientTokenProvider) follows; plan() is plans_by_organization[current],
none when it has no entry (current_organization_has_no_active_subscription
treats a missing entry as no subscription; an unknown plan as Free). The
plugin has no switcher, so it now picks as a user switching would:
- the organization the sign-in saved, while it still has a plan that
calls models (any but Free) and models aren't turned off for it;
- else the default, if it has one; else the personal one with one; else
any with one;
- none with one: what Zed picks (saved, else default, else first).
planOf names the picked organization's own plan ("" without an entry);
only a reply with no organizations falls back to plan_v3.
A sign-in saved before this under the unsubscribed default is moved on
the first 402 (llm_tokens, /models, /completions) or empty list: the
account is read again, moved if another organization has a plan, the
move saved through client.auth.set (and kept in memory in case the save
doesn't land), and the request asked once more. The usage hook re-picks
the same way. The model-token cache and the model list are keyed by
organization now, so a move mints and lists anew. There is no explicit
organization choice in the plugin or in magpie to respect; the saved
organization is the sticky one.
Run (bun 1.4.2, macOS, worktree at origin/main 8cdf2d2 + this):
- packages/zed/org.test.mjs (new, no network: fetch stubbed): 11 pass.
With the old index.mjs and the new tests: 10 fail, 1 pass (the
no-plan fallback the old code also did).
- HOME=$(mktemp -d) bun test (whole repo): 1802 pass, 0 fail.
- bun scripts/check.mjs: every package ok.
Not tried against a real Zed account; the reporter's /users/me shape is
from the issue's sanitized read.