Skip to content

Fix version-switcher stuck-on-unversioned bug and Environments modal duplicates - #38

Merged
SayantanCode merged 1 commit into
mainfrom
fix/version-switcher-and-environments-bugs
Jul 26, 2026
Merged

Fix version-switcher stuck-on-unversioned bug and Environments modal duplicates#38
SayantanCode merged 1 commit into
mainfrom
fix/version-switcher-and-environments-bugs

Conversation

@SayantanCode

Copy link
Copy Markdown
Owner

Summary

Three more real bugs found while manually testing the docs UI against a real production API (600+ endpoints):

  • Stuck on "Unversioned." The app's default version key (usually "v1", from schema-engine's resolveVersion fallback) only ever appears in the version switcher once a real ApiVersionDoc is 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. VersionSwitcher now always surfaces the default version key as a selectable option when it isn't a real stored version yet.
  • Stale tree during version switches. The loading-state fix from the previous PR only covered the very first load — switching versions afterward could leave the previous version's folders/content on screen for however long the new version's fetch took, indistinguishable from the switch silently failing. Now cleared and re-armed on every version change.
  • Environments modal allowed duplicate creation. No 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: extracted isDefaultVersionPhantom (pure, tested) and synthesizes a selectable entry for the app's default version key when needed.
  • DocsApp.tsx: renamed initialLoadPendingspecLoadPending, now re-armed (and folders/doc cleared) on every version switch, not just first load.
  • EnvironmentsModal.tsx: added saving state (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 — passes
  • pnpm lint — clean
  • pnpm check:boundaries — clean
  • pnpm test — 657/657 passing (4 new tests for isDefaultVersionPhantom)
  • CI green on this PR

…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.
@SayantanCode
SayantanCode merged commit 05b01a2 into main Jul 26, 2026
3 checks passed
@SayantanCode
SayantanCode deleted the fix/version-switcher-and-environments-bugs branch July 26, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant