Skip to content

fix: improve error UX with actionable messages and pre-flight AI check#21

Merged
jjroelofs merged 1 commit into1.xfrom
fix/error-ux-nielsen-heuristics
Apr 7, 2026
Merged

fix: improve error UX with actionable messages and pre-flight AI check#21
jjroelofs merged 1 commit into1.xfrom
fix/error-ux-nielsen-heuristics

Conversation

@jjroelofs
Copy link
Copy Markdown
Contributor

Summary

Applies Nielsen/NNGroup usability heuristics to error handling in the GUI.

  • Error prevention (Heuristic One-Click 'Create Draft from This Idea' Buttons #5): Pre-flight checkHealth() check disables the Generate button and shows a Drupal messenger warning when no AI provider is configured — users no longer have to click, wait, and discover it won't work
  • Actionable error messages (Heuristic FIX drupal lint and check issues #9): All 6 AJAX handlers now use buildUserFriendlyErrorMessage() (previously only 2 of 6 did). Tightened pattern matching, plain-language messages, every error includes a concrete next step
  • Drupal APIs (Heuristic Broken permission in routes #1): Pre-flight warning uses $this->messenger()->addWarning() so it renders through the theme's standard message pipeline

Also fixes phpcbf exit code handling in the auto-fix script (exit 2 = "nothing to fix" is success, not failure).

Test plan

  • Visit /admin/reports/ai/content-strategy with no AI provider configured — warning message appears, Generate button is disabled
  • Configure an AI provider — warning disappears, button is enabled
  • Trigger various error conditions (no provider, bad API key, rate limit) — each shows a specific, actionable message with link
  • Delete a card/idea that was already deleted — shows "Item not found. Refresh the page." instead of raw exception

Closes #20

Apply Nielsen/NNGroup usability heuristics to error handling:

Heuristic #5 — Error Prevention:
- Pre-flight checkHealth() before rendering the Generate button
- Disable button and show Drupal messenger warning when no AI
  provider is configured, preventing the error entirely

Heuristic #9 — Help Users Recognize, Diagnose, and Recover:
- Unify all 6 AJAX error handlers to use buildUserFriendlyErrorMessage()
  (previously only 2 of 6 used it — the rest showed raw exceptions)
- Tighten pattern matching: match specific error strings like
  "no chat provider" instead of broad substrings like "provider"
- Add patterns for CRUD errors ("card not found", "idea not found")
- Plain language: "No AI service connected" not "Chat provider is
  not properly configured"
- Every message includes a concrete next step (link or action)
- Shorter generic fallback that links to error log

Heuristic #1 — Visibility of System Status:
- Use Drupal messenger API for the pre-flight warning so it renders
  through the theme's message pipeline

Also fix phpcbf exit code handling: exit 2 ("nothing to fix") is
success, not failure.

Closes #20
@jjroelofs jjroelofs merged commit be5ef86 into 1.x Apr 7, 2026
3 checks passed
@jjroelofs jjroelofs deleted the fix/error-ux-nielsen-heuristics branch April 7, 2026 09:52
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.

fix: improve error UX with actionable, user-friendly messages across all AJAX handlers

1 participant