fix(frontend): block deletion of app's last revision#3940
fix(frontend): block deletion of app's last revision#3940JasonOA888 wants to merge 1 commit intoAgenta-AI:mainfrom
Conversation
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
|
@JasonOA888 is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
mmabrouk
left a comment
There was a problem hiding this comment.
Thank you @JasonOA888 for the PR. }
Can you please share a video demo of the implemented feature?
|
|
|
@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
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)
Would a code walkthrough or screenshots be acceptable instead? I can set up a local environment if video is mandatory. |
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
isLastRevisioncheck that counts total visible revisions across all variantsChanges
DeleteVariantModal/Content.tsxTesting
Fixes #3892