fix(server): a refused hub read keeps the account's last good usage reading #38397
MergedKrarilotus(GitHub profile, opens in a new tab)merged 7 commits into
main fromrefs/pull/38397/headmerged by juliusmarminge View on GitHubtanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- @@ -52,3 +52,19 @@5252 }5353 }545455+/**56+ * A refused read of one account keeps its last good reading, as provider probes keep their bars57+ * (see ServerProviderUsageLimits); a reading with none to keep stays listed as unreadable.58+ */59+function keepLastGoodReadings(60+ previous: ReadonlyArray<UsageLimitSourceSnapshot>,61+ next: ReadonlyArray<UsageLimitSourceSnapshot>,62+): ReadonlyArray<UsageLimitSourceSnapshot> {63+ return next.map((source) => {64+ const before = previous.find((candidate) => candidate.id === source.id);65+ if (!before) return source;66+ return {67+ ...source,68+ accounts: source.accounts.map((account) => {69+ if (account.usageLimits.unavailable?.reason !== "probeFailed") return account;70+ const last = before.accounts.find(
- @@ -52,3 +52,14 @@5252 }5353 }545455+/**56+ * A refused read of one account keeps its last good reading, as provider probes keep their bars57+ * (see ServerProviderUsageLimits); a reading with none to keep stays listed as unreadable.58+ */59+function keepLastGoodReadings(60+ previous: ReadonlyArray<UsageLimitSourceSnapshot>,61+ next: ReadonlyArray<UsageLimitSourceSnapshot>,62+): ReadonlyArray<UsageLimitSourceSnapshot> {63+ return next.map((source) => {64+ const before = previous.find((candidate) => candidate.id === source.id);65+ if (!before) return source;
juliusmarminge added labelstakeover:in-progress
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -54,0 +57,21 @@57+ * (see ServerProviderUsageLimits); a reading with none to keep stays listed as unreadable.58+ */59+function keepLastGoodReadings(60+ previous: ReadonlyArray<UsageLimitSourceSnapshot>,61+ next: ReadonlyArray<UsageLimitSourceSnapshot>,62+): ReadonlyArray<UsageLimitSourceSnapshot> {63+ return next.map((source) => {64+ // Auth file names can be reused, so only the same hub and login may lend a reading.65+ const before = previous.find(66+ (candidate) => candidate.id === source.id && candidate.endpoint === source.endpoint,67+ );68+ if (!before) return source;69+ return {70+ ...source,71+ accounts: source.accounts.map((account) => {72+ if (account.usageLimits.unavailable?.reason !== "probeFailed") return account;73+ const last = before.accounts.find(74+ (candidate) =>75+ candidate.id === account.id &&76+ candidate.driver === account.driver &&77+ candidate.email === account.email &&
- @@ -54,0 +59,21 @@59+function keepLastGoodReadings(60+ previous: ReadonlyArray<UsageLimitSourceSnapshot>,61+ next: ReadonlyArray<UsageLimitSourceSnapshot>,62+): ReadonlyArray<UsageLimitSourceSnapshot> {63+ return next.map((source) => {64+ // Auth file names can be reused, so only the same hub and login may lend a reading.65+ const before = previous.find(66+ (candidate) => candidate.id === source.id && candidate.endpoint === source.endpoint,67+ );68+ if (!before) return source;69+ return {70+ ...source,71+ accounts: source.accounts.map((account) => {72+ if (account.usageLimits.unavailable?.reason !== "probeFailed") return account;73+ const last = before.accounts.find(74+ (candidate) =>75+ candidate.id === account.id &&76+ candidate.driver === account.driver &&77+ // Fingerprinted Antigravity readings omit the listed identity, so absent means unknown.78+ (candidate.email === undefined || candidate.email === account.email) &&79+ (candidate.workspaceId === undefined || candidate.workspaceId === account.workspaceId),
juliusmarminge added labelstakeover:ready
juliusmarminge removed labelstakeover:in-progress
juliusmarminge merged this724f5c6
juliusmarminge closed this
juliusmarminge removed labelstakeover:ready
Sign in to join this conversation.




macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed