I'm trying to visualize angles on a polar plot using ggplot2. It works well when I only plot points, but drawing lines between the points doesn't really work: the line makes an extra loop around the plot when the data jumps from -pi to pi... See here:

(I am quite attached to ggplot2, if it's possible I would prefer not to move to plotly...)
Here is some dummy data and code to reproduce the figure:
test = data.frame(x= 1:25,
theta = c(seq(0, pi, length.out=13), seq(-pi+pi/25, 0, length.out=12)))
ggplot(test, aes(x= x, y =theta, color = x))+
geom_line()+
geom_point()+
scale_color_viridis_c("x")+
coord_radial(theta = "y", start=pi, clip= "off", r.axis.inside = T, expand=F, rotate.angle = T)+scale_y_continuous(limits = c(-pi, pi))+
xlab("x")+ylab("Angle (rad)")
How can I connect the lines via the shortest path, i.e. over the pi/-pi without the additional circle?