review: harden version read + fix MonitoringScreen docstring

Address PR #1641 review feedback:

- Add readInspectorVersionSafe() (non-throwing) in core/node/version.ts and use
  it in the web backend, so a failure to resolve the root manifest hides the
  (cosmetic) version badge instead of crashing the backend at startup. Covered
  by tests for both the resolved and unresolvable paths.
- Update MonitoringScreen's docstrings: it now wraps every supplied screen in a
  ScreenStage (only the active tab mounts, cross-fading) rather than rendering
  just the active tab's node.

The third fetch-consolidation suggestion (one useInitialConfig instead of three
GET /api/config hooks) is tracked as a follow-up in #1643.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BrihGWcrM9JGRyu41nzZYw
This commit is contained in:
cliffhall 2026-07-10 22:40:34 -04:00
commit a26cbac609

View file

@ -64,3 +64,23 @@ export function readInspectorVersion(callerUrl: string): string {
`Could not locate the ${ROOT_PACKAGE_NAME} root package.json above ${startDir}`,
);
}
/**
* Non-throwing variant of {@link readInspectorVersion}: returns `undefined`
* instead of throwing when the root manifest can't be resolved. For callers
* where the version is cosmetic (e.g. the web backend surfacing it to the
* browser) — a resolution failure should hide the version, not take the caller
* down at startup.
*
* @param callerUrl the calling module's `import.meta.url`
* @returns the root version, or `undefined` if it can't be resolved
*/
export function readInspectorVersionSafe(
callerUrl: string,
): string | undefined {
try {
return readInspectorVersion(callerUrl);
} catch {
return undefined;
}
}