Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(replay-vision): back from an observation returns to the filtered list (#94143)

Carles Salvadorcce4b2d57da6
diff --git a/products/replay_vision/frontend/observations/ReplayObservation.tsx b/products/replay_vision/frontend/observations/ReplayObservation.tsx
index d88ffaf088ee..f99a5bbf9485 100644
--- a/products/replay_vision/frontend/observations/ReplayObservation.tsx
+++ b/products/replay_vision/frontend/observations/ReplayObservation.tsx
@@ -69,7 +69,12 @@ import {
import { scannerLabel } from '../utils/observation'
import { ObservationLabelControl } from './ObservationLabelControl'
import { ObservationPinnedProperties } from './ObservationPinnedProperties'
-import { neighborFilterParams, observationDetailUrl, replayObservationLogic } from './replayObservationLogic'
+import {
+ neighborFilterParams,
+ observationDetailUrl,
+ replayObservationLogic,
+ scannerReturnParams,
+} from './replayObservationLogic'
import { replayObservationSceneLogic } from './replayObservationSceneLogic'
export const scene: SceneExport = {
@@ -218,7 +223,9 @@ export function ReplayObservationSceneComponent(): JSX.Element {
// navigation (and the server-computed neighbor ids) stay within the filtered list.
const neighborParams = neighborFilterParams(searchParams)
const neighborsFiltered = Object.keys(neighborParams).some((key) => key !== 'order_by')
- const observationUrl = (id: string): string => observationDetailUrl(id, neighborParams)
+ // Prev/next keeps the return params too, so back still lands on the list view the reader came from.
+ const observationUrl = (id: string): string =>
+ observationDetailUrl(id, { ...neighborParams, ...scannerReturnParams(searchParams) })
const seekEmbeddedPlayer = (ms: number): void => {
if (!recordingExpanded) {
diff --git a/products/replay_vision/frontend/observations/replayObservationLogic.test.ts b/products/replay_vision/frontend/observations/replayObservationLogic.test.ts
index ca45cf2648bc..a983fa3df4a4 100644
--- a/products/replay_vision/frontend/observations/replayObservationLogic.test.ts
+++ b/products/replay_vision/frontend/observations/replayObservationLogic.test.ts
@@ -90,4 +90,59 @@ describe('replayObservationLogic', () => {
logic.unmount()
}
})
+
+ // The list view rides along in the observation URL, so the back crumb restores the tab, filters,
+ // sort, and page the reader opened the observation from rather than the scanner overview.
+ it('back returns to the filtered observations list the reader came from', async () => {
+ router.actions.push('/replay-vision/observation/obs-1', {
+ tab: 'observations',
+ verdict: 'yes',
+ sort: 'score',
+ page: 2,
+ })
+ const logic = replayObservationLogic({ id: 'obs-1' })
+ logic.mount()
+ try {
+ await expectLogic(logic).toDispatchActions(['loadObservationSuccess'])
+ const { breadcrumbs } = sceneLogic.values
+ expect(breadcrumbs[breadcrumbs.length - 2].path).toBe(
+ '/replay-vision/scanner-9?tab=observations&page=2&sort=score&verdict=yes'
+ )
+ } finally {
+ logic.unmount()
+ }
+ })
+
+ // The router decodes `q=true` to a boolean, so a naive string-only guard would drop it and land
+ // back on an empty search. Searching the literal text "true" must survive the round trip.
+ it('preserves a search query the router decoded to a boolean', async () => {
+ router.actions.push('/replay-vision/observation/obs-1', { tab: 'search', q: 'true' })
+ const logic = replayObservationLogic({ id: 'obs-1' })
+ logic.mount()
+ try {
+ await expectLogic(logic).toDispatchActions(['loadObservationSuccess'])
+ const { breadcrumbs } = sceneLogic.values
+ expect(breadcrumbs[breadcrumbs.length - 2].path).toBe('/replay-vision/scanner-9?tab=search&q=true')
+ } finally {
+ logic.unmount()
+ }
+ })
+
+ // Retry deletes the row and mints a pending replacement with no verdict, so the redirect must
+ // drop the reader's filters and page — a filtered list would hide the row it promises "shortly".
+ it('retry lands on the unfiltered scanner page, not the reader saved list view', async () => {
+ router.actions.push('/replay-vision/observation/obs-1', { tab: 'observations', verdict: 'yes', page: 2 })
+ const logic = replayObservationLogic({ id: 'obs-1' })
+ logic.mount()
+ try {
+ await expectLogic(logic).toDispatchActions(['loadObservationSuccess'])
+ await expectLogic(logic, () => logic.actions.retryObservation()).toDispatchActions([
+ 'retryObservationSuccess',
+ ])
+ expect(router.values.location.pathname).toContain('/replay-vision/scanner-9')
+ expect(router.values.searchParams).toEqual({})
+ } finally {
+ logic.unmount()
+ }
+ })
})
diff --git a/products/replay_vision/frontend/observations/replayObservationLogic.ts b/products/replay_vision/frontend/observations/replayObservationLogic.ts
index 745234162588..3d2f5ebaaabd 100644
--- a/products/replay_vision/frontend/observations/replayObservationLogic.ts
+++ b/products/replay_vision/frontend/observations/replayObservationLogic.ts
@@ -11,7 +11,7 @@ import { visionObservationsRetrieve } from '../generated/api'
import type { ReplayObservationApi, VisionObservationsRetrieveParams } from '../generated/api.schemas'
import { scheduleObservationPoll } from '../logics/observationPolling'
import { requestObservationRetry } from '../logics/observationRetry'
-import { OBSERVATION_LIST_FILTER_KEYS } from '../replay_scanners/types'
+import { OBSERVATION_LIST_FILTER_KEYS, OBSERVATION_LIST_URL_PARAM_KEYS } from '../replay_scanners/types'
import { scannerBreadcrumb } from '../utils/breadcrumbs'
import { hasScannerPage, scannerLabel } from '../utils/observation'
import { parseNumericParam } from '../utils/urlParams'
@@ -48,16 +48,42 @@ export function neighborFilterParams(searchParams: Record<string, unknown>): Vis
* A saved scanner owns its observations and lists them. A one-off scan is owned by the recording it
* ran from, which is also the safe side of [hasScannerPage] because it always resolves.
*/
-export function observationParentUrl(observation: ReplayObservationApi): string {
- return hasScannerPage(observation)
- ? urls.replayVision(observation.scanner_id)
- : urls.replaySingle(observation.session_id)
+export function observationParentUrl(
+ observation: ReplayObservationApi,
+ returnParams: Record<string, string | number> = {}
+): string {
+ if (!hasScannerPage(observation)) {
+ return urls.replaySingle(observation.session_id)
+ }
+ // combineUrl with no params returns the path unchanged, so the empty case needs no guard.
+ return combineUrl(urls.replayVision(observation.scanner_id), returnParams).url
+}
+
+/**
+ * The list view an observation was opened from, read back off its own URL, so going back returns to
+ * the tab, filters, sort, and page the reader left rather than the scanner's overview.
+ */
+export function scannerReturnParams(searchParams: Record<string, unknown>): Record<string, string> {
+ const params: Record<string, string> = {}
+ // `tab` and `q` (the Search tab's query) sit alongside the observations table's own params.
+ for (const key of ['tab', 'q', ...OBSERVATION_LIST_URL_PARAM_KEYS]) {
+ const value = searchParams[key]
+ // The router coerces a param by shape: `page=2` to a number, `q=true` to a boolean. Keep every
+ // scalar and stringify it; dropping the coerced ones would lose that filter on the way back.
+ if (typeof value === 'string' ? value !== '' : typeof value === 'number' || typeof value === 'boolean') {
+ params[key] = String(value)
+ }
+ }
+ return params
}
/** The crumb the observation page's back button returns to. */
-export function observationParentBreadcrumb(observation: ReplayObservationApi): Breadcrumb {
+export function observationParentBreadcrumb(
+ observation: ReplayObservationApi,
+ returnParams: Record<string, string | number> = {}
+): Breadcrumb {
if (hasScannerPage(observation)) {
- return scannerBreadcrumb(observation.scanner_id, scannerLabel(observation))
+ return scannerBreadcrumb(observation.scanner_id, scannerLabel(observation), returnParams)
}
return {
key: `recording-${observation.session_id}`,
@@ -182,7 +208,9 @@ export const replayObservationLogic = kea<replayObservationLogicType>([
actions.loadObservationSuccess(response)
// Point the breadcrumb at whatever owns this observation, so "back" returns there
// instead of the vision home.
- replayObservationSceneLogic().actions.setParentBreadcrumb(observationParentBreadcrumb(response))
+ replayObservationSceneLogic().actions.setParentBreadcrumb(
+ observationParentBreadcrumb(response, scannerReturnParams(router.values.searchParams))
+ )
} catch (error: any) {
// Only toast the initial load — background poll retries would otherwise spam one toast per tick.
if (!values.observation) {
@@ -212,6 +240,9 @@ export const replayObservationLogic = kea<replayObservationLogicType>([
if (!observation) {
return
}
+ // Land on the unfiltered parent, not the reader's saved list view: the replacement is
+ // pending with no verdict yet, so a filtered or paged list would hide the row we just
+ // promised appears "shortly".
router.actions.push(observationParentUrl(observation))
},
diff --git a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
index 640eff431501..b3a668d63cdf 100644
--- a/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/replayScannerLogic.ts
@@ -73,6 +73,7 @@ import {
reconcileVariantKey,
} from './experimentTargeting'
import { consumeGoalDraftIntent } from './goalDraftIntent'
+import { ReplayScannerTab } from './replayScannerSceneLogic'
import { clearScannerDraft, readScannerDraft, writeScannerDraft } from './scannerDraft'
import {
SCANNER_EDITOR_STEPS,
@@ -87,6 +88,7 @@ import { availableTagsFromStats, daysFromDateRange, deriveObservationStatusStats
import { findScannerTemplate, newScanner } from './scannerTemplates'
import {
MAX_CREDIT_LIMIT,
+ OBSERVATION_LIST_URL_PARAM_KEYS,
SamplingMode,
ScannerConfig,
defaultScannerName,
@@ -112,6 +114,8 @@ const OBSERVATION_TRIGGERED_BY_VALUES: readonly ObservationTriggeredByValue[] =
const OBSERVATION_VERDICT_VALUES: readonly ObservationVerdictValue[] = ['yes', 'no', 'inconclusive']
export const OBSERVATIONS_PAGE_SIZE = 50
+/** Newest first: the sort the table falls back to, and the one the URL leaves out. */
+const DEFAULT_OBSERVATIONS_SORT: ObservationsSorting = { columnKey: 'created_at', order: -1 }
// Past this many rows the clipboard is the wrong tool.
const COPY_ALL_OBSERVATIONS_LIMIT = 500
@@ -243,6 +247,25 @@ function observationFilterParams(
return params
}
+/**
+ * The observations table's filter + sort + page as URL query params. The scanner page's URL sync and
+ * the observation detail links both build from this, so the view a reader returns to via "back" is by
+ * construction the same one the list URL writes.
+ */
+export function observationListUrlParams(
+ values: ObservationFilterValues & { observationsSort: ObservationsSorting | null; observationsPage: number }
+): Record<string, string | number> {
+ const params: Record<string, string | number> = { ...observationFilterParams(values) }
+ const sort = serializeSortParam(values.observationsSort, DEFAULT_OBSERVATIONS_SORT)
+ if (sort) {
+ params.sort = sort
+ }
+ if (values.observationsPage > 1) {
+ params.page = values.observationsPage
+ }
+ return params
+}
+
/** Translate kea filter + sort state into the query params accepted by the list and stats endpoints. */
export function buildObservationListParams(
values: ObservationFilterValues & {
@@ -690,6 +713,7 @@ export interface replayScannerLogicMeta {
observationBackfillFilter: string | null
) => boolean
observationDetailLinkParams: (
+ observationsPage: number,
observationStatusFilter: ObservationStatusEnumApi[],
observationTriggeredByFilter: ObservationTriggerEnumApi[],
observationVerdictFilter: ObservationVerdictValue[],
@@ -1356,9 +1380,11 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
dateTo !== null ||
backfillFilter !== null,
],
- // Carried into observation detail links so server-computed prev/next neighbors honor the table's filters + sort.
+ // Carried into observation detail links so server-computed prev/next neighbors honor the table's
+ // filters + sort, and so the observation page can send the reader back to this exact view.
observationDetailLinkParams: [
(s) => [
+ s.observationsPage,
s.observationStatusFilter,
s.observationTriggeredByFilter,
s.observationVerdictFilter,
@@ -1373,6 +1399,7 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
s.scanner,
],
(
+ observationsPage: number,
observationStatusFilter: ObservationStatusValue[],
observationTriggeredByFilter: ObservationTriggeredByValue[],
observationVerdictFilter: ObservationVerdictValue[],
@@ -1385,8 +1412,8 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
observationBackfillFilter: string | null,
observationsSort: ObservationsSorting | null,
scanner: ReplayScanner | null
- ): Record<string, string | number> =>
- buildObservationListParams({
+ ): Record<string, string | number> => {
+ const listValues = {
observationStatusFilter,
observationTriggeredByFilter,
observationVerdictFilter,
@@ -1398,8 +1425,23 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
observationDateTo,
observationBackfillFilter,
observationsSort,
+ observationsPage,
scanner,
- }) as Record<string, string | number>,
+ }
+ // The same filter + sort + page the list URL carries, so "back" restores this exact view.
+ const params: Record<string, string | number> = {
+ ...observationListUrlParams(listValues),
+ tab: ReplayScannerTab.Observations,
+ }
+ // Prev/next reads `order_by` (an API key) to fetch neighbors in the table's order. It
+ // rides alongside `sort` because the observation page can't map `sort` to `order_by`
+ // itself: resolveOrderByKey needs the scanner type, unknown until the observation loads.
+ const orderBy = buildObservationListParams(listValues).order_by
+ if (orderBy) {
+ params.order_by = orderBy
+ }
+ return params
+ },
],
// Tag options for the observations-list Tag filter pill. Wrapped in an inline arrow with an
// explicit return type so kea-typegen can infer it (it can't from bare function references).
@@ -2111,27 +2153,24 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
}),
actionToUrl(({ values }) => {
- const buildSearchParams = (): Record<string, string | undefined> => {
- const next = { ...router.values.searchParams } as Record<string, string | undefined>
- for (const key of TABLE_URL_PARAM_KEYS) {
+ const buildSearchParams = (): Record<string, string | number | undefined> => {
+ const next = { ...router.values.searchParams } as Record<string, string | number | undefined>
+ // Clear the table's keys, then re-add only the ones the current state sets, so a cleared
+ // filter or a return to page 1 drops its param rather than lingering.
+ for (const key of OBSERVATION_LIST_URL_PARAM_KEYS) {
delete next[key]
}
- if (values.observationsPage > 1) {
- next.page = String(values.observationsPage)
- }
- const sort = values.observationsSort
- next.sort = serializeSortParam(sort, { columnKey: 'created_at', order: -1 })
- Object.assign(next, observationFilterParams(values))
+ Object.assign(next, observationListUrlParams(values))
return next
}
- const writeUrl = (): [string, Record<string, string | undefined>] => [
+ const writeUrl = (): [string, Record<string, string | number | undefined>] => [
router.values.location.pathname,
buildSearchParams(),
]
// Replace (not push) so typing in the subject search doesn't spam browser history.
const writeUrlReplace = (): [
string,
- Record<string, string | undefined>,
+ Record<string, string | number | undefined>,
Record<string, string>,
{ replace: boolean },
] => [router.values.location.pathname, buildSearchParams(), {}, { replace: true }]
@@ -2155,7 +2194,7 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
[urls.replayVision(props.id)]: (_, searchParams) => {
const pageRaw = Number(searchParams.page ?? 1)
const page = Number.isFinite(pageRaw) ? Math.max(1, pageRaw) : 1
- const sort = parseSortParam(searchParams.sort) ?? { columnKey: 'created_at', order: -1 }
+ const sort = parseSortParam(searchParams.sort) ?? DEFAULT_OBSERVATIONS_SORT
const status = parseCsvParam<ObservationStatusValue>(searchParams.status, OBSERVATION_STATUS_VALUES)
const triggeredBy = parseCsvParam<ObservationTriggeredByValue>(
searchParams.triggered_by,
@@ -2250,24 +2289,6 @@ export const replayScannerLogic = kea<replayScannerLogicType>([
}),
])
-const TABLE_URL_PARAM_KEYS = [
- 'page',
- 'sort',
- 'status',
- 'triggered_by',
- 'verdict',
- 'tags',
- 'min_score',
- 'max_score',
- 'recording_subject',
- 'date_from',
- 'date_to',
- 'backfill_id',
-] as const
-
-/** Observation-filter params the scanner page reads from the URL; links into the Observations tab build from these keys. */
-export type ObservationsUrlParams = Partial<Record<(typeof TABLE_URL_PARAM_KEYS)[number], string>>
-
/** The step URLs of a scanner's editor wizard. */
function scannerEditorPaths(scannerId: string): string[] {
return [
diff --git a/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.ts b/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.ts
index c5426a068477..9981a711c7bf 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerEditorSceneLogic.ts
@@ -193,7 +193,7 @@ export const scannerEditorSceneLogic = kea<scannerEditorSceneLogicType>([
}
// Editing an existing scanner: surface the detail page (on its Configuration tab, where the
// Edit button lives) as an intermediate crumb so the back arrow returns there, not to the list.
- crumbs.push(scannerBreadcrumb(scannerId, null, 'configuration'), {
+ crumbs.push(scannerBreadcrumb(scannerId, null, { tab: 'configuration' }), {
key: `scanner-${scannerId}-edit`,
name: 'Edit',
path: urls.replayVisionScannerConfigure(scannerId),
diff --git a/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts b/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts
index 29978d867222..61f1866c7a16 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerOverviewLogic.ts
@@ -31,7 +31,7 @@ import {
import type { ObservationStatsApi, ScannerImpactApi } from '../generated/api.schemas'
import { scheduleObservationPoll } from '../logics/observationPolling'
import { replayScannerLogic } from './replayScannerLogic'
-import type { ObservationVerdictValue, ObservationsUrlParams } from './replayScannerLogic'
+import type { ObservationVerdictValue } from './replayScannerLogic'
import type { ClassifierTagStats, CoverageStats, MonitorStats, ScorerHistogram, ScorerSummary } from './scannerStats'
import {
availableTagsFromStats,
@@ -43,7 +43,13 @@ import {
deriveScorerSummary,
isAwaitingFirstResults,
} from './scannerStats'
-import { type ReplayScanner, type ScannerFormValues, type ScannerType, scannerFromApi } from './types'
+import {
+ type ObservationsUrlParams,
+ type ReplayScanner,
+ type ScannerFormValues,
+ type ScannerType,
+ scannerFromApi,
+} from './types'
export interface ScannerOverviewLogicProps {
scannerId: string
diff --git a/products/replay_vision/frontend/replay_scanners/types.ts b/products/replay_vision/frontend/replay_scanners/types.ts
index ac375aa6aa6a..c0680c2c10cc 100644
--- a/products/replay_vision/frontend/replay_scanners/types.ts
+++ b/products/replay_vision/frontend/replay_scanners/types.ts
@@ -47,6 +47,28 @@ export const OBSERVATION_LIST_FILTER_KEYS: readonly (keyof VisionObservationsRet
'order_by',
]
+/**
+ * The observations table's state as it lives in the scanner page URL: filters, sort, and page.
+ * Links into the Observations tab build from these keys, and an observation page carries them back
+ * so returning to the list restores the view the reader left.
+ */
+export const OBSERVATION_LIST_URL_PARAM_KEYS = [
+ 'page',
+ 'sort',
+ 'status',
+ 'triggered_by',
+ 'verdict',
+ 'tags',
+ 'min_score',
+ 'max_score',
+ 'recording_subject',
+ 'date_from',
+ 'date_to',
+ 'backfill_id',
+] as const
+
+export type ObservationsUrlParams = Partial<Record<(typeof OBSERVATION_LIST_URL_PARAM_KEYS)[number], string>>
+
export type EnabledFilter = 'enabled' | 'disabled'
export type IneligibleKind =
diff --git a/products/replay_vision/frontend/search/ObservationSearchTab.tsx b/products/replay_vision/frontend/search/ObservationSearchTab.tsx
index ce7b8476add9..bec9e9225a4d 100644
--- a/products/replay_vision/frontend/search/ObservationSearchTab.tsx
+++ b/products/replay_vision/frontend/search/ObservationSearchTab.tsx
@@ -8,12 +8,13 @@ import { LemonButton, LemonInput, LemonTag, Link, Spinner } from '@posthog/lemon
import { TZLabel } from 'lib/components/TZLabel'
import { aiConsentLogic } from 'scenes/settings/organization/aiConsentLogic'
import { teamLogic } from 'scenes/teamLogic'
-import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
import { ObservationResultSummary } from '../components/ObservationCard'
import { ScannerTypeBadge } from '../components/ScannerTypeBadge'
import type { ObservationSearchResultApi } from '../generated/api.schemas'
+import { observationDetailUrl } from '../observations/replayObservationLogic'
+import { ReplayScannerTab } from '../replay_scanners/replayScannerSceneLogic'
import type { ReplayScanner } from '../replay_scanners/types'
import { scannerLabel } from '../utils/observation'
import { observationSearchLogic } from './observationSearchLogic'
@@ -95,17 +96,19 @@ function SearchResultCard({
searchedQuery,
showScanner,
strongMatch,
+ returnParams,
}: {
result: ObservationSearchResultApi
searchedQuery: string
showScanner: boolean
strongMatch: boolean
+ returnParams: Record<string, string>
}): JSX.Element {
const observation = result.observation
const snapshot = observation.scanner_snapshot
return (
<Link
- to={urls.replayVisionObservation(observation.id)}
+ to={observationDetailUrl(observation.id, returnParams)}
className="block border rounded p-3 bg-surface-primary hover:border-accent space-y-2 text-primary"
data-attr="vision-search-result"
>
@@ -168,6 +171,9 @@ export function ObservationSearchTab({ scanner }: { scanner: ReplayScanner | nul
} = useValues(logic)
const { setQuery, search } = useActions(logic)
const crossScanner = scanner === null
+ // A scanner-scoped search lives in the scanner URL, so a result can point back at the query it came from.
+ const returnParams: Record<string, string> =
+ crossScanner || !searchedQuery ? {} : { tab: ReplayScannerTab.Search, q: searchedQuery }
const tryQueries = suggestedQueries.length > 0 ? suggestedQueries : exampleQueries(scanner)
const runQuery = (value: string): void => {
setQuery(value)
@@ -258,6 +264,7 @@ export function ObservationSearchTab({ scanner }: { scanner: ReplayScanner | nul
result={result}
searchedQuery={searchedQuery ?? ''}
showScanner={crossScanner}
+ returnParams={returnParams}
strongMatch={
strongMatchDistanceCutoff !== null &&
result.distance <= strongMatchDistanceCutoff
diff --git a/products/replay_vision/frontend/utils/breadcrumbs.ts b/products/replay_vision/frontend/utils/breadcrumbs.ts
index d95282f965dc..8cd4cc5c3e09 100644
--- a/products/replay_vision/frontend/utils/breadcrumbs.ts
+++ b/products/replay_vision/frontend/utils/breadcrumbs.ts
@@ -1,3 +1,5 @@
+import { combineUrl } from 'kea-router'
+
import { urls } from 'scenes/urls'
import { Breadcrumb } from '~/types'
@@ -10,12 +12,17 @@ export const VISION_ROOT_BREADCRUMB: Breadcrumb = {
iconType: 'replay_vision',
}
-/** A crumb pointing at a saved scanner's page, optionally deep-linked to one of its tabs. */
-export function scannerBreadcrumb(scannerId: string, name?: string | null, tab?: string): Breadcrumb {
+/** A crumb pointing at a saved scanner's page, optionally deep-linked to one of its tabs and its state. */
+export function scannerBreadcrumb(
+ scannerId: string,
+ name?: string | null,
+ searchParams?: Record<string, string | number>
+): Breadcrumb {
const path = urls.replayVision(scannerId)
return {
key: `scanner-${scannerId}`,
name: name || 'Scanner',
- path: tab ? `${path}?tab=${tab}` : path,
+ // combineUrl with no params returns the path unchanged, so the empty case needs no guard.
+ path: combineUrl(path, searchParams ?? {}).url,
}
}