Skip to content

fix(web): accept numeric node capacity input values - #514

Merged
athNdev merged 2 commits into
mainfrom
codex/node-capacity-fix
Nov 18, 2026
Merged

athNdev merged 2 commits into
mainfrom
codex/node-capacity-fix

Conversation

@athNdev

@athNdev athNdev commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Defect

parseCapacity in node-settings.svelte called raw.trim() on a value it assumed was a string. The capacity fields use type="number" with bind:value, so Svelte assigns a number (or undefined when cleared) at runtime. Typing any value into #edit-node-max-srv / #edit-node-max-mem (or the add-dialog equivalents) threw raw.trim is not a function. Pre-existing on main; reproduced by real-browser QA (14-S13-capacity-input-runtime-error.png, capacity-probe.json).

Fix

  • Extract parseCapacity to a pure util (src/lib/utils/node-capacity.ts) that accepts string | number | null | undefined and rejects unexpected runtime types.
  • Preserve existing semantics: blank ('', null, undefined) -> 0 (unlimited); whole non-negative safe integers -> value; negative / fractional / NaN / Infinity / unsafe / non-numeric -> null (invalid).
  • No design-system or markup changes; the component simply imports the shared parser.

Verification

  • bun test src/lib/utils/node-capacity.test.ts: 7 focused cases pass (string/number/null/undefined/invalid/negative).
  • bun run check: 0 errors / 0 warnings (both tsconfigs).
  • bun test: 286 pass / 0 fail.
  • bun run lint: clean.
  • go run ./cmd/knowledge-lint -root . -fix then without -fix: queries 38/38 pass, indexes current (one pre-existing data-safety re-verify warning, unrelated).
  • Real-browser check (task-owned headless Chromium, fixture-backed vite dev, PLAYWRIGHT_SKIP_BROWSER_GC=1): typed 16 and -1 into both edit capacity fields and both add-dialog fields — 5/5 scenarios PASS, 0 page errors, 0 console errors. Valid 16 shows no validation feedback; -1 shows validation feedback instead of crashing. Evidence: browser-qa-2026-11-18/node-capacity-fix/capacity-fix-evidence.json plus screenshots.

Scope note

Branch is based on c15b8d7d and intentionally not rebased onto current main so it does not incorporate PR510's node-settings redaction work. The parser change is localized to the import/function removal and merges cleanly with that file's other changes. Do not merge until the publication gate is lifted.

The capacity fields are type=number with bind:value, so Svelte assigns a number (or undefined when cleared) to the bound state. parseCapacity assumed a string and threw raw.trim is not a function on any entry.

Extract the parser to a pure util that accepts string, number, null and undefined while preserving blank=0 (unlimited), whole non-negative safe integers, and null for negative/fractional/invalid values. Add focused regression tests and verify by real-browser typing in both edit and add-dialog capacity fields.
@athNdev
athNdev merged commit a4dcaa4 into main Nov 18, 2026
13 checks passed
@athNdev
athNdev deleted the codex/node-capacity-fix branch November 18, 2026 03:38
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.

1 participant