← Back to community index
# contributor·Active

Ray - The post-routing hook is up as three tsci...

The post routing hook is up as three tscircuit PRs. The core PR is a draft until the props PR is merged and released. [props 939](https://github.com/tscircuit/props/pull/939) adds the pcbPostRoutingHook prop to <board and subcircuit <group , with the typed context the hook receiv

Started by RayOct 15, 202623 messages

Discussion

Last active 4 days ago · plain text
Rayoriginal post
The post-routing hook is up as three tscircuit PRs. The core PR is a draft until the props PR is merged and released. [props#939](https://github.com/tscircuit/props/pull/939) adds the pcbPostRoutingHook prop to <board> and subcircuit <group>, with the typed context the hook receives. The PR body covers the details the props repo asks for (accepted inputs, defaults, migration). All 684 props tests pass and typecheck is clean. [core#4657](https://github.com/tscircuit/core/pull/4657) is the implementation. It needs the props change, so after props#939 is released I'll bump @tscircuit/props in core and mark it ready. [docs#947](https://github.com/tscircuit/docs/pull/947) adds an "Edit the PCB After Routing" page. Its example runs correctly against the core branch. [core#4629](https://github.com/tscircuit/core/issues/4629), the issue, now links all three.
Seve
RE: pcbPostRoutingHook- why not use an autoroutingphase?
Seve
you can set the phaseOrderIndex to order one or more phases
Seve
the problem with hooks is you can't "stack hooks" as easily, they are also more tightly TS-coupled
Ray
(claude response) I tried it. autoroutingphase + algorithmFn on core main can't cover this: - a phase only runs when it has connections, reroute+region/connection, or pcbTracePaths. A trailing "after everything" phase with just algorithmFn never gets called - with reroute+region it re-routes: it cuts traces at the region edge and hands the solver the pieces, with obstacles as abstract rects - the output is SimplifiedPcbTrace[] only. I returned a pcb_smtpad and it was silently dropped, so no test pads, silkscreen, keepouts or custom DRC errors - returning the existing traces wider left both copies on the board (0.15 and 0.5), so it can't edit the router's traces either The hook's job is editing circuit-json (insert/update/remove any pcb_* element) after routing and before pours/DRC. That's a different contract from "routing problem in, traces out". You're right about stacking though. Would you take it as an ordered element instead of a prop, e.g. <pcbpostroutingstep order={1} fn={addTestPoints} />, several allowed, run in order, each journaled/undone on reroute? Same shape as autoroutingphase. And by TS-coupled do you mean you'd want something serializable rather than a function? algorithmFn is a function too, so I want to make sure I get what you mean.
Ray
an even better solution that might also address your issues is to actually be able to write tsx that handles post routing hook. I'm dogfooding on my own contacts with ears design now.
Seve
what is an ear in this case
Seve
it seems like if we adjust how reroute works it could work- reroute should be able to work without a bounded region
Ray
https://discord.com/channels/1233487248129921135/1415179482641469490/1560010488308433027 The ear is my use case and I’m trying to add support to tscircuit in a generic way so that I can do this in userland without hard coding it in tsci
Seve
ah ok yes- sorry, still catching up on threads
Seve
this is very interesting, it's kind of a footprint adjustment
Ray
a dynamic one, to stick the test point around the routed traces but before the copper pour
Seve
right that's a really good userland case
Seve
i think we may want to use real hooks
Seve
i.e. react hooks, that's how this would conventionally work in a react paradigm
Seve
basically if you want to adjust based on output and insert new elements, that's actually a pretty normal thing in react
Seve
we just don't support conventional hooks right now
Seve
but you could do a lot more if we did
Seve
i will iterate on some approaches today
Ray
I'm finishing my good PR update shortly to show the functionality I want and you can try other things for parity all you want 🙂
Ray
my favorite tscircuit pastime: writing complex code that will never be merged upstream 😂
Ray
I believe I am all done working on these PRs, ball is fully in your court.
Seve
yep working on it

Want to add to the conversation?

Reply in Discord so your notes stay connected to the source.
Continue in Discord ↗