feat(ai-assistant): make the AI-disabled error link to AI Settings#295
Merged
Conversation
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 })`.
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.
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.
Changes
AI Assistant (
src/ai-assistant/impl.ts)desktop_mode_ai_disablederror, 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._openAiSettings()closes the assistant and deep-links to the AI tab.codethrough the error paths that carry it (fetch 403 body + SSEerrorevent).openOsSettings({ tabId })(src/desktop.ts,src/settings/index.ts,src/api/facade.ts)openOsSettingsnow accepts an optional{ tabId }. The tab is set before the window opens (fresh mount lands on it); newOsSettings.focusTab()live-switches the<wpd-tabs>value when the window is already open.item-visibility-menualready passed{ tabId: 'apps-icons' }); fixedplugins-windowwhich passed a bare string.Styling (
assets/css/ai-assistant.css,assets/css/desktop.css)cursor: default !importantno-pointer policy, so a genuine link reads as clickable. Scoped underbody.desktop-mode-activeto 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-stampai-assistant.css(was on the static plugin version) so this fast-iterating surface busts cache without a version bump — same patternwindows.css/chromeless.cssalready use.Docs
openOsSettings({ tabId })injavascript-reference.mdanddock-customization.md.Test plan
Gates:
typecheck,lint,test:js(1519 tests) green; full build clean.Note
The opt-in SSE transport returns a bare
403before 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.