Fix: AI Assistant 'Open in desktop' throws config.id TypeError#89
Merged
Conversation
Reproduce: open AI Assistant, ask "open my latest post", click
"Open post in desktop" on the entity result. Throws:
Uncaught TypeError: windowManager.open(): config.id must be a non-empty string.
at WindowManager.open
at AiAssistant._openInLegacyWindow
Cause: `_openInLegacyWindow()` in src/ai-assistant.ts called
`wm.open({ url, title, icon })` without `id`. The WindowManager
strict-checks `config.id` since the boundary-validation work that
landed earlier in `src/window-manager/index.ts:373` — every other
shell call site already passes one (derived via
`wp.desktop.deriveWindowId(url)`), but the AI assistant slipped
through.
Fix: derive the id from the URL via the same shell helper that
the dock and command-palette use. Coalesces with any existing
window pointing at the same admin page (matches "click the dock"
behaviour). Falls back to a URL-slugified synthetic id if the
helper isn't exposed (older shell, contrived test env).
Also tightened the `WindowManagerLite` interface to make `id`
required so any future caller fails at compile time, not at
runtime.
Contributor
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
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.
Reproduce
The console throws:
Cause
_openInLegacyWindow()insrc/ai-assistant.tscalledwm.open({ url, title, icon })withoutid. The WindowManager strict-checksconfig.id(boundary validation insrc/window-manager/index.ts:373) — every other shell call site already passes a derived id viawp.desktop.deriveWindowId(url), but the AI assistant slipped through.Fix
wp.desktop.deriveWindowId(url)helper. Coalesces with any existing window pointing at the same admin page (matches "click the dock" behaviour for that entity).WindowManagerLiteinterface to makeidrequired so future callers fail at compile time, not at runtime.Test plan
npm run linttsc --noEmitnpm run test:js— 768 passed