united-states
My understanding is that even if I don't profit from a copyright I hold, I can still sue for statutory damages if someone violates that copyright.
That understanding is fully correct. It all boils down to that you have to prove infringement.
To get statutory damages, you only have to prove Infringement
To prove infringement, you need to prove access and similarity of the work. You also need to show that you actually have a copyright in the code and thus might need to prove the originality and authorship of your code.
To prove access, you'd need to either prove that the user did access your work, or prove that the AI did reproduce your code, and not the code of someone else that is almost identical but created separately. For that, you might need to subpoena or sue the AI-company to tell you that they used your code in the training data.
To prove similarity, both codes would need to be very close to one another. A straight reproduction would be without difference and thus easy to prove here.
But, here comes the elephant in the room, because generative AI is involved and AI products are uncopyrightable: The other side could claim your work is trivial or not creative or original and thus not copyrightable in the first place. To have a copyright, you only need two requirements, Originality and Fixation, but, if they can topple your originality, the whole copyright is gone. Cases like Feist v Rural do clearly say, that for a work to be original, the owner of the work needs to show at least a modicum of creativity:
(a) Article I, § 8, cl. 8, of the Constitution mandates originality as a prerequisite for copyright protection. The constitutional requirement necessitates independent creation plus a modicum of creativity.
Feist Publications, Inc. v. Rural Tel. Serv. Co., 499 U.S. 340 (1991)
To prove originality or creativity, you have to prove that your code is non-trivial. If your code is on the level of "Hello, World!", that's trivial. If your code can be straight-up put together from the documentation by AI, that's trivial. If your code is annotated and shows your own style beyond the mere conventions in naming, then you have a case.
To prove authorship, you might need to supply that you did not copy the code or substantial snippets from other people.