Skip to content

Add error notification banner system#649

Merged
tracygardner merged 1 commit into
mainfrom
claude/determined-goldberg-Y1kTH
May 22, 2026
Merged

Add error notification banner system#649
tracygardner merged 1 commit into
mainfrom
claude/determined-goldberg-Y1kTH

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

@tracygardner tracygardner commented May 22, 2026

Summary

Introduces a centralized error notification banner system to display user-friendly error messages for startup failures, physics crashes, WebGL context loss, and runtime errors. Replaces ad-hoc error handling with a consistent, accessible notification UI.

Key Changes

  • New notification module (ui/notifications.js): Provides a DOM-based banner system with:

    • showBanner() and dismissBanner() for displaying/removing notifications
    • handleError() as a single error funnel that logs details to console and shows friendly translated messages
    • isBenignAbort() to filter out benign abort errors (cancelled fetches, teardown) while preserving genuine physics OOM crashes
    • installGlobalErrorHandlers() to catch unhandled errors and promise rejections globally
  • Styling (style.css): Added .flock-banner and related classes with theme-aware colors across all five themes (light, dark, dark high-contrast, high-contrast, low-vision)

  • Error handling integration:

    • Physics OOM errors now use the banner system instead of inline DOM manipulation
    • WebGL context loss now triggers a fatal error banner with reload action
    • Startup failures (Blockly initialization, Flock initialization) show fatal banners
    • Runtime errors during code execution show non-fatal banners
    • Render loop errors are caught and displayed instead of crashing silently
  • Autosave robustness (main/files.js): Added validation to prevent overwriting good autosaves with empty workspace states, enabling recovery via the Reload action

  • Translations: Added new message keys for all error types and banner actions in English and Spanish locales

  • Tests (tests/notifications.test.js): Comprehensive test suite covering banner creation, deduplication, dismissal, actions, error handling, and benign abort detection

Notable Implementation Details

  • Banners are keyed by error source to deduplicate repeated errors and prevent stacking
  • Uses semantic HTML (role="alert", aria-live="assertive") for accessibility
  • Escape key dismisses banners; focus is managed for keyboard navigation
  • Raw error details never reach users; only translated, friendly messages are shown
  • WebAssembly.RuntimeError with "abort" in message is treated as genuine OOM, not benign
  • CSG2 initialization failure is downgraded to a warning since it only affects boolean mesh blocks

https://claude.ai/code/session_014dfd5yijb6Td1SP93T97Cn

Summary by CodeRabbit

  • New Features

    • Introduced error notification banners for startup failures, physics out-of-memory, WebGL context loss, and project crashes with user-friendly messaging.
    • Added "Reload" and "Dismiss" actions for error recovery.
    • Implemented global error handlers for uncaught errors and unhandled promise rejections.
    • Added error message translations for English and Spanish.
  • Bug Fixes

    • Improved error reporting with dedicated notification UI instead of silent console logging.
  • Style

    • Added theme-specific error banner styling with color variables.
  • Tests

    • Added comprehensive test coverage for notification system.

Review Change Stack

Route runtime error surfaces through one ui/notifications.js module
instead of inconsistent printText overlays and duplicated inline-style
banners. Unrecoverable failures (startup, WebGL context loss, physics
out-of-memory) show a banner with a Reload action; project crashes show
a friendly dismissible banner. Recoverable problems (CSG2, autosave,
storage) log a console warning only. All banner text is translatable
and theme-aware; raw error detail stays in the console.

A crashing project no longer reloads the starter project over the
child's work. Autosave refuses to overwrite a good save with an empty
workspace, so the banner's Reload action restores reliably.

https://claude.ai/code/session_014dfd5yijb6Td1SP93T97Cn
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

📝 Walkthrough

Walkthrough

This PR implements a centralized error and notification system for Flock, replacing scattered console logging and direct DOM manipulation with a unified error handler that displays accessible, themed banners to users while logging enhanced details to the console for developers.

Changes

Centralized Error Notification System

Layer / File(s) Summary
Error notification UI and styling
ui/notifications.js, style.css
Creates the notifications module with showBanner, dismissBanner, and handleError functions. Maintains id-keyed banner state for deduplication, creates accessible alert banners with optional action buttons and keyboard dismissal, and includes isBenignAbort and installGlobalErrorHandlers for global error suppression and routing. CSS adds theme-specific error banner colors and styling for fixed-position notifications with action/close controls and focus management.
Error message localization
locale/en.js, locale/es.js
Adds error message keys (error_startup, error_project_crash, error_webgl_lost, error_physics_oom) and banner action labels (banner_reload, banner_dismiss) in English and Spanish locales to support user-facing error messaging.
Startup and initialization error handling
main/main.js
Installs global error handlers at the start of window.onload. Routes Blockly workspace initialization and flock engine startup failures to handleError with fatal: true, aborting setup on critical errors instead of logging to console.
Runtime engine error handling
flock.js
Updates physics OOM, WebGL context loss, CSG2 init failure, scene startup banner cleanup, and render loop abort paths to call handleError with appropriate source and fatal flags. Removes direct DOM banner creation, console error calls, and fallback starter-project loading behavior.
Execution and file save error handling
main/execution.js, main/files.js
Routes code execution failures to handleError with source: "project-run". Wraps autosave serialization in try/catch, logging warnings on failure instead of throwing, with guards to prevent invalid workspace overwrites.
Notification system test suite
tests/notifications.test.js, tests/tests.html
Adds comprehensive test coverage for banner rendering, deduplication, dismissal, action buttons, fatal vs non-fatal error output, error detail redaction, and isBenignAbort classification including WebAssembly runtime error edge cases. Registers new notifications test suite in test harness.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

codex

Poem

🐰 Errors once scattered, now gather 'round,
In banners themed and safe and sound,
No more console logs for users to fear—
Just friendly alerts, crisp and clear!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Add error notification banner system' directly and clearly summarizes the main change: the introduction of a new error notification/banner system.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/determined-goldberg-Y1kTH

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying flockxr with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5d9e453
Status: ✅  Deploy successful!
Preview URL: https://8c5d0b64.flockxr.pages.dev
Branch Preview URL: https://claude-determined-goldberg-y.flockxr.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@main/main.js`:
- Around line 1094-1103: The startup flow currently launches flock.initialize()
in a detached async IIFE so window.onload continues even if initialization
fails; change the code so the window.onload handler awaits flock.initialize
directly (make the onload handler async), keep the try/catch around await
flock.initialize, call handleError(error, { source: "startup", fatal: true }) in
the catch, and then return/exit the onload handler (do not continue startup or
call hideLoadingScreen) to prevent further app execution when flock.initialize
fails; this touches the flock.initialize call, the existing handleError usage,
and hideLoadingScreen so you only call hideLoadingScreen on successful
initialization.

In `@style.css`:
- Line 1768: The font-family declaration uses quoted single-word family name
"Asap"; update the CSS rule containing the font-family property (font-family:
"Asap", sans-serif;) to remove the quotes so it reads font-family: Asap,
sans-serif; ensuring the change is made where the font-family property is
defined in the stylesheet.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6f00a9a6-a478-4070-9b3e-3c991b1e0394

📥 Commits

Reviewing files that changed from the base of the PR and between 9aff10c and 5d9e453.

📒 Files selected for processing (10)
  • flock.js
  • locale/en.js
  • locale/es.js
  • main/execution.js
  • main/files.js
  • main/main.js
  • style.css
  • tests/notifications.test.js
  • tests/tests.html
  • ui/notifications.js

Comment thread main/main.js
Comment thread style.css
align-items: center;
gap: 12px;
padding: 12px 16px;
font-family: "Asap", sans-serif;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove quotes around the font family name.

The font family name "Asap" should not be quoted according to CSS conventions for single-word font names.

📝 Proposed fix
-  font-family: "Asap", sans-serif;
+  font-family: Asap, sans-serif;

As per coding guidelines, stylelint flagged: Expected no quotes around "Asap".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
font-family: "Asap", sans-serif;
font-family: Asap, sans-serif;
🧰 Tools
🪛 GitHub Actions: Prettier / prettier

[warning] Prettier reported formatting issues.

🪛 Stylelint (17.11.1)

[error] 1768-1768: Expected no quotes around "Asap" (font-family-name-quotes)

(font-family-name-quotes)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@style.css` at line 1768, The font-family declaration uses quoted single-word
family name "Asap"; update the CSS rule containing the font-family property
(font-family: "Asap", sans-serif;) to remove the quotes so it reads font-family:
Asap, sans-serif; ensuring the change is made where the font-family property is
defined in the stylesheet.

@tracygardner tracygardner merged commit bc1d9ea into main May 22, 2026
13 checks passed
@tracygardner tracygardner deleted the claude/determined-goldberg-Y1kTH branch May 22, 2026 17:49
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.

2 participants