The best way to control Claude Code, Codex and more from any computer or phone
fix(server): Codex usage answering after three seconds is no longer dropped (#36189)
Julius Marminge committed
Nov 13, 2026 at 06:19 UTC
8610b31ee8df481f8f53bfb9827fe0abe5d0fab2
2 files changed
+82
-6
apps/server/src/provider/CodexProvider.ts
+1
-6
@@ -57,7 +57,6 @@ import {
57
import * as HostProcess from "@t3tools/shared/HostProcess";
58
import packageJson from "../../package.json" with { type: "json" };
59
const isCodexAppServerSpawnError = Schema.is(CodexErrors.CodexAppServerSpawnError);
60
-const RATE_LIMITS_PROBE_TIMEOUT_MS = 3_000;
60
61
type CodexRateLimitsProbe =
62
| {
@@ -670,11 +669,7 @@ const readCodexRateLimits = (
669
client: CodexClient.CodexAppServerClient["Service"],
670
deadlineMs: number,
671
) =>
673
- withCodexDiscoveryDeadline(
674
- client.request("account/rateLimits/read", null),
675
- deadlineMs,
676
- RATE_LIMITS_PROBE_TIMEOUT_MS,
677
- ).pipe(
672
+ withCodexDiscoveryDeadline(client.request("account/rateLimits/read", null), deadlineMs).pipe(
673
Effect.map((response): CodexRateLimitsProbe =>
674
response
675
? {
apps/server/src/provider/ProviderRegistry.test.ts
+81
@@ -17,6 +17,7 @@ import * as FileSystem from "effect/FileSystem";
17
import * as Layer from "effect/Layer";
18
import * as Path from "effect/Path";
19
import * as PubSub from "effect/PubSub";
20
+import * as Queue from "effect/Queue";
21
import * as Ref from "effect/Ref";
22
import * as Schema from "effect/Schema";
23
import * as Scope from "effect/Scope";
@@ -788,6 +789,86 @@ it.layer(
789
}),
790
);
791
792
+ it.effect("shows Codex usage that answers after three seconds inside the probe budget", () =>
793
+ Effect.gen(function* () {
794
+ const usageRequested = yield* Deferred.make<void>();
795
+ const spawner = ChildProcessSpawner.make(() =>
796
+ Effect.gen(function* () {
797
+ const scope = yield* Effect.scope;
798
+ const output = yield* Queue.unbounded<Uint8Array>();
799
+ const send = (message: unknown) =>
800
+ Queue.offer(output, encoder.encode(`${JSON.stringify(message)}\n`));
801
+ const results: Record<string, unknown> = {
802
+ initialize: {
803
+ userAgent: "codex_cli_rs/0.167.0",
804
+ codexHome: "/nonexistent-codex-home",
805
+ platformFamily: "unix",
806
+ platformOs: "linux",
807
+ },
808
+ "account/read": {
809
+ account: { type: "chatgpt", email: "test@example.com", planType: "pro" },
810
+ requiresOpenaiAuth: true,
811
+ },
812
+ "config/read": { config: {}, origins: {} },
813
+ "skills/list": { data: [] },
814
+ "model/list": { data: [] },
815
+ };
816
+ const answer = (line: string) => {
817
+ const { id, method } = JSON.parse(line) as { id?: number; method?: string };
818
+ if (id === undefined || method === undefined) return Effect.void;
819
+ if (method !== "account/rateLimits/read") {
820
+ return send({ id, result: results[method] ?? {} });
821
+ }
822
+ return Deferred.succeed(usageRequested, undefined).pipe(
823
+ Effect.andThen(Effect.sleep("4 seconds")),
824
+ Effect.andThen(
825
+ send({
826
+ id,
827
+ result: {
828
+ rateLimits: {
829
+ limitId: "codex",
830
+ planType: "pro",
831
+ primary: { usedPercent: 42, windowDurationMins: 300, resetsAt: 2e9 },
832
+ },
833
+ rateLimitsByLimitId: null,
834
+ rateLimitResetCredits: null,
835
+ accountId: null,
836
+ },
837
+ }),
838
+ ),
839
+ Effect.forkIn(scope),
840
+ );
841
+ };
842
+ const decoder = new TextDecoder();
843
+ let buffered = "";
844
+ return ChildProcessSpawner.makeHandle({
845
+ ...mockHandle({ stdout: "", stderr: "", code: 0 }),
846
+ exitCode: Effect.never,
847
+ isRunning: Effect.succeed(true),
848
+ stdin: Sink.forEach((chunk: Uint8Array) => {
849
+ buffered += decoder.decode(chunk, { stream: true });
850
+ const lines = buffered.split("\n");
851
+ buffered = lines.pop() ?? "";
852
+ return Effect.forEach(lines.filter(Boolean), answer, { discard: true });
853
+ }),
854
+ stdout: Stream.fromQueue(output),
855
+ });
856
+ }),
857
+ );
858
+ const fiber = yield* checkCodexProviderStatus(defaultCodexSettings).pipe(
859
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
860
+ Effect.forkChild,
861
+ );
862
+ yield* Deferred.await(usageRequested);
863
+ yield* TestClock.adjust("25 seconds");
864
+ const status = yield* Fiber.join(fiber);
865
+
866
+ assert.strictEqual(status.auth.status, "authenticated");
867
+ assert.isUndefined(status.usageLimits?.unavailable);
868
+ assert.strictEqual(status.usageLimits?.windows[0]?.usedPercent, 42);
869
+ }),
870
+ );
871
+
872
it.effect("does not run --version when the Codex executable cannot start", () =>
873
Effect.gen(function* () {
874
if ((yield* HostProcess.Platform) === "win32") return;