Skip to content

Fix: AI Assistant 'Open in desktop' throws config.id TypeError#89

Merged
epeicher merged 2 commits into
trunkfrom
fix/ai-assistant-window-id
May 6, 2026
Merged

Fix: AI Assistant 'Open in desktop' throws config.id TypeError#89
epeicher merged 2 commits into
trunkfrom
fix/ai-assistant-window-id

Conversation

@epeicher
Copy link
Copy Markdown
Collaborator

@epeicher epeicher commented May 6, 2026

Reproduce

  1. Open the AI Assistant (Cmd+K).
  2. Ask "open my latest post".
  3. Click Open post in desktop on the entity result.

The console throws:

Uncaught TypeError: windowManager.open(): config.id must be a non-empty string.
    at WindowManager.open                    (desktop.js:8352:15)
    at AiAssistant._openInLegacyWindow       (desktop.js:23571:10)
    at HTMLButtonElement.<anonymous>         (desktop.js:23874:18)

Cause

_openInLegacyWindow() in src/ai-assistant.ts called wm.open({ url, title, icon }) without id. The WindowManager strict-checks config.id (boundary validation in src/window-manager/index.ts:373) — every other shell call site already passes a derived id via wp.desktop.deriveWindowId(url), but the AI assistant slipped through.

Fix

  • Derive the id from the URL using the existing wp.desktop.deriveWindowId(url) helper. Coalesces with any existing window pointing at the same admin page (matches "click the dock" behaviour for that entity).
  • Fall back to a URL-slugified synthetic id when the helper isn't exposed (older shells / contrived test envs).
  • Tightened the local WindowManagerLite interface to make id required so future callers fail at compile time, not at runtime.

Test plan

  • npm run lint
  • tsc --noEmit
  • npm run test:js — 768 passed
  • Manual: AI Assistant → ask "open my latest post" → click Open post in desktop → window opens, no console error
  • Manual: AI Assistant → ask "take me to plugin settings" → click an admin-link result → window opens
Open WordPress Playground Preview
epeicher added 2 commits May 6, 2026 10:39
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.
@epeicher epeicher enabled auto-merge (squash) May 6, 2026 08:42
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@epeicher epeicher merged commit e0f107c into trunk May 6, 2026
5 checks passed
@epeicher epeicher deleted the fix/ai-assistant-window-id branch May 6, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant