@@ -456,6 +456,7 @@ function observeSplitMergeTools() {
456456 let wasMulticutActive = false ;
457457 let wasMergeActive = false ;
458458 let hadPointsPlaced = false ;
459+ let multicutOpenTime = 0 ;
459460
460461 // Track NG status bar messages to capture split/merge errors
461462 let lastStatusText = '' ;
@@ -517,6 +518,7 @@ function observeSplitMergeTools() {
517518
518519 // Read point counts from internal multicut state (sinks = red, sources = blue)
519520 const viewer : any = ( < any > window ) [ 'viewer' ] ;
521+ let gotInternalCounts = false ;
520522 try {
521523 const segLayer = viewer ?. selectedLayer ?. layer ?. layer ;
522524 const gc = segLayer ?. graphConnection ?. value ;
@@ -526,6 +528,7 @@ function observeSplitMergeTools() {
526528 const sourceCount = ms . sources ?. size ?? 0 ;
527529 store . updatePointCounts ( sinkCount , sourceCount ) ;
528530 if ( sinkCount > 0 || sourceCount > 0 ) hadPointsPlaced = true ;
531+ gotInternalCounts = true ;
529532
530533 // Detect submit: points reset to 0 means user submitted
531534 if ( wasMulticutActive &&
@@ -537,8 +540,18 @@ function observeSplitMergeTools() {
537540 prevSinkCount = sinkCount ;
538541 prevSourceCount = sourceCount ;
539542 }
540- } catch { /* fallback: leave counts as-is */ }
543+ } catch { /* fallback below */ }
544+
545+ // Fallback: detect points from DOM if internal state access failed
546+ if ( ! gotInternalCounts ) {
547+ const annotations = multicutEl . querySelectorAll ( '[class*="annotation"], [class*="point"], circle, .neuroglancer-annotation-layer-view' ) ;
548+ if ( annotations . length > 0 ) hadPointsPlaced = true ;
549+ // Also check if the multicut UI shows any point count text
550+ const text = multicutEl . textContent || '' ;
551+ if ( / \d + \s * ( s o u r c e | s i n k | p o i n t ) / i. test ( text ) ) hadPointsPlaced = true ;
552+ }
541553
554+ if ( ! wasMulticutActive ) multicutOpenTime = Date . now ( ) ;
542555 wasMulticutActive = true ;
543556 wasMergeActive = false ;
544557
@@ -582,7 +595,11 @@ function observeSplitMergeTools() {
582595 } else {
583596 // Tool DOM disappeared
584597 if ( wasMulticutActive ) {
585- if ( store . submitting || hadPointsPlaced ) {
598+ // Tool was open long enough that user likely placed points and submitted,
599+ // even if we couldn't detect points via internal state
600+ const toolWasUsed = store . submitting || hadPointsPlaced ||
601+ ( Date . now ( ) - multicutOpenTime > 3000 ) ;
602+ if ( toolWasUsed ) {
586603 // Had points placed and tool disappeared — likely submitted
587604 store . beginSuccessClose ( 'Split complete' ) ;
588605 } else {
0 commit comments