From 3aa45164f04894d9f604b5fe7970ecbf33cf9d5f Mon Sep 17 00:00:00 2001 From: Neil Date: Mon, 16 Nov 2026 01:01:02 -0800 Subject: [PATCH] fix(cloud): GH-SOLO a teammate whose grant is still being revoked keeps the workspace from being solo --- cloud/apps/sandbox-control/src/member-git.ts | 5 +++-- .../sandbox-control/test/gh-solo-member.test.ts | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cloud/apps/sandbox-control/src/member-git.ts b/cloud/apps/sandbox-control/src/member-git.ts index f25046b9649..d98c93cc733 100644 --- a/cloud/apps/sandbox-control/src/member-git.ts +++ b/cloud/apps/sandbox-control/src/member-git.ts @@ -85,11 +85,12 @@ export async function actingMember(db: D1Database, row: SandboxRow, now: number, /** * GH-SOLO: the one person who can use this workspace, or null. From the people set itself (active grantees, plus * the untransferred owner, who may have no grant row: the create's own pairing code), never from "no expiry". - * Someone else's grant still being issued (their device may be pairing) means not solo. + * Someone else's grant still being issued or revoked (their device may be pairing, or not yet unpaired) means not + * solo. */ export async function soloMember(db: D1Database, row: SandboxRow): Promise { const { results } = await db - .prepare(`SELECT DISTINCT user_id, status FROM workspace_grants WHERE sandbox_id = ? AND status IN ('issuing', 'active')`) + .prepare(`SELECT DISTINCT user_id, status FROM workspace_grants WHERE sandbox_id = ? AND status IN ('issuing', 'active', 'revoking')`) .bind(row.id) .all<{ user_id: string; status: string }>() const pick = pickActing( diff --git a/cloud/apps/sandbox-control/test/gh-solo-member.test.ts b/cloud/apps/sandbox-control/test/gh-solo-member.test.ts index 6bb4ab6d536..eefc020fa8d 100644 --- a/cloud/apps/sandbox-control/test/gh-solo-member.test.ts +++ b/cloud/apps/sandbox-control/test/gh-solo-member.test.ts @@ -132,4 +132,17 @@ describe('the control plane marks a workspace solo only while one person can use expect(write).toBeGreaterThanOrEqual(0) expect(drop).toBeGreaterThan(write) }) + + it('a teammate whose grant is still being revoked (device not yet unpaired) keeps it from being solo', async () => { + const t = await workspace() + await t.connect('alice', 11) + t.h.raw + .prepare(`INSERT INTO workspace_grants (id, sandbox_id, account_id, user_id, device_kind, device_label, status, created_at) VALUES ('grt_out', ?, 'org:acme', 'bob', 'desktop', 'b', 'revoking', 1)`) + .run(t.id) + const row = (await getSandbox(t.h.env.SANDBOX_DB, t.id))! + expect(await soloMember(t.h.env.SANDBOX_DB, row)).toBeNull() + t.h.raw.prepare(`UPDATE workspace_grants SET status = 'revoked' WHERE id = 'grt_out'`).run() + expect(await soloMember(t.h.env.SANDBOX_DB, row)).toBe('alice') + }) }) +