The Swatches panel menu gets Add Selected Colors next to Add Used Colors.
It is on while art is selected and runs swatch.addUsedColors with
selection and global: each color of the selected art that the panel does
not hold yet becomes a global swatch, and the art's matching paints link
to it, in one undo step.
swatch.addUsedColors no longer records an undo step when there is no new
color to add.