feat: add OpenAI connection status indicator#175
Open
HardeepAsrani wants to merge 1 commit into
Open
Conversation
Surface whether the saved OpenAI API key is connected, mirroring the License field's status feedback. Previously saving a key gave no visual confirmation that it was valid and working. - Add Main::is_api_key_connected(), exposed as `isApiKeyConnected` in the dashboard options data. A key counts as connected when it is set and the last stored OpenAI error is not one that invalidates the key itself (transient errors such as rate limiting stay connected). - Show a "Connected" / "Not connected" indicator under the API Key field in Advanced settings, and hide the "Get an API key" link once connected. - Add unit tests for the connection helper. Part of Codeinwp/hyve#208
abaicus
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds visual confirmation that the saved OpenAI API key is connected, mirroring the status feedback the License field already provides. Previously, saving an API key gave no indication of whether it was valid and working.
The key is already validated against OpenAI on save (
update_settingsruns a livemoderate()test and fails the save on a bad key) — this PR surfaces that result as a persistent indicator.Changes
inc/Main.php— newMain::is_api_key_connected()helper, exposed asisApiKeyConnectedinhyve_options_data(so it's available to both Lite and Pro). A key counts as connected when it's set and the last stored OpenAI error isn't one that invalidates the key itself. Transient errors (e.g.rate_limit_exceeded) stay connected.src/backend/parts/settings/Advanced.js— a "Connected" / "Not connected" indicator under the API Key field, with a small status state machine (server flag on load →connectedon successful save,erroron failed save, cleared while editing). The "Get an API key ↗" link is hidden once connected.tests/php/unit/tests/test-api-key-connected.php— unit tests for the helper (empty / connected / key-invalidating error / transient error / error without code).Test plan
Pro counterpart
The Pro indicator (next to the License "Valid" badge in Pro's Advanced screen) consumes the
isApiKeyConnectedfield added here:Part of Codeinwp/hyve#208