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.

feat(conversations): composer header and send menu behind a flag (#113991)

Jon McCallumf090278cdb6d
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 52a4145a930a..d7ba623739eb 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -506,6 +506,7 @@ export const FEATURE_FLAGS = {
PRODUCT_SUPPORT_CREATE_TICKET: 'product-support-create-ticket', // owner: @veryayskiy #team-conversations
PRODUCT_SUPPORT_GITHUB_CHANNEL: 'product-support-github-channel', // owner: @veryayskiy #team-conversations
PRODUCT_SUPPORT_IMPORT_TICKETS: 'product-support-import-tickets', // owner: @veryayskiy #team-conversations
+ PRODUCT_SUPPORT_SIMPLIFIED_REPLIES: 'conversations-simplified-replies', // owner: @jonmcwest #team-conversations, composer header + one Send menu in place of draft mode
PRODUCT_SUPPORT_SLACK_NOTIFY_ON_MEMBERS: 'product-support-slack-notify-on-members', // owner: @veryayskiy #team-conversations
PRODUCT_SUPPORT_TEAMS_ENABLED: 'product-support-teams-enabled', // owner: @veryayskiy #team-conversations
PRODUCT_TOURS: 'product-tours-2025', // owner: @adboio #team-surveys
diff --git a/products/conversations/frontend/components/Channels/ChannelsTag.tsx b/products/conversations/frontend/components/Channels/ChannelsTag.tsx
index fc05260055c9..ca388877ef1a 100644
--- a/products/conversations/frontend/components/Channels/ChannelsTag.tsx
+++ b/products/conversations/frontend/components/Channels/ChannelsTag.tsx
@@ -34,6 +34,21 @@ export function getReplyPlaceholder(channel?: TicketChannel): string {
return label ? `Reply in ${label}...` : 'Type your message...'
}
+// Where a reply goes, as the composer header names it.
+export function getReplyDestination(channel?: TicketChannel): string {
+ const label = channel ? replyChannelLabel[channel] : undefined
+ if (label) {
+ return `Reply in ${label}`
+ }
+ if (channel === 'email') {
+ return 'Reply by email'
+ }
+ if (channel === 'widget') {
+ return 'Reply in the chat widget'
+ }
+ return 'Reply'
+}
+
export function hasReplyChannelBranding(channel?: TicketChannel): channel is TicketChannel {
return !!channel && channel in replyChannelLabel
}
diff --git a/products/conversations/frontend/components/Chat/ChatView.tsx b/products/conversations/frontend/components/Chat/ChatView.tsx
index 95bc0c91b661..7eb363087567 100644
--- a/products/conversations/frontend/components/Chat/ChatView.tsx
+++ b/products/conversations/frontend/components/Chat/ChatView.tsx
@@ -13,6 +13,7 @@ import type {
TicketChannel,
TicketStatus,
} from '../../types'
+import type { SimplifiedRepliesProps } from '../ComposerHeader/ComposerHeader'
import { MessageInput } from './MessageInput'
import { MessageList, type TimelineExtra } from './MessageList'
@@ -70,6 +71,8 @@ export interface ChatViewProps {
sendConfirmationMessage?: string
/** When provided, renders a dropdown next to the send button to send and set the ticket status in one go */
sendAndSetStatusOptions?: { value: TicketStatus; statusLabel: string }[]
+ /** Composer header and send menu in place of draft mode; see MessageInput */
+ simplifiedReplies?: SimplifiedRepliesProps
/** Other unsaved ticket edits that sending with a status would also persist */
unsavedTicketChanges?: string[]
latestAiMessageId?: string | null
@@ -122,6 +125,7 @@ export function ChatView({
onDraftModeChange,
sendConfirmationMessage,
sendAndSetStatusOptions,
+ simplifiedReplies,
unsavedTicketChanges,
latestAiMessageId,
latestAiDraftId,
@@ -195,6 +199,7 @@ export function ChatView({
onDraftModeChange={onDraftModeChange}
sendConfirmationMessage={sendConfirmationMessage}
sendAndSetStatusOptions={sendAndSetStatusOptions}
+ simplifiedReplies={simplifiedReplies}
unsavedTicketChanges={unsavedTicketChanges}
editingMessageId={editingMessageId}
onCancelEdit={onCancelEdit}
diff --git a/products/conversations/frontend/components/Chat/MessageInput.test.tsx b/products/conversations/frontend/components/Chat/MessageInput.test.tsx
index 579c02b3bc66..8ca4d9a9d050 100644
--- a/products/conversations/frontend/components/Chat/MessageInput.test.tsx
+++ b/products/conversations/frontend/components/Chat/MessageInput.test.tsx
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom'
-import { cleanup, render, screen } from '@testing-library/react'
+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { Provider } from 'kea'
@@ -19,11 +19,13 @@ jest.mock('../Editor', () => {
onPressCmdEnter,
disabled,
autoFocus,
+ header,
}: {
onCreate: (editor: unknown) => void
onPressCmdEnter: () => void
disabled?: boolean
autoFocus?: boolean
+ header?: React.ReactNode
}) => {
React.useEffect(() => {
const el = document.querySelector('[data-attr="support-editor"]') as HTMLElement | null
@@ -41,9 +43,14 @@ jest.mock('../Editor', () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
return React.createElement(
- 'button',
- { 'data-attr': 'support-editor', 'data-disabled': disabled, onClick: onPressCmdEnter },
- 'Editor shortcut'
+ React.Fragment,
+ null,
+ header,
+ React.createElement(
+ 'button',
+ { 'data-attr': 'support-editor', 'data-disabled': disabled, onClick: onPressCmdEnter },
+ 'Editor shortcut'
+ )
)
},
serializeToMarkdown: (): string => 'hello',
@@ -121,6 +128,129 @@ describe('MessageInput', () => {
expect(onSendMessage).toHaveBeenCalledTimes(1)
expect(onSendMessage).toHaveBeenCalledWith('hello', { type: 'doc' }, isPrivate, expect.any(Function), 'pending')
})
+
+ describe('simplified replies', () => {
+ function renderSimplified(onSendMessage = jest.fn()): jest.Mock {
+ render(
+ <Provider>
+ <MessageInput
+ onSendMessage={onSendMessage}
+ messageSending={false}
+ channel="slack"
+ showPrivateOption
+ draftMode
+ onDraftModeChange={jest.fn()}
+ draftContent={{ type: 'doc', content: [] }}
+ sendConfirmationMessage="This will send to the linked Slack thread"
+ sendAndSetStatusOptions={SEND_AND_SET_STATUS_OPTIONS}
+ simplifiedReplies={{ recipient: 'Ada Example', statusLabel: 'Open' }}
+ />
+ </Provider>
+ )
+ return onSendMessage
+ }
+
+ it('names the destination, recipient and status above the editor, and drops draft mode', () => {
+ renderSimplified()
+
+ const header = screen.getByTestId('composer-header')
+ expect(header).toHaveTextContent('Reply in Slack')
+ expect(header).toHaveTextContent('Ada Example')
+ expect(header).toHaveTextContent('Ticket status: Open')
+ expect(screen.queryByRole('switch')).not.toBeInTheDocument()
+ })
+
+ // Send only opens the menu: sending straight from the button would skip the confirm step this replaces.
+ it('sends nothing until a row is picked, then sends with that status', async () => {
+ const onSendMessage = renderSimplified()
+
+ await userEvent.click(screen.getByTestId('send-menu-trigger'))
+ expect(onSendMessage).not.toHaveBeenCalled()
+ expect(await screen.findByText('This will send to the linked Slack thread')).toBeInTheDocument()
+
+ await userEvent.click(screen.getByText('Send and set resolved'))
+ expect(onSendMessage).toHaveBeenCalledWith(
+ 'hello',
+ { type: 'doc' },
+ false,
+ expect.any(Function),
+ 'resolved'
+ )
+ })
+
+ test.each<[string, string, TicketStatus | undefined]>([
+ ['Enter keeps the status', '{Enter}', undefined],
+ ['a digit sets the numbered status', '2', 'on_hold'],
+ ])('%s', async (_name, keys, status) => {
+ const onSendMessage = renderSimplified()
+
+ // The editor's Cmd+Enter shortcut opens the menu instead of sending.
+ await userEvent.click(screen.getByTestId('support-editor'))
+ expect(onSendMessage).not.toHaveBeenCalled()
+ expect(await screen.findByTestId('send-menu')).toBeInTheDocument()
+
+ await userEvent.keyboard(keys)
+ expect(onSendMessage).toHaveBeenCalledTimes(1)
+ expect(onSendMessage).toHaveBeenCalledWith('hello', { type: 'doc' }, false, expect.any(Function), status)
+ })
+
+ it('Enter on a focused menu row sends with that row, not the default', async () => {
+ const onSendMessage = renderSimplified()
+
+ await userEvent.click(screen.getByTestId('support-editor'))
+ expect(await screen.findByTestId('send-menu')).toBeInTheDocument()
+
+ screen.getByText('Send and set resolved').closest('button')?.focus()
+ await userEvent.keyboard('{Enter}')
+ expect(onSendMessage).toHaveBeenCalledTimes(1)
+ expect(onSendMessage).toHaveBeenCalledWith(
+ 'hello',
+ { type: 'doc' },
+ false,
+ expect.any(Function),
+ 'resolved'
+ )
+ })
+
+ test.each<[string, string]>([
+ ['Enter', '{Enter}'],
+ ['a digit', '2'],
+ ])('%s in a field outside the composer does not send', async (_name, keys) => {
+ const onSendMessage = renderSimplified()
+ render(<input aria-label="Sidebar field" />)
+
+ await userEvent.click(screen.getByTestId('support-editor'))
+ expect(await screen.findByTestId('send-menu')).toBeInTheDocument()
+
+ screen.getByLabelText('Sidebar field').focus()
+ await userEvent.keyboard(keys)
+ expect(onSendMessage).not.toHaveBeenCalled()
+ })
+
+ test.each<[string, string]>([
+ ['an Enter that confirms', 'Enter'],
+ ['a digit that picks a candidate in', '2'],
+ ])('%s an IME composition does not send', async (_name, key) => {
+ const onSendMessage = renderSimplified()
+
+ await userEvent.click(screen.getByTestId('support-editor'))
+ expect(await screen.findByTestId('send-menu')).toBeInTheDocument()
+
+ fireEvent.keyDown(screen.getByTestId('support-editor'), { key, isComposing: true, keyCode: 229 })
+ expect(onSendMessage).not.toHaveBeenCalled()
+ })
+
+ it('goes back to the draft on Escape', async () => {
+ const onSendMessage = renderSimplified()
+
+ await userEvent.click(screen.getByTestId('support-editor'))
+ expect(await screen.findByTestId('send-menu')).toBeInTheDocument()
+
+ await userEvent.keyboard('{Escape}')
+ expect(onSendMessage).not.toHaveBeenCalled()
+ await waitFor(() => expect(screen.queryByTestId('send-menu')).not.toBeInTheDocument())
+ })
+ })
})
describe('MessageInput collapsed composer', () => {
diff --git a/products/conversations/frontend/components/Chat/MessageInput.tsx b/products/conversations/frontend/components/Chat/MessageInput.tsx
index d2ac1657fb63..fd3e79d59821 100644
--- a/products/conversations/frontend/components/Chat/MessageInput.tsx
+++ b/products/conversations/frontend/components/Chat/MessageInput.tsx
@@ -1,5 +1,5 @@
import { JSONContent } from '@tiptap/core'
-import { useEffect, useRef, useState } from 'react'
+import { useCallback, useEffect, useRef, useState } from 'react'
import { IconLock } from '@posthog/icons'
import { LemonButton, LemonCheckbox, LemonInput, LemonSwitch, Tooltip } from '@posthog/lemon-ui'
@@ -9,7 +9,9 @@ import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
import type { TicketChannel, TicketStatus } from '../../types'
import { channelIcon, getReplyPlaceholder, hasReplyChannelBranding } from '../Channels/ChannelsTag'
+import { ComposerHeader, SimplifiedRepliesProps } from '../ComposerHeader/ComposerHeader'
import { SupportEditor, serializeToMarkdown } from '../Editor'
+import { SendMenu } from '../SendMenu/SendMenu'
export interface MessageInputProps {
onSendMessage: (
@@ -61,6 +63,8 @@ export interface MessageInputProps {
threadId?: string
/** When this changes, seed the editor from draftContent even if it is already mounted. */
composerPrefillAt?: number
+ /** When set, a header names where the reply goes, and Send opens a menu of every way to send. Replaces draft mode. */
+ simplifiedReplies?: SimplifiedRepliesProps
}
export function MessageInput({
@@ -88,21 +92,27 @@ export function MessageInput({
collapseUntilActive = false,
threadId,
composerPrefillAt = 0,
+ simplifiedReplies,
}: MessageInputProps): JSX.Element {
const [isEmpty, setIsEmpty] = useState(!draftContent)
const [isUploading, setIsUploading] = useState(false)
const [localIsPrivate, setLocalIsPrivate] = useState(false)
const [composerExpanded, setComposerExpanded] = useState(false)
+ const [sendMenuOpen, setSendMenuOpen] = useState(false)
const lastThreadIdRef = useRef(threadId)
if (lastThreadIdRef.current !== threadId) {
lastThreadIdRef.current = threadId
setComposerExpanded(false)
}
const editorRef = useRef<RichContentEditorType | null>(null)
+ const composerRef = useRef<HTMLDivElement>(null)
const lastSeededEditId = useRef<string | null>(null)
const draftContentRef = useRef(draftContent)
draftContentRef.current = draftContent
const isEditing = !!editingMessageId
+ // The send menu asks before every send, so it replaces draft mode rather than adding a second confirm.
+ const draftModeActive = draftMode && !simplifiedReplies
+ const sendsThroughMenu = !!simplifiedReplies && !isEditing
useEffect(() => {
setIsEmpty(!draftContent)
@@ -226,7 +236,7 @@ export function MessageInput({
<li key={change}>{change}</li>
))}
</ul>
- {draftMode && !isPrivate && sendConfirmationMessage ? (
+ {draftModeActive && !isPrivate && sendConfirmationMessage ? (
<p>{sendConfirmationMessage}</p>
) : null}
</>
@@ -234,7 +244,7 @@ export function MessageInput({
primaryButton: { children: `${sendVerb} and save`, type: 'primary', onClick: doSend },
secondaryButton: { children: 'Cancel' },
})
- } else if (!isEditing && draftMode && !isPrivate && sendConfirmationMessage) {
+ } else if (!isEditing && draftModeActive && !isPrivate && sendConfirmationMessage) {
// Private notes are never sent externally, so they skip the draft-mode confirmation.
LemonDialog.open({
title: 'Ready to send?',
@@ -271,6 +281,28 @@ export function MessageInput({
? 'Sending is disabled'
: undefined
+ const closeSendMenu = useCallback((): void => {
+ setSendMenuOpen(false)
+ editorRef.current?.focus()
+ }, [])
+ const sendFromMenu = (statusAfterSend?: TicketStatus): void => {
+ setSendMenuOpen(false)
+ handleSubmit(statusAfterSend)
+ }
+
+ const sendButtonContent = isEditing ? (
+ 'Save'
+ ) : isPrivate ? (
+ 'Attach'
+ ) : showChannelLogo ? (
+ <span className="inline-flex items-center gap-1.5">
+ {buttonText}
+ <span className="text-sm dark:grayscale">{channelIcon[channel]}</span>
+ </span>
+ ) : (
+ buttonText
+ )
+
const showFullComposer = !collapseUntilActive || composerExpanded || !!draftContent || !!editingMessageId
if (!showFullComposer) {
@@ -288,7 +320,7 @@ export function MessageInput({
}
return (
- <div>
+ <div ref={composerRef}>
<SupportEditor
initialContent={typeof draftContent === 'string' ? null : draftContent}
placeholder={resolvedPlaceholder}
@@ -301,17 +333,29 @@ export function MessageInput({
}
}}
onUpdate={handleUpdate}
- onPressCmdEnter={() => handleSubmit()}
+ onPressCmdEnter={() => {
+ // With the send menu, the shortcut opens it rather than sending: every send is confirmed there.
+ if (!sendsThroughMenu) {
+ handleSubmit()
+ } else if (!sendBlockedReason) {
+ setSendMenuOpen(true)
+ }
+ }}
onUploadingChange={setIsUploading}
disabled={messageSending || !!sendDisabledReason}
minRows={minRows}
className={
isPrivate || isEditing
? 'bg-warning-highlight border-warning'
- : draftMode
+ : draftModeActive
? 'bg-success-highlight border-success'
: undefined
}
+ header={
+ simplifiedReplies && !isEditing ? (
+ <ComposerHeader isPrivate={isPrivate} channel={channel} {...simplifiedReplies} />
+ ) : undefined
+ }
/>
<div className="flex justify-between items-center mt-2">
{showPrivateOption ? (
@@ -334,7 +378,7 @@ export function MessageInput({
<div />
)}
<div className="flex items-center gap-2">
- {onDraftModeChange && (
+ {onDraftModeChange && !simplifiedReplies && (
<Tooltip
title={
isPrivate || isEditing
@@ -363,47 +407,56 @@ export function MessageInput({
Cancel
</LemonButton>
)}
- <LemonButton
- type="primary"
- onClick={() => handleSubmit()}
- loading={messageSending}
- disabledReason={sendBlockedReason}
- sideAction={
- !isEditing && sendAndSetStatusOptions?.length
- ? {
- 'aria-label': `${sendVerb} and set ticket status`,
- disabled: messageSending,
- disabledReason: sendBlockedReason,
- dropdown: {
- placement: 'bottom-end',
- overlay: sendAndSetStatusOptions.map((option) => (
- <LemonButton
- key={option.value}
- fullWidth
- size="small"
- onClick={() => handleSubmit(option.value)}
- >
- {`${sendVerb} and set ${option.statusLabel}`}
- </LemonButton>
- )),
- },
- }
- : undefined
- }
- >
- {isEditing ? (
- 'Save'
- ) : isPrivate ? (
- 'Attach'
- ) : showChannelLogo ? (
- <span className="inline-flex items-center gap-1.5">
- {buttonText}
- <span className="text-sm dark:grayscale">{channelIcon[channel]}</span>
- </span>
- ) : (
- buttonText
- )}
- </LemonButton>
+ {sendsThroughMenu ? (
+ <SendMenu
+ visible={sendMenuOpen}
+ onVisibilityChange={setSendMenuOpen}
+ onSend={sendFromMenu}
+ onCancel={closeSendMenu}
+ composerRef={composerRef}
+ verb={sendVerb}
+ isPrivate={isPrivate}
+ channel={channel}
+ audience={sendConfirmationMessage}
+ statusLabel={simplifiedReplies?.statusLabel}
+ statusOptions={sendAndSetStatusOptions}
+ disabledReason={sendBlockedReason}
+ loading={messageSending}
+ >
+ {sendButtonContent}
+ </SendMenu>
+ ) : (
+ <LemonButton
+ type="primary"
+ onClick={() => handleSubmit()}
+ loading={messageSending}
+ disabledReason={sendBlockedReason}
+ sideAction={
+ !isEditing && sendAndSetStatusOptions?.length
+ ? {
+ 'aria-label': `${sendVerb} and set ticket status`,
+ disabled: messageSending,
+ disabledReason: sendBlockedReason,
+ dropdown: {
+ placement: 'bottom-end',
+ overlay: sendAndSetStatusOptions.map((option) => (
+ <LemonButton
+ key={option.value}
+ fullWidth
+ size="small"
+ onClick={() => handleSubmit(option.value)}
+ >
+ {`${sendVerb} and set ${option.statusLabel}`}
+ </LemonButton>
+ )),
+ },
+ }
+ : undefined
+ }
+ >
+ {sendButtonContent}
+ </LemonButton>
+ )}
</div>
</div>
</div>
diff --git a/products/conversations/frontend/components/ComposerHeader/ComposerHeader.tsx b/products/conversations/frontend/components/ComposerHeader/ComposerHeader.tsx
new file mode 100644
index 000000000000..36f605392917
--- /dev/null
+++ b/products/conversations/frontend/components/ComposerHeader/ComposerHeader.tsx
@@ -0,0 +1,38 @@
+import { Tooltip } from '@posthog/lemon-ui'
+
+import type { TicketChannel } from '../../types'
+import { getReplyDestination } from '../Channels/ChannelsTag'
+import { ReplyIcon } from '../ReplyIcon/ReplyIcon'
+
+export interface SimplifiedRepliesProps {
+ /** Who the reply reaches, e.g. the customer's email address or name */
+ recipient?: string | null
+ /** The ticket's saved status, e.g. "Open" */
+ statusLabel?: string
+}
+
+// The editor placeholder names the channel only until the agent starts to type, so the header keeps the destination visible.
+export function ComposerHeader({
+ isPrivate,
+ channel,
+ recipient,
+ statusLabel,
+}: SimplifiedRepliesProps & { isPrivate: boolean; channel?: TicketChannel }): JSX.Element {
+ const detail = isPrivate ? 'Only your team will see this' : recipient
+ return (
+ <div className="flex items-center gap-2 px-2 py-1 text-xs" data-attr="composer-header">
+ <span className="flex text-sm">
+ <ReplyIcon isPrivate={isPrivate} channel={channel} />
+ </span>
+ <span className="font-semibold shrink-0">{isPrivate ? 'Private note' : getReplyDestination(channel)}</span>
+ {detail ? (
+ <Tooltip title={<span className="ph-no-capture">{detail}</span>}>
+ <span className="ph-no-capture truncate text-secondary min-w-0">{detail}</span>
+ </Tooltip>
+ ) : null}
+ {statusLabel ? (
+ <span className="ml-auto shrink-0 text-secondary">{`Ticket status: ${statusLabel}`}</span>
+ ) : null}
+ </div>
+ )
+}
diff --git a/products/conversations/frontend/components/Editor/SupportEditor.tsx b/products/conversations/frontend/components/Editor/SupportEditor.tsx
index 306379065879..d4859a632dec 100644
--- a/products/conversations/frontend/components/Editor/SupportEditor.tsx
+++ b/products/conversations/frontend/components/Editor/SupportEditor.tsx
@@ -159,6 +159,8 @@ export type SupportEditorProps = {
minRows?: number
className?: string
autoFocus?: boolean
+ /** Rendered inside the editor's frame, above the text */
+ header?: React.ReactNode
}
const DEFAULT_INITIAL_CONTENT: JSONContent = {
@@ -479,6 +481,7 @@ export function SupportEditor({
minRows,
className,
autoFocus = false,
+ header,
}: SupportEditorProps): JSX.Element {
const [isDragging, setIsDragging] = useState<boolean>(false)
const [ttEditor, setTTEditor] = useState<TTEditor | null>(null)
@@ -501,11 +504,18 @@ export function SupportEditor({
linkShortcutCallbackRef.current()
}, [])
+ // Extension options are fixed when the editor is created, so the shortcut reads the latest callback from a ref
+ const cmdEnterCallbackRef = useRef(onPressCmdEnter)
+ cmdEnterCallbackRef.current = onPressCmdEnter
+ const handlePressCmdEnter = useCallback(() => {
+ cmdEnterCallbackRef.current?.()
+ }, [])
+
const editor = useRichContentEditor({
extensions: [
...SUPPORT_EXTENSIONS,
Placeholder.configure({ placeholder }),
- CommandEnterExtension.configure({ onPressCmdEnter }),
+ CommandEnterExtension.configure({ onPressCmdEnter: handlePressCmdEnter }),
LinkShortcutExtension.configure({ onLinkShortcut: handleLinkShortcut }),
],
disabled,
@@ -615,6 +625,7 @@ export function SupportEditor({
onDragOver={handleDragOver}
onDrop={handleDrop}
>
+ {header}
<EditorContent
editor={editor}
className="SupportEditor__content p-2"
diff --git a/products/conversations/frontend/components/Editor/SupportEditorShortcut.test.tsx b/products/conversations/frontend/components/Editor/SupportEditorShortcut.test.tsx
new file mode 100644
index 000000000000..f43dbb3b2f29
--- /dev/null
+++ b/products/conversations/frontend/components/Editor/SupportEditorShortcut.test.tsx
@@ -0,0 +1,40 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, fireEvent, render } from '@testing-library/react'
+import { Provider } from 'kea'
+
+import { initKeaTests } from '~/test/init'
+
+import { SupportEditor } from './SupportEditor'
+
+const CONTENT = { type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: 'Hello' }] }] }
+
+describe('SupportEditor keyboard shortcuts', () => {
+ beforeEach(() => {
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ cleanup()
+ })
+
+ it('Cmd+Enter calls the onPressCmdEnter from the latest render', () => {
+ const fromFirstRender = jest.fn()
+ const fromLatestRender = jest.fn()
+ const { rerender, container } = render(
+ <Provider>
+ <SupportEditor initialContent={CONTENT} onPressCmdEnter={fromFirstRender} />
+ </Provider>
+ )
+ rerender(
+ <Provider>
+ <SupportEditor initialContent={CONTENT} onPressCmdEnter={fromLatestRender} />
+ </Provider>
+ )
+
+ fireEvent.keyDown(container.querySelector('.ProseMirror')!, { key: 'Enter', ctrlKey: true })
+
+ expect(fromLatestRender).toHaveBeenCalledTimes(1)
+ expect(fromFirstRender).not.toHaveBeenCalled()
+ })
+})
diff --git a/products/conversations/frontend/components/ReplyIcon/ReplyIcon.tsx b/products/conversations/frontend/components/ReplyIcon/ReplyIcon.tsx
new file mode 100644
index 000000000000..e5a748053bec
--- /dev/null
+++ b/products/conversations/frontend/components/ReplyIcon/ReplyIcon.tsx
@@ -0,0 +1,11 @@
+import { IconLock, IconSend } from '@posthog/icons'
+
+import type { TicketChannel } from '../../types'
+import { channelIcon } from '../Channels/ChannelsTag'
+
+export function ReplyIcon({ isPrivate, channel }: { isPrivate: boolean; channel?: TicketChannel }): JSX.Element {
+ if (isPrivate) {
+ return <IconLock />
+ }
+ return channel ? channelIcon[channel] : <IconSend />
+}
diff --git a/products/conversations/frontend/components/SendMenu/SendMenu.tsx b/products/conversations/frontend/components/SendMenu/SendMenu.tsx
new file mode 100644
index 000000000000..f7f1ade17502
--- /dev/null
+++ b/products/conversations/frontend/components/SendMenu/SendMenu.tsx
@@ -0,0 +1,143 @@
+import { useEffect } from 'react'
+
+import { IconSend } from '@posthog/icons'
+import { LemonButton, LemonMenu, LemonMenuItem, Link } from '@posthog/lemon-ui'
+
+import type { TicketChannel, TicketStatus } from '../../types'
+import { getReplyDestination } from '../Channels/ChannelsTag'
+import { ReplyIcon } from '../ReplyIcon/ReplyIcon'
+
+const DIGITS = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] as const
+
+export function SendMenu({
+ visible,
+ onVisibilityChange,
+ onSend,
+ onCancel,
+ composerRef,
+ verb,
+ isPrivate,
+ channel,
+ audience,
+ statusLabel,
+ statusOptions = [],
+ disabledReason,
+ loading,
+ children,
+}: {
+ visible: boolean
+ onVisibilityChange: (visible: boolean) => void
+ onSend: (statusAfterSend?: TicketStatus) => void
+ onCancel: () => void
+ /** The composer the shortcuts belong to */
+ composerRef: React.RefObject<HTMLElement>
+ verb: string
+ isPrivate: boolean
+ channel?: TicketChannel
+ audience?: string
+ statusLabel?: string
+ statusOptions?: { value: TicketStatus; statusLabel: string }[]
+ disabledReason?: string | JSX.Element
+ loading: boolean
+ children: React.ReactNode
+}): JSX.Element {
+ const choices = statusOptions.slice(0, DIGITS.length)
+
+ // Capture phase, so the keys never reach the editor while the menu is open (Enter would add a line).
+ useEffect(() => {
+ if (!visible) {
+ return
+ }
+ const onKeyDown = (e: KeyboardEvent): void => {
+ // Keys confirm or move inside an IME composition, so leave them to the editor. Safari reports 229.
+ if (e.metaKey || e.ctrlKey || e.altKey || e.isComposing || e.keyCode === 229) {
+ return
+ }
+ const target = e.target as HTMLElement
+ const inMenu = !!target.closest('.SendMenu')
+ // Another focused control, like a ticket sidebar field, keeps its own keys.
+ if (!inMenu && target !== document.body && !composerRef.current?.contains(target)) {
+ return
+ }
+ if (e.key === 'Enter') {
+ // A focused row inside the menu answers to Enter itself.
+ if (inMenu && target.closest('button, a')) {
+ return
+ }
+ e.preventDefault()
+ e.stopPropagation()
+ onSend()
+ return
+ }
+ if (e.key === 'Escape') {
+ e.preventDefault()
+ e.stopPropagation()
+ onCancel()
+ return
+ }
+ const index = DIGITS.indexOf(e.key as (typeof DIGITS)[number])
+ if (index !== -1 && choices[index]) {
+ e.preventDefault()
+ e.stopPropagation()
+ onSend(choices[index].value)
+ }
+ }
+ document.addEventListener('keydown', onKeyDown, true)
+ return () => document.removeEventListener('keydown', onKeyDown, true)
+ }, [visible, onSend, onCancel, choices, composerRef])
+
+ const items: LemonMenuItem[] = [
+ {
+ label: verb,
+ icon: <IconSend />,
+ keyboardShortcut: ['enter'],
+ onClick: () => onSend(),
+ },
+ ...choices.map(
+ (option, i): LemonMenuItem => ({
+ label: `${verb} and set ${option.statusLabel}`,
+ keyboardShortcut: [DIGITS[i]],
+ onClick: () => onSend(option.value),
+ })
+ ),
+ ]
+
+ return (
+ <LemonMenu
+ className="SendMenu"
+ visible={visible}
+ onVisibilityChange={onVisibilityChange}
+ closeOnClickInside={false}
+ placement="top-end"
+ items={[
+ {
+ title: (
+ <div className="min-w-80 px-2 pt-1 pb-2 border-b" data-attr="send-menu">
+ <div className="flex items-center gap-1 text-xs text-secondary">
+ <ReplyIcon isPrivate={isPrivate} channel={channel} />
+ <span>{isPrivate ? 'Private note' : getReplyDestination(channel)}</span>
+ </div>
+ <div className="ph-no-capture font-semibold">
+ {isPrivate ? 'Only your team will see this.' : audience}
+ </div>
+ {statusLabel ? (
+ <div className="text-xs text-secondary">{`Ticket status is ${statusLabel}.`}</div>
+ ) : null}
+ </div>
+ ),
+ items,
+ footer: (
+ <div className="flex items-center justify-between gap-4 px-2 pt-1 border-t text-xs text-secondary">
+ <span>Esc to go back and keep editing</span>
+ <Link onClick={onCancel}>Cancel</Link>
+ </div>
+ ),
+ },
+ ]}
+ >
+ <LemonButton type="primary" loading={loading} disabledReason={disabledReason} data-attr="send-menu-trigger">
+ {children}
+ </LemonButton>
+ </LemonMenu>
+ )
+}
diff --git a/products/conversations/frontend/scenes/settings/GeneralSection.tsx b/products/conversations/frontend/scenes/settings/GeneralSection.tsx
index 794d5c8b5a16..f4fc0af65e3e 100644
--- a/products/conversations/frontend/scenes/settings/GeneralSection.tsx
+++ b/products/conversations/frontend/scenes/settings/GeneralSection.tsx
@@ -171,7 +171,8 @@ export function GeneralSection(): JSX.Element {
</LemonCard>
</SceneSection>
<SecretApiKeySection />
- <DraftModeSection />
+ {/* The send menu confirms every send, so the draft-mode default has nothing left to set. */}
+ {!featureFlags[FEATURE_FLAGS.PRODUCT_SUPPORT_SIMPLIFIED_REPLIES] && <DraftModeSection />}
</>
)}
</>
diff --git a/products/conversations/frontend/scenes/ticket/SupportTicketScene.test.ts b/products/conversations/frontend/scenes/ticket/SupportTicketScene.test.ts
index dc6c197f728a..a6dadbaa5eaa 100644
--- a/products/conversations/frontend/scenes/ticket/SupportTicketScene.test.ts
+++ b/products/conversations/frontend/scenes/ticket/SupportTicketScene.test.ts
@@ -1,19 +1,54 @@
-import { scene } from './SupportTicketScene'
+import type { Ticket } from '../../types'
+import { scene, simplifiedRepliesFor } from './SupportTicketScene'
-describe('SupportTicketScene paramsToProps', () => {
- // supportTicketSceneLogic is keyed via `key((props) => props.id)`. App.tsx binds the scene's
- // logic (and the side panel context selector reads it) using whatever `paramsToProps` returns,
- // while the rendered component separately builds `supportTicketSceneLogic({ id: ticketId })`.
- // If `paramsToProps` ever stops returning `id` matching that same value, those become two
- // different logic instances: the bound one stays empty, and the ticket detail side panel's
- // access control tab silently disappears (the reported regression this test guards).
- it('keys paramsToProps by id, matching the value the component builds its logic with', () => {
- const props = scene.paramsToProps?.({ params: { ticketId: 'ticket-123' }, searchParams: {}, hashParams: {} })
- expect(props).toEqual(expect.objectContaining({ id: 'ticket-123' }))
+describe('SupportTicketScene', () => {
+ describe('paramsToProps', () => {
+ // supportTicketSceneLogic is keyed via `key((props) => props.id)`. App.tsx binds the scene's
+ // logic (and the side panel context selector reads it) using whatever `paramsToProps` returns,
+ // while the rendered component separately builds `supportTicketSceneLogic({ id: ticketId })`.
+ // If `paramsToProps` ever stops returning `id` matching that same value, those become two
+ // different logic instances: the bound one stays empty, and the ticket detail side panel's
+ // access control tab silently disappears (the reported regression this test guards).
+ it('keys paramsToProps by id, matching the value the component builds its logic with', () => {
+ const props = scene.paramsToProps?.({
+ params: { ticketId: 'ticket-123' },
+ searchParams: {},
+ hashParams: {},
+ })
+ expect(props).toEqual(expect.objectContaining({ id: 'ticket-123' }))
+ })
+
+ it('falls back to the "new" ticket key when no ticketId param is present', () => {
+ const props = scene.paramsToProps?.({ params: {}, searchParams: {}, hashParams: {} })
+ expect(props).toEqual(expect.objectContaining({ id: 'new' }))
+ })
})
- it('falls back to the "new" ticket key when no ticketId param is present', () => {
- const props = scene.paramsToProps?.({ params: {}, searchParams: {}, hashParams: {} })
- expect(props).toEqual(expect.objectContaining({ id: 'new' }))
+ describe('simplifiedRepliesFor', () => {
+ const slackTicket = (name: unknown): Ticket => ({
+ id: 'ticket-1',
+ ticket_number: 1,
+ distinct_id: 'distinct-1',
+ status: 'open',
+ channel_source: 'slack',
+ anonymous_traits: {},
+ identity_verified: false,
+ ai_resolved: false,
+ created_at: '2026-06-12T00:00:00Z',
+ updated_at: '2026-06-12T00:00:00Z',
+ message_count: 1,
+ last_message_at: '2026-06-12T00:00:00Z',
+ last_message_text: 'Hello',
+ unread_team_count: 0,
+ unread_customer_count: 0,
+ person: { id: 'person-1', name: '', distinct_ids: ['distinct-1'], properties: { name } },
+ })
+
+ test.each<[string, unknown, string]>([
+ ['a string name as typed', 'Ada Example', 'Ada Example'],
+ ['an object name as JSON text', { first: 'Ada', last: 'Example' }, '{"first":"Ada","last":"Example"}'],
+ ])('shows %s', (_name, name, expected) => {
+ expect(simplifiedRepliesFor(slackTicket(name), '').recipient).toBe(expected)
+ })
})
})
diff --git a/products/conversations/frontend/scenes/ticket/SupportTicketScene.tsx b/products/conversations/frontend/scenes/ticket/SupportTicketScene.tsx
index beff73146bf8..0eaf6c856db9 100644
--- a/products/conversations/frontend/scenes/ticket/SupportTicketScene.tsx
+++ b/products/conversations/frontend/scenes/ticket/SupportTicketScene.tsx
@@ -9,8 +9,10 @@ import { AccessControlAction } from 'lib/components/AccessControlAction'
import { Resizer } from 'lib/components/Resizer/Resizer'
import { ResizerLogicProps, resizerLogic } from 'lib/components/Resizer/resizerLogic'
import { TZLabel } from 'lib/components/TZLabel'
+import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
import { LemonCalendarSelectInput } from 'lib/lemon-ui/LemonCalendar/LemonCalendarSelect'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { getAccessControlDisabledReason, accessLevelSatisfied } from 'lib/utils/accessControlUtils'
import { newInternalTab } from 'lib/utils/newInternalTab'
import { SceneExport } from 'scenes/sceneTypes'
@@ -28,11 +30,18 @@ import { PersonDisplay } from 'products/persons/frontend/components/PersonDispla
import { AssigneeIconDisplay, AssigneeLabelDisplay, AssigneeSelect } from '../../components/Assignee'
import { ChannelsTag, getChannelThreadUrl } from '../../components/Channels/ChannelsTag'
import { ChatView } from '../../components/Chat/ChatView'
+import type { SimplifiedRepliesProps } from '../../components/ComposerHeader/ComposerHeader'
import { SupportMarkdown } from '../../components/Editor'
import { IdentityBadge } from '../../components/IdentityBadge/IdentityBadge'
import { SlaDisplay } from '../../components/SlaDisplay/SlaDisplay'
import { TicketTags } from '../../components/TicketTags'
-import { type TicketPriority, type TicketStatus, priorityOptions, statusOptionsWithoutAll } from '../../types'
+import {
+ type Ticket,
+ type TicketPriority,
+ type TicketStatus,
+ priorityOptions,
+ statusOptionsWithoutAll,
+} from '../../types'
import { AIPanel } from './AIPanel'
import { ExceptionsPanel } from './ExceptionsPanel'
import { PreviousTicketsPanel } from './PreviousTicketsPanel'
@@ -75,6 +84,21 @@ const SEND_AND_SET_STATUS_OPTIONS: { value: TicketStatus; statusLabel: string }[
{ value: 'resolved', statusLabel: 'resolved' },
]
+export function simplifiedRepliesFor(ticket: Ticket, emailRecipients: string): SimplifiedRepliesProps {
+ const customer =
+ ticket.person?.properties?.name ||
+ ticket.person?.properties?.email ||
+ ticket.anonymous_traits?.name ||
+ ticket.anonymous_traits?.email ||
+ null
+ // Person properties and traits can hold any JSON value, and React cannot render an object.
+ const customerText = customer === null || typeof customer === 'string' ? customer : JSON.stringify(customer)
+ return {
+ recipient: ticket.channel_source === 'email' ? emailRecipients : customerText,
+ statusLabel: statusOptionsWithoutAll.find((option) => option.value === ticket.status)?.label,
+ }
+}
+
export function SupportTicketScene({ ticketId }: { ticketId: string }): JSX.Element {
const logic = supportTicketSceneLogic({ id: ticketId || 'new' })
const {
@@ -144,6 +168,8 @@ export function SupportTicketScene({ ticketId }: { ticketId: string }): JSX.Elem
} = useActions(logic)
const { user } = useValues(userLogic)
+ const { featureFlags } = useValues(featureFlagLogic)
+ const simplifiedReplies = !!featureFlags[FEATURE_FLAGS.PRODUCT_SUPPORT_SIMPLIFIED_REPLIES]
const { currentTeam } = useValues(teamLogic)
const aiSuggestionsEnabled = !!currentTeam?.conversations_settings?.ai_suggestions_enabled
@@ -287,6 +313,11 @@ export function SupportTicketScene({ ticketId }: { ticketId: string }): JSX.Elem
onDraftModeChange={setDraftModeEnabled}
sendConfirmationMessage={`This will send to ${replyRecipientDescription}`}
sendAndSetStatusOptions={ticket ? SEND_AND_SET_STATUS_OPTIONS : undefined}
+ simplifiedReplies={
+ simplifiedReplies && ticket
+ ? simplifiedRepliesFor(ticket, replyRecipientDescription)
+ : undefined
+ }
unsavedTicketChanges={unsavedTicketChanges}
replyDisabledReason={replyDisabledReason}
sendDisabledReason={sendDisabledReason}