Skip to content

fix(frontend): block deletion of app's last revision#3940

Open
JasonOA888 wants to merge 1 commit intoAgenta-AI:mainfrom
JasonOA888:fix/block-last-revision-deletion
Open

fix(frontend): block deletion of app's last revision#3940
JasonOA888 wants to merge 1 commit intoAgenta-AI:mainfrom
JasonOA888:fix/block-last-revision-deletion

Conversation

@JasonOA888
Copy link

Problem

A user can delete all revisions of an app from the Playground. Opening Playground after that leaves it in a broken state with no explanation.

Solution

  • Add isLastRevision check that counts total visible revisions across all variants
  • Disable delete button when deleting would remove all revisions
  • Show helpful message: Cannot delete the only revision. Delete the app instead.

Changes

  • Modified DeleteVariantModal/Content.tsx
  • Added logic to detect when deletion would remove the last revision
  • Button is disabled with tooltip explaining why
  • User sees clear message about what to do instead

Testing

  1. Create an app with a single revision
  2. Open Playground and try to delete via header menu (⋯ → Delete)
  3. Expected: Delete button is disabled with message

Fixes #3892

When a user tries to delete the last revision of an app from Playground,
the UI now prevents this action instead of leaving the app in a broken state.

Changes:
- Add isLastRevision check that counts total visible revisions
- Disable delete button when deleting would remove all revisions
- Show helpful message: Cannot delete the only revision. Delete the app instead.

Fixes Agenta-AI#3892
@vercel
Copy link

vercel bot commented Mar 9, 2026

@JasonOA888 is attempting to deploy a commit to the agenta projects Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Mar 9, 2026
Copy link
Member

@mmabrouk mmabrouk 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 @JasonOA888 for the PR. }

Can you please share a video demo of the implemented feature?

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@JasonOA888
Copy link
Author

@mmabrouk Thanks for reviewing!

I don't have a local Agenta development environment set up to record a video demo. However, I can walk through the logic:

What the PR Does

  1. Detects last revision: Counts total visible revisions across all variants
  2. Disables delete button: When isLastRevision is true
  3. Shows user guidance: "Cannot delete the only revision. Delete the app instead."

Code Changes

// New logic to detect last revision
const isLastRevision = useMemo(() => {
  let totalRevisions = 0
  Object.values(variantGroups).forEach((group) => {
    totalRevisions += group.totalIds.length
  })
  return totalRevisions > 0 && totalSelectedCount >= totalRevisions
}, [variantGroups, totalSelectedCount])

// Disable button and show message
<Button disabled={... || isLastRevision} ... />
{isLastRevision && <Text>Cannot delete the only revision...</Text>}

Testing Steps (for maintainer)

  1. Create an app with a single revision
  2. Go to Playground, try to delete via ⋯ menu
  3. Expected: Delete button disabled, message shown

Would a code walkthrough or screenshots be acceptable instead? I can set up a local environment if video is mandatory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(frontend): block deletion of an app's last revision

3 participants