Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(registry): make publish-scope refresh authoritative

Josuéa1aab0e1e0aa
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index f52b8d497..e274676d8 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.398",
+ "version": "0.1.399",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.398",
+ "version": "0.1.399",
"dependencies": {
"@clerum/image-policy": "file:../packages/image-policy",
"@clerum/llm-providers": "file:../packages/llm-providers",
diff --git a/control-api/package.json b/control-api/package.json
index a85e64e68..342e9df2e 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.398",
+ "version": "0.1.399",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/src/services/registryClient.ts b/control-api/src/services/registryClient.ts
index 1616741f1..7f34673e5 100644
--- a/control-api/src/services/registryClient.ts
+++ b/control-api/src/services/registryClient.ts
@@ -7,6 +7,9 @@
import { config } from '../config.js'
import { rootLogger } from '../observability/logger.js'
import { resolveMachineCreds } from './registryConnectionDb.js'
+import { getRegistryIdentityCacheGeneration } from './registryIdentityCache.js'
+
+export { invalidateRegistryIdentityCaches } from './registryIdentityCache.js'
const API_BASE = `${config.registryUrl}/api/v1`
@@ -38,7 +41,7 @@ function isTransientFetchError(err: unknown): boolean {
// process. Refreshed ~30s before expiry so we never hit 401 from expiry in
// the steady state. On a real 401 (e.g. registry key rotation), authedFetch
// evicts the cache and retries once.
-let cached: { token: string; expiresAt: number } | null = null
+let cached: { token: string; expiresAt: number; generation: number } | null = null
// ── Catalog cache (declared here so __resetTokenCacheForTests can clear it;
// populated/consumed by withReadThroughCache below). ─────────────────────────
@@ -73,7 +76,9 @@ export function __resetTokenCacheForTests(): void {
export async function mintToken(envOverride?: NodeJS.ProcessEnv): Promise<string> {
const env = envOverride ?? process.env
const now = Date.now()
- if (cached && now < cached.expiresAt - 30_000) return cached.token
+ const cacheGeneration = getRegistryIdentityCacheGeneration()
+ if (cached && cached.generation === cacheGeneration && now < cached.expiresAt - 30_000)
+ return cached.token
// An explicit override is a test-only path and remains fully env-driven. In
// production, credentials MUST come from the mode-aware resolver: managed
@@ -134,8 +139,13 @@ export async function mintToken(envOverride?: NodeJS.ProcessEnv): Promise<string
throw new Error(`registry credential rejected: ${res.status} ${body}`)
}
const json = (await res.json()) as { access_token: string; expires_in: number }
- cached = { token: json.access_token, expiresAt: now + json.expires_in * 1000 }
- return cached.token
+ const next = {
+ token: json.access_token,
+ expiresAt: now + json.expires_in * 1000,
+ generation: cacheGeneration,
+ }
+ if (getRegistryIdentityCacheGeneration() === cacheGeneration) cached = next
+ return next.token
}
interface RegistrySearchParams {
@@ -626,9 +636,10 @@ export async function listOrgEntries(
}
// ── Publish scope (who is this control-api, and where do its publishes land) ──
-// Resolved once from the registry's /whoami (the registry maps our machine
-// OAuth client to its bound org / curator status). control-api is one-per-deploy
-// so this is static for the process lifetime — hence the module-level cache.
+// Resolved from the registry's /whoami (the registry maps our machine OAuth
+// client to its bound org / curator status). The module-level cache is scoped to
+// the current registry identity generation and is invalidated when the local
+// registry connection row or credentials change.
export interface PublishScope {
curator: boolean
@@ -636,7 +647,7 @@ export interface PublishScope {
scope: string | null
}
-let _scopeCache: PublishScope | null = null
+let _scopeCache: { generation: number; scope: PublishScope } | null = null
export async function whoami(): Promise<{
clientId?: string
@@ -648,9 +659,11 @@ export async function whoami(): Promise<{
}
export async function resolvePublishScope(opts?: { force?: boolean }): Promise<PublishScope> {
- if (_scopeCache && !opts?.force) return _scopeCache
+ const cacheGeneration = getRegistryIdentityCacheGeneration()
+ if (_scopeCache && _scopeCache.generation === cacheGeneration && !opts?.force)
+ return _scopeCache.scope
const w = await whoami()
- _scopeCache = {
+ const scope = {
curator: w.curator,
orgName: w.orgName,
// Curator publishes stay unscoped (the registry maps them to @clerum).
@@ -658,7 +671,10 @@ export async function resolvePublishScope(opts?: { force?: boolean }): Promise<P
// (scope_required), so we derive the @<org> prefix here.
scope: w.curator || !w.orgName ? null : `@${w.orgName}`,
}
- return _scopeCache
+ if (getRegistryIdentityCacheGeneration() === cacheGeneration) {
+ _scopeCache = { generation: cacheGeneration, scope }
+ }
+ return scope
}
export function __resetScopeCacheForTests(): void {
diff --git a/control-api/src/services/registryConnectionDb.ts b/control-api/src/services/registryConnectionDb.ts
index 11455dfe4..abe0bc9ed 100644
--- a/control-api/src/services/registryConnectionDb.ts
+++ b/control-api/src/services/registryConnectionDb.ts
@@ -6,6 +6,7 @@ import {
deriveOAuthEncryptionKey,
encryptOAuthSecret,
} from '../oauth/encryption.js'
+import { invalidateRegistryIdentityCaches } from './registryIdentityCache.js'
/**
* Thrown when no voucher signing key/kid is resolvable (route maps to 500
@@ -147,6 +148,7 @@ export async function upsertPendingConnection(
if (db) await run(db)
else await withTransaction(run)
cached = undefined
+ invalidateRegistryIdentityCaches()
}
export async function markConnected(
@@ -167,12 +169,15 @@ export async function markConnected(
[input.clientId, encSecret, input.orgName, input.deploymentId]
)
cached = undefined
- return (res.rowCount ?? 0) > 0
+ const wrote = (res.rowCount ?? 0) > 0
+ if (wrote) invalidateRegistryIdentityCaches()
+ return wrote
}
export async function deleteConnection(db: DbClient = pool): Promise<void> {
await db.query(`DELETE FROM registry_connection`)
cached = undefined
+ invalidateRegistryIdentityCaches()
}
/** Mode-aware voucher signing material (spec §14.2). */
diff --git a/control-api/src/services/registryIdentityCache.ts b/control-api/src/services/registryIdentityCache.ts
new file mode 100644
index 000000000..2da1e6dcd
--- /dev/null
+++ b/control-api/src/services/registryIdentityCache.ts
@@ -0,0 +1,13 @@
+let registryIdentityCacheGeneration = 0
+
+export function invalidateRegistryIdentityCaches(): void {
+ registryIdentityCacheGeneration += 1
+}
+
+export function getRegistryIdentityCacheGeneration(): number {
+ return registryIdentityCacheGeneration
+}
+
+export function __resetRegistryIdentityCacheGenerationForTests(): void {
+ registryIdentityCacheGeneration = 0
+}
diff --git a/control-api/test/registryClient.test.ts b/control-api/test/registryClient.test.ts
index 79cf2164a..5b711418a 100644
--- a/control-api/test/registryClient.test.ts
+++ b/control-api/test/registryClient.test.ts
@@ -5,11 +5,13 @@ import {
__resetTokenCacheForTests,
applyPublishScope,
getCategories,
+ invalidateRegistryIdentityCaches,
mintToken,
publishEntry,
resolvePublishScope,
searchEntries,
} from '../src/services/registryClient.js'
+import { __resetRegistryIdentityCacheGenerationForTests } from '../src/services/registryIdentityCache.js'
// mintToken() with NO envOverride resolves both the active decision and the
// credential pair through this mode-aware dependency. Most tests in this file
@@ -37,8 +39,27 @@ const ENV_OVERRIDE: NodeJS.ProcessEnv = {
CLERUM_REGISTRY_AUTH_ENABLED: 'true',
}
+function deferred<T>() {
+ let resolve!: (value: T) => void
+ let reject!: (reason?: unknown) => void
+ const promise = new Promise<T>((resolvePromise, rejectPromise) => {
+ resolve = resolvePromise
+ reject = rejectPromise
+ })
+ return { promise, reject, resolve }
+}
+
+async function waitUntil(predicate: () => boolean, message: string): Promise<void> {
+ for (let attempt = 0; attempt < 20; attempt += 1) {
+ if (predicate()) return
+ await new Promise(resolve => setImmediate(resolve))
+ }
+ throw new Error(message)
+}
+
beforeEach(() => {
process.env = { ...ORIGINAL_ENV }
+ __resetRegistryIdentityCacheGenerationForTests()
__resetTokenCacheForTests()
__resetScopeCacheForTests()
connDb.resolveMachineCreds.mockReset().mockImplementation(async () => {
@@ -548,6 +569,152 @@ describe('registryClient — resolvePublishScope', () => {
expect(second).toEqual(first)
expect(fetchMock.mock.calls.length).toBe(callsAfterFirst)
})
+
+ it('invalidates cached token and publish scope when registry identity changes', async () => {
+ let tokenCalls = 0
+ let whoamiCalls = 0
+ const fetchMock = vi.fn().mockImplementation((url: string, init?: RequestInit) => {
+ if (url.endsWith('/oauth/token')) {
+ tokenCalls += 1
+ return Promise.resolve(fakeTokenResponse(tokenCalls === 1 ? 'tok-alpha' : 'tok-bravo'))
+ }
+ whoamiCalls += 1
+ const headers = init?.headers as Record<string, string> | undefined
+ const orgName = headers?.Authorization === 'Bearer tok-alpha' ? 'alpha' : 'bravo'
+ return Promise.resolve(
+ new Response(JSON.stringify({ clientId: orgName, orgName, curator: false }), {
+ status: 200,
+ headers: { 'content-type': 'application/json' },
+ })
+ )
+ })
+ vi.stubGlobal('fetch', fetchMock)
+ Object.assign(process.env, ENV_OVERRIDE)
+
+ await expect(resolvePublishScope()).resolves.toEqual({
+ curator: false,
+ orgName: 'alpha',
+ scope: '@alpha',
+ })
+
+ invalidateRegistryIdentityCaches()
+
+ await expect(resolvePublishScope()).resolves.toEqual({
+ curator: false,
+ orgName: 'bravo',
+ scope: '@bravo',
+ })
+ expect(tokenCalls).toBe(2)
+ expect(whoamiCalls).toBe(2)
+ })
+
+ it('does not reuse a connected scope after disconnect invalidation', async () => {
+ let tokenCalls = 0
+ const fetchMock = vi.fn().mockImplementation((url: string, init?: RequestInit) => {
+ if (url.endsWith('/oauth/token')) {
+ tokenCalls += 1
+ return Promise.resolve(fakeTokenResponse(tokenCalls === 1 ? 'tok-connected' : 'tok-open'))
+ }
+ const headers = init?.headers as Record<string, string> | undefined
+ const connected = headers?.Authorization === 'Bearer tok-connected'
+ return Promise.resolve(
+ new Response(
+ JSON.stringify({
+ clientId: connected ? 'acme' : 'unbound',
+ orgName: connected ? 'acme' : null,
+ curator: false,
+ }),
+ {
+ status: 200,
+ headers: { 'content-type': 'application/json' },
+ }
+ )
+ )
+ })
+ vi.stubGlobal('fetch', fetchMock)
+ Object.assign(process.env, ENV_OVERRIDE)
+
+ expect(await resolvePublishScope()).toEqual({
+ curator: false,
+ orgName: 'acme',
+ scope: '@acme',
+ })
+
+ invalidateRegistryIdentityCaches()
+
+ expect(await resolvePublishScope()).toEqual({
+ curator: false,
+ orgName: null,
+ scope: null,
+ })
+ })
+
+ it('prevents an older pending publish-scope request from overwriting a newer identity', async () => {
+ const staleWhoami = deferred<Response>()
+ let tokenCalls = 0
+ let whoamiCalls = 0
+ const fetchMock = vi.fn().mockImplementation((url: string, init?: RequestInit) => {
+ if (url.endsWith('/oauth/token')) {
+ tokenCalls += 1
+ return Promise.resolve(fakeTokenResponse(tokenCalls === 1 ? 'tok-alpha' : 'tok-bravo'))
+ }
+ whoamiCalls += 1
+ const headers = init?.headers as Record<string, string> | undefined
+ if (headers?.Authorization === 'Bearer tok-alpha') return staleWhoami.promise
+ return Promise.resolve(
+ new Response(JSON.stringify({ clientId: 'bravo', orgName: 'bravo', curator: false }), {
+ status: 200,
+ headers: { 'content-type': 'application/json' },
+ })
+ )
+ })
+ vi.stubGlobal('fetch', fetchMock)
+ Object.assign(process.env, ENV_OVERRIDE)
+
+ const staleRequest = resolvePublishScope()
+ await waitUntil(() => whoamiCalls === 1, 'stale whoami request did not start')
+
+ invalidateRegistryIdentityCaches()
+
+ const freshScope = await resolvePublishScope()
+ expect(freshScope).toEqual({ curator: false, orgName: 'bravo', scope: '@bravo' })
+
+ staleWhoami.resolve(
+ new Response(JSON.stringify({ clientId: 'alpha', orgName: 'alpha', curator: false }), {
+ status: 200,
+ headers: { 'content-type': 'application/json' },
+ })
+ )
+ expect(await staleRequest).toEqual({ curator: false, orgName: 'alpha', scope: '@alpha' })
+
+ expect(await resolvePublishScope()).toEqual(freshScope)
+ expect(tokenCalls).toBe(2)
+ expect(whoamiCalls).toBe(2)
+ })
+
+ it('prevents an older pending token mint from overwriting a newer token', async () => {
+ const staleToken = deferred<Response>()
+ let tokenCalls = 0
+ const fetchMock = vi.fn().mockImplementation((url: string) => {
+ if (!url.endsWith('/oauth/token')) throw new Error(`unexpected fetch: ${url}`)
+ tokenCalls += 1
+ if (tokenCalls === 1) return staleToken.promise
+ return Promise.resolve(fakeTokenResponse('tok-bravo', 600))
+ })
+ vi.stubGlobal('fetch', fetchMock)
+
+ const staleRequest = mintToken(ENV_OVERRIDE)
+ await waitUntil(() => tokenCalls === 1, 'stale token request did not start')
+
+ invalidateRegistryIdentityCaches()
+
+ await expect(mintToken(ENV_OVERRIDE)).resolves.toBe('tok-bravo')
+ staleToken.resolve(fakeTokenResponse('tok-alpha', 600))
+ await expect(staleRequest).resolves.toBe('tok-alpha')
+
+ await expect(mintToken(ENV_OVERRIDE)).resolves.toBe('tok-bravo')
+ expect(tokenCalls).toBe(2)
+ })
})
describe('registryClient — applyPublishScope', () => {
diff --git a/control-api/test/services.registryConnectionDb.test.ts b/control-api/test/services.registryConnectionDb.test.ts
index 57f49ac84..d2f9874c5 100644
--- a/control-api/test/services.registryConnectionDb.test.ts
+++ b/control-api/test/services.registryConnectionDb.test.ts
@@ -20,6 +20,10 @@ import {
// authoritative home). Task 4 re-exports it from registryVoucher.js and flips
// this import to match the production path.
import { VoucherUnavailableError } from '../src/services/registryConnectionDb.js'
+import {
+ __resetRegistryIdentityCacheGenerationForTests,
+ getRegistryIdentityCacheGeneration,
+} from '../src/services/registryIdentityCache.js'
const { cfg } = vi.hoisted(() => ({
cfg: {
@@ -84,6 +88,7 @@ function makeRawRow(encKeyHex: string, overrides: Partial<RawRowShape> = {}): Ra
afterEach(() => {
__resetRegistryConnectionCacheForTests()
+ __resetRegistryIdentityCacheGenerationForTests()
dbQuery.mockReset()
cfg.registryConnectionMode = 'managed'
cfg.registryVoucherPrivateKey = ''
@@ -217,6 +222,7 @@ describe('upsertPendingConnection — writes ciphertext, never plaintext (C-I3a)
expect(decryptOAuthSecret(deriveOAuthEncryptionKey(encKeyHex), storedPriv)).toBe(privateKey)
// The public key is NOT encrypted (it is public material).
expect(params[2]).toBe('PUB-PEM')
+ expect(getRegistryIdentityCacheGeneration()).toBe(1)
})
})
@@ -255,10 +261,12 @@ describe('markConnected — writes ciphertext for the client secret (C-I3a)', ()
describe('deleteConnection', () => {
it('deletes the singleton row and evicts the cache', async () => {
dbQuery.mockResolvedValue({ rows: [], rowCount: 1 })
+ const before = getRegistryIdentityCacheGeneration()
await deleteConnection()
expect(
dbQuery.mock.calls.some(([sql]) => /DELETE FROM registry_connection/.test(String(sql)))
).toBe(true)
+ expect(getRegistryIdentityCacheGeneration()).toBe(before + 1)
})
})
@@ -385,6 +393,7 @@ describe('markConnected — scoped write', () => {
orgName: 'acme',
})
expect(ok).toBe(true)
+ expect(getRegistryIdentityCacheGeneration()).toBe(1)
const upd = dbQuery.mock.calls.find(([sql]) =>
String(sql).includes('UPDATE registry_connection')
)
@@ -408,6 +417,7 @@ describe('markConnected — scoped write', () => {
orgName: 'acme',
})
expect(ok).toBe(false)
+ expect(getRegistryIdentityCacheGeneration()).toBe(0)
})
})
diff --git a/control-ui/components/AuthContext.tsx b/control-ui/components/AuthContext.tsx
index ca1140c83..5b7e633ac 100644
--- a/control-ui/components/AuthContext.tsx
+++ b/control-ui/components/AuthContext.tsx
@@ -56,11 +56,11 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
// this singleton registration tied to them if either provider is remounted.
useEffect(() => {
const handleAuthError = () => {
+ if (sessionExpiredToastShownRef.current) return
+ sessionExpiredToastShownRef.current = true
resetPublishScopeCache()
setAuthState({ id: '', isLoggedIn: false, isLoading: false, username: '', email: '' })
router.replace(buildControlUiLoginPath(getCurrentControlUiPath()))
- if (sessionExpiredToastShownRef.current) return
- sessionExpiredToastShownRef.current = true
showToast('Session expired. Please sign in again.', { tone: 'error' })
}
setGlobalAuthErrorHandler(handleAuthError)
diff --git a/control-ui/components/RegistryConnectPanel.tsx b/control-ui/components/RegistryConnectPanel.tsx
index f259a8dd7..e2da0fa60 100644
--- a/control-ui/components/RegistryConnectPanel.tsx
+++ b/control-ui/components/RegistryConnectPanel.tsx
@@ -2,6 +2,7 @@
import { useCallback, useEffect, useState } from 'react'
import {
+ type RegistryConnectionStatus,
type RegistryRecoveryError,
disconnectRegistryConnection,
getRegistryConnection,
@@ -32,6 +33,45 @@ type View =
| { kind: 'not-self-hosted' }
| { kind: 'error' }
+function viewForRegistryStatus(s: RegistryConnectionStatus): View {
+ if (s.state === 'connected') {
+ return { kind: 'connected', org: s.org, authEnabled: s.authEnabled }
+ }
+ if (s.state === 'connecting') {
+ return {
+ kind: 'connecting',
+ deploymentId: s.deploymentId,
+ requestedOrgName: s.requestedOrgName,
+ authEnabled: s.authEnabled,
+ recoveryError: s.recoveryError,
+ }
+ }
+ if (s.state === 'approved') {
+ return {
+ kind: 'approved',
+ deploymentId: s.deploymentId,
+ requestedOrgName: s.requestedOrgName,
+ }
+ }
+ if (s.state === 'rejected') return { kind: 'rejected', requestedOrgName: s.requestedOrgName }
+ if (s.state === 'pending') {
+ return {
+ kind: 'pending',
+ deploymentId: s.deploymentId,
+ requestedOrgName: s.requestedOrgName,
+ }
+ }
+ if (s.state === 'disconnected') return { kind: 'request' }
+
+ const never: never = s.state
+ void never
+ return { kind: 'error' }
+}
+
+function viewNeedsPublishScopeResync(view: View): boolean {
+ return view.kind === 'connected' || view.kind === 'request'
+}
+
export default function RegistryConnectPanel() {
const { showToast } = useToast()
const { confirm, confirmDialog } = useConfirmDialog()
@@ -54,50 +94,28 @@ export default function RegistryConnectPanel() {
// approved and a human must paste the token they were given out of band —
// A1's claim token only becomes redeemable once the registry poll flips
// pending → approved.
- const load = useCallback(async () => {
+ const load = useCallback(async (): Promise<View | null> => {
try {
const s = await getRegistryConnection()
- if (s.state === 'connected')
- setView({ kind: 'connected', org: s.org, authEnabled: s.authEnabled })
- else if (s.state === 'connecting')
- setView({
- kind: 'connecting',
- deploymentId: s.deploymentId,
- requestedOrgName: s.requestedOrgName,
- authEnabled: s.authEnabled,
- recoveryError: s.recoveryError,
- })
- else if (s.state === 'approved')
- setView({
- kind: 'approved',
- deploymentId: s.deploymentId,
- requestedOrgName: s.requestedOrgName,
- })
- else if (s.state === 'rejected')
- setView({ kind: 'rejected', requestedOrgName: s.requestedOrgName })
- else if (s.state === 'pending')
- setView({
- kind: 'pending',
- deploymentId: s.deploymentId,
- requestedOrgName: s.requestedOrgName,
- })
- else if (s.state === 'disconnected') setView({ kind: 'request' })
- else {
- // Exhaustiveness guard. The old default was `{kind:'request'}`, which
- // renders the registration FORM for any unrecognised state — and
- // re-registering deletes the deployment keypair. A new state must be a
- // compile error here, never a data-loss path.
- const never: never = s.state
- void never
- setView({ kind: 'error' })
- }
+ const nextView = viewForRegistryStatus(s)
+ setView(nextView)
+ return nextView
} catch (e) {
const code = (e as { code?: string }).code
if (code === 'not_self_hosted') setView({ kind: 'not-self-hosted' })
else setView({ kind: 'error' })
+ return null
}
}, [])
+ const loadAfterRegistryStateChange = useCallback(async () => {
+ const nextView = await load()
+ if (nextView && viewNeedsPublishScopeResync(nextView)) {
+ await refreshPublishScope({ force: true })
+ }
+ return nextView
+ }, [load, refreshPublishScope])
+
useEffect(() => {
void load()
}, [load])
@@ -149,8 +167,8 @@ export default function RegistryConnectPanel() {
}
} catch (e) {
const code = (e as { code?: string }).code
- if (code === 'already_connected') await load()
- else if (code === 'recovery_in_progress') await load()
+ if (code === 'already_connected') await loadAfterRegistryStateChange()
+ else if (code === 'recovery_in_progress') await loadAfterRegistryStateChange()
else if (code === 'org_blocklisted')
setFormError('That organization name is not available. Try a different one.')
else if (code === 'org_name_taken')
@@ -200,7 +218,7 @@ export default function RegistryConnectPanel() {
'This deployment can no longer authenticate: its one-time credentials were issued but never stored. Disconnect, then register again with a different organization name.'
)
else if (code === 'not_pending')
- await load() // server state moved on — re-sync
+ await loadAfterRegistryStateChange() // server state moved on — re-sync
else setFormError('Could not complete the claim. Try again shortly.')
} finally {
setBusy(false)
@@ -220,8 +238,10 @@ export default function RegistryConnectPanel() {
void refreshPublishScope({ force: true })
showToast(`Connected to @${s.org}.`, { tone: 'success' })
} else {
- await load()
- setFormError('Still finishing the connection. Try again in a moment.')
+ const nextView = await loadAfterRegistryStateChange()
+ if (!nextView || !viewNeedsPublishScopeResync(nextView)) {
+ setFormError('Still finishing the connection. Try again in a moment.')
+ }
}
} catch (e) {
const code = (e as { code?: string }).code
@@ -233,7 +253,7 @@ export default function RegistryConnectPanel() {
setFormError('This deployment has been suspended by Evenfire. Contact support.')
else if (code === 'client_unavailable')
setFormError('This deployment can no longer authenticate. Contact support.')
- else if (code === 'not_recoverable') await load()
+ else if (code === 'not_recoverable') await loadAfterRegistryStateChange()
else setFormError('Could not finish connecting. Try again shortly.')
} finally {
setBusy(false)
diff --git a/control-ui/components/__tests__/AuthContext.test.tsx b/control-ui/components/__tests__/AuthContext.test.tsx
index 503236887..02590e586 100644
--- a/control-ui/components/__tests__/AuthContext.test.tsx
+++ b/control-ui/components/__tests__/AuthContext.test.tsx
@@ -21,13 +21,16 @@ function response(status: number, body: unknown = {}) {
} as Response
}
-function ExpireSessionButton() {
+function ExpireSessionButton({ repeated = false }: { repeated?: boolean }) {
useAuth()
return (
<button
type="button"
onClick={() => {
- void apiGet('/api/v1/admin/hosts').catch(() => undefined)
+ const requests = repeated
+ ? [apiGet('/api/v1/admin/hosts'), apiGet('/api/v1/admin/llm-models')]
+ : [apiGet('/api/v1/admin/hosts')]
+ void Promise.allSettled(requests)
}}
>
Expire session
@@ -82,7 +85,7 @@ describe('AuthProvider session expiry handling', () => {
render(
<ToastProvider>
<AuthProvider>
- <ExpireSessionButton />
+ <ExpireSessionButton repeated />
</AuthProvider>
</ToastProvider>
)
@@ -94,6 +97,7 @@ describe('AuthProvider session expiry handling', () => {
expect(screen.getAllByText('Session expired. Please sign in again.')).toHaveLength(1)
})
expect(replaceMock).toHaveBeenCalledWith('/?next=%2Fagents%2Fchatllm%2Fenv%23runtime')
+ expect(replaceMock).toHaveBeenCalledTimes(1)
expect(window.localStorage.getItem('controlUiAdminToken')).toBeNull()
})
@@ -131,6 +135,40 @@ describe('AuthProvider session expiry handling', () => {
)
})
+ it('does not re-arm the session-expired toast after a failed auth check', async () => {
+ window.history.pushState({}, '', '/agents')
+ const fetchMock = vi
+ .fn()
+ .mockResolvedValueOnce(response(200, { me: { id: 'admin', role: 'admin' } }))
+ .mockResolvedValueOnce(response(401, { error: 'expired' }))
+ .mockResolvedValueOnce(response(401, { error: 'expired' }))
+ .mockResolvedValueOnce(response(401, { error: 'expired' }))
+ vi.stubGlobal('fetch', fetchMock)
+
+ render(
+ <ToastProvider>
+ <AuthProvider>
+ <ExpireSessionButton />
+ <CheckAuthButton />
+ </AuthProvider>
+ </ToastProvider>
+ )
+
+ await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(1))
+ fireEvent.click(screen.getByRole('button', { name: /expire session/i }))
+ await waitFor(() =>
+ expect(screen.getAllByText('Session expired. Please sign in again.')).toHaveLength(1)
+ )
+
+ fireEvent.click(screen.getByRole('button', { name: /check auth/i }))
+ await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(3))
+
+ fireEvent.click(screen.getByRole('button', { name: /expire session/i }))
+ await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(4))
+ expect(screen.getAllByText('Session expired. Please sign in again.')).toHaveLength(1)
+ expect(replaceMock).toHaveBeenCalledTimes(1)
+ })
+
it('clears legacy storage without a toast when no cookie session exists on mount', async () => {
window.history.pushState({}, '', '/contexts/context1')
window.localStorage.setItem('controlUiAdminToken', 'expired-token')
diff --git a/control-ui/components/__tests__/RegistryConnectPanel.test.tsx b/control-ui/components/__tests__/RegistryConnectPanel.test.tsx
index 0193edf25..37515eec6 100644
--- a/control-ui/components/__tests__/RegistryConnectPanel.test.tsx
+++ b/control-ui/components/__tests__/RegistryConnectPanel.test.tsx
@@ -50,6 +50,7 @@ describe('RegistryConnectPanel', () => {
vi.mocked(api.getRegistryConnection).mockResolvedValue({ state: 'disconnected' })
render(<RegistryConnectPanel />)
await waitFor(() => expect(screen.getByText('Request registration')).toBeInTheDocument())
+ expect(publishScopeMocks.refresh).not.toHaveBeenCalled()
})
it('shows the not-self-hosted banner on a not_self_hosted code', async () => {
@@ -137,6 +138,7 @@ describe('RegistryConnectPanel', () => {
expect(screen.getByText(/Connected to the Evenfire Registry/)).toBeInTheDocument()
)
expect(publishScopeMocks.refresh).toHaveBeenCalledTimes(1)
+ expect(publishScopeMocks.refresh).toHaveBeenCalledWith({ force: true })
})
it('shows the expired-token message on a claim_expired code', async () => {
@@ -236,6 +238,7 @@ describe('RegistryConnectPanel', () => {
// renders "Connected to @acme." — a bare /@acme/ match would be ambiguous.
expect(await screen.findByText(/Connected to the Evenfire Registry.*@acme/)).toBeInTheDocument()
expect(publishScopeMocks.refresh).toHaveBeenCalledTimes(1)
+ expect(publishScopeMocks.refresh).toHaveBeenCalledWith({ force: true })
// The toast is a SEPARATE mutation from the view: branching the view but
// leaving the toast unconditional tells a connected user to wait for an
// operator who does not exist.
@@ -360,6 +363,7 @@ describe('RegistryConnectPanel', () => {
await userEvent.click(await screen.findByRole('button', { name: /finish connecting/i }))
expect(await screen.findByText(/Connected to the Evenfire Registry.*@acme/)).toBeInTheDocument()
expect(publishScopeMocks.refresh).toHaveBeenCalledTimes(1)
+ expect(publishScopeMocks.refresh).toHaveBeenCalledWith({ force: true })
})
// Renamed from the original "shows a retry message when recovery is not yet
@@ -526,6 +530,7 @@ describe('RegistryConnectPanel', () => {
expect(message).toMatch(/cannot be recovered/i)
await waitFor(() => expect(api.disconnectRegistryConnection).toHaveBeenCalledTimes(1))
expect(publishScopeMocks.refresh).toHaveBeenCalledTimes(1)
+ expect(publishScopeMocks.refresh).toHaveBeenCalledWith({ force: true })
})
it('does not disconnect the connecting view when Start over is cancelled', async () => {
@@ -566,6 +571,124 @@ describe('RegistryConnectPanel', () => {
await userEvent.click(await screen.findByRole('button', { name: /^disconnect$/i }))
await waitFor(() => expect(api.disconnectRegistryConnection).toHaveBeenCalledTimes(1))
expect(publishScopeMocks.refresh).toHaveBeenCalledTimes(1)
+ expect(publishScopeMocks.refresh).toHaveBeenCalledWith({ force: true })
+ expect(screen.getByText('Request registration')).toBeInTheDocument()
+ })
+
+ it('refreshes publish scope after starting over from a rejected request', async () => {
+ vi.mocked(api.getRegistryConnection).mockResolvedValue({
+ state: 'rejected',
+ deploymentId: 'd',
+ requestedOrgName: 'acme',
+ })
+ render(<RegistryConnectPanel />)
+ await userEvent.click(await screen.findByRole('button', { name: /start over/i }))
+ await waitFor(() => expect(api.disconnectRegistryConnection).toHaveBeenCalledTimes(1))
+ expect(publishScopeMocks.refresh).toHaveBeenCalledWith({ force: true })
+ expect(screen.getByText('Request registration')).toBeInTheDocument()
+ })
+
+ it('does not force-refresh publish scope when disconnect fails', async () => {
+ vi.mocked(api.getRegistryConnection).mockResolvedValue({
+ state: 'connected',
+ deploymentId: 'd',
+ org: 'acme',
+ })
+ vi.mocked(api.disconnectRegistryConnection).mockRejectedValue(new Error('nope'))
+ render(<RegistryConnectPanel />)
+ await userEvent.click(await screen.findByRole('button', { name: /^disconnect$/i }))
+ await waitFor(() => expect(api.disconnectRegistryConnection).toHaveBeenCalledTimes(1))
+ expect(publishScopeMocks.refresh).not.toHaveBeenCalled()
+ })
+
+ it('refreshes publish scope after already_connected re-sync returns connected', async () => {
+ const events: string[] = []
+ vi.mocked(api.getRegistryConnection)
+ .mockImplementationOnce(async () => {
+ events.push('initial-load')
+ return { state: 'disconnected' }
+ })
+ .mockImplementationOnce(async () => {
+ events.push('resync-load')
+ return { state: 'connected', deploymentId: 'd', org: 'acme' }
+ })
+ vi.mocked(api.requestRegistryConnection).mockRejectedValue(
+ Object.assign(new Error('x'), { code: 'already_connected' })
+ )
+ publishScopeMocks.refresh.mockImplementationOnce(async options => {
+ events.push(`refresh:${JSON.stringify(options)}`)
+ return null
+ })
+
+ render(<RegistryConnectPanel />)
+ await userEvent.type(await screen.findByLabelText(/organization/i), 'acme')
+ await userEvent.type(screen.getByLabelText(/email/i), '[email protected]')
+ await userEvent.click(screen.getByRole('button', { name: /request registration/i }))
+
+ expect(await screen.findByText(/Connected to the Evenfire Registry.*@acme/)).toBeInTheDocument()
+ expect(events).toEqual(['initial-load', 'resync-load', 'refresh:{"force":true}'])
+ expect(publishScopeMocks.refresh).toHaveBeenCalledWith({ force: true })
+ })
+
+ it('refreshes publish scope after not_pending re-sync returns disconnected', async () => {
+ vi.mocked(api.getRegistryConnection)
+ .mockResolvedValueOnce({
+ state: 'approved',
+ deploymentId: 'd',
+ requestedOrgName: 'acme',
+ })
+ .mockResolvedValueOnce({ state: 'disconnected' })
+ vi.mocked(api.submitRegistryClaim).mockRejectedValue(
+ Object.assign(new Error('x'), { code: 'not_pending' })
+ )
+
+ render(<RegistryConnectPanel />)
+ await userEvent.type(await screen.findByLabelText(/claim token/i), 'tok-1')
+ await userEvent.click(screen.getByRole('button', { name: /complete connection/i }))
+
+ await waitFor(() => expect(api.getRegistryConnection).toHaveBeenCalledTimes(2))
expect(screen.getByText('Request registration')).toBeInTheDocument()
+ expect(publishScopeMocks.refresh).toHaveBeenCalledWith({ force: true })
+ })
+
+ it('does not force-refresh publish scope when already_connected re-sync fails', async () => {
+ vi.mocked(api.getRegistryConnection)
+ .mockResolvedValueOnce({ state: 'disconnected' })
+ .mockRejectedValueOnce(new Error('load failed'))
+ vi.mocked(api.requestRegistryConnection).mockRejectedValue(
+ Object.assign(new Error('x'), { code: 'already_connected' })
+ )
+
+ render(<RegistryConnectPanel />)
+ await userEvent.type(await screen.findByLabelText(/organization/i), 'acme')
+ await userEvent.type(screen.getByLabelText(/email/i), '[email protected]')
+ await userEvent.click(screen.getByRole('button', { name: /request registration/i }))
+
+ await waitFor(() => expect(api.getRegistryConnection).toHaveBeenCalledTimes(2))
+ expect(publishScopeMocks.refresh).not.toHaveBeenCalled()
+ })
+
+ it('refreshes publish scope after not_recoverable re-sync returns connected', async () => {
+ vi.mocked(api.getRegistryConnection)
+ .mockResolvedValueOnce({
+ state: 'connecting',
+ deploymentId: 'dep-1',
+ requestedOrgName: 'acme',
+ })
+ .mockResolvedValueOnce({
+ state: 'connected',
+ deploymentId: 'dep-1',
+ org: 'acme',
+ authEnabled: true,
+ })
+ vi.mocked(api.recoverRegistryConnection).mockRejectedValue(
+ Object.assign(new Error('x'), { code: 'not_recoverable' })
+ )
+
+ render(<RegistryConnectPanel />)
+ await userEvent.click(await screen.findByRole('button', { name: /finish connecting/i }))
+
+ expect(await screen.findByText(/Connected to the Evenfire Registry.*@acme/)).toBeInTheDocument()
+ expect(publishScopeMocks.refresh).toHaveBeenCalledWith({ force: true })
})
})
diff --git a/control-ui/lib/__tests__/loadingStyles.test.ts b/control-ui/lib/__tests__/loadingStyles.test.ts
index 36cf60706..aec6b3dc0 100644
--- a/control-ui/lib/__tests__/loadingStyles.test.ts
+++ b/control-ui/lib/__tests__/loadingStyles.test.ts
@@ -4,27 +4,101 @@ import { resolve } from 'node:path'
const css = readFileSync(resolve(__dirname, '../../app/globals.css'), 'utf8')
+type CssRule = {
+ body: string
+ selectors: string[]
+}
+
function selectorRule(selector: string): string {
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const match = css.match(new RegExp(`(?:^|\\n)${escaped}\\s*\\{([^}]*)\\}`))
return match?.[1] ?? ''
}
+function extractBlocks(cssText: string, atRule: string): string[] {
+ const blocks: string[] = []
+ let cursor = 0
+
+ while (cursor < cssText.length) {
+ const atIndex = cssText.indexOf('@media', cursor)
+ if (atIndex === -1) break
+ const openIndex = cssText.indexOf('{', atIndex)
+ if (openIndex === -1) break
+ const prelude = cssText.slice(atIndex, openIndex)
+ let depth = 0
+ let closeIndex = -1
+ for (let index = openIndex; index < cssText.length; index += 1) {
+ const char = cssText[index]
+ if (char === '{') depth += 1
+ else if (char === '}') {
+ depth -= 1
+ if (depth === 0) {
+ closeIndex = index
+ break
+ }
+ }
+ }
+ if (closeIndex === -1) break
+ if (prelude.includes(atRule)) blocks.push(cssText.slice(openIndex + 1, closeIndex))
+ cursor = closeIndex + 1
+ }
+
+ return blocks
+}
+
+function parseRules(cssText: string): CssRule[] {
+ const rules: CssRule[] = []
+ let cursor = 0
+
+ while (cursor < cssText.length) {
+ const openIndex = cssText.indexOf('{', cursor)
+ if (openIndex === -1) break
+ const selectorText = cssText.slice(cursor, openIndex).trim()
+ let depth = 0
+ let closeIndex = -1
+ for (let index = openIndex; index < cssText.length; index += 1) {
+ const char = cssText[index]
+ if (char === '{') depth += 1
+ else if (char === '}') {
+ depth -= 1
+ if (depth === 0) {
+ closeIndex = index
+ break
+ }
+ }
+ }
+ if (closeIndex === -1) break
+ if (selectorText && !selectorText.startsWith('@')) {
+ rules.push({
+ body: cssText.slice(openIndex + 1, closeIndex),
+ selectors: selectorText.split(',').map(selector => selector.trim()),
+ })
+ }
+ cursor = closeIndex + 1
+ }
+
+ return rules
+}
+
+function expectReducedMotionAnimationDisabled(selector: string) {
+ const reducedMotionCss = extractBlocks(css, '(prefers-reduced-motion: reduce)').join('\n')
+ const rule = parseRules(reducedMotionCss).find(candidate =>
+ candidate.selectors.includes(selector)
+ )
+ expect(rule, `${selector} should be in the reduced-motion media block`).toBeDefined()
+ expect(rule?.body).toMatch(/animation:\s*none/)
+}
+
describe('loading style accessibility', () => {
it('disables skeleton and spinner animations for reduced-motion users', () => {
- expect(css).toMatch(/@media\s*\(prefers-reduced-motion:\s*reduce\)/)
- expect(css).toMatch(
- /@media[\s\S]*prefers-reduced-motion[\s\S]*\.cu-skeleton[\s\S]*animation:\s*none/
- )
- expect(css).toMatch(
- /@media[\s\S]*prefers-reduced-motion[\s\S]*\.cu-spin[\s\S]*animation:\s*none/
- )
- expect(css).toMatch(
- /@media[\s\S]*prefers-reduced-motion[\s\S]*\.cu-btn__spinner[\s\S]*animation:\s*none/
- )
- expect(css).toMatch(
- /@media[\s\S]*prefers-reduced-motion[\s\S]*\.cu-identity-skeleton__line[\s\S]*animation:\s*none/
- )
+ expect(extractBlocks(css, '(prefers-reduced-motion: reduce)')).not.toHaveLength(0)
+ expectReducedMotionAnimationDisabled('.cu-skeleton')
+ expectReducedMotionAnimationDisabled('.cu-spin')
+ expectReducedMotionAnimationDisabled('.cu-btn__spinner')
+ expectReducedMotionAnimationDisabled('.cu-identity-skeleton__tabs')
+ expectReducedMotionAnimationDisabled('.cu-identity-skeleton__header')
+ expectReducedMotionAnimationDisabled('.cu-identity-skeleton__line')
+ expectReducedMotionAnimationDisabled('.cu-identity-skeleton__box')
})
it('keeps the shared skeleton class visibly styled', () => {
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 0833bc7f7..65bbe92aa 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.369",
+ "version": "0.1.370",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.369",
+ "version": "0.1.370",
"dependencies": {
"@clerum/llm-providers": "file:../packages/llm-providers",
"@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",
@@ -2436,7 +2436,6 @@
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
- "dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
diff --git a/control-ui/package.json b/control-ui/package.json
index 17f42bbd4..cf08c12b6 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.369",
+ "version": "0.1.370",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/profile-ui/package-lock.json b/profile-ui/package-lock.json
index 189a943d0..2073f3c55 100644
--- a/profile-ui/package-lock.json
+++ b/profile-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.105",
+ "version": "0.1.106",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-profile-ui",
- "version": "0.1.105",
+ "version": "0.1.106",
"dependencies": {
"next": "16.2.11",
"react": "^18.3.1",
@@ -696,7 +696,6 @@
"integrity": "sha512-z9VXpC7MWrhfWipitjNdgCauoMLRdIILQsAEV+ZesIzBq/oUlxk0m3ApZuMFCXdnS4U7KrI+l3WRUEGQ8K1QKw==",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"@types/prop-types": "*",
"csstype": "^3.2.2"
@@ -895,7 +894,6 @@
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
"license": "MIT",
- "peer": true,
"dependencies": {
"loose-envify": "^1.1.0"
},
@@ -908,7 +906,6 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
"license": "MIT",
- "peer": true,
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "^0.23.2"
diff --git a/profile-ui/package.json b/profile-ui/package.json
index f5c368b96..9c6d3f381 100644
--- a/profile-ui/package.json
+++ b/profile-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-profile-ui",
- "version": "0.1.105",
+ "version": "0.1.106",
"private": true,
"scripts": {
"dev": "next dev",
diff --git a/profile-ui/test/loadingStyles.test.ts b/profile-ui/test/loadingStyles.test.ts
index 8901ebdce..9b57d363e 100644
--- a/profile-ui/test/loadingStyles.test.ts
+++ b/profile-ui/test/loadingStyles.test.ts
@@ -5,26 +5,96 @@ import test from 'node:test'
const css = readFileSync(resolve(process.cwd(), 'app/globals.css'), 'utf8')
+type CssRule = {
+ body: string
+ selectors: string[]
+}
+
function selectorRule(selector: string): string {
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const match = css.match(new RegExp(`(?:^|\\n)${escaped}\\s*\\{([^}]*)\\}`))
return match?.[1] ?? ''
}
-test('profile loading animations are disabled for reduced-motion users', () => {
- assert.match(css, /@media\s*\(prefers-reduced-motion:\s*reduce\)/)
- assert.match(
- css,
- /@media[\s\S]*prefers-reduced-motion[\s\S]*\.profile-skeleton__line[\s\S]*animation:\s*none/
- )
- assert.match(
- css,
- /@media[\s\S]*prefers-reduced-motion[\s\S]*\.cu-skeleton[\s\S]*animation:\s*none/
- )
- assert.match(
- css,
- /@media[\s\S]*prefers-reduced-motion[\s\S]*\.cu-btn__spinner[\s\S]*animation:\s*none/
+function extractBlocks(cssText: string, atRule: string): string[] {
+ const blocks: string[] = []
+ let cursor = 0
+
+ while (cursor < cssText.length) {
+ const atIndex = cssText.indexOf('@media', cursor)
+ if (atIndex === -1) break
+ const openIndex = cssText.indexOf('{', atIndex)
+ if (openIndex === -1) break
+ const prelude = cssText.slice(atIndex, openIndex)
+ let depth = 0
+ let closeIndex = -1
+ for (let index = openIndex; index < cssText.length; index += 1) {
+ const char = cssText[index]
+ if (char === '{') depth += 1
+ else if (char === '}') {
+ depth -= 1
+ if (depth === 0) {
+ closeIndex = index
+ break
+ }
+ }
+ }
+ if (closeIndex === -1) break
+ if (prelude.includes(atRule)) blocks.push(cssText.slice(openIndex + 1, closeIndex))
+ cursor = closeIndex + 1
+ }
+
+ return blocks
+}
+
+function parseRules(cssText: string): CssRule[] {
+ const rules: CssRule[] = []
+ let cursor = 0
+
+ while (cursor < cssText.length) {
+ const openIndex = cssText.indexOf('{', cursor)
+ if (openIndex === -1) break
+ const selectorText = cssText.slice(cursor, openIndex).trim()
+ let depth = 0
+ let closeIndex = -1
+ for (let index = openIndex; index < cssText.length; index += 1) {
+ const char = cssText[index]
+ if (char === '{') depth += 1
+ else if (char === '}') {
+ depth -= 1
+ if (depth === 0) {
+ closeIndex = index
+ break
+ }
+ }
+ }
+ if (closeIndex === -1) break
+ if (selectorText && !selectorText.startsWith('@')) {
+ rules.push({
+ body: cssText.slice(openIndex + 1, closeIndex),
+ selectors: selectorText.split(',').map(selector => selector.trim()),
+ })
+ }
+ cursor = closeIndex + 1
+ }
+
+ return rules
+}
+
+function assertReducedMotionAnimationDisabled(selector: string) {
+ const reducedMotionCss = extractBlocks(css, '(prefers-reduced-motion: reduce)').join('\n')
+ const rule = parseRules(reducedMotionCss).find(candidate =>
+ candidate.selectors.includes(selector)
)
+ assert.ok(rule, `${selector} should be in the reduced-motion media block`)
+ assert.match(rule.body, /animation:\s*none/)
+}
+
+test('profile loading animations are disabled for reduced-motion users', () => {
+ assert.notEqual(extractBlocks(css, '(prefers-reduced-motion: reduce)').length, 0)
+ assertReducedMotionAnimationDisabled('.profile-skeleton__line')
+ assertReducedMotionAnimationDisabled('.cu-skeleton')
+ assertReducedMotionAnimationDisabled('.cu-btn__spinner')
})
test('profile sidebar loading placeholders have visible stable skeleton styling', () => {