fix(sidebar): prevent stuck spinner after table list loads#1460
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0055b23ce2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| guard isCurrentLoadGeneration(generation, for: connectionId, phase: "tables-failed") else { | ||
| if case .loading = states[connectionId] { | ||
| states[connectionId] = .idle |
There was a problem hiding this comment.
Don't clear state for a newer load
When an older table fetch fails after a newer load has already started (for example the schema/database switch paths invalidate and then reload), this stale branch observes the newer load's .loading state and changes it to .idle. That clears the sidebar spinner and exposes an empty/idle table list even though the current generation is still fetching; stale generations should not mutate states for a different in-flight generation.
Useful? React with 👍 / 👎.
# Conflicts: # .gitignore # CHANGELOG.md # CLAUDE.md # TablePro/Core/Services/Query/SchemaService.swift
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 886a058b27
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| guard isCurrentLoadGeneration(generation, for: connectionId, phase: "tables-loaded") else { | ||
| return | ||
| } | ||
| states[connectionId] = .loaded(tables) |
There was a problem hiding this comment.
Bump generation when publishing tables
When a reload replaces the table list with a different list of the same count while routine/schema fetches are still pending, this assignment makes the new tables observable without changing generationToken; SidebarViewModel.filteredTables(from:) and kind caches key only on count, generation, and query, so after the .loading bump they can keep returning the old table rows until auxiliary metadata completes (or indefinitely if it hangs). Bump the generation at the point the loaded table state is published, before awaiting procedures/functions/schemas.
Useful? React with 👍 / 👎.
Summary
catchblock now resets state to.idleinstead of leaving it at.loadingTask.yield()poll loop intableStateLoadsBeforeAuxiliaryMetadatatest with deterministictablesGategatingTest plan
SchemaServiceRoutinesTestspasses without flakes