Skip to content

Commit 9562adf

Browse files
natagh23claude
andcommitted
fix(prompts): keep compare dialog target correct during deep-link pagination
Inject the already-resolved activeVersion into the versions array passed to ComparePromptVersionDialog when it isn't yet in the paginated list. Without this, opening Diff while a deep-linked version's page was still loading made the dialog silently fall back to the newest loaded version instead of the one actually requested. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 60f0e33 commit 9562adf

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

  • apps/opik-frontend/src/v2/pages/PromptPage/PromptTab

apps/opik-frontend/src/v2/pages/PromptPage/PromptTab/PromptTab.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ const PromptTab = ({ prompt }: PromptTabInterface) => {
115115
[activeVersion?.environments],
116116
);
117117

118+
// While a deep-linked/active version's page hasn't loaded yet, it's
119+
// missing from `versions` — passing that incomplete list to the compare
120+
// dialog makes it silently fall back to whatever's newest loaded instead
121+
// of the version the user actually asked to compare. `activeVersion` is
122+
// already resolved independently (by id, not by pagination), so inject it
123+
// whenever it isn't already present.
124+
const versionsForCompare = useMemo(() => {
125+
if (!versions) return activeVersion ? [activeVersion] : [];
126+
if (!activeVersion || versions.some((v) => v.id === activeVersion.id)) {
127+
return versions;
128+
}
129+
return [...versions, activeVersion];
130+
}, [versions, activeVersion]);
131+
118132
const isChatPrompt =
119133
prompt?.template_structure === PROMPT_TEMPLATE_STRUCTURE.CHAT;
120134
const template = activeVersion?.template ?? "";
@@ -516,7 +530,7 @@ const PromptTab = ({ prompt }: PromptTabInterface) => {
516530
<ComparePromptVersionDialog
517531
open={openCompare}
518532
setOpen={setOpenCompare}
519-
versions={versions ?? []}
533+
versions={versionsForCompare}
520534
initialBaseVersionId={compareAgainstVersionId ?? undefined}
521535
initialDiffVersionId={effectiveVersionId || undefined}
522536
/>

0 commit comments

Comments
 (0)