: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
fix(aio): Make playground section headers accessible toggles (#110706)
Juraj Majerikecdd1b21009f
diff --git a/products/ai_observability/frontend/playground/AIObservabilityPlaygroundScene.tsx b/products/ai_observability/frontend/playground/AIObservabilityPlaygroundScene.tsxindex 198122e9d758..9fc3de77409f 100644--- a/products/ai_observability/frontend/playground/AIObservabilityPlaygroundScene.tsx+++ b/products/ai_observability/frontend/playground/AIObservabilityPlaygroundScene.tsx@@ -3,7 +3,6 @@ import posthog from 'posthog-js'import React from 'react'import {- IconChevronRight,IconGear,IconPencil,IconPlay,@@ -49,6 +48,7 @@ import { JSONEditor } from '../components/JSONEditor'import { MetadataHeader } from '../ConversationDisplay/MetadataHeader'import { getModelPickerFooterLink, ModelPicker, parsePlaygroundProviderKeyId } from '../ModelPicker'import { modelPickerLogic } from '../modelPickerLogic'+import { CollapsibleChevronIcon } from './CollapsibleChevronIcon'import { llmPlaygroundModelLogic } from './llmPlaygroundModelLogic'import {getLinkedSourceLabel,@@ -91,17 +91,6 @@ const EXAMPLE_TOOL = [},]-function CollapsibleChevron({ collapsed }: { collapsed: boolean }): JSX.Element {- return (- <LemonButton- size="xsmall"- noPadding- className="h-5 w-5 [&_svg]:h-3.5 [&_svg]:w-3.5"- icon={<IconChevronRight className={`transition-transform ${collapsed ? 'rotate-0' : 'rotate-90'}`} />}- />- )-}-export const scene: SceneExport = {component: AIObservabilityPlaygroundScene,logic: llmPlaygroundPromptsLogic,@@ -944,11 +933,13 @@ function SystemMessageDisplay({ promptId }: { promptId: string }): JSX.Element {/></div>- <div- className={`flex items-center gap-2 cursor-pointer ${collapsed ? 'mb-0' : 'mb-2'}`}+ <button+ type="button"+ className={`flex w-full items-center gap-2 cursor-pointer text-left ${collapsed ? 'mb-0' : 'mb-2'}`}onClick={() => toggleCollapsed(`system:${promptId}`)}+ aria-expanded={!collapsed}>- <CollapsibleChevron collapsed={collapsed} />+ <CollapsibleChevronIcon collapsed={collapsed} /><span className={`w-2 h-2 rounded-full shrink-0 ${getRoleDotClass('system')}`} /><LemonTag type="default" size="small">System@@ -965,7 +956,7 @@ function SystemMessageDisplay({ promptId }: { promptId: string }): JSX.Element {: 'No system prompt'}</span>)}- </div>+ </button><AnimatedCollapsible collapsed={collapsed}><div>@@ -1093,7 +1084,16 @@ function MessageDisplay({className={`flex items-center gap-2 cursor-pointer ${collapsed ? 'mb-0' : 'mb-2'}`}onClick={() => toggleCollapsed(messageKey)}>- <CollapsibleChevron collapsed={collapsed} />+ {/* The row click is a convenience target; this button is the accessible+ control, and its click bubbles to the row handler */}+ <button+ type="button"+ className="flex items-center cursor-pointer"+ aria-label="Toggle message"+ aria-expanded={!collapsed}+ >+ <CollapsibleChevronIcon collapsed={collapsed} />+ </button><span className={`w-2 h-2 rounded-full shrink-0 ${getRoleDotClass(message.role)}`} /><div onClick={(e) => e.stopPropagation()}><LemonSelect<MessageRole>diff --git a/products/ai_observability/frontend/playground/CollapsibleChevronIcon.tsx b/products/ai_observability/frontend/playground/CollapsibleChevronIcon.tsxnew file mode 100644index 000000000000..af24e0d977bf--- /dev/null+++ b/products/ai_observability/frontend/playground/CollapsibleChevronIcon.tsx@@ -0,0 +1,9 @@+import { IconChevronRight } from '@posthog/icons'++export function CollapsibleChevronIcon({ collapsed }: { collapsed: boolean }): JSX.Element {+ return (+ <IconChevronRight+ className={`h-3.5 w-3.5 shrink-0 transition-transform ${collapsed ? 'rotate-0' : 'rotate-90'}`}+ />+ )+}diff --git a/products/ai_observability/frontend/playground/PlaygroundVariablesPanel.tsx b/products/ai_observability/frontend/playground/PlaygroundVariablesPanel.tsxindex 4421559b6b58..0e8633073e97 100644--- a/products/ai_observability/frontend/playground/PlaygroundVariablesPanel.tsx+++ b/products/ai_observability/frontend/playground/PlaygroundVariablesPanel.tsx@@ -1,11 +1,12 @@import { useActions, useValues } from 'kea'import { Fragment } from 'react'-import { IconChevronRight, IconWarning } from '@posthog/icons'+import { IconWarning } from '@posthog/icons'import { LemonTag, LemonTextArea, Tooltip } from '@posthog/lemon-ui'import { AnimatedCollapsible } from 'lib/components/AnimatedCollapsible'+import { CollapsibleChevronIcon } from './CollapsibleChevronIcon'import { llmPlaygroundPromptsLogic } from './llmPlaygroundPromptsLogic'import { llmPlaygroundVariablesLogic } from './llmPlaygroundVariablesLogic'import { getVariableValue } from './playgroundTemplating'@@ -31,9 +32,7 @@ export function PlaygroundVariablesPanel(): JSX.Element {data-attr="llma-playground-toggle-variables"className="flex items-center gap-2 cursor-pointer text-sm font-semibold">- <IconChevronRight- className={`h-3.5 w-3.5 transition-transform ${collapsed ? 'rotate-0' : 'rotate-90'}`}- />+ <CollapsibleChevronIcon collapsed={collapsed} />Variables{detectedVariables.length > 0 ? ` (${detectedVariables.length})` : ''}</button>{unfilledVariables.length > 0 && (