: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(conversations): gate AI private notes behind a feature flag (#78815)
Alex V03440a8cbeab
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex 0e94d95bbfb9..5893ba3f9b34 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -441,6 +441,7 @@ export const FEATURE_FLAGS = {PRODUCT_AUTONOMY: 'product-autonomy', // owner: #team-self-drivingPRODUCT_BUSINESS_KNOWLEDGE: 'product-business-knowledge', // owner: @veryayskiy #team-conversationsPRODUCT_DATA_CATALOG: 'product-data-catalog', // owner: #team-data-modeling, gates the semantic layer (governed-metrics catalog and its agent prompt steering)+ PRODUCT_SUPPORT_AI_NOTES: 'product-support-ai-notes', // owner: @veryayskiy #team-conversations, shows AI private notes in the ticket threadPRODUCT_SUPPORT_AI_SUGGESTION: 'product-support-ai-suggestion', // owner: @veryayskiy #team-conversationsPRODUCT_SUPPORT_CREATE_TICKET: 'product-support-create-ticket', // owner: @veryayskiy #team-conversationsPRODUCT_SUPPORT_GITHUB_CHANNEL: 'product-support-github-channel', // owner: @veryayskiy #team-conversationsdiff --git a/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.test.ts b/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.test.tsindex 8be01b187d17..f2f93eace54e 100644--- a/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.test.ts+++ b/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.test.ts@@ -60,13 +60,13 @@ import { conversationsTicketsNotesPartialUpdate } from 'products/conversations/fconst submitAiFeedbackMock = api.conversationsTickets.submitAiFeedback as jest.Mock-function makeAiComment(id: string): CommentType {+function makeAiComment(id: string, isPrivate: boolean = true): CommentType {return {id,content: 'AI reply body',scope: 'conversations_ticket',item_id: 'ticket-1',- item_context: { author_type: 'AI', is_private: true },+ item_context: { author_type: 'AI', is_private: isPrivate },created_at: '2026-01-01T00:00:00Z',created_by: null,} as unknown as CommentType@@ -100,6 +100,7 @@ describe('supportTicketSceneLogic ai reply feedback', () => {submitAiFeedbackMock.mockClear()logic = supportTicketSceneLogic({ id: 'new' })logic.mount()+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.PRODUCT_SUPPORT_AI_NOTES]: true })logic.actions.setTicket(makeTicket())logic.actions.setMessages([makeAiComment('msg-ai-1')])})@@ -177,7 +178,7 @@ describe('supportTicketSceneLogic ai reply feedback', () => {})})-function makeCustomerComment(id: string, itemContext: Record<string, any>): CommentType {+function makeCustomerComment(id: string, itemContext: Record<string, any> = {}): CommentType {return {id,content: 'reply body',@@ -211,6 +212,28 @@ describe('supportTicketSceneLogic chatMessages author attribution', () => {})})+describe('supportTicketSceneLogic AI note visibility', () => {+ let logic: ReturnType<typeof supportTicketSceneLogic.build>++ beforeEach(() => {+ initKeaTests()+ logic = supportTicketSceneLogic({ id: 'new' })+ logic.mount()+ logic.actions.setTicket(makeTicket())+ })++ test.each<[string, boolean, boolean, string[]]>([+ ['hides AI private notes without the flag', false, true, ['msg-customer']],+ ['shows AI private notes with the flag', true, true, ['msg-customer', 'msg-ai']],+ ['keeps sent AI replies visible without the flag', false, false, ['msg-customer', 'msg-ai']],+ ])('%s', (_name, flagEnabled, isPrivate, expectedIds) => {+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.PRODUCT_SUPPORT_AI_NOTES]: flagEnabled })+ logic.actions.setMessages([makeCustomerComment('msg-customer'), makeAiComment('msg-ai', isPrivate)])++ expect(logic.values.chatMessages.map((m) => m.id)).toEqual(expectedIds)+ })+})+type GateTicket = Pick<Ticket, 'channel_source' | 'email_from' | 'email_to'>const emailTicket = (overrides: Partial<GateTicket> = {}): GateTicket => ({diff --git a/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.ts b/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.tsindex 660ba302f085..4e9a44b1a3ab 100644--- a/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.ts+++ b/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.ts@@ -178,6 +178,16 @@ export function getEmailReplyBlockedReason(return null}+/**+ * An AI draft the pipeline saved as an internal note, i.e. one the customer never received.+ * Gated behind PRODUCT_SUPPORT_AI_NOTES because agents who don't want the drafts read them as+ * noise. A published AI reply is not one of these: hiding what the customer already got would+ * make the thread misrepresent the conversation.+ */+export function isAiPrivateNote(message: Pick<CommentType, 'item_context'>): boolean {+ return message.item_context?.author_type === 'AI' && message.item_context?.is_private === true+}+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface supportTicketSceneLogicValues {resolveAssignee: (assignee: TicketAssignee) => Assignee // assigneeSelectLogic@@ -466,7 +476,11 @@ export interface supportTicketSceneLogicMeta {unsavedTicketChanges: string[]) => booleanhasPendingWork: (hasUnsavedChanges: boolean, editingMessageId: string | null) => boolean- chatMessages: (messages: CommentType[], ticket: Ticket | null) => ChatMessage[]+ chatMessages: (+ messages: CommentType[],+ ticket: Ticket | null,+ featureFlags: FeatureFlagsSet // featureFlagLogic+ ) => ChatMessage[]eventsQuery: (ticket: Ticket | null) => DataTableNode | nullexceptionsQuery: (ticket: Ticket | null) => DataTableNode | nulllatestAiMessage: (chatMessages: ChatMessage[]) => ChatMessage | null@@ -966,58 +980,64 @@ export const supportTicketSceneLogic = kea<supportTicketSceneLogicType>([},],chatMessages: [- (s) => [s.messages, s.ticket],- (messages: CommentType[], ticket: Ticket | null): ChatMessage[] =>- messages.map((message) => {- const authorType = message.item_context?.author_type || 'customer'- let displayName = 'Anonymous user'- if (message.created_by) {- displayName =- [message.created_by.first_name, message.created_by.last_name].filter(Boolean).join(' ') ||- message.created_by.email ||- 'Support'- } else if (authorType === 'AI') {- displayName = 'PostHog Assistant'- } else {- // Per-message author identity (e.g. Zendesk import stores each comment's own- // author) takes precedence over the ticket-level requester, so a reply from a- // second requester or an agent shows the real name instead of the ticket owner.- const messageAuthorName =- message.item_context?.author_name ||- message.item_context?.author_email ||- message.item_context?.slack_author_name ||- message.item_context?.teams_author_name ||- message.item_context?.teams_author_email ||- message.item_context?.email_from_name- if (messageAuthorName) {- displayName = messageAuthorName- } else if (authorType === 'customer') {+ (s) => [s.messages, s.ticket, s.featureFlags],+ (messages: CommentType[], ticket: Ticket | null, featureFlags: FeatureFlagsSet): ChatMessage[] => {+ const showAiNotes = !!featureFlags[FEATURE_FLAGS.PRODUCT_SUPPORT_AI_NOTES]+ return messages+ .filter((message) => showAiNotes || !isAiPrivateNote(message))+ .map((message) => {+ const authorType = message.item_context?.author_type || 'customer'+ let displayName = 'Anonymous user'+ if (message.created_by) {displayName =- ticket?.person?.properties?.name ||- ticket?.person?.properties?.email ||- ticket?.anonymous_traits?.name ||- ticket?.anonymous_traits?.email ||- 'Anonymous user'+ [message.created_by.first_name, message.created_by.last_name]+ .filter(Boolean)+ .join(' ') ||+ message.created_by.email ||+ 'Support'+ } else if (authorType === 'AI') {+ displayName = 'PostHog Assistant'} else {- // Staff message with no resolvable author (e.g. deleted ex-agent).- displayName = 'Support'+ // Per-message author identity (e.g. Zendesk import stores each comment's own+ // author) takes precedence over the ticket-level requester, so a reply from a+ // second requester or an agent shows the real name instead of the ticket owner.+ const messageAuthorName =+ message.item_context?.author_name ||+ message.item_context?.author_email ||+ message.item_context?.slack_author_name ||+ message.item_context?.teams_author_name ||+ message.item_context?.teams_author_email ||+ message.item_context?.email_from_name+ if (messageAuthorName) {+ displayName = messageAuthorName+ } else if (authorType === 'customer') {+ displayName =+ ticket?.person?.properties?.name ||+ ticket?.person?.properties?.email ||+ ticket?.anonymous_traits?.name ||+ ticket?.anonymous_traits?.email ||+ 'Anonymous user'+ } else {+ // Staff message with no resolvable author (e.g. deleted ex-agent).+ displayName = 'Support'+ }}- }- return {- id: message.id,- content: message.content || '',- richContent: message.rich_content,- authorType: authorType === 'support' ? 'human' : authorType,- authorName: displayName,- createdBy: message.created_by,- createdAt: message.created_at,- isPrivate: message.item_context?.is_private || false,- version: message.version,- emailDeliveryStatus: message.item_context?.email_delivery_status,- fromZendesk: message.item_context?.from_zendesk === true,- }- }),+ return {+ id: message.id,+ content: message.content || '',+ richContent: message.rich_content,+ authorType: authorType === 'support' ? 'human' : authorType,+ authorName: displayName,+ createdBy: message.created_by,+ createdAt: message.created_at,+ isPrivate: message.item_context?.is_private || false,+ version: message.version,+ emailDeliveryStatus: message.item_context?.email_delivery_status,+ fromZendesk: message.item_context?.from_zendesk === true,+ }+ })+ },],eventsQuery: [(s) => [s.ticket],