@devries-cameron20 / t3code Mirror · read-only / commits / 984fe2d45e
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 02:00 UTC

perf(shared): scan usage-limit support once per provider catalog (#32179)

luke committed Nov 7, 2026 at 06:34 UTC 984fe2d45e06ff20a1a184ae48a856c74f9c05a4
2 files changed +19 -1
packages/shared/src/usageLimits.test.ts
+11
@@ -1412,6 +1412,17 @@ describe("/usage-limits", () => {
1412 expect(
1413 withUsageLimitsCommands([selected], [])[0]?.slashCommands.map((command) => command.name),
1414 ).toEqual(["usage-limits"]);
1415 + const unrelated = provider({ driver: ProviderDriverKind.make("claudeAgent") });
1416 + const disabled = provider({ ...unrelated, enabled: false, usageLimits: limits });
1417 + const mixed = withUsageLimitsCommands([selected, withWorkspace, unrelated, disabled], []);
1418 + expect(mixed.map((entry) => entry.slashCommands.map((command) => command.name))).toEqual([
1419 + ["usage-limits"],
1420 + ["usage-limits"],
1421 + [],
1422 + [],
1423 + ]);
1424 + expect(mixed[2]).toBe(unrelated);
1425 + expect(mixed[3]).toBe(disabled);
1426 });
1427 });
1428
packages/shared/src/usageLimits.ts
+8 -1
@@ -729,8 +729,15 @@ export function withUsageLimitsCommands(
729 providers: readonly ServerProvider[],
730 sources: UsageLimitSourceSnapshots,
731 ): ServerProvider[] {
732 + const supportedDrivers = new Set([
733 + ...providersWithLimits(providers).map((provider) => provider.driver),
734 + ...sources.flatMap((source) => source.accounts.map((account) => account.driver)),
735 + ]);
736 + const unreadableSource = sources.some(
737 + (source) => source.error !== undefined && source.accounts.length === 0,
738 + );
739 return providers.map((provider) => {
733 - if (!hasProviderUsageLimits(provider.driver, providers, sources)) return provider;
740 + if (!unreadableSource && !supportedDrivers.has(provider.driver)) return provider;
741 const commands = (items: readonly ServerProviderSlashCommand[]) => [
742 ...items.filter((command) => command.name !== USAGE_LIMITS_COMMAND.name),
743 USAGE_LIMITS_COMMAND,