[OPIK-6838] [FE] fix: link Playground prompt versions to experiments and traces#7017
Conversation
…e path (OPIK-6838) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ed flag (OPIK-6838 #4) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…838 #2) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…on in Configuration tab (OPIK-6838) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…er (OPIK-6838) Addresses the Baz review comment plus the multi-agent final-review findings: - Dedupe the version-resolution logic shared by the CHAT and TEXT paths in useHydratePromptMetadata into a single tested helper. - Resolve the embedded latest_version without an extra fetch when no explicit version is requested (restores pre-refactor perf parity for the TEXT path). - Pass the resolved PromptVersion straight to buildPromptLibraryMetadata instead of re-spreading its fields at both call sites. - Add unit tests for resolvePromptVersionForLink, metadata pass-through, and multi-message collection.
| export const resolvePromptVersionForLink = async ( | ||
| promptData: { latest_version?: PromptVersion } | undefined, | ||
| explicitVersionId: string | undefined, | ||
| fetchPromptVersion: FetchPromptVersion, | ||
| ): Promise<PromptVersion | undefined> => { |
There was a problem hiding this comment.
resolvePromptVersionForLink duplicates the version-resolution/fetch logic in v1 useHydratePromptMetadata, so should we reuse this helper there too or extract a shared function?
Want Baz to fix this for you? Activate Fixer
There was a problem hiding this comment.
Commit 2c53828 addressed this comment by extracting the prompt-version linkage logic into shared helpers in promptLinkage.ts, which matches the suggested “extract a shared function” refactor. That removes the duplicated version-selection logic from the old per-path implementation.
|
🔄 Test environment deployment process has started Phase 1: Deploying base version You can monitor the progress here. |
…vation (OPIK-6838) Replace the compound ternary (compare-guard + optional chaining + .length truthiness + empty fallback) with a clear compare-vs-single branch; the consumer maps the array, so an empty array renders nothing.
| const isCompare = experimentsIds.length > 1; | ||
|
|
||
| // Prompt-version links only make sense for a single experiment; in compare | ||
| // mode we don't show them. An empty array simply renders nothing. | ||
| const promptVersions = isCompare ? [] : experiments[0]?.prompt_versions ?? []; | ||
|
|
||
| const [columnsWidth, setColumnsWidth] = useLocalStorageState< |
There was a problem hiding this comment.
promptVersions/NavigationTag prompt-link rendering duplicates CompareExperimentsDetails.tsx, should we extract a shared helper/component so both tabs stay in sync?
Want Baz to fix this for you? Activate Fixer
|
✅ Test environment is now available! To configure additional Environment variables for your environment, run [Deploy Opik AdHoc Environment workflow] (https://github.com/comet-ml/comet-deployment/actions/workflows/deploy_opik_adhoc_env.yaml) Access Information
The deployment has completed successfully and the version has been verified. |
…d const (OPIK-6838)
| const versionRefs = collectPromptVersionRefs(prompt); | ||
| const promptVersions = versionRefs.length | ||
| ? versionRefs.map((ref) => ({ id: ref.id, prompt_id: ref.promptId })) | ||
| : undefined; |
There was a problem hiding this comment.
Lines 39-42 duplicate the collectPromptVersionRefs(prompt) -> prompt_versions/promptLibraryVersions mapping from usePromptDatasetItemCombination.ts; should we move this into promptLinkage.ts as something like buildPromptVersionsPayload so both paths share the same {id, prompt_id?} shape?
Want Baz to fix this for you? Activate Fixer
Follow-up to PR #7017. Review feedback on the prompt-linkage work flagged that experiment surfaces show the raw prompt commit hash, which users don't recognize. Show the human-readable version (version_number, e.g. v3) next to the prompt name, mirroring the already-approved Prompt Library experiments tab, and fall back to the commit hash only when no version number is available (null for masks). Surfaces updated (all v2, display-only — no data-layer/BE change): - ExperimentsPage/GeneralDatasetsTab: "Prompt commit" column -> "Prompt", rendering "<name> (<version>)" via version_label. - CompareExperimentsPage/ConfigurationTab: NavigationTag label built from version_number ?? commit instead of commit. - dashboards/ExperimentsLeaderboardWidget: same column fix (caught in review; identical commit-hash issue on the dashboard leaderboard). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…sh in experiment views (#7031) * [OPIK-6838] [FE] fix: show prompt name + version instead of commit hash Follow-up to PR #7017. Review feedback on the prompt-linkage work flagged that experiment surfaces show the raw prompt commit hash, which users don't recognize. Show the human-readable version (version_number, e.g. v3) next to the prompt name, mirroring the already-approved Prompt Library experiments tab, and fall back to the commit hash only when no version number is available (null for masks). Surfaces updated (all v2, display-only — no data-layer/BE change): - ExperimentsPage/GeneralDatasetsTab: "Prompt commit" column -> "Prompt", rendering "<name> (<version>)" via version_label. - CompareExperimentsPage/ConfigurationTab: NavigationTag label built from version_number ?? commit instead of commit. - dashboards/ExperimentsLeaderboardWidget: same column fix (caught in review; identical commit-hash issue on the dashboard leaderboard). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [OPIK-6838] [FE] refactor: extract shared formatPromptVersionLabel helper Address review feedback (baz): the "<name> (<version>)" formatting was duplicated across the three surfaces. Centralize it in a single tested helper in lib/experiments.ts and reuse it from the Experiments table column, the single-experiment Configuration tab, and the dashboard leaderboard widget so the display rule changes in one place. Also adds unit tests for the version-number/commit fallback and the no-version case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…and traces (#7017) * feat(playground): add shared prompt-version linkage helpers (OPIK-6838) * refactor(playground): reuse shared prompt-version collector in execute path (OPIK-6838) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(playground): link CHAT prompt versions on dataset experiment runs (OPIK-6838 #1,#3) * fix(playground): keep trace prompt link on edited prompts with modified flag (OPIK-6838 #4) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(traces): show modified badge on edited playground prompt link (OPIK-6838 #4) * feat(experiments): link prompt version from Configuration tab (OPIK-6838 #2) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(playground): anchor TEXT prompt version + link experiment's version in Configuration tab (OPIK-6838) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(playground): extract shared resolvePromptVersionForLink helper (OPIK-6838) Addresses the Baz review comment plus the multi-agent final-review findings: - Dedupe the version-resolution logic shared by the CHAT and TEXT paths in useHydratePromptMetadata into a single tested helper. - Resolve the embedded latest_version without an extra fetch when no explicit version is requested (restores pre-refactor perf parity for the TEXT path). - Pass the resolved PromptVersion straight to buildPromptLibraryMetadata instead of re-spreading its fields at both call sites. - Add unit tests for resolvePromptVersionForLink, metadata pass-through, and multi-message collection. * refactor(experiments): simplify Configuration tab promptVersions derivation (OPIK-6838) Replace the compound ternary (compare-guard + optional chaining + .length truthiness + empty fallback) with a clear compare-vs-single branch; the consumer maps the array, so an empty array renders nothing. * refactor(playground): hoist prompt_versions request mapping to a named const (OPIK-6838) --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…sh in experiment views (#7031) * [OPIK-6838] [FE] fix: show prompt name + version instead of commit hash Follow-up to PR #7017. Review feedback on the prompt-linkage work flagged that experiment surfaces show the raw prompt commit hash, which users don't recognize. Show the human-readable version (version_number, e.g. v3) next to the prompt name, mirroring the already-approved Prompt Library experiments tab, and fall back to the commit hash only when no version number is available (null for masks). Surfaces updated (all v2, display-only — no data-layer/BE change): - ExperimentsPage/GeneralDatasetsTab: "Prompt commit" column -> "Prompt", rendering "<name> (<version>)" via version_label. - CompareExperimentsPage/ConfigurationTab: NavigationTag label built from version_number ?? commit instead of commit. - dashboards/ExperimentsLeaderboardWidget: same column fix (caught in review; identical commit-hash issue on the dashboard leaderboard). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [OPIK-6838] [FE] refactor: extract shared formatPromptVersionLabel helper Address review feedback (baz): the "<name> (<version>)" formatting was duplicated across the three surfaces. Centralize it in a single tested helper in lib/experiments.ts and reuse it from the Experiments table column, the single-experiment Configuration tab, and the dashboard leaderboard widget so the display rule changes in one place. Also adds unit tests for the version-number/commit fallback and the no-version case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Details
Experiments and traces created from the Playground over a regular Dataset (or via a direct run) silently lost their Prompt Library version link, while runs over a Test Suite kept it. Root cause: the dataset/"log" path collected only per-message TEXT prompt versions and ignored the loaded CHAT prompt version (
loadedChatPromptVersionId), whereas the test-suite/"execute" path collected both. This produced an empty "Prompt commit" column, dataset experiments missing from a prompt's Experiments tab, and no prompt reference in the single-experiment view.This PR removes that drift by introducing one shared version collector used by both paths, surfaces the prompt-version link in the Configuration tab, and keeps the trace↔prompt reference even after a loaded prompt is edited. Frontend-only — no backend, migrations, or
v1changes.collectPromptVersionRefs+buildPromptLibraryMetadatainto a shared, unit-testedsrc/api/playground/promptLinkage.ts(single source of truth); reuse it in both the execute and log paths.activeVersionId).metadata.opik_prompts, a frontend-only field) now keeps the reference for edited prompts with amodifiedflag, plus a "modified" badge on the trace's Prompts card; TEXT path anchors to the message's own version instead of latest.Change checklist
Issues
AI-WATERMARK
AI-WATERMARK: yes
main, then verified each fixed in the running app (local, OpenAI provider, Chrome).Testing
Commands (from
apps/opik-frontend):npm run typecheck— clean (project-wide)npm run lint— 0 warnings (project-wide)npm run test -- src/api/playground— pass, including newpromptLinkage.test.ts(9 cases)npx vitest run(full suite) — 1751 passed. The only failures (23 insrc/lib/ls-migrations/*) are a pre-existing happy-domlocalStorage.clearenv issue, unrelated to this change (they fail in isolation and touch none of the changed files).Manual UI (local process mode, OpenAI provider, Chrome) — loaded a CHAT library prompt into the Playground and ran an experiment over a regular Dataset:
-).opik_prompts(with the newmodifiedfield) and renders the prompt card on the Prompts tab.Confirmed all four reproduce as broken on
main.Not run: a live screenshot of the
modified: truebadge — local ClickHouse trace-list ingestion lag prevented surfacing the edited-run trace in time. Themodifiedflag is confirmed present in trace metadata and the badge rendering is covered by code review.Documentation
N/A — no user-facing docs change.
🤖 Generated with Claude Code