Skip to content

feat(ai-assistant): make the AI-disabled error link to AI Settings#295

Merged
epeicher merged 1 commit into
trunkfrom
feat/ai-error-settings-link
Jun 4, 2026
Merged

feat(ai-assistant): make the AI-disabled error link to AI Settings#295
epeicher merged 1 commit into
trunkfrom
feat/ai-error-settings-link

Conversation

@epeicher
Copy link
Copy Markdown
Collaborator

@epeicher epeicher commented Jun 4, 2026

What & why

When AI features aren't enabled, the AI Assistant showed a plain red sentence — "AI features are not enabled. Enable them in OS Settings → AI Settings." — with nothing to click. This makes the "OS Settings → AI Settings" phrase an inline link that opens OS Settings directly on the AI tab, so the error is recoverable in one click.

CleanShot 2026-06-04 at 18 17 24@2x

Changes

AI Assistant (src/ai-assistant/impl.ts)

  • On the desktop_mode_ai_disabled error, linkify the "OS Settings → AI Settings" phrase. Keyed on the server error code, not the wording, so copy/translation tweaks don't break the affordance; falls back to a trailing link if the phrase is absent.
  • New _openAiSettings() closes the assistant and deep-links to the AI tab.
  • Threaded the error code through the error paths that carry it (fetch 403 body + SSE error event).

openOsSettings({ tabId }) (src/desktop.ts, src/settings/index.ts, src/api/facade.ts)

  • openOsSettings now accepts an optional { tabId }. The tab is set before the window opens (fresh mount lands on it); new OsSettings.focusTab() live-switches the <wpd-tabs> value when the window is already open.
  • Backwards-compatible, additive widening of the public type. Also makes the previously dead tab-targeting callers work (item-visibility-menu already passed { tabId: 'apps-icons' }); fixed plugins-window which passed a bare string.

Styling (assets/css/ai-assistant.css, assets/css/desktop.css)

  • Style the phrase as an inline text link (bold + underline, inherits the error color).
  • Add a scoped pointer-cursor exception to the shell's deliberate cursor: default !important no-pointer policy, so a genuine link reads as clickable. Scoped under body.desktop-mode-active to out-specify the policy (same trick the resize-handle exceptions use), and cross-referenced in the policy comment so the documented exception list stays accurate.

Caching (includes/assets.php)

  • filemtime-stamp ai-assistant.css (was on the static plugin version) so this fast-iterating surface busts cache without a version bump — same pattern windows.css/chromeless.css already use.

Docs

  • Documented openOsSettings({ tabId }) in javascript-reference.md and dock-customization.md.

Test plan

  1. As a user with AI features disabled, open the AI Assistant and submit any query.
  2. The error now renders "…Enable them in OS Settings → AI Settings." with the phrase as an underlined link (pointer cursor on hover).
  3. Clicking it closes the assistant and opens OS Settings on the AI tab.
  4. Bonus, now working: right-click a dock/desktop tile → Apps & Icons settings… lands on the Apps & Icons tab; the Plugins window "configure features" entry lands on the Features tab.

Gates: typecheck, lint, test:js (1519 tests) green; full build clean.

Note

The opt-in SSE transport returns a bare 403 before streaming on this gate, so that (non-default) path still shows the generic "Lost connection" message rather than the link. Left out of scope; happy to make the SSE handler emit the disabled error too if wanted.

Open WordPress Playground Preview

When AI features aren't enabled, the assistant showed a plain red
sentence ("Enable them in OS Settings → AI Settings.") with no way to
act on it. Turn the "OS Settings → AI Settings" phrase into an inline
link that opens OS Settings directly on the AI tab.

- impl.ts: on the `desktop_mode_ai_disabled` error, linkify the phrase
  (keyed on the server error code, not wording, so copy/translation
  tweaks don't break it; falls back to a trailing link if absent).
  `_openAiSettings()` closes the assistant and deep-links to the tab.
- openOsSettings now accepts `{ tabId }`: desktop.ts sets the tab before
  opening (fresh mount) and calls the new `OsSettings.focusTab()` after
  (live-switches an already-open window via the `<wpd-tabs>` value).
  Widened the public type in facade.ts. This also makes the previously
  dead tab-targeting callers work; fixed plugins-window passing a bare
  string instead of `{ tabId }`.
- ai-assistant.css: style the phrase as an inline text link, and add a
  scoped pointer-cursor exception to the shell's no-pointer policy so it
  reads as a link. Noted the exception in desktop.css's policy comment.
- assets.php: filemtime-stamp ai-assistant.css so this surface can
  iterate without a plugin version bump (same pattern as windows.css).
- docs: document `openOsSettings({ tabId })`.
@epeicher epeicher merged commit c798e10 into trunk Jun 4, 2026
5 checks passed
@epeicher epeicher deleted the feat/ai-error-settings-link branch June 4, 2026 16:22
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.

1 participant