Skip to content

feat: surface per-module load errors in Settings → Modules#9

Open
Teamingzooper wants to merge 1 commit into
feat/settings-import-exportfrom
feat/module-devtools
Open

feat: surface per-module load errors in Settings → Modules#9
Teamingzooper wants to merge 1 commit into
feat/settings-import-exportfrom
feat/module-devtools

Conversation

@Teamingzooper

Copy link
Copy Markdown
Owner

Summary

When a directory under `modules/` or `~/.nexus/modules/` can't be loaded as a module (usually a malformed `nexus-module.json`), Nexus previously just logged a warning and silently skipped it. Users would notice "Hey, my custom module isn't showing up" with no signal about why.

This PR surfaces those load errors directly in Settings → Modules, with the validation issue paths spelled out where possible.

Branch base: `feat/settings-import-export` — fourth in the stack. Merge in order: #6#7#8 → this.

What's shown

For each rejected module directory:

  • Its absolute filesystem path (monospace, so it's copy-pasteable).
  • A human-readable error message.
  • For Zod manifest-validation failures: a bulleted list of each issue, formatted as `path.to.field: explanation` (e.g. `url: module url must be https`).
  • For JSON parse errors: the parser's own message (`Manifest is not valid JSON: Unexpected token …`).

The panel only renders when there are errors, so the UI stays clean for users with no broken modules. Clicking the existing Reload modules button re-runs the scan and refreshes both the working modules list AND the errors list — fix-and-reload loop converges on an empty panel.

Scope (deliberately narrow)

The original ask included three "module devtools" capabilities:

  1. Better error surfacing when a manifest is malformed ← shipped here.
  2. "Validate manifest" command — overlapping with Native OS notifications: [Nexus] <instance> — <message> #1 (showing manifest errors). A standalone file-picker validator for module authors is genuinely useful but doesn't fit a 1-PR scope. Punted to v2.
  3. Hot-reload local modules without restarting — the existing Reload modules button is the manual-trigger version. A file watcher would be nicer but adds a dependency (chokidar/native FS watch) and dev-only UX considerations. Punted to v2.

Implementation

  • New `ModuleLoadError` type in shared types.
  • New IPC channel `nexus:modules:list-errors`.
  • `ModuleRegistryService` clears its error list at the start of each load and pushes a structured `{ path, message, details? }` for each rejected module. Errors are categorised by type: Zod (paths + issue messages), SyntaxError (JSON parse), or generic Error.
  • Renderer store fetches errors in `init()` alongside modules, and in `reloadModules()` both lists refresh in parallel.
  • Settings → Modules renders the panel conditionally when `moduleErrors.length > 0`.

Test plan

  • `npm run typecheck` — clean
  • `npm run test` — 178/178 passing
  • `npm run build` — renderer + main both clean
  • Manual smoke: drop a directory under `~/.nexus/modules/` with a broken `nexus-module.json` (e.g. `{ "id": "test" }` — missing required `name` / `version` / `url`). Click Reload modules. The error panel should appear listing the missing fields with their schema paths.
  • Manual smoke: drop a directory with malformed JSON (`{ this is not json`). Reload. The panel should show the JSON parse error.
  • Manual smoke: fix one of the broken modules, leave another broken, reload. The error panel should now show only the still-broken one.

🤖 Generated with Claude Code

Previously, malformed module manifests were logged at warn level and
silently skipped — users would just see modules missing from their
list with no signal about why. Now ModuleRegistryService captures the
load error for each rejected module directory and the renderer shows
a per-row panel above the module list.

For Zod validation failures (the common case — typo in a manifest
field), each issue is listed with its path. For JSON parse errors
the parser's message is shown. For everything else the error's
.message is shown.

The errors panel is only rendered when there are errors, so the UI
stays clean for users with no broken modules. Clicking "Reload
modules" re-runs the scan and refreshes both the modules list AND
the errors list, so users fix-and-reload until the panel is empty.

Scope deliberately narrow: this is the highest-value piece of the
"module devtools" request. Hot-reload via file watcher and a
standalone "validate manifest" picker are valuable but not as
impactful as making existing errors visible — both deferred to v2.

178/178 unit tests pass, typecheck + build clean.
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