Skip to content

feat: add OpenAI connection status indicator#175

Open
HardeepAsrani wants to merge 1 commit into
developmentfrom
feat/openai-key-connected-indicator
Open

feat: add OpenAI connection status indicator#175
HardeepAsrani wants to merge 1 commit into
developmentfrom
feat/openai-key-connected-indicator

Conversation

@HardeepAsrani

@HardeepAsrani HardeepAsrani commented Jun 29, 2026

Copy link
Copy Markdown
Member

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_settings runs a live moderate() test and fails the save on a bad key) — this PR surfaces that result as a persistent indicator.

Changes

  • inc/Main.php — new Main::is_api_key_connected() helper, exposed as isApiKeyConnected in hyve_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 → connected on successful save, error on 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

  1. Settings → Advanced with no key: no indicator, "Get an API key" link visible.
  2. Enter a valid key, Save → green Connected, "Get an API key" link hidden.
  3. Enter an invalid key, Save → red Not connected + the existing error notice.
  4. Reload with a valid key already saved → shows Connected immediately.

Pro counterpart

The Pro indicator (next to the License "Valid" badge in Pro's Advanced screen) consumes the isApiKeyConnected field added here:

  • Codeinwp/hyve#224

Part of Codeinwp/hyve#208

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
@HardeepAsrani HardeepAsrani requested a review from abaicus June 29, 2026 02:52
@github-actions

Copy link
Copy Markdown

Plugin build for a240205 is ready 🛎️!

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