Consolidate document draft management and add delete draft#1000
Consolidate document draft management and add delete draft#1000SachaProbo wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
2 issues found across 15 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="e2e/console/document_version_test.go">
<violation number="1" location="e2e/console/document_version_test.go:550">
P1: Parallel subtests share and mutate one `result` variable, causing a data race and flaky tests.</violation>
</file>
<file name="apps/console/src/pages/organizations/documents/_components/DocumentActionsDropdown.tsx">
<violation number="1" location="apps/console/src/pages/organizations/documents/_components/DocumentActionsDropdown.tsx:208">
P1: After deleting a draft, the code no longer navigates away from a draft-version route, which can leave users on a URL referencing a deleted version.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
apps/console/src/pages/organizations/documents/_components/DocumentActionsDropdown.tsx
Outdated
Show resolved
Hide resolved
546d010 to
e92c0fc
Compare
|
@cubic-dev-ai please review |
@SachaProbo I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
1 issue found across 15 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="pkg/probo/document_service.go">
<violation number="1" location="pkg/probo/document_service.go:1611">
P2: Missing auto-delete check after creating a new draft. When the latest version is published and a new draft is created, the code does not verify whether the draft actually differs from the published version. If all non-nil request fields match the published values, an identical draft is left behind. The draft-exists branch handles this correctly—consider applying the same comparison logic here, or checking for actual field changes before creating the draft.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
446e6f5 to
625d167
Compare
| } | ||
|
|
||
| // Refetch layout when draft status changes (created or deleted) | ||
| // so the drawer and header reflect the current version. |
There was a problem hiding this comment.
What happens if I start writing again during this call, do I lose this content after the refetch?
There was a problem hiding this comment.
The refetch is there only for the edge case where the connection membership changes (draft created or deleted), not on every save. In those situation the page refetch and it is not really possible to writes during the refetch.
| // so the drawer and header reflect the current version. | ||
| const draftReturned = !!data.updateDocument.documentVersion; | ||
| if (wasDraft !== draftReturned) { | ||
| onRefetch(); |
There was a problem hiding this comment.
Why should we refetch instead of just updating the store?
If the mutation sends back needed data then the store should update itself without the need for refetch.
| }); | ||
|
|
||
| useEffect(() => { | ||
| if (draftDeletedAt > 0) { |
There was a problem hiding this comment.
I don't understand the use of this? Why do we need to refetch here, when a draft is deleted then we should navigate to the last available version if we were on the draft page. This should be enough without refetch
There was a problem hiding this comment.
The version is not in the url.
9616ea4 to
1469d70
Compare
df70de8 to
a9393cd
Compare
Merge createDraftDocumentVersion, updateDocumentVersion, and deleteDraftDocumentVersion into the existing updateDocument mutation. The backend auto-creates a draft when title, content, classification, or type changes, updates an existing draft, and auto-deletes it when all fields revert to match the published version. Add a new deleteDocumentDraft mutation (GraphQL, MCP) that takes a document ID and deletes the latest version if it is a draft (excluding the initial v0.1). Exposed in the actions dropdown before archive. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
a9393cd to
bb21ffb
Compare
Merge createDraftDocumentVersion, updateDocumentVersion, and deleteDraftDocumentVersion into the existing updateDocument mutation. The backend auto-creates a draft when title, content, classification, or type changes, updates an existing draft, and auto-deletes it when all fields revert to match the published version.
Add a new deleteDocumentDraft mutation (GraphQL, MCP) that takes a document ID and deletes the latest version if it is a draft (excluding the initial v0.1). Exposed in the actions dropdown before archive.
Summary by cubic
Consolidates all draft logic into
updateDocumentand addsdeleteDocumentDraftby document ID. The console edits the latest version; drafts are auto-created/updated/removed and the UI refreshes on version changes.New Features
updateDocumentnow acceptstitle,content,classification, anddocumentType. It auto-creates/updates a draft on change and auto-deletes it when values match the published version. The payload includesdocumentVersionwhen a draft exists or is created.updateDocument. The description editor is enabled only on the latest version when the document isn’t archived and you havecore:document:update; historical versions are read-only. The layout usesstore-and-networkand refetches when a draft is created/deleted or the version changes.core:document:delete-draft. It callsdeleteDocumentDraft, refetches, and navigates to the description on success.Migration
createDraftDocumentVersion,updateDocumentVersion, anddeleteDraftDocumentVersion(GraphQL and MCP). UseupdateDocumentfor title/content/classification/type anddeleteDocumentDraftwithdocumentId. Permissions: usecore:document:updateandcore:document:delete-draft(version-level update/delete-draft actions are removed).probo document create-draftandprobo document update-version. Useprobo document update --title/--content/--document-type/--classificationandprobo document delete-draft <document-id>.Written for commit bb21ffb. Summary will update on new commits.