: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(user_interviews): render interview transcripts as chat bubbles (#60683)
Paul D'Ambrac797b0b45fe8
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex fb77011fdbff..b08cd37214c2 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1939,7 +1939,7 @@ snapshots:filters-taxonomic-filter-headless--properties--dark:hash: v1.k794b7964.4ee695e5751c6f73e9742ab0cfeecf61b5adfe829cf3a0d49ab2877cae8b212f.jPN9l5TDgLRy9NzHenXHCU903UDg8-GdeGpf4PXt7aAfilters-taxonomic-filter-headless--properties--light:- hash: v1.k794b7964.bd715b36b456df8730e934366a35faed4556dffa881456db1272e2804047a036.IH74-bf3miZ6nC3E0bqbzIb0km4fBh97_2XubTpcmns+ hash: v1.k794b7964.7af6b884e5d826df422db99e4a99d2172f3316561a499dbe386ea098b1fc54a9.rti2DMpqC0WEtd_AtG838vQlgQMHfwjBAR4uLN_HnUkfilters-taxonomic-filter-headless--suggested-filters-with-recents--dark:hash: v1.k794b7964.c3a6cd419610bc486261efa753816547f080f00c838bde0b8720cf12067b3b22.nxBtExiDfJ3USkhV9RY1VPU_U2dGyEYCMFbhvtOcuVsfilters-taxonomic-filter-headless--suggested-filters-with-recents--light:@@ -5990,6 +5990,38 @@ snapshots:hash: v1.k794b7964.5fd9cfd154dfac9e92c492b11d72f4b26f8f6c91b073d7b8c728ecbcb8f699e4.Y7xIgQfsOCcp9HiLZaExdWRFGE7WFst8c13z8uM8tMEscenes-app-surveys-surveyresponsekeysreference--webhook--light:hash: v1.k794b7964.9b5c484a3a1bd7a09c266a1f164e3ed9eef3ffabbcd12253f0843b3f0b69a808.cc6Rai2vShlFJA_KypMbVcc1IIaVX0nTcZ29RPEEZjo+ scenes-app-user-interviews-transcript-chat--assistant-and-interviewee--dark:+ hash: v1.k794b7964.084b950f4b470d0061709a6a85c831da13309784821c2cf312b55fc3883868a0.JNwWroG3W7Lch3VlcXPjsNk_QDOHTbXyTHl9ytGr79E+ scenes-app-user-interviews-transcript-chat--assistant-and-interviewee--light:+ hash: v1.k794b7964.1a748d091961d06351e8c495289befa1bcd899426f3a6c9771d4d719c1c31764.wi6viN4eU0HDQNTw4Xy6Barng7ePp5PhwnjFBbfFoVY+ scenes-app-user-interviews-transcript-chat--fallback-leading-prose--dark:+ hash: v1.k794b7964.a4e38eec62022261c3cd416f47ea7d263a37883b459205bb6817ef3e41138817.RjCukgO8N4j4zE72JC-Yqaos2NXeVpjvc11FG-UGPfE+ scenes-app-user-interviews-transcript-chat--fallback-leading-prose--light:+ hash: v1.k794b7964.b809042acf99d7bf4adfce4b3186a7ffe94133dd5fc3a0d7e8e3cdfa919cb889.1RaWNsXQ5iuyJSgRW132FVlTp02kf6-9TYwYpA4smHc+ scenes-app-user-interviews-transcript-chat--fallback-no-speaker-markers--dark:+ hash: v1.k794b7964.5099e9a9e91ebfc7e069ca52524fcf9370e10f2ee892f2235176ecd1a429637d.owhccW87r03zCJN-b3NdiijL0oAp0TkUn0-cDNymRwU+ scenes-app-user-interviews-transcript-chat--fallback-no-speaker-markers--light:+ hash: v1.k794b7964.8664c56671cd5dc9fd9e7b235c9b787baea74a083b39f50ce3fc3e95a6bd29a8.KI-UnuB5FpP4x7_esYRZxeo7eLnA7PMiCaUDr9XV9cw+ scenes-app-user-interviews-transcript-chat--identifier-only--dark:+ hash: v1.k794b7964.cbe8de44e591e8f0c1bb34bb7b67171c7e73261a692203da1097e40f8da65c6b.-Fh1Xs0EiG6SxG5hpg_27JytJxG9cYRhjfiVLF09qCM+ scenes-app-user-interviews-transcript-chat--identifier-only--light:+ hash: v1.k794b7964.65d04eef2bc45e18a8b784282ab919c36b6e1a95917636a813e533c27ff11c40.Six8N1g_dQO_ALm07aAjheTlI8xcem8Xo8B3aSfJAX8+ scenes-app-user-interviews-transcript-chat--inline-no-newlines--dark:+ hash: v1.k794b7964.24e17e99ff7e9803668354820afed0ff792c2736090710bf58ab6241669e05b8.EF_CuQMwNgiHSqruknNf6dnVwKGQfAaqIke0EFEpaiY+ scenes-app-user-interviews-transcript-chat--inline-no-newlines--light:+ hash: v1.k794b7964.f6fd52089572235506900c1d33cbf47ce0dab419eb1dd767f64b0e30cc76de72.aURuiSlwcQMrPB-suC3XLDH98ucsJH6dJd-SvAok9JE+ scenes-app-user-interviews-transcript-chat--known-person--dark:+ hash: v1.k794b7964.919b0822b38cae6b1907568d0728d3e3cad94464fea90b90bf6d3875a59be9f5.5bqYUxtajmJEdM1_1wnTeP2GYli6QaH1d7Wknf-PoBk+ scenes-app-user-interviews-transcript-chat--known-person--light:+ hash: v1.k794b7964.ce9f352e02877fd32e992c32e26d970ede95561d1f7a146ac21873380f5f232d.wSLZ0twQIvUHTQQ9zGrVJKKQrz3kFohYfcfqZ1XP9lQ+ scenes-app-user-interviews-transcript-chat--non-email-identifier--dark:+ hash: v1.k794b7964.e1688d6d824d3d8cb78ac3c59f7a06cd36136238775d0de40ae10248e49348be.efKCsy7FskvtVXWW9E-JHbAFdIz7alyWw5TILuydVvg+ scenes-app-user-interviews-transcript-chat--non-email-identifier--light:+ hash: v1.k794b7964.6dc84a6aefe2eef457d4a3b1cc0d8a790c65c611bc95eb3f327414ba4ee1457c.5H8dVKoSxfH_H-HiHkWYygThHlPp2WD6B_wNHASrfYs+ scenes-app-user-interviews-transcript-chat--speaker-keyword-in-body--dark:+ hash: v1.k794b7964.eb9164b98022c22fdfc471cfcf1e07d6b748619cf5e1ba0a8b556dc4580afa2a.qdk1LJYlsSz34-0VTBskYZI0X1QEwvnS26gbZCgADlM+ scenes-app-user-interviews-transcript-chat--speaker-keyword-in-body--light:+ hash: v1.k794b7964.5d8746de3dd5d5b28a24b5e22671e46e95ce1b0fc250c4e64ac95a2b7a9acbbc.o8VKgTNssudZfeSYPC4ax6u-slSlybW82EYZRQO8S-4scenes-app-user-research-topics--search-no-results--dark:hash: v1.k794b7964.194b84216db3619fdf87c7b1e7fcb01c3006e9de717ee1a7f0a6586cd19e6430.hVr4aj9pbjvmrSYZzZqj0u5Y6htcodeHNOM44V6BEQMscenes-app-user-research-topics--search-no-results--light:diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 2fc18f06ad02..4f966fe4c8a5 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -3471,12 +3471,18 @@ importers:'@posthog/icons':specifier: '*'+ '@storybook/react':+ specifier: '*'+ version: 7.6.24([email protected])([email protected]([email protected]))([email protected])([email protected])'@types/react':specifier: 18.3.27version: 18.3.27clsx:specifier: '*'version: 1.2.1+ jest:+ specifier: '*'+ version: 30.0.5(@types/[email protected])([email protected]([email protected]))([email protected](@swc/[email protected])(@types/[email protected])([email protected]))kea:specifier: 'catalog:'version: 4.0.0-pre.5([email protected])@@ -3492,6 +3498,9 @@ importers:react:specifier: 18.3.1version: 18.3.1+ typescript:+ specifier: 6.0.3+ version: 6.0.3products/visual_review:dependencies:diff --git a/products/user_interviews/frontend/TranscriptChat.stories.tsx b/products/user_interviews/frontend/TranscriptChat.stories.tsxnew file mode 100644index 000000000000..ad2b3a11f35a--- /dev/null+++ b/products/user_interviews/frontend/TranscriptChat.stories.tsx@@ -0,0 +1,122 @@+import type { Meta, StoryObj } from '@storybook/react'++import { PersonType } from '~/types'++import { TranscriptChat } from './TranscriptChat'++const meta: Meta<typeof TranscriptChat> = {+ title: 'Scenes-App/User Interviews/Transcript Chat',+ component: TranscriptChat,+}+export default meta++type Story = StoryObj<typeof TranscriptChat>++const fakePerson: PersonType = {+ id: '1',+ uuid: '00000000-0000-0000-0000-000000000000',+ distinct_ids: ['[email protected]'],+ properties: {+ name: 'Alex Example',+ email: '[email protected]',+ },+ created_at: '2024-01-15T12:00:00Z',+ is_identified: true,+}++const multiTurnTranscript = [+ 'AI: Thanks for making the time. Mind if I ask a few questions about your workflow? Should take about five minutes.',+ 'User: Yep, go ahead.',+ "AI: I see you've created a bunch of insights in the last month through the MCP integration but never via the web UI. Do you ever use the web UI at all?",+ 'User: Honestly, just the MCP integration for me. I do most of my work inside another tool and pull data in from there.',+ 'AI: That makes sense. Walk me through the most recent thing you were trying to figure out.',+ 'User: I was trying to figure out the install rate on iOS, because it matters a lot for our product right now.',+ 'AI: Why reach for MCP for that instead of opening the dashboard yourself?',+ 'User: Having one tool that can synthesize across platforms is really valuable. I would not know where to look in the UI on my own.',+].join('\n')++const inlineNoNewlinesTranscript =+ 'AI: Hey there, thanks for joining. Could you describe a typical week for you? User: Sure, mostly product work. AI: Where do you feel the most friction? User: Honestly, switching between tools — every context switch costs me momentum.'++const speakerKeywordInBodyTranscript =+ 'AI: When you say the User: experience felt slow, do you mean the loading time or the time-to-first-interaction?\nUser: The loading time.\nAI: Got it.'++const namedSpeakerTranscript = `Assistant: Welcome. Before we dive in, could you tell me what brought you to the product?+Interviewee: A friend recommended it. We needed a way to track usage without piecing things together ourselves.+Assistant: And what does success look like for your team in the next quarter?+Interviewee: Cutting the time it takes to answer a "did this feature move the needle" question from days to minutes.`++const noSpeakerTranscript = `This transcript did not include any speaker labels — perhaps because the+transcription provider could not segment speakers. The fallback renderer+should still show this content as plain markdown so nothing is lost.++- It may even contain markdown lists.+- Or **bold text**.`++const leadingProseTranscript = `Interview started 2026-05-29 with Alex Example.+AI: Thanks for joining. Walk me through your last week.+User: Mostly product work — Monday dashboards, Tuesday writing, Thursday customer calls.`++export const KnownPerson: Story = {+ args: {+ transcript: multiTurnTranscript,+ person: fakePerson,+ identifier: '[email protected]',+ },+}++export const IdentifierOnly: Story = {+ args: {+ transcript: multiTurnTranscript,+ person: null,+ identifier: '[email protected]',+ },+}++export const InlineNoNewlines: Story = {+ args: {+ transcript: inlineNoNewlinesTranscript,+ person: fakePerson,+ identifier: '[email protected]',+ },+}++export const SpeakerKeywordInBody: Story = {+ args: {+ transcript: speakerKeywordInBodyTranscript,+ person: fakePerson,+ identifier: '[email protected]',+ },+}++export const AssistantAndInterviewee: Story = {+ args: {+ transcript: namedSpeakerTranscript,+ person: fakePerson,+ identifier: '[email protected]',+ },+}++export const FallbackNoSpeakerMarkers: Story = {+ args: {+ transcript: noSpeakerTranscript,+ person: null,+ identifier: 'unknown',+ },+}++export const FallbackLeadingProse: Story = {+ args: {+ transcript: leadingProseTranscript,+ person: fakePerson,+ identifier: '[email protected]',+ },+}++export const NonEmailIdentifier: Story = {+ args: {+ transcript: multiTurnTranscript,+ person: null,+ identifier: 'distinct_id_abc123',+ },+}diff --git a/products/user_interviews/frontend/TranscriptChat.test.tsx b/products/user_interviews/frontend/TranscriptChat.test.tsxnew file mode 100644index 000000000000..d0ef6a6e2688--- /dev/null+++ b/products/user_interviews/frontend/TranscriptChat.test.tsx@@ -0,0 +1,105 @@+import { ParsedTranscript, parseTranscript } from './parseTranscript'++const EMPTY: ParsedTranscript = { leadingText: '', turns: [] }++describe('parseTranscript', () => {+ describe.each<[string, string, ParsedTranscript]>([+ ['empty string', '', EMPTY],+ ['no speaker markers falls through to empty', 'Just some prose without any labels at all.', EMPTY],+ [+ 'single AI turn',+ 'AI: Hello there.',+ { leadingText: '', turns: [{ speaker: 'ai', name: 'AI', text: 'Hello there.' }] },+ ],+ [+ 'multi-turn newline-delimited (Vapi format)',+ 'AI: Hi.\nUser: Hello.\nAI: How are you?',+ {+ leadingText: '',+ turns: [+ { speaker: 'ai', name: 'AI', text: 'Hi.' },+ { speaker: 'user', name: 'User', text: 'Hello.' },+ { speaker: 'ai', name: 'AI', text: 'How are you?' },+ ],+ },+ ],+ [+ 'trailing newline at end of transcript is tolerated',+ 'AI: Hi.\nUser: Hello.\n',+ {+ leadingText: '',+ turns: [+ { speaker: 'ai', name: 'AI', text: 'Hi.' },+ { speaker: 'user', name: 'User', text: 'Hello.' },+ ],+ },+ ],+ [+ 'assistant and interviewee aliases',+ 'Assistant: Welcome.\nInterviewee: Thanks.',+ {+ leadingText: '',+ turns: [+ { speaker: 'ai', name: 'Assistant', text: 'Welcome.' },+ { speaker: 'user', name: 'Interviewee', text: 'Thanks.' },+ ],+ },+ ],+ [+ 'colons in turn body do not split',+ 'AI: Pick a number: any number.\nUser: Five.',+ {+ leadingText: '',+ turns: [+ { speaker: 'ai', name: 'AI', text: 'Pick a number: any number.' },+ { speaker: 'user', name: 'User', text: 'Five.' },+ ],+ },+ ],+ [+ 'speaker keyword mid-turn-body does not split',+ 'AI: How did the User: experience feel?\nUser: Good.',+ {+ leadingText: '',+ turns: [+ { speaker: 'ai', name: 'AI', text: 'How did the User: experience feel?' },+ { speaker: 'user', name: 'User', text: 'Good.' },+ ],+ },+ ],+ [+ 'lowercase prefixes are accepted',+ 'ai: Hello.\nuser: Hi.',+ {+ leadingText: '',+ turns: [+ { speaker: 'ai', name: 'ai', text: 'Hello.' },+ { speaker: 'user', name: 'user', text: 'Hi.' },+ ],+ },+ ],+ [+ 'inline turns on a single line yield one degraded turn (no newline delimiter present)',+ 'AI: Hey, Chris. User: Yep. Go ahead.',+ {+ leadingText: '',+ turns: [{ speaker: 'ai', name: 'AI', text: 'Hey, Chris. User: Yep. Go ahead.' }],+ },+ ],+ [+ 'leading prose before first speaker prefix is reported (caller falls back to markdown)',+ 'Interview started 2026-05-29.\nAI: Hi.\nUser: Hello.',+ {+ leadingText: 'Interview started 2026-05-29.',+ turns: [+ { speaker: 'ai', name: 'AI', text: 'Hi.' },+ { speaker: 'user', name: 'User', text: 'Hello.' },+ ],+ },+ ],+ ])('case: %s', (_label, input, expected) => {+ it('parses into the expected shape', () => {+ expect(parseTranscript(input)).toEqual(expected)+ })+ })+})diff --git a/products/user_interviews/frontend/TranscriptChat.tsx b/products/user_interviews/frontend/TranscriptChat.tsxnew file mode 100644index 000000000000..753696521e9c--- /dev/null+++ b/products/user_interviews/frontend/TranscriptChat.tsx@@ -0,0 +1,92 @@+import clsx from 'clsx'++import { RobotHog } from 'lib/components/hedgehogs'+import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'+import { asDisplay } from 'scenes/persons/person-utils'+import { PersonIcon } from 'scenes/persons/PersonDisplay'++import { PersonType } from '~/types'++import { TranscriptTurn, parseTranscript } from './parseTranscript'++interface TranscriptChatProps {+ transcript: string+ person: PersonType | null+ identifier: string+}++export function TranscriptChat({ transcript, person, identifier }: TranscriptChatProps): JSX.Element {+ const { leadingText, turns } = parseTranscript(transcript)++ if (turns.length === 0 || leadingText) {+ return (+ <div data-attr="transcript-chat" data-parsed="false">+ <LemonMarkdown className="text-sm leading-relaxed">{transcript}</LemonMarkdown>+ </div>+ )+ }++ return (+ <div data-attr="transcript-chat" data-parsed="true" className="flex flex-col gap-3">+ {turns.map((turn, index) => (+ <TranscriptBubble key={index} turn={turn} person={person} identifier={identifier} />+ ))}+ </div>+ )+}++interface TranscriptBubbleProps {+ turn: TranscriptTurn+ person: PersonType | null+ identifier: string+}++function TranscriptBubble({ turn, person, identifier }: TranscriptBubbleProps): JSX.Element {+ const isUser = turn.speaker === 'user'+ return (+ <div className={clsx('flex items-start gap-2', isUser ? 'flex-row-reverse' : 'flex-row')}>+ <div className="shrink-0">+ <TranscriptAvatar turn={turn} person={person} identifier={identifier} />+ </div>+ <div+ className={clsx(+ 'rounded-lg border px-3 py-2 max-w-[85%] min-w-0',+ isUser ? 'bg-accent-highlight-secondary' : 'bg-surface-primary'+ )}+ >+ <div className="text-xs font-semibold mb-1 text-muted">{labelFor(turn, person, identifier)}</div>+ <LemonMarkdown className="text-sm">{turn.text}</LemonMarkdown>+ </div>+ </div>+ )+}++function TranscriptAvatar({ turn, person, identifier }: TranscriptBubbleProps): JSX.Element {+ if (turn.speaker === 'ai') {+ return (+ <span+ className="inline-flex items-center justify-center w-8 h-8 rounded-full bg-surface-tertiary overflow-hidden"+ title={turn.name}+ >+ <RobotHog className="w-8 h-8 object-cover" />+ </span>+ )+ }++ if (turn.speaker === 'user') {+ return <PersonIcon person={effectivePerson(person, identifier)} size="md" />+ }++ return <PersonIcon displayName={turn.name} size="md" />+}++function labelFor(turn: TranscriptTurn, person: PersonType | null, identifier: string): string {+ if (turn.speaker === 'user') {+ return asDisplay(effectivePerson(person, identifier))+ }+ return turn.name+}++function effectivePerson(person: PersonType | null, identifier: string): PersonType {+ return person ?? { distinct_ids: [identifier], properties: {} }+}diff --git a/products/user_interviews/frontend/UserInterviewResponse.tsx b/products/user_interviews/frontend/UserInterviewResponse.tsxindex fabde1ff3ee0..57bb8140c755 100644--- a/products/user_interviews/frontend/UserInterviewResponse.tsx+++ b/products/user_interviews/frontend/UserInterviewResponse.tsx@@ -20,6 +20,7 @@ import { PersonType } from '~/types'import { userInterviewTopicsRetrieve, userInterviewTopicsIntervieweesList, userInterviewsList } from './generated/api'import type { UserInterviewTopicApi, IntervieweeContextApi, UserInterviewApi } from './generated/api.schemas'import { InterviewLinkCopyButton } from './InterviewLinkCopyButton'+import { TranscriptChat } from './TranscriptChat'import { userInterviewLogic } from './userInterviewLogic'export interface UserInterviewResponseProps {@@ -128,9 +129,11 @@ export function UserInterviewResponse({ topicId, responseId }: UserInterviewResp<LemonWidget title="Transcript">{interview?.transcript ? (<div className="p-4">- <LemonMarkdown className="text-sm leading-relaxed">- {interview.transcript}- </LemonMarkdown>+ <TranscriptChat+ transcript={interview.transcript}+ person={person}+ identifier={identifier}+ /></div>) : (<div className="p-4 text-muted text-center">diff --git a/products/user_interviews/frontend/parseTranscript.ts b/products/user_interviews/frontend/parseTranscript.tsnew file mode 100644index 000000000000..16b675b64951--- /dev/null+++ b/products/user_interviews/frontend/parseTranscript.ts@@ -0,0 +1,43 @@+export type TranscriptTurnSpeaker = 'ai' | 'user' | 'other'++export interface TranscriptTurn {+ speaker: TranscriptTurnSpeaker+ name: string+ text: string+}++export interface ParsedTranscript {+ leadingText: string+ turns: TranscriptTurn[]+}++const TURN_SPLIT_RE = /(?:^|\n)\s*(AI|Assistant|Interviewer|User|Interviewee):\s+/i++const AI_SPEAKER_RE = /^(AI|Assistant|Interviewer)$/i+const USER_SPEAKER_RE = /^(User|Interviewee)$/i++export function parseTranscript(transcript: string): ParsedTranscript {+ if (!transcript) {+ return { leadingText: '', turns: [] }+ }+ const parts = transcript.split(TURN_SPLIT_RE)+ if (parts.length < 3) {+ return { leadingText: '', turns: [] }+ }++ const turns: TranscriptTurn[] = []+ for (let i = 1; i < parts.length; i += 2) {+ const name = parts[i]+ const text = (parts[i + 1] ?? '').trim()+ if (!text) {+ continue+ }+ const speaker: TranscriptTurnSpeaker = AI_SPEAKER_RE.test(name)+ ? 'ai'+ : USER_SPEAKER_RE.test(name)+ ? 'user'+ : 'other'+ turns.push({ speaker, name, text })+ }+ return { leadingText: (parts[0] ?? '').trim(), turns }+}diff --git a/products/user_interviews/package.json b/products/user_interviews/package.jsonindex 85f5a47bcac6..a5c4356726b0 100644--- a/products/user_interviews/package.json+++ b/products/user_interviews/package.json@@ -12,8 +12,11 @@},"peerDependencies": {"@posthog/icons": "*",+ "@storybook/react": "*","@types/react": "*","clsx": "*",- "react": "*"+ "jest": "*",+ "react": "*",+ "typescript": "catalog:*"}}