// Shared handler for logged-in action failures (like / follow / reply). If the write fails // because the signed-in session predates a scope we added, offer to sign out and back in // (which re-grants the scope). Otherwise show the raw error. export async function handleActionError(err: unknown, action: string): Promise { const msg = String((err as any)?.message ?? err); if (/scope/i.test(msg)) { const relogin = window.confirm( `${action} needs a permission that was added after you signed in. ` + `Sign out and sign back in to enable it?`, ); if (relogin) { const w = window as any; try { await w.atnClient?.revoke(w.atn?.session?.sub); } catch { /* revoke best-effort */ } localStorage.removeItem('atn-label'); location.href = '/login'; } return; } window.alert(`${action} failed: ${msg}`); }