Fix version-switcher stuck-on-unversioned bug and Environments modal duplicates - #38
Merged
Merged
Conversation
…duplicates Found while manually testing the docs UI against a real production API: - The active version could get permanently stuck on "Unversioned" - the app's own default version key (usually "v1") only ever appeared in the switcher once a real ApiVersionDoc existed for it, so switching away from it before ever creating one was a one-way trip. VersionSwitcher now always surfaces it as a selectable option in that case. - Switching versions could leave the PREVIOUS version's tree/content on screen for as long as the new version's fetch took - the loading state from the last fix only covered the very first load, not subsequent switches. Now cleared and re-armed on every version change too. - The Environments modal allowed double-clicking Save to create two identical environments (nothing disabled the button mid-request) and never checked for duplicate names. Added a saving state and a duplicate-name check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three more real bugs found while manually testing the docs UI against a real production API (600+ endpoints):
resolveVersionfallback) only ever appears in the version switcher once a realApiVersionDocis explicitly created for it. A brand-new project has real data under it but no such record — so switching to "Unversioned" (always listed) before ever visiting "Manage versions…" was a one-way trip with no way back except manually creating a version with that exact name.VersionSwitchernow always surfaces the default version key as a selectable option when it isn't a real stored version yet.saving/disabled state on the Save button meant a double-click fired two identical create requests before the first even resolved. Also no duplicate-name check at all, and the form never reset after a successful creation.Changes
VersionSwitcher.tsx: extractedisDefaultVersionPhantom(pure, tested) and synthesizes a selectable entry for the app's default version key when needed.DocsApp.tsx: renamedinitialLoadPending→specLoadPending, now re-armed (andfolders/doccleared) on every version switch, not just first load.EnvironmentsModal.tsx: addedsavingstate (disables Save/Delete/Close, shows "Saving…"), resets the form after a successful creation, added a case-insensitive duplicate-name check with an inline error.Test plan
pnpm build— passespnpm lint— cleanpnpm check:boundaries— cleanpnpm test— 657/657 passing (4 new tests forisDefaultVersionPhantom)