Skip to content

Conversation

@jordanl17
Copy link
Member

@jordanl17 jordanl17 commented Nov 13, 2025

Description

With the launch of Scheduled Drafts there are a few issues when it comes to deleting scheduled drafts.

When a scheduled draft is deleted, we immediately delete the release and the version document within it. This means that if there are changed that are not reflected in another version of the document, they will be lost.

This was flagged as being an obvious issue - there was no reasonable way of copying across the changed, and just deleting the schedule - eg imagining that you wanted to make an amendment to the scheduled draft's content. This would involve API manipulation.

With these changes this issue is resolved.

  • In the case that the revision ID of the existing draft and the scheduled draft are the same, when the user attempts to delete the scheduled draft, we will just delete - ie, there is no change in this instance
  • In the case that the revision ID of the existing draft is different from the scheduled draft, when the user attempts to delete the scheduled draft we will show an updated confirmation dialog.
Screenshot 2025-11-19 at 01 04 23

The default is that the 'copy to draft' is selected. In this case the existing draft will be overridden with the content of the scheduled draft, before the scheduled draft is then deleted. If the user unchecks, then the existing draft will remain and the content in the scheduled draft will be discarded.

  • Finally, in the instance that a draft does not exist, when deleting the scheduled draft the content will be first copied into a newly created draft so that no content is lost.

What to review

Testing

Notes for release

Deleting Scheduled Drafts will give the option for the content of the scheduled version to be copied to a draft version of the document.

@vercel
Copy link

vercel bot commented Nov 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
page-building-studio Ready Ready Preview Comment Nov 25, 2025 5:18pm
test-studio Ready Ready Preview Comment Nov 25, 2025 5:18pm
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
e2e-studio Ignored Ignored Nov 25, 2025 5:18pm
studio-workshop Ignored Ignored Preview Nov 25, 2025 5:18pm
test-next-studio Ignored Ignored Nov 25, 2025 5:18pm

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

🧪 E2E Preview environment

🔑 Environment Variables for Local Testing

This is the preview URL for the E2E tests: https://e2e-studio-ktz5xr8fy.sanity.dev

To run the E2E tests locally, you can use the following environment variables, then run pnpm test:e2e --ui to open the Playwright test runner.

💬 Remember to build the project first with pnpm build:e2e.

  SANITY_E2E_PROJECT_ID=ittbm412
  SANITY_E2E_BASE_URL=https://e2e-studio-ktz5xr8fy.sanity.dev
  SANITY_E2E_DATASET="update depending the project you want to test (pr-11143-chromium-19677944800 || pr-11143-firefox-19677944800 )"
  SANITY_E2E_DATASET_CHROMIUM=pr-11143-chromium-19677944800
  SANITY_E2E_DATASET_FIREFOX=pr-11143-firefox-19677944800

@github-actions
Copy link
Contributor

🧪 E2E Preview environment

Waiting for preview deployment to finish…

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

📊 Playwright Test Report

Download Full E2E Report

This report contains test results, including videos of failing tests.

@github-actions
Copy link
Contributor

📊 Playwright Test Report

Waiting for E2E tests to finish…

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

⚡️ Editor Performance Report

Deploying studio and running performance tests…

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 44.74% 63814 / 142602
🔵 Statements 44.74% 63814 / 142602
🔵 Functions 48.32% 3407 / 7050
🔵 Branches 79.39% 12996 / 16368
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/sanity/src/core/i18n/bundles/studio.ts 100% 100% 100% 100%
packages/sanity/src/core/releases/components/documentHeader/VersionChip.tsx 72.36% 38.77% 18.75% 72.36% 140-142, 147-149, 157-159, 166, 170, 174, 179-190, 198-213, 285-293, 298-308, 313-317
packages/sanity/src/core/releases/tool/overview/ScheduledDraftMenuButtonWrapper.tsx 13.33% 100% 0% 13.33% 19-85
packages/sanity/src/core/singleDocRelease/components/DeleteScheduledDraftDialog.tsx 92.97% 95.58% 100% 92.97% 97-111, 213
packages/sanity/src/core/singleDocRelease/hooks/useScheduleDraftOperations.ts 89.81% 80.76% 100% 89.81% 141-154
packages/sanity/src/core/singleDocRelease/hooks/useScheduledDraftMenuActions.tsx 99.16% 96.42% 100% 99.16% 172
packages/sanity/src/core/singleDocRelease/hooks/__mocks__/useScheduleDraftOperations.mock.ts 100% 100% 100% 100%
packages/sanity/src/core/singleDocRelease/plugin/documentActions/ScheduledDraftDocumentActions.tsx 41.86% 100% 50% 41.86% 24-57
Generated in workflow #46250 for commit 560668c by the Vitest Coverage Report Action

@jordanl17 jordanl17 force-pushed the feat/copy-delete-scheduled-draft-to-draft branch from 74bf037 to b4f4bc9 Compare November 19, 2025 00:50
@jordanl17 jordanl17 marked this pull request as ready for review November 19, 2025 15:06
@jordanl17 jordanl17 requested a review from a team as a code owner November 19, 2025 15:06
@jordanl17 jordanl17 requested review from pedrobonamin and removed request for a team November 19, 2025 15:06
{t('release.dialog.delete-schedule-draft.body')}
</Text>
</Box>
{showCopyCheckbox && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking that maybe it's better to always show this option, it will give security to editors that the scheduled draft document won't be lost.
Even if it's the same, you will need to previously know that and be sure that nothing is changing, if we always show it, then they will be sure that when removing they won't lose it.
wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems odd to show the checkbox when it has no effect though. Perhaps we could just show copy like 'This draft will still be available' or words to that effect?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Simplify and improve the copy/showing of the checkbox

Comment on lines 138 to 160
if (draftDoc) {
await client.discardVersion({publishedId}, false)
}

// Create a new draft version from the scheduled draft
await client.createVersion({
baseId: scheduledDraftId,
ifBaseRevisionId: scheduledDraftDoc._rev,
publishedId,
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to discard the existing? I think we can do a client.createOrReplace
If we need to discard it, then I think we should do both operations in a transaction, so if for any reason it fails we don't lose the draft

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeh fair

  • Try createOrReplace or make it transactional

Copy link
Contributor

@pedrobonamin pedrobonamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this Jordan!
It looks great and it will improve the experience for the users, added some comments to discuss

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.

3 participants