Skip to content

fix: lazy-load ChiefOfStaff, async pathExists, accessibility labels, hook stability#133

Merged
atomantic merged 2 commits intomainfrom
better/code-quality
Apr 10, 2026
Merged

fix: lazy-load ChiefOfStaff, async pathExists, accessibility labels, hook stability#133
atomantic merged 2 commits intomainfrom
better/code-quality

Conversation

@atomantic
Copy link
Copy Markdown
Owner

@atomantic atomantic commented Apr 10, 2026

Better Audit -- Code Quality & Style

Summary

11 files improved for code quality, accessibility, and hook stability.

Changes

  • Lazy-load ChiefOfStaff page to reduce initial bundle size (App.jsx)
  • Replace sync existsSync with async pathExists in apps.js routes for non-blocking file checks
  • Add htmlFor/id pairs to BodyTab.jsx form inputs for accessibility
  • Fix hook stability issues: useRef for stale closure in useUpdateChecker, ref guard for initial selection in useProviderModels
  • Add AbortController cleanup in useMoltworldWs to cancel in-flight requests on unmount
  • Add error handling in useNotifications with try/catch/finally
  • Guard autoFixer double-init and catch unhandled async errors in event handler
  • Increase cosEvents maxListeners to prevent warning
  • Document env vars in .env.example (OpenClaw, CoS runner, LM Studio, Claude path, Moltworld)
  • Pass options through in apiAccounts.moltworldWsStatus for signal support

Files Modified

.env.example, client/src/App.jsx, client/src/components/meatspace/tabs/BodyTab.jsx, client/src/hooks/{useMoltworldWs,useNotifications,useProviderModels,useUpdateChecker}.js(x), client/src/services/apiAccounts.js, server/routes/apps.js, server/services/{autoFixer,cosEvents}.js

Merge Order

Independent -- can be merged in any order

Copilot AI review requested due to automatic review settings April 10, 2026 04:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves reliability and maintainability across server routes/services and several client pages by standardizing async error handling, surfacing previously swallowed errors, and replacing scattered magic numbers with named constants. It also updates some UI flows to update local state instead of always refetching.

Changes:

  • Wrap async Express route handlers with asyncHandler (Jira/DataDog/LM Studio) and replace silent .catch(() => {}) patterns with visible error reporting.
  • Improve operational logging (e.g., avoid overly verbose JSON.stringify for validation errors) and extract repeated numeric values into constants.
  • Update client pages to use shared API helpers and perform more reactive state updates after save/delete.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
server/services/telegram.js Extract health-check interval magic number into a named constant.
server/services/character.js Extract HP calculation constants for clearer intent.
server/services/brain.js Make validation failure logging less noisy while retaining useful signal.
server/services/agentPromptBuilder.js Stop silently swallowing JIRA title generation errors (warn instead).
server/routes/lmstudio.js Wrap LM Studio routes with asyncHandler for consistent async error handling.
server/routes/jira.js Refactor Jira routes to use asyncHandler instead of per-route try/catch.
server/routes/datadog.js Refactor DataDog routes to use asyncHandler instead of per-route try/catch.
server/lib/telegramClient.js Extract retry delays into named constants for readability/tuning.
client/src/pages/Jira.jsx Update instance list locally after save/delete; improve error logging text.
client/src/pages/FeatureAgents.jsx Replace swallowed errors with user-visible toasts (but see review comments re: duplicate toasts).
client/src/pages/FeatureAgentDetail.jsx Same as above for detail view actions (but see duplicate toast concern).
client/src/pages/DataDog.jsx Update instance list locally after save/delete.
client/src/pages/CharacterSheet.jsx Replace bespoke fetch wrapper with shared api service helpers.
client/src/hooks/useAutoRefetch.js Log auto-refetch failures instead of silently ignoring them.
client/src/components/digital-twin/tabs/EnrichTab.jsx Update Digital Twin API method naming and log failures when loading questions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atomantic atomantic requested a review from Copilot April 10, 2026 04:53
@atomantic atomantic changed the title fix: add asyncHandler, replace swallowed errors, extract magic numbers fix: lazy-load ChiefOfStaff, async pathExists, accessibility labels, hook stability Apr 10, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atomantic atomantic merged commit 96f273c into main Apr 10, 2026
2 checks passed
@atomantic atomantic deleted the better/code-quality branch April 10, 2026 13:59
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