Skip to content

Commit 90e7b10

Browse files
fix(server): compare device host configurations through their schema
1 parent 653fa9c commit 90e7b10

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎apps/server/src/device/DeviceService.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
type DeviceShutdownInput,
3232
type DeviceSummary,
3333
type SshDeviceHostConfig,
34+
SshDeviceHostConfigs,
3435
type DeviceHostSummary,
3536
LOCAL_DEVICE_HOST_ID,
3637
type ThreadId,
@@ -918,11 +919,11 @@ export const make = Effect.gen(function* () {
918919
const hostContext =
919920
yield* Effect.context<Effect.Services<ReturnType<typeof SshDeviceHost.make>>>();
920921
const configured = new Map<string, { config: SshDeviceHostConfig; scope: Scope.Closeable }>();
921-
let lastHostsConfig: string | undefined;
922+
const hostsEqual = Schema.toEquivalence(SshDeviceHostConfigs);
923+
let lastHostsConfig: ReadonlyArray<SshDeviceHostConfig> | undefined;
922924
const reconcile = (configuredHosts: ReadonlyArray<SshDeviceHostConfig>) =>
923925
Effect.gen(function* () {
924-
const hostsConfig = JSON.stringify(configuredHosts);
925-
if (hostsConfig === lastHostsConfig) return;
926+
if (lastHostsConfig && hostsEqual(configuredHosts, lastHostsConfig)) return;
926927
const next = yield* remoteSshDeviceHosts(configuredHosts).pipe(
927928
Effect.provide(localTargetContext),
928929
);
@@ -991,7 +992,7 @@ export const make = Effect.gen(function* () {
991992
yield* service.refreshHosts;
992993
}),
993994
);
994-
lastHostsConfig = hostsConfig;
995+
lastHostsConfig = configuredHosts;
995996
});
996997
const changes = yield* settings.subscribeChanges;
997998
yield* reconcile((yield* settings.getSettings).deviceHosts);

0 commit comments

Comments
 (0)