(onDone: LocalJSXCommandOnDone, context: LocalJSXCommandContext)
| 17 | import { checkAndDisableAutoModeIfNeeded, checkAndDisableBypassPermissionsIfNeeded, resetAutoModeGateCheck, resetBypassPermissionsCheck } from '../../utils/permissions/bypassPermissionsKillswitch.js'; |
| 18 | import { resetUserCache } from '../../utils/user.js'; |
| 19 | export async function call(onDone: LocalJSXCommandOnDone, context: LocalJSXCommandContext): Promise<React.ReactNode> { |
| 20 | return <Login onDone={async success => { |
| 21 | context.onChangeAPIKey(); |
| 22 | // Signature-bearing blocks (thinking, connector_text) are bound to the API key — |
| 23 | // strip them so the new key doesn't reject stale signatures. |
| 24 | context.setMessages(stripSignatureBlocks); |
| 25 | if (success) { |
| 26 | // Post-login refresh logic. Keep in sync with onboarding in src/interactiveHelpers.tsx |
| 27 | // Reset cost state when switching accounts |
| 28 | resetCostState(); |
| 29 | // Refresh remotely managed settings after login (non-blocking) |
| 30 | void refreshRemoteManagedSettings(); |
| 31 | // Refresh policy limits after login (non-blocking) |
| 32 | void refreshPolicyLimits(); |
| 33 | // Clear user data cache BEFORE GrowthBook refresh so it picks up fresh credentials |
| 34 | resetUserCache(); |
| 35 | // Refresh GrowthBook after login to get updated feature flags (e.g., for claude.ai MCPs) |
| 36 | refreshGrowthBookAfterAuthChange(); |
| 37 | // Clear any stale trusted device token from a previous account before |
| 38 | // re-enrolling — prevents sending the old token on bridge calls while |
| 39 | // the async enrollTrustedDevice() is in-flight. |
| 40 | clearTrustedDeviceToken(); |
| 41 | // Enroll as a trusted device for Remote Control (10-min fresh-session window) |
| 42 | void enrollTrustedDevice(); |
| 43 | // Reset killswitch gate checks and re-run with new org |
| 44 | resetBypassPermissionsCheck(); |
| 45 | const appState = context.getAppState(); |
| 46 | void checkAndDisableBypassPermissionsIfNeeded(appState.toolPermissionContext, context.setAppState); |
| 47 | if (feature('TRANSCRIPT_CLASSIFIER')) { |
| 48 | resetAutoModeGateCheck(); |
| 49 | void checkAndDisableAutoModeIfNeeded(appState.toolPermissionContext, context.setAppState, appState.fastMode); |
| 50 | } |
| 51 | // Increment authVersion to trigger re-fetching of auth-dependent data in hooks (e.g., MCP servers) |
| 52 | context.setAppState(prev => ({ |
| 53 | ...prev, |
| 54 | authVersion: prev.authVersion + 1 |
| 55 | })); |
| 56 | } |
| 57 | onDone(success ? 'Login successful' : 'Login interrupted'); |
| 58 | }} />; |
| 59 | } |
| 60 | export function Login(props) { |
| 61 | const $ = _c(12); |
| 62 | const mainLoopModel = useMainLoopModel(); |
nothing calls this directly
no test coverage detected