Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(opencode): Go-key-only instances keep OpenCode Go usage on OpenCode 2 #36519

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/36519/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 83 additions and 1 deletion.

x
0 of 2 viewed, 2 left
79 additions and 0 deletionspackages/provider-opencode/src/server/driver.test.tsModified
View file
@@ -1053,6 +1053,85 @@
assert.strictEqual(serverStarts, starts);
}).pipe(Effect.scoped, Effect.provide(TestClock.layer())),
+​
+ it.effect("reads Go usage from a stored key when the local server has no Console workspace", () =>
+ Effect.gen(function* () {
+ let goUsageReads = 0;
+ const usageStarted = yield* Deferred.make<void>();
+ const server = HttpClient.make((request) => {
+ if (request.url === "https://opencode.ai/zen/go/v1/usage") {
+ goUsageReads += 1;
+ assert.strictEqual(request.headers.authorization, "Bearer test-go-key");
+ const window = { percent: 10, resetsAt: "2026-11-01T00:00:00.000Z" };
+ return Effect.succeed(
+ HttpClientResponse.fromWeb(
+ request,
+ Response.json({ usage: { rolling: window, weekly: window, monthly: window } }),
+ ),
+ );
+ }
+ const path = new URL(request.url).pathname;
+ if (path === "/api/experimental/usage/limits") {
+ const response = HttpClientResponse.fromWeb(
+ request,
+ Response.json({ location: { directory: "/work" }, data: null }),
+ );
+ return Deferred.succeed(usageStarted, undefined).pipe(Effect.as(response));
+ }
+ const body =