: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(mobile): make chat errors readable and dismiss the keyboard (#129598)
Chris Volzer14f1303007ab
diff --git a/products/mobile/docs/CHAT.md b/products/mobile/docs/CHAT.mdindex 967eda5b86f9..fed580cc9960 100644--- a/products/mobile/docs/CHAT.md+++ b/products/mobile/docs/CHAT.md@@ -341,7 +341,12 @@ The answer goes as a `permission_response` command and shows in the thread as th## Errors-- A send, answer or stop that fails shows one notice line above the composer.+`ChatErrorNotice` owns the message surface, screen-reader alert, optional recovery actions and 44pt Dismiss button.+`SessionDecisionPanel` supplies the message and callbacks. Recovery actions wrap below the message on narrow screens.+New-chat suggestions scroll above the notice and composer. Tap empty space or drag the suggestions area to dismiss the keyboard.+Tapping a suggestion still fills the draft in one tap.++- A send, answer or stop that fails shows a bordered notice above the composer, wrapping to fit its full text.A failed send also sets `unsentText`; the sheet puts it back into an empty input once.- **PostHog Desktop gate.** `run/` and `user_message` answer 403 `code_access_required` for a user the gate refuses.The message is under `error`, and the app shows it as is, because it names the reason (Startup plan, prepaid credits).diff --git a/products/mobile/docs/DESIGN.md b/products/mobile/docs/DESIGN.mdindex 9584d85dde95..e4d8f6682bd6 100644--- a/products/mobile/docs/DESIGN.md+++ b/products/mobile/docs/DESIGN.md@@ -137,6 +137,9 @@ The native build supports rotation; iOS builds use Xcode 27.1 for the full Duo d## Component inventory+`features/chat/ChatErrorNotice.tsx` provides a bordered, wrapping error message with a screen-reader alert and 44pt Dismiss button.+Optional recovery actions sit below the message and wrap on narrow screens.+| Component | File | Notes || ------------------------------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || `Pressable44` | `ui/Pressable44.tsx` | Default 6pt hit slop so 34pt visuals reach 44pt; pressed and hover background; optional haptic |diff --git a/products/mobile/docs/TESTING.md b/products/mobile/docs/TESTING.mdindex 3599f3f1027a..e9da17ed18ee 100644--- a/products/mobile/docs/TESTING.md+++ b/products/mobile/docs/TESTING.md@@ -217,6 +217,11 @@ After returning from chat, rotate a report and check that its footer stays attac## Chat navigation and header+In a new chat, fail a send with a multi-line error while the keyboard is open. Check that the full notice and Dismiss button stay above the composer without overlapping suggestions.+Tap empty space to dismiss the keyboard, refocus the draft, then drag down in the suggestions area to dismiss it again.+Repeat with larger system text. Suggestions must scroll when they do not fit, and dismissing the notice must preserve the draft.+For an unsaved draft, check that Retry save remains visible and disabled while saving. For a lost connection, check Reconnect and Dismiss.+On iOS and Android, open an existing chat and start a new chat. Both must fill the screen without asheet grabber or drag-down dismissal. Header Back and platform Back return to the previous page;a direct link falls back to the configured default page. Scroll a long thread under the title-freediff --git a/products/mobile/src/features/chat/ChatErrorNotice.tsx b/products/mobile/src/features/chat/ChatErrorNotice.tsxnew file mode 100644index 000000000000..837d36a2e529--- /dev/null+++ b/products/mobile/src/features/chat/ChatErrorNotice.tsx@@ -0,0 +1,79 @@+import type { ReactElement, ReactNode } from 'react'+import { Text, View } from 'react-native'++import { CloseIcon } from '@/ui/icons/CloseIcon'+import { Pressable44 } from '@/ui/Pressable44'+import { createStyles, useColors } from '@/ui/theme'+import { iconSizes, radii, type } from '@/ui/tokens'++interface ChatErrorNoticeProps {+ message: string+ onDismiss?: () => void+ actions?: ReactNode+ testID?: string+}++export function ChatErrorNotice({ message, onDismiss, actions, testID }: ChatErrorNoticeProps): ReactElement {+ const colors = useColors()+ const styles = useStyles()+ return (+ <View style={styles.notice} testID={testID}>+ <View style={styles.row}>+ <Text style={styles.message} accessibilityRole="alert" accessibilityLiveRegion="polite">+ {message}+ </Text>+ {onDismiss ? (+ <Pressable44+ onPress={onDismiss}+ accessibilityLabel="Dismiss"+ pressedBackground={colors.pressed}+ hitSlop={0}+ style={styles.dismiss}+ >+ <CloseIcon size={iconSizes.inline} color={colors.orange} />+ </Pressable44>+ ) : null}+ </View>+ {actions ? <View style={styles.actions}>{actions}</View> : null}+ </View>+ )+}++const useStyles = createStyles(({ colors }) => ({+ notice: {+ paddingLeft: 12,+ paddingRight: 4,+ paddingVertical: 4,+ borderWidth: 1,+ borderColor: colors.border,+ borderRadius: radii.card,+ backgroundColor: colors.background,+ },+ row: {+ flexDirection: 'row',+ alignItems: 'flex-start',+ gap: 8,+ },+ message: {+ ...type.meta,+ color: colors.orange,+ flex: 1,+ minWidth: 0,+ paddingVertical: 8,+ },+ dismiss: {+ width: 44,+ height: 44,+ flexShrink: 0,+ alignItems: 'center',+ justifyContent: 'center',+ borderRadius: radii.card,+ },+ actions: {+ flexDirection: 'row',+ flexWrap: 'wrap',+ gap: 8,+ paddingRight: 8,+ paddingBottom: 4,+ },+}))diff --git a/products/mobile/src/features/chat/ChatScreen.test.tsx b/products/mobile/src/features/chat/ChatScreen.test.tsxindex 574d7de2aeec..0b7374cfaa40 100644--- a/products/mobile/src/features/chat/ChatScreen.test.tsx+++ b/products/mobile/src/features/chat/ChatScreen.test.tsx@@ -124,6 +124,7 @@ describe('chat send preparation', () => {expect(screen.getByDisplayValue('First message')).toBeTruthy()expect(screen.getByText(draft.draftError)).toBeTruthy()expect(screen.queryByTestId('session-reconnect')).toBeNull()+ expect(screen.queryByLabelText('Dismiss')).toBeNull()fireEvent.press(screen.getByTestId('chat-draft-retry'))expect(draft.retrySave).toHaveBeenCalledTimes(1)draft.draftSaving = true@@ -138,6 +139,8 @@ describe('chat send preparation', () => {expect(screen.getByText(session.notice)).toBeTruthy()fireEvent.press(screen.getByTestId('session-reconnect'))expect(session.reconnect).toHaveBeenCalledTimes(1)+ fireEvent.press(screen.getByLabelText('Dismiss'))+ expect(session.dismissNotice).toHaveBeenCalledTimes(1)})test.each(['new', 'close', 'unmount'])('a prepared message does not send after %s', async (transition) => {let finishStorage!: (settle: (sent: boolean) => Promise<void>) => voiddiff --git a/products/mobile/src/features/chat/ChatScreen.tsx b/products/mobile/src/features/chat/ChatScreen.tsxindex c5283914b400..c5b7a0457de7 100644--- a/products/mobile/src/features/chat/ChatScreen.tsx+++ b/products/mobile/src/features/chat/ChatScreen.tsx@@ -630,8 +630,9 @@ export function ChatScreen({{showEmptyState ? (<ScrollViewstyle={styles.empty}- contentContainerStyle={{ flexGrow: 1, paddingTop: contentInset }}+ contentContainerStyle={{ flexGrow: 1, paddingTop: contentInset, paddingBottom: 16 }}keyboardShouldPersistTaps="handled"+ keyboardDismissMode="on-drag"><ChatEmptyStatereportCount={attached.length}diff --git a/products/mobile/src/features/chat/session/SessionDecisionPanel.tsx b/products/mobile/src/features/chat/session/SessionDecisionPanel.tsxindex 1341bacfef95..5fc4fe2494bb 100644--- a/products/mobile/src/features/chat/session/SessionDecisionPanel.tsx+++ b/products/mobile/src/features/chat/session/SessionDecisionPanel.tsx@@ -1,12 +1,12 @@import type { ReactElement } from 'react'import { Text, View } from 'react-native'+import { ChatErrorNotice } from '@/features/chat/ChatErrorNotice'import { DecisionRequest } from '@/features/handoff/DecisionRequest'import type { DecisionAnswerInput } from '@/model/types'-import { CloseIcon } from '@/ui/icons/CloseIcon'import { Pressable44 } from '@/ui/Pressable44'-import { createStyles, useColors } from '@/ui/theme'-import { iconSizes, type } from '@/ui/tokens'+import { createStyles } from '@/ui/theme'+import { type } from '@/ui/tokens'import type { SessionDecision } from './types'@@ -31,7 +31,6 @@ export function SessionDecisionPanel({onRetryNotice,noticePending,}: SessionDecisionPanelProps): ReactElement | null {- const colors = useColors()const styles = useStyles()if (!decision && !notice) {return null@@ -39,39 +38,41 @@ export function SessionDecisionPanel({return (<View style={styles.panel}>{notice ? (- <View style={styles.notice} testID="session-decision-notice">- <Text style={styles.noticeText}>{notice}</Text>- {onReconnect ? (- <Pressable44- onPress={onReconnect}- accessibilityLabel="Reconnect to the agent"- testID="session-reconnect"- >- <Text style={styles.reconnectText}>Reconnect</Text>- </Pressable44>- ) : null}- {onRetryNotice ? (- <Pressable44- onPress={onRetryNotice}- disabled={noticePending}- accessibilityLabel="Retry saving draft"- accessibilityState={{ disabled: noticePending, busy: noticePending }}- style={styles.retry}- testID="chat-draft-retry"- >- <Text style={styles.retryText}>{noticePending ? 'Saving…' : 'Retry save'}</Text>- </Pressable44>- ) : (- <Pressable44- onPress={onDismissNotice}- accessibilityLabel="Dismiss"- style={styles.close}- hitSlop={10}- >- <CloseIcon size={iconSizes.inline} color={colors.orange} />- </Pressable44>- )}- </View>+ <ChatErrorNotice+ message={notice}+ onDismiss={onRetryNotice ? undefined : onDismissNotice}+ testID="session-decision-notice"+ actions={+ onReconnect || onRetryNotice ? (+ <>+ {onReconnect ? (+ <Pressable44+ onPress={onReconnect}+ accessibilityLabel="Reconnect to the agent"+ style={styles.action}+ testID="session-reconnect"+ >+ <Text style={styles.actionText}>Reconnect</Text>+ </Pressable44>+ ) : null}+ {onRetryNotice ? (+ <Pressable44+ onPress={onRetryNotice}+ disabled={noticePending}+ accessibilityLabel="Retry saving draft"+ accessibilityState={{ disabled: noticePending, busy: noticePending }}+ style={styles.action}+ testID="chat-draft-retry"+ >+ <Text style={styles.actionText}>+ {noticePending ? 'Saving…' : 'Retry save'}+ </Text>+ </Pressable44>+ ) : null}+ </>+ ) : undefined+ }+ />) : null}{decision ? (<View testID="session-decision">@@ -90,29 +91,13 @@ export function SessionDecisionPanel({const useStyles = createStyles(({ colors }) => ({panel: {marginHorizontal: 10,+ marginBottom: 8,gap: 8,},- notice: {- flexDirection: 'row',- alignItems: 'center',- gap: 8,- paddingLeft: 6,- },- noticeText: {- ...type.meta,- color: colors.orange,- flex: 1,- },- reconnectText: {- ...type.meta,- color: colors.orange,- },- retry: { paddingHorizontal: 8 },- retryText: { ...type.meta, color: colors.orange },- close: {- width: 24,- height: 24,- alignItems: 'center',+ action: {+ minHeight: 44,+ paddingHorizontal: 8,justifyContent: 'center',},+ actionText: { ...type.meta, color: colors.orange },}))