Commit 09e6c4e
[OPIK-8050] [FE] fix: paginate prompt version history and fix version labeling (#8140)
* [OPIK-8050] [FE] fix: paginate prompt version history and fix version labeling
Version history on the Prompt tab only ever loaded the first 25 versions
(single page, client-computed vN labels), so older versions were
unreachable and a deep link to one silently fell back to the latest
version while still showing a stale label. Switches to a paginated
usePromptVersionsByIdInfinite hook, wires the lazy-load already built
into VersionHistoryTimeline, and replaces index-derived labels with the
backend's persistent version_number (falling back to commit when a
pre-migration row has none). Also fixes OPIK-8189: the Compare sheet
recomputed labels from whatever was locally loaded instead of the true
total, mislabeling versions past the first page.
Guards a stale/crafted activeVersionId from rendering a different
prompt's content, aligns the new hook's cache key with existing
mutation invalidations so the sidebar refreshes after writes, and
extends the Diff dropdown to auto-paginate so "Compare against" isn't
capped at the first loaded page either.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(prompts): guard version-history pagination, dedupe fetcher, extract orchestration hook
- Gate the deep-link, diff-menu, and scroll-sentinel pagination triggers on
isFetching/isError (not just isFetchingNextPage) to stop a permanently
failing page fetch from hammering the backend in an infinite retry loop.
- Reject version_type=mask when resolving the active version by id, both for
rendering and for the playground-load fetch, since the by-id lookup isn't
scoped the way the paginated list is.
- Fix the mobile version dropdown to highlight the resolved active version
instead of the raw query param.
- Share one fetcher between usePromptVersionsById and
usePromptVersionsByIdInfinite instead of duplicating the request logic.
- Reuse an already-loaded version from the paginated list instead of issuing
a redundant by-id fetch when switching between loaded versions.
- Extract version-history orchestration (pagination, selection, active
version resolution) out of PromptTab into usePromptVersionHistory.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(prompts): paginate Deploy menu owners, unify positional labels, dedupe pagination triggers
- DeployToEnvironmentMenu now auto-paginates while open (mirroring the Diff
menu) so "Currently vN" resolves for owners on unloaded pages instead of
silently omitting them.
- Replace remaining positional v{total-idx} labels with the backend's
version_number/commit in usePromptVersionLabel, usePromptVersionsWithLabels,
and PromptLibraryMenu, so labels stay correct across Playground, trace
details, prompt select boxes, Optimizations, and Agent Runner even after
older versions are deleted.
- Merge the deep-link, Diff-menu, and Deploy-menu pagination triggers into a
single effect so at most one fetchNextPage() fires per render — two
separate effects both firing in the same render could cancel each other
via TanStack Query's default cancelRefetch behavior.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* 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>
* fix(prompts): bound version-history refetch cost to actual changes
useInfiniteQuery refetches every already-loaded page sequentially on any
trigger, and the Diff/Deploy menus can load many pages for large prompts —
so the prior refetchInterval/refetchOnWindowFocus multiplied request volume
by however many pages a session had loaded. Drop those from the infinite
query and instead poll the cheap prompt object (version_count) on the same
interval, invalidating the versions list only when that count actually
changes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(prompts): disable window-focus refetch on version-history query
The prior fix's intent comment claimed refetchOnWindowFocus was off, but
never actually set it — the default true still refetched every loaded page
on window focus, defeating the point of bounding refetch cost to actual
version_count changes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(prompts): guard pagination, dedupe scan cost, and stop compare-dialog resets
- usePromptVersionsByIdInfinite: getNextPageParam now treats an empty page
as terminal instead of trusting `total`, which could loop forever if the
two go out of sync (e.g. a concurrent delete between the count and the
page query). Also gives the infinite-query cache key an explicit
`view: "infinite"` marker instead of relying on the implicit (and
breakable) "this hook never has page/size" invariant to stay distinct
from usePromptVersionsById's key.
- usePromptVersionHistory: memoize isChasingDeepLink so a stale/nonexistent
activeVersionId doesn't re-scan the whole (growing) version list on every
unrelated render while it chases pages.
- ComparePromptVersionDialog: the selection-reset effect now fires only on
the open transition (reading the rest via a ref) instead of on every
versions/versionOptions change while already open, so a background
refetch (pagination continuing, a version_count invalidation) no longer
silently resets the comparison the user is looking at.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(prompts): keep compare dialog target correct during deep-link pagination
ComparePromptVersionDialog previously stored the selected base/diff
PromptVersion objects as state, snapshotted on open. Combined with the
open-only reconciliation effect (added to stop background refetches from
resetting the user's selection), this meant a background refetch could
leave the dialog rendering stale content, or a removed version rendering
content that no longer exists.
Store only the selected version id in state and re-resolve the actual
version live from `versions` on every render instead: a background refetch
now keeps rendered content current, and a version that disappears from the
list resolves to undefined (renders nothing) rather than stale data — while
still not resetting the selection on harmless background changes.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(prompts): guard compare-dialog media diff on missing versions
anyMediaChanged alone gated the media section, unlike the Prompt/Metadata
sections which already require both baseVersion and diffVersion. Since
collectMedia falls back to empty media arrays when a version is undefined
(e.g. deleted out from under an open dialog), any media on the surviving
version read as "changed" and rendered — a one-sided comparison against a
version that no longer exists. Add the same baseVersion && diffVersion
guard already used by the other two sections.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>1 parent e5eec6b commit 09e6c4e
13 files changed
Lines changed: 527 additions & 179 deletions
File tree
- apps/opik-frontend/src
- api/prompts
- hooks
- v2
- pages/PromptPage
- CommitsTab
- PromptTab
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
Lines changed: 9 additions & 54 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
53 | 8 | | |
54 | 9 | | |
55 | | - | |
56 | | - | |
| 10 | + | |
| 11 | + | |
57 | 12 | | |
58 | 13 | | |
59 | 14 | | |
| |||
Lines changed: 61 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
12 | 9 | | |
13 | 10 | | |
14 | 11 | | |
| |||
27 | 24 | | |
28 | 25 | | |
29 | 26 | | |
30 | | - | |
31 | | - | |
32 | | - | |
| 27 | + | |
| 28 | + | |
33 | 29 | | |
34 | 30 | | |
35 | 31 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
245 | 244 | | |
246 | 245 | | |
247 | 246 | | |
| |||
259 | 258 | | |
260 | 259 | | |
261 | 260 | | |
262 | | - | |
263 | | - | |
| 261 | + | |
| 262 | + | |
264 | 263 | | |
265 | 264 | | |
266 | 265 | | |
| |||
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | | - | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
| |||
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
76 | 85 | | |
77 | 86 | | |
78 | 87 | | |
| |||
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
28 | 38 | | |
29 | 39 | | |
30 | 40 | | |
| |||
35 | 45 | | |
36 | 46 | | |
37 | 47 | | |
| 48 | + | |
| 49 | + | |
38 | 50 | | |
39 | 51 | | |
40 | 52 | | |
41 | 53 | | |
42 | 54 | | |
43 | 55 | | |
44 | | - | |
| 56 | + | |
45 | 57 | | |
46 | 58 | | |
47 | | - | |
| 59 | + | |
48 | 60 | | |
49 | 61 | | |
50 | 62 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
0 commit comments