Based on the shader code you posted, you're not interpolating the UVs from the vertices - rather it appears you're interpolating the 3D position (
fragVert), then calculating the UVs by transforming to spherical coordinates.
Your analysis is correct in that the smallest mipmap is chosen when there is a discontinuity, since mipmap selection is based on derivatives that are estimated numerically from the UVs used in neighboring pixels. When one pixel has u = 0 and another has u = 1 you get a very large derivative. Your attempted fix has the same issue in that large derivatives occur around u = 0.01 and u = 0.99, which is why two seams appear on either side of where the original seam was.
A relatively simple approach to fix the problem would be to decide which mip level to use yourself and call
textureLod to sample it directly. If the planet is always going to be fairly close to the camera, you could just hard-code the mip level to 0 (or, for that matter, just not include mip levels in the texture at all). Otherwise, it could be based on the log2 of the point's distance from the camera, scaled by some suitable factors. Note that this will effectively disable anisotropic filtering.
A more "correct" approach would be to calculate some higher-quality derivatives. Instead of using
dFdy on the UVs, which have discontinuities due to the
atan2, you could apply
fragVert (which will be continuous all the way around the sphere), then use some calculus (chain rule) to find the formula to get the UV derivatives from the position derivatives. This will be more complicated and slower, but has the advantage that anisotropic filtering should work.
Finally, since you're new to OpenGL I'll just note that while calculating UVs from spherical coordinates is a perfectly valid way to texture a sphere, it's not the "usual" way that most people pick. It's more common to build a sphere mesh that has UVs specified per vertex, and simply passed from the vertex shader to the pixel shader (linearly interpolated across each triangle). Vertices are placed along the seam, like this, such that there are two copies of each vertex, at exactly the same positions, but half with u = 0 connected to the triangles on one side, and the other half with u = 1 connected to the triangles on the other side. This eliminates any visible seam and doesn't require any tricks in the pixel shader.