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:
parent
ea8715c9c4
commit
a26cbac609
1 changed files with 47 additions and 6 deletions
|
|
@ -11,6 +11,7 @@ import { join, dirname } from "path";
|
|||
import { pathToFileURL, fileURLToPath } from "url";
|
||||
import {
|
||||
readInspectorVersion,
|
||||
readInspectorVersionSafe,
|
||||
ROOT_PACKAGE_NAME,
|
||||
} from "@inspector/core/node/version.js";
|
||||
|
||||
|
|
@ -67,3 +68,19 @@ describe("readInspectorVersion", () => {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("readInspectorVersionSafe", () => {
|
||||
it("returns the version when the root manifest resolves", () => {
|
||||
expect(readInspectorVersionSafe(import.meta.url)).toBe(readRootVersion());
|
||||
});
|
||||
|
||||
it("returns undefined instead of throwing when the root can't be resolved", () => {
|
||||
// A caller rooted in the OS temp dir (outside the repo) has no inspector
|
||||
// root manifest above it — readInspectorVersion would throw, but the safe
|
||||
// variant swallows it so a cosmetic version read never crashes the caller.
|
||||
const callerUrl = pathToFileURL(
|
||||
join(tmpdir(), "nowhere", "caller.js"),
|
||||
).href;
|
||||
expect(readInspectorVersionSafe(callerUrl)).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue