Skip to content

Commit 37c92a6

Browse files
committed
fix(audit-logs): stop Refresh issuing the read the scope gate exists to prevent
`refetch` ignores `enabled`, so pressing Refresh while the workspace scope was unresolved or its lookup had failed fired the audit query anyway — and its filter carries no workspace in that state, so the request was the organization-wide read the gate exists to prevent. The result was never presented, but it was still asked for. Refresh now repeats the gate: the feed is refetched only while the scope is answerable, and the lookup — the thing that has to succeed for a closed feed to reopen — is retried whenever a scope asked for it.
1 parent 265b7b4 commit 37c92a6

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

apps/sim/ee/audit-logs/components/audit-logs.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,19 @@ export function AuditLogs({ organizationId }: AuditLogsProps) {
406406
refreshTimers.delete(timerId)
407407
}, REFRESH_SPINNER_DURATION_MS)
408408
refreshTimers.add(timerId)
409+
const pending: Promise<unknown>[] = []
409410
/*
410-
The workspace lookup too, but only when a scope asked for it: a failed lookup
411-
closes the feed, so refreshing only the feed would leave the one control on
412-
screen unable to clear the state it is showing. `refetch` ignores `enabled`, so
413-
an unconditional call would fire a request the unscoped feed has no use for and
414-
could fail a refresh that otherwise succeeded.
411+
`refetch` ignores `enabled`, so this has to repeat the gate. While the scope is
412+
unanswerable the feed's filter carries no workspace, and refreshing it would
413+
issue exactly the organization-wide read the gate exists to prevent.
415414
*/
416-
const pending = workspaceScope ? [refetch(), orgWorkspaces.refetch()] : [refetch()]
415+
if (isScopeAnswerable) pending.push(refetch())
416+
/*
417+
The lookup is what has to succeed for a closed feed to reopen, so it is retried
418+
whenever a scope asked for it — and skipped entirely when none did, where it is
419+
a disabled query with nothing to say.
420+
*/
421+
if (workspaceScope) pending.push(orgWorkspaces.refetch())
417422
Promise.all(pending).catch((error: unknown) => {
418423
logger.error('Failed to refresh audit logs', { error })
419424
})

0 commit comments

Comments
 (0)