fix: stop relation metadata requests on grid scroll - #491
Merged
Conversation
Reviewer's GuideIntroduces a scoped external store for relation display metadata, wires it into relation headers via useRelationData, and coordinates cache invalidation with the workspace database catalog so metadata requests are shared, bounded, and properly refreshed on invalidation events and session changes. Sequence diagram for shared relation display metadata loadingsequenceDiagram
actor RelationHeader
participant useRelationData
participant WorkspaceDatabaseCatalog as getWorkspaceDatabaseCatalog
participant RelationDisplayStore as relation_display_metadata
participant ViewApi as getViewIdFromDatabaseId/loadViewMeta
RelationHeader->>useRelationData: mount(fieldId, enabled=true)
useRelationData->>WorkspaceDatabaseCatalog: getWorkspaceDatabaseCatalog(workspaceId)
Note over useRelationData,WorkspaceDatabaseCatalog: wait for catalog result
alt database catalogued
WorkspaceDatabaseCatalog-->>useRelationData: candidates with relatedDatabaseId
useRelationData->>RelationDisplayStore: subscribeRelationDisplayMetadata(workspaceId, relatedDatabaseId)
useRelationData-->>RelationHeader: selectedView from catalog
else database not in catalog
WorkspaceDatabaseCatalog-->>useRelationData: []
useRelationData->>RelationDisplayStore: loadRelationDisplayMetadata(workspaceId, relatedDatabaseId, knownViewId)
RelationDisplayStore->>ViewApi: getViewIdFromDatabaseId(databaseId)
ViewApi-->>RelationDisplayStore: viewId
RelationDisplayStore->>ViewApi: loadViewMeta(viewId)
ViewApi-->>RelationDisplayStore: childView (and optional parent)
RelationDisplayStore-->>useRelationData: ready snapshot via subscribeRelationDisplayMetadata
useRelationData-->>RelationHeader: selectedView from fallback metadata
Note over RelationDisplayStore,RelationHeader: remount headers reuse cached snapshot without new requests
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The relation-display-metadata cache/invalidation logic is quite intricate (sessionGeneration, workspaceScope, cacheGenerations, expiryTimers, invalidationSubscriptions); consider factoring some of the responsibility into smaller, focused helpers or modules to make the lifecycle (request, cache, expiry, invalidation) easier to reason about.
- In relation-display-metadata, requestIsCurrent depends on currentUserScope(); since currentUserScope uses getTokenParsed on every call, a token change mid-request could invalidate the request unexpectedly—if that’s intentional, a brief comment explaining the rationale near requestIsCurrent would help future maintainers.
- In useRelationData, the loading state now depends on workspaceId, fieldId, and enabled; you may want to add a small comment around the catalogLoading computation explaining why the synchronous derivation is needed to avoid the fallback metadata effect racing ahead of the catalog effect.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The relation-display-metadata cache/invalidation logic is quite intricate (sessionGeneration, workspaceScope, cacheGenerations, expiryTimers, invalidationSubscriptions); consider factoring some of the responsibility into smaller, focused helpers or modules to make the lifecycle (request, cache, expiry, invalidation) easier to reason about.
- In relation-display-metadata, requestIsCurrent depends on currentUserScope(); since currentUserScope uses getTokenParsed on every call, a token change mid-request could invalidate the request unexpectedly—if that’s intentional, a brief comment explaining the rationale near requestIsCurrent would help future maintainers.
- In useRelationData, the loading state now depends on workspaceId, fieldId, and enabled; you may want to add a small comment around the catalogLoading computation explaining why the synchronous derivation is needed to avoid the fallback metadata effect racing ahead of the catalog effect.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
appflowy
force-pushed
the
fix/relation-header-metadata-requests
branch
from
August 20, 2026 14:18
a4437d2 to
8b4c1e1
Compare
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.
Description
Scrolling a virtualized database grid unmounts and remounts its normal and sticky relation headers. For a legacy relation missing from both the workspace database catalog and the currently materialized (lazy) folder outline, each header instance fell back to
GET /view/:id?depth=1for the relation view and its optional parent. The existing generic view cache was only short-lived and did not cache failures; when the parent was inaccessible, the successful child metadata was discarded and the next remount repeated the sequence.This PR moves that fallback into the app-wide folder metadata path:
metadataOnlylookup mode for relation labels while keeping the existing depth-1loadViewMetabehavior unchanged for navigation and database tabs;The normal catalog path performs no folder-by-ID request. A legacy miss performs at most one shared child lookup and one optional parent lookup; later header remounts use the global metadata result.
Testing
pnpm lint(TypeScript + repository-wide ESLint)pnpm buildgit diff --check/view/:id?depth=1,/database?offset, or/trashrequestsChecklist
General
Testing
Feature-Specific
loadViewMetabehavior.Summary by Sourcery
Centralize relation view metadata resolution and invalidation to eliminate redundant requests during virtualized grid scrolling.
Bug Fixes:
Enhancements:
CI:
Tests: