({
onSelect,
onApiKeySubmit,
settings,
initialErrorMessage,
}: AuthDialogProps)
| 20 | } |
| 21 | |
| 22 | export function AuthDialog({ |
| 23 | onSelect, |
| 24 | onApiKeySubmit, |
| 25 | settings, |
| 26 | initialErrorMessage, |
| 27 | }: AuthDialogProps): React.JSX.Element { |
| 28 | const handleApiKeySubmit = useCallback( |
| 29 | (apiKey: string) => { |
| 30 | onApiKeySubmit(apiKey, SettingScope.User); |
| 31 | }, |
| 32 | [onApiKeySubmit], |
| 33 | ); |
| 34 | |
| 35 | const handleCancel = useCallback(() => { |
| 36 | // Only allow canceling if already authenticated |
| 37 | if (settings.merged.selectedAuthType !== undefined) { |
| 38 | onSelect(undefined, SettingScope.User); |
| 39 | } |
| 40 | }, [onSelect, settings.merged.selectedAuthType]); |
| 41 | |
| 42 | // Check if API key already exists in environment |
| 43 | const existingApiKey = |
| 44 | process.env['GROK_API_KEY'] || settings.merged.grok?.apiKey; |
| 45 | const hasExistingKey = !!existingApiKey; |
| 46 | |
| 47 | // Show info about existing key but still allow input for new key |
| 48 | const infoMessage = hasExistingKey |
| 49 | ? 'Existing OpenRouter API key detected in environment. You can enter a new one below or press Escape to continue with the existing key.' |
| 50 | : null; |
| 51 | |
| 52 | return ( |
| 53 | <Box flexDirection="column"> |
| 54 | <ApiKeyInput |
| 55 | onSubmit={handleApiKeySubmit} |
| 56 | onCancel={handleCancel} |
| 57 | errorMessage={initialErrorMessage} |
| 58 | /> |
| 59 | {infoMessage && ( |
| 60 | <Box marginTop={1} paddingX={1}> |
| 61 | <Text color={Colors.Gray}>{infoMessage}</Text> |
| 62 | </Box> |
| 63 | )} |
| 64 | <Box marginTop={1} paddingX={1}> |
| 65 | <Text>ANUS Terms of Service and Privacy Notice</Text> |
| 66 | </Box> |
| 67 | <Box marginTop={1} paddingX={1}> |
| 68 | <Text color={Colors.AccentBlue}> |
| 69 | https://github.com/anus-dev/anus/docs/tos-privacy.md |
| 70 | </Text> |
| 71 | </Box> |
| 72 | </Box> |
| 73 | ); |
| 74 | } |
nothing calls this directly
no outgoing calls
no test coverage detected