@devries-cameron20 / t3code Mirror · read-only / commits / 966cc05a90
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 24, 19:00 UTC

fix(contracts): decode ServerProviders forward-compatibly (#5327)

Co-authored-by: Rodrigo Brechard <rodrigo@clubtidy.fr>

Rodrigo Brechard committed Aug 4, 2026 at 13:07 UTC 966cc05a9007a4ad1b7f8d5d3a1fc0e5c82a5b94
2 files changed +41 -2
packages/contracts/src/server.test.ts
+36 -1
@@ -1,12 +1,30 @@
1 import * as Schema from "effect/Schema";
2 import { describe, expect, it } from "vite-plus/test";
3
4 -import { ServerConfig, ServerProvider, ServerUpsertKeybindingResult } from "./server.ts";
4 +import {
5 + ServerConfig,
6 + ServerProvider,
7 + ServerProviders,
8 + ServerUpsertKeybindingResult,
9 +} from "./server.ts";
10
11 const decodeServerProvider = Schema.decodeUnknownSync(ServerProvider);
12 +const decodeServerProviders = Schema.decodeUnknownSync(ServerProviders);
13 const decodeUpsertKeybindingResult = Schema.decodeUnknownSync(ServerUpsertKeybindingResult);
14 const decodeAvailableEditors = Schema.decodeUnknownSync(ServerConfig.fields.availableEditors);
15
16 +const baseProviderSnapshot = {
17 + instanceId: "codex",
18 + driver: "codex",
19 + enabled: true,
20 + installed: true,
21 + version: "1.0.0",
22 + status: "ready",
23 + auth: { status: "authenticated" },
24 + checkedAt: "2026-04-10T00:00:00.000Z",
25 + models: [],
26 +};
27 +
28 describe("ServerProvider", () => {
29 it("defaults capability arrays when decoding provider snapshots", () => {
30 const parsed = decodeServerProvider({
@@ -119,4 +137,21 @@ describe("server config forward compatibility", () => {
137
138 expect(parsed).toEqual(["zed", "vscode"]);
139 });
140 +
141 + // A provider status this build has never seen (a new ServerProviderState,
142 + // ServerProviderAuthStatus, etc. member) previously failed the whole
143 + // `providers` array, taking every other provider down with it and, since
144 + // `providers` sits inside `ServerConfig`, failing the whole config decode —
145 + // an older client would drop its connection over one provider it can't
146 + // render. Dropping just that element keeps every other provider working.
147 + it("drops providers this build cannot decode instead of failing the whole array", () => {
148 + const decodedBase = decodeServerProvider(baseProviderSnapshot);
149 +
150 + const parsed = decodeServerProviders([
151 + baseProviderSnapshot,
152 + { ...baseProviderSnapshot, instanceId: "future", status: "some-future-status" },
153 + ]);
154 +
155 + expect(parsed).toEqual([decodedBase]);
156 + });
157 });
packages/contracts/src/server.ts
+5 -1
@@ -197,7 +197,11 @@ export const ServerProvider = Schema.Struct({
197 });
198 export type ServerProvider = typeof ServerProvider.Type;
199
200 -export const ServerProviders = Schema.Array(ServerProvider);
200 +// Provider status kinds grow over time (ServerProviderState,
201 +// ServerProviderAuthStatus, ServerProviderVersionAdvisoryStatus,
202 +// ServerProviderUpdateStatus); an older client must not fail the whole config
203 +// decode over one provider it cannot render.
204 +export const ServerProviders = ForwardCompatibleArray(ServerProvider);
205 export type ServerProviders = typeof ServerProviders.Type;
206
207 /**