Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): correctly report usage limits with multi-account Codex routing #11625

ClosedExotic209093(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/11625/headopened View on GitHub

Showing 2 changed files with 193 additions and 4 deletions.

x
0 of 2 viewed, 2 left
157 additions and 0 deletionsapps/server/src/usage/UsageService.test.tsAdded
View file
@@ -0,0 +1,157 @@
+import * as NodeServices from "@effect/platform-node/NodeServices";
+import { describe, expect, it } from "@effect/vitest";
+import * as Effect from "effect/Effect";
+import * as Path from "effect/Path";
+import * as Schema from "effect/Schema";
+​
+import {
+ CodexSettings,
+ ProviderDriverKind,
+} from "@t3tools/contracts";
+import { resolveCodexHomeLayout } from "../provider/Drivers/CodexHomeLayout.ts";
+​
+const decodeCodexSettings = Schema.decodeSync(CodexSettings);
+const codexDriverKind = ProviderDriverKind.make("codex");
+​
+/**
+ * Regression test for #11515: UsageService.resolveTranscriptDirs must scan
+ * every configured Codex instance, not just the legacy single-instance config.
+ *
+ * We test the underlying logic (resolveCodexHomeLayout + deduplication) rather
+ * than the full service because the service requires a live settings layer and
+ * filesystem. The bug was that `settings.providerInstances` entries with
+ * `driver === "codex"` were ignored entirely, so their session directories
+ * never appeared in the scan list.
+ */
+it.layer(NodeServices.layer)("UsageService multi-account Codex routing (#11515)", (it) => {
+ describe("resolveTranscriptDirs multi-instance enumeration", () => {
+ it.effect("resolves distinct session dirs for multiple Codex instances", () =>
+ Effect.gen(function* () {
+ const path = yield* Path.Path;