Skip to content

Commit d4afbf4

Browse files
perf(server): skip device host refreshes for unchanged settings
Every settings save re-published the device host list even when no SSH device host changed, which re-queried every host summary and emitted a state update for nothing. Only refresh when a host was actually added or removed. The refresh after new hosts start is kept for removals too, so a status written by an old host while its scope was closing is still cleared instead of lingering as a ghost entry. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent d6044f5 commit d4afbf4

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ export const make = Effect.gen(function* () {
10891089
configured.delete(id);
10901090
removed.push({ id, scope: previous.scope });
10911091
}
1092-
yield* service.refreshHosts;
1092+
if (removed.length > 0) yield* service.refreshHosts;
10931093
return removed;
10941094
}),
10951095
);
@@ -1105,8 +1105,10 @@ export const make = Effect.gen(function* () {
11051105
);
11061106
yield* service.withLifecycleLock(
11071107
Effect.gen(function* () {
1108+
let added = false;
11081109
for (const host of next) {
11091110
if (configured.has(host.id)) continue;
1111+
added = true;
11101112
const hostScope = yield* Scope.fork(scope);
11111113
const instance = yield* SshDeviceHost.make(
11121114
host,
@@ -1130,7 +1132,8 @@ export const make = Effect.gen(function* () {
11301132
hosts.set(host.id, instance);
11311133
configured.set(host.id, { config: host, scope: hostScope });
11321134
}
1133-
yield* service.refreshHosts;
1135+
// Refresh again after removed scopes closed so a late status write from an old host cannot linger.
1136+
if (added || removed.length > 0) yield* service.refreshHosts;
11341137
}),
11351138
);
11361139
});

0 commit comments

Comments
 (0)