opik icon indicating copy to clipboard operation
opik copied to clipboard

[OPIK-3271] [FE] Fix restored prompt commit not auto-selected in UI

Open Nimrod007 opened this issue 1 month ago • 0 comments

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) to onSetActiveVersionId(data.id)
  • Backend Behavior: The restore endpoint (POST /prompts/{promptId}/versions/{versionId}/restore) returns a complete PromptVersion object with the new restored version's id

Change checklist

  • [x] User facing
  • [ ] Documentation update

Issues

  • OPIK-3271

Testing

Manual Testing Steps

  1. Navigate to a prompt with multiple commits (e.g., Prompt Library → Select a prompt with version history)
  2. In the commit history panel, hover over an older commit (not the latest)
  3. Click the "Restore" button (undo icon)
  4. Confirm the restoration
  5. Verify: The newly restored commit is automatically selected (highlighted) in the commit history panel
  6. 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.

Nimrod007 avatar Dec 01 '25 07:12 Nimrod007