fix(publish): preserve related database templates - #462
Merged
Conversation
Reviewer's GuideThis PR hardens the publish-duplicate flow so destination spaces are loaded reliably with shallow hierarchies and failures are surfaced, and ensures published database relations resolve from the snapshot rather than private live rows, backed by unit tests and an end-to-end Playwright BDD scenario. Sequence diagram for destination space loading and retry in publish duplicate flowsequenceDiagram
actor User
participant DuplicateModal
participant useLoadWorkspaces
participant WorkspaceService
participant SpaceList
User->>DuplicateModal: click StartWithThisTemplate
DuplicateModal->>useLoadWorkspaces: loadSpaces(selectedWorkspaceId)
useLoadWorkspaces->>WorkspaceService: getFolder(selectedWorkspaceId, 2)
alt [request fails]
useLoadWorkspaces->>useLoadWorkspaces: setSpaceError(true)
useLoadWorkspaces->>useLoadWorkspaces: setSpaceList([])
useLoadWorkspaces->>DuplicateModal: spaceError=true
DuplicateModal->>SpaceList: render with error=true
User->>SpaceList: click onRetry
SpaceList->>DuplicateModal: onRetry()
DuplicateModal->>useLoadWorkspaces: loadSpaces(selectedWorkspaceId)
useLoadWorkspaces->>WorkspaceService: getFolder(selectedWorkspaceId, 2)
else [request succeeds]
useLoadWorkspaces->>useLoadWorkspaces: setSpaceError(false)
useLoadWorkspaces->>useLoadWorkspaces: setSpaceList(spaces)
useLoadWorkspaces->>DuplicateModal: spaceList
DuplicateModal->>SpaceList: render with spaceList
end
opt [workspace changed during request]
useLoadWorkspaces->>useLoadWorkspaces: requestId check
useLoadWorkspaces-->>useLoadWorkspaces: ignore stale response
end
Sequence diagram for published database row resolution from snapshotsequenceDiagram
participant PublishProvider
participant createSnapshotRenderDoc
participant createDatabaseYjsRenderDocsFromSnapshot
participant RowService
PublishProvider->>createSnapshotRenderDoc: snapshot
alt [snapshot.kind === database]
createSnapshotRenderDoc->>createDatabaseYjsRenderDocsFromSnapshot: snapshot
createDatabaseYjsRenderDocsFromSnapshot-->>createSnapshotRenderDoc: { doc, rowMap }
createSnapshotRenderDoc->>PublishProvider: register rowMap in databaseRowDocsRef
else [snapshot.kind !== database]
createSnapshotRenderDoc-->>PublishProvider: createDocumentYjsRenderDocFromSnapshot(snapshot)
end
PublishProvider->>PublishProvider: createRow(rowKey)
alt [snapshotRow exists]
PublishProvider-->>PublishProvider: return databaseRowDocsRef.get(rowKey)
else [no snapshotRow]
PublishProvider->>RowService: create(rowKey)
RowService-->>PublishProvider: YDoc
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
published-relation-template.steps.tsfile is quite large and mixes generic helper utilities with scenario definitions; consider extracting reusable helpers (API wrappers, workspace traversal, auth-token access) into shared support modules to keep the step file focused and easier to maintain. - In
useLoadWorkspaces, the request-cancellation logic usingspaceRequestIdRefand the unmountuseEffectis somewhat opaque; adding a dedicated "canceled" flag or wrapping the pattern in a small helper could make the intent clearer and reduce the chance of future misuse when this hook evolves.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `published-relation-template.steps.ts` file is quite large and mixes generic helper utilities with scenario definitions; consider extracting reusable helpers (API wrappers, workspace traversal, auth-token access) into shared support modules to keep the step file focused and easier to maintain.
- In `useLoadWorkspaces`, the request-cancellation logic using `spaceRequestIdRef` and the unmount `useEffect` is somewhat opaque; adding a dedicated "canceled" flag or wrapping the pattern in a small helper could make the intent clearer and reduce the chance of future misuse when this hook evolves.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
🥷 Ninja i18n – 🛎️ Translations need to be updatedProject
|
| lint rule | new reports | level | link |
|---|---|---|---|
| Missing translation | 56 | warning | contribute (via Fink 🐦) |
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.
What changed
depth=2, guard against stale workspace responses, and distinguish retryable failures from an empty space list.Related DB, while its relation cell resolves before and after reload.Validation
pnpm test:e2e:bdd --grep @published-document-template-dependencies: 5 passed.pnpm exec playwright test -c playwright.bdd.config.ts --grep @published-relation-template --workers=1: 1 passed, including the depth-2 destination request and copied database name.Server dependency
Requires AppFlowy-Cloud-Premium PR #982 for recursive publication of referenced pages, nested database dependencies, relation remapping, and relation-target container names.