opik
opik copied to clipboard
[OPIK-3271] [FE] Fix restored prompt commit not auto-selected in UI
Details
Fixed a bug where restoring a prompt commit did not automatically select the newly restored commit in the UI.
Root Cause
The RestoreVersionDialog component was accessing data.versionId in the success callback, but the backend API returns a PromptVersion object with an id field, not versionId.
Solution
Changed data.versionId to data.id in the onSuccess callback to correctly access the restored version's ID and automatically select it in the commit history.
Technical Details
- File Modified:
apps/opik-frontend/src/components/pages/PromptPage/PromptTab/RestoreVersionDialog.tsx - Change: Line 42 - Changed
onSetActiveVersionId(data.versionId)toonSetActiveVersionId(data.id) - Backend Behavior: The restore endpoint (
POST /prompts/{promptId}/versions/{versionId}/restore) returns a completePromptVersionobject with the new restored version'sid
Change checklist
- [x] User facing
- [ ] Documentation update
Issues
- OPIK-3271
Testing
Manual Testing Steps
- Navigate to a prompt with multiple commits (e.g., Prompt Library → Select a prompt with version history)
- In the commit history panel, hover over an older commit (not the latest)
- Click the "Restore" button (undo icon)
- Confirm the restoration
- ✅ Verify: The newly restored commit is automatically selected (highlighted) in the commit history panel
- ✅ Verify: The prompt content displays the restored version
Expected Behavior
- After restoring a commit, the UI should automatically select and highlight the newly created restored commit
- The commit history should scroll to show the selected commit
- The prompt content area should display the restored version's template
Before Fix
- Restoring a commit would succeed but the UI would not update to show the newly restored commit as selected
- User had to manually click on the restored commit to view it
After Fix
- Restoring a commit automatically selects the newly restored commit in the UI
- User immediately sees the restored version without additional clicks
Documentation
No documentation updates required - this is a bug fix that makes the existing feature work as expected.