Skip to content

Commit c696193

Browse files
MarcoDotIOclaude
andcommitted
perf(client): a repeated settings update keeps the same config object
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1433dc8 commit c696193

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎packages/client-runtime/src/state/serverConfigProjection.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ describe("applyServerConfigProjection settingsUpdated", () => {
7676
type: "settingsUpdated",
7777
payload: { settings: decode() },
7878
} as ServerConfigStreamEvent);
79-
expect(Option.getOrThrow(next).config.settings).toBe(settings);
79+
expect(Option.getOrThrow(next).config).toBe(Option.getOrThrow(current).config);
8080
});
8181
});

‎packages/client-runtime/src/state/serverConfigProjection.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,17 @@ export function applyServerConfigProjection(
107107
source: "live",
108108
}));
109109
case "settingsUpdated":
110-
return Option.map(current, (projection) => ({
111-
config: {
112-
...projection.config,
113-
settings: reuseUnchanged(projection.config.settings, event.payload.settings),
114-
},
115-
latestEvent: event,
116-
source: "live",
117-
}));
110+
return Option.map(current, (projection) => {
111+
const settings = reuseUnchanged(projection.config.settings, event.payload.settings);
112+
return {
113+
config:
114+
settings === projection.config.settings
115+
? projection.config
116+
: { ...projection.config, settings },
117+
latestEvent: event,
118+
source: "live",
119+
};
120+
});
118121
case "environmentThemesUpdated":
119122
return Option.map(current, (projection) => ({
120123
config: {

0 commit comments

Comments
 (0)