94c6b5d5a5
Desktop Client Build / Resolve Build Metadata (push) Successful in 29s
Frontend CI / Frontend (push) Successful in 4m48s
Desktop Client Build / Build Desktop Client (push) Successful in 26m5s
Desktop Client Build / Publish Client Artifacts to NAS (push) Successful in 42s
Business calls (heartbeat, account sync, lease/pull/resume tasks, preempt monitoring lease) used to short-circuit any 401 into handleAuthExpired, which tore down the runtime and switched the window to login. That stole the screen on transient or per-request auth glitches and conflicted with the renderer-side proactive token renewal. Now business 401s fall through to the existing warn/danger activity log paths and runtime keeps running. The login redirect is owned solely by the renderer's renewAuthenticatedSession → on refresh / rotate failure → forceLogoutAfterRenewFailure path. Server-side revocation via error code 40991 is unaffected. Removed the now-orphan plumbing: handleAuthExpired, isApiClientError helper, emitRuntimeAuthExpired / onRuntimeAuthExpired events, and forceLoginWindowForAuthExpired listener registration. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
40 lines
945 B
TypeScript
40 lines
945 B
TypeScript
type RuntimeInvalidationReason = 'account-health' | 'publish-task-lease'
|
|
|
|
type RuntimeInvalidationListener = (event: {
|
|
reason: RuntimeInvalidationReason
|
|
at: number
|
|
accountId?: string
|
|
taskId?: string
|
|
}) => void
|
|
|
|
const listeners = new Set<RuntimeInvalidationListener>()
|
|
|
|
export function emitRuntimeInvalidated(
|
|
reason: RuntimeInvalidationReason,
|
|
details: { accountId?: string; taskId?: string } = {},
|
|
): void {
|
|
const event = {
|
|
reason,
|
|
at: Date.now(),
|
|
...details,
|
|
} as const
|
|
|
|
for (const listener of listeners) {
|
|
try {
|
|
listener(event)
|
|
} catch (error) {
|
|
console.warn('[desktop-runtime] invalidation listener failed', {
|
|
reason,
|
|
message: error instanceof Error ? error.message : String(error),
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
export function onRuntimeInvalidated(listener: RuntimeInvalidationListener): () => void {
|
|
listeners.add(listener)
|
|
return () => {
|
|
listeners.delete(listener)
|
|
}
|
|
}
|