@@ -56,6 +56,7 @@ const PIPELINE_SOLVERS = {
5656const PIPELINE_STORAGE_KEY = "selectedPipeline"
5757const EFFORT_STORAGE_KEY = "selectedEffort"
5858const LAYER_OVERRIDE_STORAGE_KEY = "selectedLayerOverride"
59+ const AUTO_SOLVE_STORAGE_KEY = "autoSolve"
5960const AUTO_RUN_DRC_STORAGE_KEY = "autoRunDrc"
6061
6162const parseLayerOverride = ( value : string | null ) : LayerOverride => {
@@ -300,6 +301,19 @@ export const AutoroutingPipelineDebugger = ({
300301 }
301302 }
302303
304+ const [ autoSolve , setAutoSolveState ] = useState < boolean > (
305+ ( ) => localStorage . getItem ( AUTO_SOLVE_STORAGE_KEY ) === "true" ,
306+ )
307+
308+ const setAutoSolve = ( enabled : boolean ) => {
309+ setAutoSolveState ( enabled )
310+ try {
311+ localStorage . setItem ( AUTO_SOLVE_STORAGE_KEY , String ( enabled ) )
312+ } catch ( e ) {
313+ console . warn ( "Could not save auto-solve preference to localStorage:" , e )
314+ }
315+ }
316+
303317 const [ autoRunDrc , setAutoRunDrcState ] = useState < boolean > (
304318 ( ) => localStorage . getItem ( AUTO_RUN_DRC_STORAGE_KEY ) === "true" ,
305319 )
@@ -417,6 +431,7 @@ export const AutoroutingPipelineDebugger = ({
417431 ( ) => window . localStorage . getItem ( "lastBreakpointNodeId" ) || "" ,
418432 )
419433 const isSolvingToBreakpointRef = useRef ( false ) // Ref to track breakpoint solving state
434+ const autoSolvedSolverRef = useRef < any > ( null )
420435 const autoRanDrcForSolveRef = useRef ( false )
421436
422437 // Reset solver
@@ -464,6 +479,26 @@ export const AutoroutingPipelineDebugger = ({
464479 }
465480 } , [ isAnimating , speedLevel , solver , animationSpeed ] )
466481
482+ useEffect ( ( ) => {
483+ if ( ! autoSolve || solver . solved || solver . failed ) {
484+ return
485+ }
486+
487+ if ( autoSolvedSolverRef . current === solver ) {
488+ return
489+ }
490+
491+ autoSolvedSolverRef . current = solver
492+ isSolvingToBreakpointRef . current = false
493+ setIsAnimating ( false )
494+
495+ const startTime = performance . now ( ) / 1000
496+ solver . solve ( )
497+ const endTime = performance . now ( ) / 1000
498+ setSolveTime ( endTime - startTime )
499+ setForceUpdate ( ( prev ) => prev + 1 )
500+ } , [ autoSolve , solver ] )
501+
467502 useEffect ( ( ) => {
468503 if ( ! solver . solved ) {
469504 autoRanDrcForSolveRef . current = false
@@ -924,6 +959,8 @@ export const AutoroutingPipelineDebugger = ({
924959 onSetCanSelectObjects = { setCanSelectObjects }
925960 onRunDrcChecks = { handleRunDrcChecks }
926961 onRunRelaxedDrcChecks = { handleRunRelaxedDrcChecks }
962+ autoSolve = { autoSolve }
963+ onSetAutoSolve = { setAutoSolve }
927964 autoRunDrc = { autoRunDrc }
928965 onSetAutoRunDrc = { setAutoRunDrc }
929966 animationSpeed = { speedLevel }
0 commit comments