Skip to content

fix: carry net highlightColor into pcb_trace.highlight_color (#2839)#2840

Open
DPS0340 wants to merge 1 commit into
tscircuit:mainfrom
DPS0340:fix/net-highlight-color
Open

fix: carry net highlightColor into pcb_trace.highlight_color (#2839)#2840
DPS0340 wants to merge 1 commit into
tscircuit:mainfrom
DPS0340:fix/net-highlight-color

Conversation

@DPS0340

@DPS0340 DPS0340 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Closes #2839.

NetProps.highlightColor is documented and pcb_trace.highlight_color exists on the circuit-JSON schema, but the value was never written — grep -rn "highlightColor\|highlight_color" lib/ returned nothing in core.

                                        before      after
trace on <net highlightColor="#ff0000"> undefined   "#ff0000"
trace on <net /> (no prop)              undefined   undefined

Finding the right insertion site mattered more than the fix

There are five db.pcb_trace.insert sites. My first attempt patched the ones in Trace_doInitialPcbTraceRender / Trace_doInitialPcbManualTraceRender and added a Trace._getHighlightColor() helper. The helper resolved correctly — I verified it returns #ff0000and the output was still undefined, because for a normally autorouted board none of those sites run.

I instrumented each site with a marker to find out which one actually executes: it's the segment insert in Group.ts, after getSourceTraceIdForRoutedTrace. That's where this PR writes the field.

That site has only a source_trace_id, and source_net has no highlight field to read back:

source_net: type, source_net_id, name, member_source_group_ids, is_power, is_ground,
            is_digital_signal, is_analog_signal, is_positive_voltage_source,
            trace_width, subcircuit_id, subcircuit_connectivity_map_key

So getHighlightColorForSourceTrace resolves source_trace.connected_source_net_ids → matching Net component → highlightColor. It's a small standalone helper rather than inline code so the other insertion sites can adopt it if they ever become reachable.

I kept the Trace._getHighlightColor() helper too, since the Trace_* sites are reachable for cached-route and manual-path boards, and left both paths consistent.

Verification

The test bites. Reverting only Group.ts:

expect(highlightByNetName.VCC).toBe("#ff0000")
Received: undefined
(fail) carries net highlightColor into pcb_trace.highlight_color

It also asserts a second net without the prop stays undefined, so the fix can't pass by blanket-applying a colour.

Suite: 1260 pass / 0 fail, no snapshot churn, biome format and tsc --noEmit clean.

One note on process: an intermediate run of mine reported 7 unrelated failures (3D/PCB snapshot tests). Those were an artifact of my machine hitting 100% disk during the run — they pass individually and the count returns to 0 fail on a clean run of this same branch, and main is also 0 fail. Flagging it so a stray number in my earlier notes isn't mistaken for a real regression.

How this was found

Cross-referenced every interface *Props in @tscircuit/props against the circuit-JSON schema, keeping props whose snake_case name exists as a schema field but which core references under neither name. Exactly two hits: InductorProps.maxCurrentRating (#2837 / #2838) and this one. The sweep is now exhausted for that particular pattern.

@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:11pm

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.

net highlightColor is ignored: pcb_trace.highlight_color is never written

1 participant