The best way to control Claude Code, Codex and more from any computer or phone
perf(client): a reconnect snapshot keeps unchanged skills and providers identical (#20855)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 17, 2026 at 03:37 UTC
bc5f754baabf62b5488cfb4007d3ab33b6957c03
2 files changed
+31
-6
packages/client-runtime/src/state/serverConfigProjection.test.ts
+23
-1
@@ -1,6 +1,8 @@
1
+import type { ServerConfig, ServerConfigStreamEvent } from "@t3tools/contracts";
2
+import * as Option from "effect/Option";
3
import { describe, expect, it } from "vite-plus/test";
4
3
-import { reuseUnchanged } from "./serverConfigProjection.ts";
5
+import { applyServerConfigProjection, reuseUnchanged } from "./serverConfigProjection.ts";
6
7
describe("reuseUnchanged", () => {
8
const provider = (checkedAt: string, skills: ReadonlyArray<string>) => ({
@@ -38,3 +40,23 @@ describe("reuseUnchanged", () => {
40
expect(dropped).toEqual({ a: 1 });
41
});
42
});
43
+
44
+describe("applyServerConfigProjection snapshot", () => {
45
+ const snapshot = (checkedAt: string) =>
46
+ ({
47
+ type: "snapshot",
48
+ config: {
49
+ environment: { capabilities: {} },
50
+ providers: [{ instanceId: "claude", checkedAt, skills: [{ name: "review" }] }],
51
+ },
52
+ }) as unknown as ServerConfigStreamEvent;
53
+ const providersOf = (projection: ReturnType<typeof applyServerConfigProjection>) =>
54
+ (Option.getOrThrow(projection).config as ServerConfig).providers;
55
+
56
+ it("keeps unchanged skills when a reconnect re-sends the config", () => {
57
+ const first = applyServerConfigProjection(Option.none(), snapshot("a"));
58
+ const second = applyServerConfigProjection(first, snapshot("b"));
59
+ expect(providersOf(second)[0]!.checkedAt).toBe("b");
60
+ expect(providersOf(second)[0]!.skills).toBe(providersOf(first)[0]!.skills);
61
+ });
62
+});
packages/client-runtime/src/state/serverConfigProjection.ts
+8
-5
@@ -24,6 +24,7 @@ export function withoutEnvironmentThemes(config: ServerConfig): ServerConfig {
24
* previous object. A provider status push re-sends every provider even when
25
* only one field (often just `checkedAt`) changed, so this keeps unchanged
26
* providers, models and skills identical and lets memoized UI skip them.
27
+ * A reconnect snapshot re-sends the whole config the same way.
28
*/
29
export function reuseUnchanged<T>(previous: unknown, next: T): T {
30
if (Object.is(previous, next)) return next;
@@ -78,12 +79,14 @@ export function applyServerConfigProjection(
79
capabilities.usageLimitSources === true && Option.isSome(current)
80
? current.value.config.usageLimitSources
81
: undefined;
82
+ const config: ServerConfig = {
83
+ ...event.config,
84
+ ...(carriedThemes === undefined ? {} : { environmentThemes: carriedThemes }),
85
+ ...(carriedSources === undefined ? {} : { usageLimitSources: carriedSources }),
86
+ };
87
return Option.some({
82
- config: {
83
- ...event.config,
84
- ...(carriedThemes === undefined ? {} : { environmentThemes: carriedThemes }),
85
- ...(carriedSources === undefined ? {} : { usageLimitSources: carriedSources }),
86
- },
88
+ // Every reconnect re-sends the whole config, usually unchanged apart from timestamps.
89
+ config: Option.isSome(current) ? reuseUnchanged(current.value.config, config) : config,
90
latestEvent: event,
91
source: "live" as const,
92
});