Skip to content

ADFA-2709 | Verify API keys before saving and improve onboarding - #59

Open
jatezzz wants to merge 2 commits into
mainfrom
feat/ADFA-2709-gemini-key-onboarding
Open

ADFA-2709 | Verify API keys before saving and improve onboarding#59
jatezzz wants to merge 2 commits into
mainfrom
feat/ADFA-2709-gemini-key-onboarding

Conversation

@jatezzz

@jatezzz jatezzz commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Description

This PR improves the Gemini API key onboarding experience by guiding users to Google AI Studio and validating keys before they are saved to the device. This eliminates the need for users to navigate the complex Google Cloud Console and deal with manual billing/project setup.

  • Guided Acquisition: Added a "Get a free key" button that opens [aistudio.google.com/apikey](https://aistudio.google.com/apikey) directly in the system browser.
  • Live Verification: The save action now tests the key against Google's API using GeminiCatalogGateway. Keys that are rejected by Google are no longer saved.
  • Graceful Degradation: If the key cannot be verified due to network issues or an outdated ai-core plugin, the user is prompted with an option to save the unverified key anyway.
  • Improved Error Handling: Updated GeminiErrorFormatter to cleanly translate failure states into user-friendly localized strings instead of dumping raw JSON payloads into the UI.

Details

  • Added new strings, icons, and layout updates for the Gemini API key settings pane.
  • Introduced GeminiKeyOnboarding, KeyVerification, and CatalogResult to manage the validation logic and state.
  • Updated tooltips and README.md/index.html documentation to reflect the new AI Studio flow.

🎦 Demo on the ticket to protect confidential information

Ticket

ADFA-2709

Observation

The verification step relies on a reflective call (GeminiCatalogGateway) to listModels(apiKey) in the ai-core plugin to maintain the cross-plugin architecture without adding new permissions to the ai-assistant manifest.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

Adds live key validation via ai-core and links to AI Studio for easier setup.
"cross-plugin contract changed. Expected " +
"`fun listModels($signature): CompletableFuture<List<String>>`.",
e
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: prefer context.logger

Comment on lines +75 to +78
android.util.Log.w(
"KeyVerification",
"Unmapped ListModels HTTP $status; treating the key as unchecked, not rejected"
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please clean up logs or use context.logger for better log surfacing

* Anchored on the whole prefix, not a bare `HTTP \d{3}`: Google's error body is appended to that
* message, and a looser pattern could read a verdict on the key out of server-supplied text.
*/
private val HTTP_STATUS = Regex("""ListModels HTTP (\d{3})""")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a better variable name for HTTP_STATUS since it's a failure?

…gger

Replaces android.util.Log in the Gemini catalog gateway and AI settings ViewModel with the plugin's PluginLogger, so diagnostics surface in the IDE log view. Drops the redundant unmapped-status log from KeyVerification (the gateway already reports the cause) and renames the status regex to say it comes from a failure message.
@jatezzz
jatezzz requested a review from Daniel-ADFA August 4, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants