Skip to content

Commit 193a3fb

Browse files
authored
Merge pull request #3507 from Agenta-AI/frontend-fix/testset-page-navigation
[Frontend fix] Use nextjs router for proper testset page navigation
2 parents 2afb3a8 + 24cccff commit 193a3fb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

web/oss/src/components/TestsetsTable/TestsetsTable.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {Button, Dropdown, Modal, Space, Tag, Typography} from "antd"
1919
import clsx from "clsx"
2020
import {useAtom, useAtomValue, useSetAtom} from "jotai"
2121
import dynamic from "next/dynamic"
22+
import {useRouter} from "next/router"
2223

2324
import {
2425
InfiniteVirtualTableFeatureShell,
@@ -87,6 +88,7 @@ const TestsetsTable = ({
8788
onSelectRevision,
8889
selectedRevisionId,
8990
}: TestsetsTableProps) => {
91+
const router = useRouter()
9092
const {projectURL} = useURL()
9193
const projectId = useAtomValue(projectIdAtom)
9294

@@ -192,7 +194,7 @@ const TestsetsTable = ({
192194

193195
// If it's a revision, navigate to it directly
194196
if (isRevision) {
195-
window.location.href = `${projectURL}/testsets/${record.id}`
197+
router.push(`${projectURL}/testsets/${record.id}`)
196198
return
197199
}
198200

@@ -202,7 +204,7 @@ const TestsetsTable = ({
202204
if (cachedChildren && cachedChildren.length > 0) {
203205
// Navigate to the first child (latest revision)
204206
const latestRevision = cachedChildren[0]
205-
window.location.href = `${projectURL}/testsets/${latestRevision.id}`
207+
router.push(`${projectURL}/testsets/${latestRevision.id}`)
206208
return
207209
}
208210

@@ -216,13 +218,13 @@ const TestsetsTable = ({
216218
)
217219
if (revisions.length > 0) {
218220
// Navigate to the first revision (latest)
219-
window.location.href = `${projectURL}/testsets/${revisions[0].id}`
221+
router.push(`${projectURL}/testsets/${revisions[0].id}`)
220222
}
221223
} catch (error) {
222224
console.error("[TestsetsTable] Failed to fetch revisions for navigation:", error)
223225
}
224226
},
225-
[projectURL, childrenCache, isSelectMode, onSelectRevision],
227+
[projectURL, childrenCache, isSelectMode, onSelectRevision, router],
226228
)
227229

228230
// Action handlers - consolidated

0 commit comments

Comments
 (0)