Skip to content

Commit a636c3d

Browse files
fix(admin): address review findings on recent impersonations
1 parent 39a46b9 commit a636c3d

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

apps/sim/app/workspace/[workspaceId]/settings/components/admin/use-recent-impersonations.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { useCallback, useState } from 'react'
2-
3-
/** Survives clearUserData via the keysToKeep allowlist in @/stores. */
4-
export const RECENT_IMPERSONATIONS_STORAGE_KEY = 'recent-impersonations'
2+
import { RECENT_IMPERSONATIONS_STORAGE_KEY } from '@/stores'
53

64
const MAX_RECENT = 5
75

@@ -24,7 +22,11 @@ export function useRecentImpersonations() {
2422

2523
const recordImpersonation = useCallback((email: string) => {
2624
const next = [email, ...readRecentEmails().filter((e) => e !== email)].slice(0, MAX_RECENT)
27-
localStorage.setItem(RECENT_IMPERSONATIONS_STORAGE_KEY, JSON.stringify(next))
25+
try {
26+
localStorage.setItem(RECENT_IMPERSONATIONS_STORAGE_KEY, JSON.stringify(next))
27+
} catch {
28+
/* best-effort: recording must never block the impersonation transition */
29+
}
2830
setRecentEmails(next)
2931
}, [])
3032

apps/sim/hooks/queries/admin-users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async function fetchAdminUsersByEmails(
9191
const { data, error } = await client.admin.listUsers(
9292
{
9393
query: {
94-
limit: 5,
94+
limit: 20,
9595
searchField: 'email',
9696
searchValue: email,
9797
searchOperator: 'contains',

apps/sim/stores/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { createLogger } from '@sim/logger'
44
import { getQueryClient } from '@/app/_shell/providers/get-query-client'
5-
import { RECENT_IMPERSONATIONS_STORAGE_KEY } from '@/app/workspace/[workspaceId]/settings/components/admin/use-recent-impersonations'
65
import { environmentKeys } from '@/hooks/queries/environment'
76
import { useExecutionStore } from '@/stores/execution'
87
import { useMothershipDraftsStore } from '@/stores/mothership-drafts/store'
@@ -13,6 +12,9 @@ import { useWorkflowStore } from '@/stores/workflows/workflow/store'
1312

1413
const logger = createLogger('Stores')
1514

15+
/** localStorage key for the admin recent-impersonations list; kept through clearUserData. */
16+
export const RECENT_IMPERSONATIONS_STORAGE_KEY = 'recent-impersonations'
17+
1618
/**
1719
* Reset all Zustand stores and React Query caches to initial state.
1820
*/

0 commit comments

Comments
 (0)