Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(license): keep Pro when the device-bound status read does not answer
review7349e3827d45
diff --git a/src/core/license.test.ts b/src/core/license.test.tsindex 11bb8302c..85f09b160 100644--- a/src/core/license.test.ts+++ b/src/core/license.test.ts@@ -145,6 +145,31 @@ describe('license entitlement refresh', () => {expect(sent().at(-1)!.active).toBe(false)})+ // A status read that did not run is not a cancellation. The server rate-limits 30/min per IP+ // (a few users behind one NAT, or the Upgrade screen's 4s poll, is enough to trip it) and relays a+ // keygen outage as an error; either used to delete a still-valid 7-day token on the spot.+ it.each([+ ['a 429 from the rate limiter', { ok: false, status: 429, json: async () => ({ error: 'rate_limited' }) }],+ ['a keygen outage relayed as 502', { ok: false, status: 502, json: async () => ({ error: 'unavailable' }) }],+ ['a 5xx with no body', { ok: false, status: 503, json: async () => { throw new Error('not json') } }],+ ['a 2xx that states nothing', { ok: true, status: 200, json: async () => ({}) }]+ ])('a periodic refresh that gets %s keeps Pro and the stored token', async (_label, reply) => {+ fetchMock.mockResolvedValueOnce(+ jsonResponse({ active: true, token: mint(7 * 24 * 60 * 60) })+ )+ const { initLicense } = await import('./license')+ initLicense()+ await refreshed()+ expect(sent().at(-1)!.active).toBe(true)++ fetchMock.mockResolvedValue(reply)+ await vi.advanceTimersByTimeAsync(24 * HOUR)+ await refreshed()+ expect(sent().at(-1)!.active).toBe(true)+ const onDisk = JSON.parse(readFileSync(path.join(h.userData, 'license.json'), 'utf8')) as { token?: string }+ expect(onDisk.token).toBeTruthy()+ })+it('rejects a token minted for a different device (copied license.json)', async () => {// Simulates copying license.json + a foreign token onto this machine.fetchMock.mockResolvedValue(diff --git a/src/core/license.ts b/src/core/license.tsindex fe299b1ea..469680f4a 100644--- a/src/core/license.ts+++ b/src/core/license.ts@@ -211,16 +211,24 @@ async function call(path: string, body: unknown): Promise<MintReply> {}}+/** What the device-bound status poll answers. `answered` is true only for a 2xx: it is the one+ * reply that may state "this device is not entitled". A 429 from our rate limiter, a 5xx, or a+ * keygen outage relayed as an error is the server failing to answer, not answering "no". */+interface StatusReply extends MintReply {+ active?: boolean+ answered?: boolean+}+// GET helper for the device-bound status poll.-async function getJson(path: string): Promise<MintReply & { active?: boolean }> {+async function getJson(path: string): Promise<StatusReply> {if (!allowed()) return { error: 'disabled' }const ctrl = new AbortController()const t = setTimeout(() => ctrl.abort(), REQUEST_TIMEOUT_MS)try {const res = await fetch(`${API_BASE}${path}`, { signal: ctrl.signal })- const json = (await res.json().catch(() => ({}))) as MintReply & { active?: boolean }+ const json = (await res.json().catch(() => ({}))) as StatusReplyif (!res.ok) return { error: json.error ?? 'network' }- return json+ return { ...json, answered: true }} catch {return { error: 'offline' }} finally {@@ -429,14 +437,19 @@ export function initLicense(onChange?: () => void): void {const next = withToken(stored, r)await save(next)broadcast(statusOf(next))- } else if (r.error === 'offline' || r.error === 'network' || r.error === 'disabled') {- // Couldn't reach the server → offline grace: keep the last valid token.- if (stored.token) broadcast(statusOf(stored))- } else {- // Server responded: this device is no longer entitled (canceled / suspended / expired)- // → drop Pro and clear the cached token, even though it hasn't expired yet.+ } else if (r.answered && r.active === false) {+ // The server ANSWERED (2xx) that this device is no longer entitled (canceled / suspended /+ // expired) → drop Pro and clear the cached token, even though it hasn't expired yet.if (stored.token) await save({ ...stored, token: undefined, termEndsAt: undefined })broadcast(statusFrom(undefined))+ } else {+ // Anything else is a status read that did not run — offline, a 429 from the rate limiter,+ // a 5xx, a keygen outage, an unusable body. Not evidence of cancellation: keep the last+ // valid token (offline grace, the same rule the key-paste branch above follows). It still+ // expires on its own clock, so a real cancellation is never held open past the token.+ // This used to be an allowlist of offline/network/disabled with every other error read as+ // "canceled", which deleted a paying customer's Pro on a single 429.+ if (stored.token) broadcast(statusOf(stored))}}}