The vii dim is a somewhat-frequently-used chord in the Baroque, especially in first inversion, as here (G#dim/B). This chord is typically used as a substitute for the dominant seventh (e.g. E7 in this case), as it shares the V7's leading tone (the G♯) and it's melodic tendency to resolve upwards towards tonic (A). Indeed, a vii dim chord is essentially a V7 chord without the root.
Technically speaking, a B dim7 chord would have the notes B D F A♭. While G♯ and A♭ are enharmonically equivalent, they imply different voice leading. The A♭ would want to resolve downwards. This difference would have been especially important in the Baroque, to a contrapunctally-minded composer such as Bach.