Skip to content

Improve error handling and robustness across CSG, materials, models, Blockly and UI#492

Merged
tracygardner merged 1 commit intomainfrom
codex/fix-lint-errors-for-unused-variables
Mar 29, 2026
Merged

Improve error handling and robustness across CSG, materials, models, Blockly and UI#492
tracygardner merged 1 commit intomainfrom
codex/fix-lint-errors-for-unused-variables

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

@tracygardner tracygardner commented Mar 29, 2026

Motivation

  • Improve observability and robustness by surfacing caught errors instead of silently ignoring them across mesh/CSD, material parsing, model loading, variable handling and UI features.
  • Make CSG preprocessing more resilient when parent meshes lack geometry and when children require conversion or merging.
  • Prevent unexpected toolbox/key handling and eyedropper cancellation from masking real failures.

Description

  • Hardened CSG mesh preparation in api/csg.js with comprehensive geometry checks, child-mesh gathering and conversion, and added warning logs for conversion/merge failures and failed CSG operations via prepareMeshForCSG, merge attempts and tryCSG wrappers.
  • Replaced many empty catch blocks with scoped catch (error) handlers that call console.warn(...) across files including api/material.js, api/models.js, blocks/blocks.js, blocks/materials.js, main/blocklyinit.js, scripts/run-api-tests.mjs and ui/colourpicker.js to surface runtime issues.
  • Fixed toolbox keyboard handler overrides in main/blocklyinit.js by aligning onKeyDown_ signatures and stubbing the handler to defer navigation to the keyboard plugin, and guarded the toolbox DOM keydown wiring.
  • Improved color parsing resilience in api/material.js and blocks/materials.js by logging parse/validation failures and falling back to #000000 when necessary.
  • Enhanced test instrumentation logging in scripts/run-api-tests.mjs to avoid serialization crashes and to warn when flock properties cannot be accessed during instrumentation.
  • Made releaseContainer cleanup more observable by logging any cleanup errors, and handled eyedropper cancellations explicitly in ui/colourpicker.js to avoid noisy logs for user aborts.

Testing

  • Ran the project's automated unit test suite via npm test, which completed without failures.
  • Executed the API test instrumentation script scripts/run-api-tests.mjs to validate logging and instrumentation changes, and the test run completed successfully.

Codex Task

Summary by CodeRabbit

  • Bug Fixes
    • Improved error reporting and logging across the application for clearer diagnostic information when operations fail.
    • Enhanced eyedropper tool to better distinguish user-initiated cancellations from system errors.

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

cloudflare-workers-and-pages bot commented Mar 29, 2026

Deploying flockdev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4a5cda8
Status: ✅  Deploy successful!
Preview URL: https://b2e233c5.flockdev.pages.dev
Branch Preview URL: https://codex-fix-lint-errors-for-un.flockdev.pages.dev

View logs

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

📝 Walkthrough

Walkthrough

This pull request systematically improves error visibility across the codebase by renaming catch parameters from abbreviations to error and adding console.warn logs to previously silent error handlers. Additionally, unused event parameters are removed from event listener callbacks, and minor formatting adjustments are made throughout.

Changes

Cohort / File(s) Summary
3D/CSG Operation Error Handling
api/csg.js
Renamed catch parameters to error and added contextual console.warn logs in prepareMeshForCSG and mergeMeshes error handlers. Primary CSG merge and fallback mesh merge failures now emit warnings before proceeding or returning null.
Material and Color Error Handling
api/material.js
Renamed exception variable in getColorFromString catch block and added console.warn log. Reformatted colorDark assignment in createColorReplaceShaderMaterial for clarity; removed trailing whitespace.
Model Creation and Cleanup Error Handling
api/models.js
Renamed catch parameters to error in createObject and releaseContainer error handlers, replacing silent failures with console.warn logs that include contextual messages.
Block Variable and Material Error Handling
blocks/blocks.js, blocks/materials.js
Updated error handling in variable management (delete/rename operations) and color field validation to use named error catches with console.warn logs instead of silent failures.
UI Color Picker Error Handling
ui/colourpicker.js
Enhanced startEyedropper error handling to distinguish user cancellation (AbortError) from other failures, logging warnings only for actual errors while allowing cancellation to proceed silently.
Event Handler Signature Cleanup
main/blocklyinit.js, main/main.js
Removed unused event parameters from toolbox.onKeyDown_ callback and #info-details toggle listener, simplifying function signatures while preserving control flow.
API Test Instrumentation
scripts/run-api-tests.mjs
Renamed exception variables to error in browser-side API instrumentation catch blocks. Added console.warn logs for JSON serialization and property access failures without altering control flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 With whispers where silence once dwelt,
Each catch block now speaks what it felt,
No errors creep by unaware,
Warnings logged with utmost care! 🚨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective of the changeset: improving error handling and robustness across multiple subsystems by replacing silent failures with logged warnings and enhancing resilience.

✏️ 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 codex/fix-lint-errors-for-unused-variables

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.

Copy link
Copy Markdown

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
api/csg.js (1)

18-18: ⚠️ Potential issue | 🟠 Major

Fix CI blocker: remove unused hasVertices declaration.

Line 18 currently triggers no-unused-vars, which matches the failing ESLint pipeline.

💡 Minimal fix
-  const hasVertices = mesh.getTotalVertices && mesh.getTotalVertices() > 0;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/csg.js` at line 18, Remove the unused local declaration causing the
ESLint no-unused-vars error: delete the line declaring hasVertices (the const
hasVertices = mesh.getTotalVertices && mesh.getTotalVertices() > 0;) or, if the
value is intended to be used, replace the unused variable by directly using
mesh.getTotalVertices() > 0 where needed; locate the occurrence near the CSG
handling code referencing mesh.getTotalVertices to apply the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@api/csg.js`:
- Line 18: Remove the unused local declaration causing the ESLint no-unused-vars
error: delete the line declaring hasVertices (the const hasVertices =
mesh.getTotalVertices && mesh.getTotalVertices() > 0;) or, if the value is
intended to be used, replace the unused variable by directly using
mesh.getTotalVertices() > 0 where needed; locate the occurrence near the CSG
handling code referencing mesh.getTotalVertices to apply the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eddeb36d-173b-482f-afa4-4cb97cd406d4

📥 Commits

Reviewing files that changed from the base of the PR and between 592ffb2 and 4a5cda8.

📒 Files selected for processing (9)
  • api/csg.js
  • api/material.js
  • api/models.js
  • blocks/blocks.js
  • blocks/materials.js
  • main/blocklyinit.js
  • main/main.js
  • scripts/run-api-tests.mjs
  • ui/colourpicker.js

@tracygardner tracygardner merged commit d1d8c70 into main Mar 29, 2026
9 checks passed
@tracygardner tracygardner deleted the codex/fix-lint-errors-for-unused-variables branch March 29, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant