: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(aio): collapse the app nav while the trace view is open (#121382)
Carlos Marchalb59326907db6
diff --git a/products/ai_observability/frontend/redesign/trace/traceViewLogic.test.ts b/products/ai_observability/frontend/redesign/trace/traceViewLogic.test.tsindex f33d88d23bcb..ceb79aa19cd1 100644--- a/products/ai_observability/frontend/redesign/trace/traceViewLogic.test.ts+++ b/products/ai_observability/frontend/redesign/trace/traceViewLogic.test.ts@@ -2,6 +2,7 @@ import { expectLogic } from 'kea-test-utils'import posthog from 'posthog-js'import { resumeKeaLoadersErrors, silenceKeaLoadersErrors } from '~/initKea'+import { panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'@@ -85,6 +86,19 @@ describe('traceViewLogic', () => {return logic}+ // Regression: an override left behind on unmount keeps the nav collapsed on every other page.+ it.each([+ ['expanded', false],+ ['collapsed', true],+ ])('collapses the nav while open and restores it %s on close', async (_name, collapsedBefore) => {+ panelLayoutLogic.mount()+ panelLayoutLogic.actions.setLayoutNavCollapsedDesktop(collapsedBefore)+ const logic = await mountedLogic()+ expect(panelLayoutLogic.values.isLayoutNavCollapsed).toBe(true)+ logic.unmount()+ expect(panelLayoutLogic.values.isLayoutNavCollapsed).toBe(collapsedBefore)+ })+it('loads the trace by its encoded id with the link timestamp as the hint and derives the summary', async () => {const logic = traceViewLogic({ traceId: 'a/b', timestampHint: '2026-09-01T10:15:00Z' })logic.mount()diff --git a/products/ai_observability/frontend/redesign/trace/traceViewLogic.ts b/products/ai_observability/frontend/redesign/trace/traceViewLogic.tsindex 3607fb69f038..92282d95f313 100644--- a/products/ai_observability/frontend/redesign/trace/traceViewLogic.ts+++ b/products/ai_observability/frontend/redesign/trace/traceViewLogic.ts@@ -1,10 +1,25 @@-import { MakeLogicType, actions, afterMount, kea, key, listeners, path, props, reducers, selectors } from 'kea'+import {+ MakeLogicType,+ actions,+ afterMount,+ beforeUnmount,+ connect,+ kea,+ key,+ listeners,+ path,+ props,+ reducers,+ selectors,+} from 'kea'import { loaders } from 'kea-loaders'import posthog from 'posthog-js'import { ApiConfig, ApiError } from 'lib/api'import { urls } from 'scenes/urls'+import { panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'+import { aiObservabilityTracesNodesRetrieve, aiObservabilityTracesRetrieve } from '../../generated/api'import type { TraceApi, TraceNodeApi, TraceNodeDetailApi, TraceTimelineRowApi } from '../../generated/api.schemas'import { TraceSummaryBarProps } from './components/TraceSummaryBar'@@ -45,6 +60,13 @@ export interface traceViewLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface traceViewLogicActions {+ setLayoutNavCollapsedOverride: (+ owner: string,+ collapsed: boolean | null+ ) => {+ collapsed: boolean | null+ owner: string+ } // panelLayoutLogicloadNode: (nodeId: string,trigger: NodeLoadTrigger@@ -131,6 +153,8 @@ function toLoadFailure(error: unknown): LoadFailure {return error instanceof ApiError && error.status === 404 ? 'not_found' : 'failed'}+const layoutNavOverrideOwner = (props: TraceViewLogicProps): string => `ai-trace-${props.traceId}`+function elapsedMs(since: number): number {return Math.round(performance.now() - since)}@@ -139,6 +163,7 @@ export const traceViewLogic = kea<traceViewLogicType>([path((key) => ['products', 'ai_observability', 'frontend', 'redesign', 'trace', 'traceViewLogic', key]),props({} as TraceViewLogicProps),key((props) => props.traceId),+ connect(() => ({ actions: [panelLayoutLogic, ['setLayoutNavCollapsedOverride']] })),actions({loadNode: (nodeId: string, trigger: NodeLoadTrigger) => ({ nodeId, trigger }),nodeRequested: (nodeId: string, trigger: NodeLoadTrigger) => ({ nodeId, trigger }),@@ -314,8 +339,12 @@ export const traceViewLogic = kea<traceViewLogicType>([loadNodeFailure: ({ nodeId }) => endRead(nodeId),}}),- afterMount(({ actions }) => {+ afterMount(({ actions, props }) => {actions.loadTrace()+ actions.setLayoutNavCollapsedOverride(layoutNavOverrideOwner(props), true)+ }),+ beforeUnmount(({ actions, props }) => {+ actions.setLayoutNavCollapsedOverride(layoutNavOverrideOwner(props), null)}),// Without a hint the backend reads ai_events only, so an early read of a node from a trace past the ai_events// retention misses. The node stays loading and is read again once the trace's timestamp is known.