Abarbanel discusses this issue in his introduction to Sefer Yehoshua and concludes (my translation):
"And it seems that when Yirmiyahu wished to write Sefer Melachim, he clarified Sefer Shmuel that came before, and he collected the prophecies that were written in that book, and without a doubt he added things to it [Sefer Shmuel] to clarify, according to what he thought was needed, and that is what it means when it is said "until this day", and he is who wrote that "beforehand in Israel etc they referred to a prophet as a seer" and the rest of the verses which I mentioned that point to a later date, they were all a part of the process of the editor and compiler, peace be upon him."
Therefore, the term "למלכי יהודה" refers to the time of Yirmiyahu. It should be noted that this does not necessarily contradict the gemara; we may say that the gemara refers to the earlier version of Sefer Shmuel, before it was edited by Yirmiyahu.1
1 I noticed something interesting today. There are (at least) two parts in Shoftim that hint at a significantly later re-edit of the book. The first is pretty explicit: In Shoftim 18:30 it says that "and Jonathan son of Gershom son of Manasseh and his descendants, served as priests to the Danite tribe until the land went into exile." - while obviously any prophet could potentially foresee the exile, adding it into a book addressed to generations that knew nothing of the exile would make it pretty meaningless. Therefore, that means that this verse was added in by someone - likely Yirmiyahu - who lived after the exile of Dan.
The second point is less explicit. In the same verse, it says that the Levite who became a priest of idolatry to the Danites was Yehonatan ben Gershom ben Menashe, and the Nun of Menashe is written in the Masoretic text as hanging above the word. The gemara explains that this Yehonatan was a descendant of Moshe and "Rather, although he was the son of Moses, because he acted as Manasseh the king of Judah, who was notorious for idol worship, acted, the verse linked him to Manasseh by calling him “the son of Manasseh." - obviously such a reference would have only been understood by people from Menashe's time and after, so it seems that even the gemara admits the existence of a later re-edit of Shoftim by another person - again, likely Yirmiyahu.