Skip to content

Commit bbffafd

Browse files
cliffhallclaude
andcommitted
fix: resolve the servers list outside the override's state updater (#2095)
`record` read `serversRef.current` from inside the `setRecords` updater. A functional updater must be pure -- React may defer or replay it -- so the pairing resolved at whatever moment the updater happened to run rather than when the record was written. A list read committing in between would then be paired with the record as its baseline, and the very read that should have superseded the override would instead certify it. Read the list once, at call time, and use it for both the pairing and the prune. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0177mPHAdECD18nLLCTwR5rh Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 8a6bec0 commit bbffafd

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎clients/web/src/hooks/usePaginatedListsOverride.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,13 @@ export function usePaginatedListsOverride(
8282
}, [servers]);
8383

8484
const record = useCallback((serverId: string, value: boolean) => {
85+
// Read outside the updater. A functional updater must be pure — React may
86+
// defer or replay it — and this one would otherwise resolve the ref at
87+
// whatever moment it happened to run. A list read committing in between
88+
// would then be paired with the record as its baseline, so the very read
89+
// that should have superseded the override would instead certify it.
90+
const list = serversRef.current;
8591
setRecords((previous) => {
86-
const list = serversRef.current;
8792
const next = new Map<string, OverrideRecord>();
8893
// Carry forward only the records the list has not moved past, so a
8994
// session that toggles across many servers does not accumulate a record

0 commit comments

Comments
 (0)