Skip to content

fix: omit the voltage half of the fuse label when voltageRating is absent (#2833)#2834

Open
DPS0340 wants to merge 1 commit into
tscircuit:mainfrom
DPS0340:fix/fuse-optional-voltage-rating
Open

fix: omit the voltage half of the fuse label when voltageRating is absent (#2833)#2834
DPS0340 wants to merge 1 commit into
tscircuit:mainfrom
DPS0340:fix/fuse-optional-voltage-rating

Conversation

@DPS0340

@DPS0340 DPS0340 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Closes #2833.

A fuse declared with only currentRating — which is the only required rating, so this is a fully supported way to write one — rendered a bare unit with no number:

before                          after
display_voltage_rating  "V"     undefined
symbol_display_value    "1A / V"  "1A"

The fix

Both call sites interpolated the formatted value unconditionally, and formatSiUnit(undefined) returns "", so the template collapsed to the unit suffix. Now the optional half is dropped instead:

if (voltage === undefined || Number.isNaN(voltage)) return currentDisplay
return `${currentDisplay} / ${formatSiUnit(voltage)}V`

This mirrors Resonator._getSchematicSymbolDisplayValue(), which already handles the same required/optional shape this way — I followed the existing convention rather than inventing one.

NaN is covered as well as undefined because the props accept strings: voltageRating="abc" goes through parseFloat and would otherwise have produced "NaNpV".

Verification

Fuses that do declare a voltage are untouched:

F1  currentRating="1A"                     → "1A"           (was "1A / V")
F2  currentRating="2A"  voltageRating="32V" → "2A / 32V"     unchanged
F3  currentRating={0.5} voltageRating={250} → "500mA / 250V" unchanged

The new test bites. Reverting only Fuse.ts:

expect(sourceByName.F1.display_voltage_rating).toBeUndefined()
Received: "V"
(fail) <fuse /> omits the voltage half of the label when voltageRating is absent

It asserts both the source fields and the schematic symbol values, and includes a two-rating fuse in the same board so a regression in either direction is caught.

Suite: 1257 pass / 0 fail (3 skipped suites unrelated). biome format and tsc --noEmit clean for the touched files.

About the 3 updated snapshots

They aren't collateral — they're the bug, captured. All three contain fuses with no voltageRating and were storing the broken label:

  • schematic-text-bounding-box-fuse — four fuses at currentRating="2A", all showing 2A / V
  • schematic-section-rp2040 and -autolayout<fuse name="F1" currentRating="500mA" />, showing 500mA / V

I rendered the bounding-box snapshot to confirm the labels now read 2A and that the text bounding boxes shrink to match, rather than the label merely being blanked.

Worth noting the existing fuse component test passes both ratings, which is why the optional path was never exercised.

@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment Jul 25, 2026 5:10pm

Request Review

@DPS0340

DPS0340 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

Housekeeping — rebased onto current main (d99c99f), still 1260 pass / 0 fail. No behaviour change.

Since I have several PRs open here now, a note on how they interact so none of this lands on you:

Five of the seven are fully independent — they touch different files and merge in any order:

PR file
#2838 Inductor.ts
#2844 Hole.ts, PlatedHole.ts
#2846 Group/Group.ts (group insert sites)
#2840 Group/Group.ts (pcb_trace segment insert)
#2842 NormalComponent.ts, Group/Group.ts, Group_doInitialPcbComponentAnchorAlignment.ts

Two pairs conflict, and both are trivial:

  1. fix: omit the voltage half of the fuse label when voltageRating is absent (#2833) #2834fix: honour schShowRatings={false} on fuse (#2835) #2836 — both edit Fuse._getSchematicSymbolDisplayValue(). Whichever merges first, the other needs the two guards stacked:

    if (this._parsedProps.schShowRatings === false) return undefined   // #2836
    if (voltage === undefined || Number.isNaN(voltage)) return currentDisplay  // #2834
    return `${currentDisplay} / ${formatSiUnit(voltage)}V`

    They're orthogonal (one suppresses the whole label, the other drops just the voltage half), so the combined behaviour is well-defined. Both test files also touch fuse.test.tsx, appending separate tests.

  2. fix: carry net highlightColor into pcb_trace.highlight_color (#2839) #2840fix: write display_offset_x/y as display strings (#2841) #2842 — both add a field to nearby inserts in Group.ts; the resolution is to keep both lines.

Happy to do the merge myself: say the word and I'll combine any subset into a single PR, or rebase the losers as soon as the first one lands. I'd rather you not spend time on conflict resolution for my changes.

I verified the above rather than assuming it — checked all 21 branch pairs for conflicts and confirmed each rebases cleanly onto d99c99f.

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.

fuse without voltageRating renders a bare unit: "1A / V" on the schematic, "V" in circuit JSON

1 participant