summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKit Langton <[email protected]>2026-03-16 10:01:42 -0400
committerGitHub <[email protected]>2026-03-16 10:01:42 -0400
commitc523aac586b5b5d3d59143f19cad65c935090e4e (patch)
treec19b14ebae4dba15df24f38afb96afd5a4a3c9cd
parent51fcd04a70258e40f04ec1b5ca165aab6a6dfc32 (diff)
downloadopencode-c523aac586b5b5d3d59143f19cad65c935090e4e.tar.gz
opencode-c523aac586b5b5d3d59143f19cad65c935090e4e.zip
fix(cli): scope active org labels to the active account (#16957)
-rw-r--r--packages/opencode/src/cli/cmd/account.ts11
1 files changed, 7 insertions, 4 deletions
diff --git a/packages/opencode/src/cli/cmd/account.ts b/packages/opencode/src/cli/cmd/account.ts
index 8ad42c5eb..b2256837d 100644
--- a/packages/opencode/src/cli/cmd/account.ts
+++ b/packages/opencode/src/cli/cmd/account.ts
@@ -11,6 +11,11 @@ const openBrowser = (url: string) => Effect.promise(() => open(url).catch(() =>
const println = (msg: string) => Effect.sync(() => UI.println(msg))
+const isActiveOrgChoice = (
+ active: Option.Option<{ id: AccountID; active_org_id: OrgID | null }>,
+ choice: { accountID: AccountID; orgID: OrgID },
+) => Option.isSome(active) && active.value.id === choice.accountID && active.value.active_org_id === choice.orgID
+
const loginEffect = Effect.fn("login")(function* (url: string) {
const service = yield* AccountService
@@ -99,11 +104,10 @@ const switchEffect = Effect.fn("switch")(function* () {
if (groups.length === 0) return yield* println("Not logged in")
const active = yield* service.active()
- const activeOrgID = Option.flatMap(active, (a) => Option.fromNullishOr(a.active_org_id))
const opts = groups.flatMap((group) =>
group.orgs.map((org) => {
- const isActive = Option.isSome(activeOrgID) && activeOrgID.value === org.id
+ const isActive = isActiveOrgChoice(active, { accountID: group.account.id, orgID: org.id })
return {
value: { orgID: org.id, accountID: group.account.id, label: org.name },
label: isActive
@@ -132,11 +136,10 @@ const orgsEffect = Effect.fn("orgs")(function* () {
if (!groups.some((group) => group.orgs.length > 0)) return yield* println("No orgs found")
const active = yield* service.active()
- const activeOrgID = Option.flatMap(active, (a) => Option.fromNullishOr(a.active_org_id))
for (const group of groups) {
for (const org of group.orgs) {
- const isActive = Option.isSome(activeOrgID) && activeOrgID.value === org.id
+ const isActive = isActiveOrgChoice(active, { accountID: group.account.id, orgID: org.id })
const dot = isActive ? UI.Style.TEXT_SUCCESS + "●" + UI.Style.TEXT_NORMAL : " "
const name = isActive ? UI.Style.TEXT_HIGHLIGHT_BOLD + org.name + UI.Style.TEXT_NORMAL : org.name
const email = UI.Style.TEXT_DIM + group.account.email + UI.Style.TEXT_NORMAL