Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6a2b31d
feat: add suggested follow-up skeleton
gijoe0295 May 12, 2026
7f25f5f
Merge branch 'main' of github.com:gijoe0295/App into App-89686
gijoe0295 May 13, 2026
c4ecb41
add sentry useSkeletonSpan
gijoe0295 May 13, 2026
a084d43
update skeleton design and animation
gijoe0295 May 13, 2026
2b5a6ad
fix lint
gijoe0295 May 13, 2026
7eefb90
update skeleton style
gijoe0295 May 13, 2026
9f5b01e
add tests
gijoe0295 May 13, 2026
28fb65d
update skeleton UI
gijoe0295 May 15, 2026
763836c
remove minor test
gijoe0295 May 15, 2026
7267127
Merge branch 'main' of github.com:gijoe0295/App into App-89686
gijoe0295 May 18, 2026
c249a2d
adjust skeleton speed
gijoe0295 May 18, 2026
d5cc567
Merge branch 'main' of github.com:gijoe0295/App into App-89686
gijoe0295 May 19, 2026
50db2ab
fix lint
gijoe0295 May 19, 2026
9e542a1
increase skeleton threshold
gijoe0295 May 19, 2026
f3b1320
remove redundant displayName
gijoe0295 May 19, 2026
5f01d11
fix failed tests
gijoe0295 May 19, 2026
c4f080c
fix visual glitch
gijoe0295 May 19, 2026
6ef726a
fix prettier
gijoe0295 May 19, 2026
e7993ac
pause TTL timer when offline
gijoe0295 May 25, 2026
15ba3cc
do not show skeleton when offline
gijoe0295 May 25, 2026
3c787ed
pass computed prop from parent component
gijoe0295 May 25, 2026
5bdb968
Merge branch 'main' of github.com:gijoe0295/App into App-89686
gijoe0295 May 25, 2026
50c415e
Merge branch 'main' of github.com:gijoe0295/App into App-89686
gijoe0295 May 25, 2026
c10ce4a
fix ts
gijoe0295 May 25, 2026
fd63838
fix thinking indicator flashes
gijoe0295 May 25, 2026
74fcba9
Hoist report-level subscriptions out of each message row
gijoe0295 May 28, 2026
810e995
Guard indicator clear by request context
gijoe0295 May 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ const ONYXKEYS = {
REPORT_IS_COMPOSER_FULL_SIZE: 'reportIsComposerFullSize_',
REPORT_USER_IS_TYPING: 'reportUserIsTyping_',
PENDING_CONCIERGE_RESPONSE: 'pendingConciergeResponse_',
CONCIERGE_PENDING_FOLLOWUP_LIST: 'conciergePendingFollowupList_',
REPORT_USER_IS_LEAVING_ROOM: 'reportUserIsLeavingRoom_',
SECURITY_GROUP: 'securityGroup_',
TRANSACTION: 'transactions_',
Expand Down Expand Up @@ -1335,6 +1336,7 @@ type OnyxCollectionValuesMapping = {
[ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE]: boolean;
[ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING]: OnyxTypes.ReportUserIsTyping;
[ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE]: OnyxTypes.PendingConciergeResponse;
[ONYXKEYS.COLLECTION.CONCIERGE_PENDING_FOLLOWUP_LIST]: OnyxTypes.ConciergePendingFollowupList;
[ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM]: boolean;
[ONYXKEYS.COLLECTION.SECURITY_GROUP]: OnyxTypes.SecurityGroup;
[ONYXKEYS.COLLECTION.TRANSACTION]: OnyxTypes.Transaction;
Expand Down
52 changes: 52 additions & 0 deletions src/components/ReportActionItem/FollowupListSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';
import {View} from 'react-native';
import Animated, {FadeIn} from 'react-native-reanimated';
import SkeletonRect from '@components/SkeletonRect';
import SkeletonViewContentLoader from '@components/SkeletonViewContentLoader';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useSkeletonSpan from '@libs/telemetry/useSkeletonSpan';

const BAR_HEIGHT = 40;
const BAR_PADDING = 16;
const BAR_WIDTH = 180;
const BAR_COUNT = 3;

function ActionableItemSkeleton() {
const styles = useThemeStyles();
const theme = useTheme();

return (
<View style={styles.actionableItemButtonSkeleton}>
<SkeletonViewContentLoader
height={BAR_HEIGHT}
width={BAR_WIDTH + BAR_PADDING * 2}
backgroundColor={theme.buttonHoveredBG}
foregroundColor={theme.skeletonLHNOut}
>
<SkeletonRect
transform={[{translateX: BAR_PADDING}, {translateY: BAR_PADDING}]}
width={BAR_WIDTH}
height="8"
/>
</SkeletonViewContentLoader>
</View>
);
}

function FollowupListSkeleton() {
const styles = useThemeStyles();
useSkeletonSpan('FollowupListSkeleton', {context: 'ReportScreen.ChatActionableButtons'});

return (
<Animated.View entering={FadeIn}>
<View style={[styles.gap2, styles.mt2, styles.flexColumn, styles.alignItemsStart]}>
{Array.from({length: BAR_COUNT}, (_, index) => (
<ActionableItemSkeleton key={index} />
))}
</View>
</Animated.View>
);
}

export default FollowupListSkeleton;
66 changes: 65 additions & 1 deletion src/hooks/usePendingConciergeResponse.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import {useEffect, useRef} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {applyPendingConciergeAction, discardPendingConciergeAction} from '@libs/actions/Report/SuggestedFollowup';
import {clearAgentZeroProcessingIndicator} from '@libs/actions/Report';
import {applyPendingConciergeAction, clearPendingFollowupList, discardPendingConciergeAction, hidePendingFollowupList} from '@libs/actions/Report/SuggestedFollowup';
import AgentZeroOptimisticStore, {MAX_AGE_MS} from '@libs/AgentZeroOptimisticStore';
import Log from '@libs/Log';
import {rand64} from '@libs/NumberUtils';
import type {ConciergeDraftEvent} from '@libs/Pusher/types';
import {parseFollowupsFromHtml} from '@libs/ReportActionFollowupUtils';
import tokenizeForReveal from '@libs/ReportActionFollowupUtils/tokenizeForReveal';
import {getReportActionHtml} from '@libs/ReportActionsUtils';
import {useConciergeDraftActions} from '@pages/inbox/ConciergeDraftContext';
import ONYXKEYS from '@src/ONYXKEYS';
import type {ReportAction, ReportActions} from '@src/types/onyx';
import useNetwork from './useNetwork';
import useOnyx from './useOnyx';

/** Default trickle duration. Targets ~19 chars/sec start (~7/sec end after ease-out) across a typical multi-paragraph response — visibly streaming without dragging the user past the moment they want to read. */
Expand All @@ -21,6 +25,8 @@ const TRICKLE_HARD_CAP_MS = 60_000;
const ACCELERATED_REMAINING_MS = 1_500;
/** Minimum char-level anchors before we opt into the trickle reveal. Replies under this fall back to the binary reveal at `displayAfter`. */
const MIN_TRICKLE_TOKEN_COUNT = 100;
/** Hard cap on a pending followup-list skeleton. If the server never appends a real followup-list within this window, drop the marker so the UI stops showing a perpetual skeleton. */
const PENDING_FOLLOWUP_LIST_HARD_CAP_MS = MAX_AGE_MS;

function easeOut(t: number): number {
const clamped = Math.max(0, Math.min(1, t));
Expand All @@ -32,13 +38,19 @@ function easeOut(t: number): number {
* the binary reveal at `displayAfter`. `REPORT_ACTIONS` is written at completion.
*/
function usePendingConciergeResponse(reportID: string | undefined) {
const {isOffline} = useNetwork();
const [pendingResponse] = useOnyx(`${ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE}${reportID}`);
const [pendingFollowupList] = useOnyx(`${ONYXKEYS.COLLECTION.CONCIERGE_PENDING_FOLLOWUP_LIST}${reportID}`);
const reportActionID = pendingResponse?.reportAction?.reportActionID;
const fullHtml = pendingResponse?.reportAction ? getReportActionHtml(pendingResponse.reportAction) : '';
// React Compiler auto-memoizes the selector closure and the tokenize result;
// explicit useCallback/useMemo would just shadow the compiler's analysis.
const persistedActionSelector = (actions: OnyxEntry<ReportActions>): ReportAction | undefined => (reportActionID && actions ? actions[reportActionID] : undefined);
const [persistedAction] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {selector: persistedActionSelector});
const pendingFollowupActionID = pendingFollowupList?.reportActionID;
const pendingFollowupActionSelector = (actions: OnyxEntry<ReportActions>): ReportAction | undefined =>
pendingFollowupActionID && actions ? actions[pendingFollowupActionID] : undefined;
const [pendingFollowupAction] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {selector: pendingFollowupActionSelector});
const {dispatchLocalDraftEvent} = useConciergeDraftActions();

const tokens = tokenizeForReveal(fullHtml);
Expand All @@ -65,6 +77,58 @@ function usePendingConciergeResponse(reportID: string | undefined) {
accelerateRef.current(Date.now());
}, [persistedAction]);

const lastOnlineTransitionAtRef = useRef<number>(0);
const wasOfflineRef = useRef<boolean>(isOffline);
useEffect(() => {
if (wasOfflineRef.current && !isOffline) {
lastOnlineTransitionAtRef.current = Date.now();
}
wasOfflineRef.current = isOffline;
}, [isOffline]);

// Hide the followup-list skeleton when the user is offline.
useEffect(() => {
if (!reportID || !pendingFollowupList || !!pendingFollowupList.hidden === isOffline) {
return;
}
hidePendingFollowupList(reportID, isOffline || null);
}, [reportID, isOffline, pendingFollowupList]);

// Clear the pending followup-list skeleton flag as soon as the server reply
// (with <followup-list>) overwrites the optimistic action.
// A TTL fallback guards against the case where no followup-list ever arrives
// so the skeleton won't get stuck.
useEffect(() => {
if (!reportID || !pendingFollowupList) {
return;
}
const html = pendingFollowupAction ? getReportActionHtml(pendingFollowupAction) : '';
const hardClearIndicator = () => {
// Skip clearing agent thinking indicator when a newer agent request has kicked off.
const optimisticEntry = AgentZeroOptimisticStore.getEntry(reportID);
const hasNewerRequest = !!optimisticEntry && optimisticEntry.startedAt > pendingFollowupList.createdAt;
if (!hasNewerRequest) {
clearAgentZeroProcessingIndicator(reportID);
}
Comment thread
gijoe0295 marked this conversation as resolved.
Resolved
clearPendingFollowupList(reportID);
};
if (parseFollowupsFromHtml(html)?.length) {
hardClearIndicator();
return;
}
if (isOffline) {
return;
}
const effectiveStart = Math.max(pendingFollowupList.createdAt, lastOnlineTransitionAtRef.current);
const remainingTTL = effectiveStart + PENDING_FOLLOWUP_LIST_HARD_CAP_MS - Date.now();
if (remainingTTL <= 0) {
hardClearIndicator();
return;
}
const ttlTimer = setTimeout(hardClearIndicator, remainingTTL);
return () => clearTimeout(ttlTimer);
}, [reportID, pendingFollowupList, pendingFollowupAction, isOffline]);

useEffect(() => {
if (!reportID || !reportActionID) {
return;
Expand Down
12 changes: 10 additions & 2 deletions src/hooks/useShouldSuppressConciergeIndicators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import useOnyx from './useOnyx';
import useSidePanelState from './useSidePanelState';

/**
* Returns true when thinking/typing indicators should be hidden in the side-panel
* welcome state — specifically for Concierge DMs before the user sends their first message.
* Returns true when thinking/typing indicators should be hidden. Two cases:
* 1. The side-panel welcome state — specifically Concierge DMs before the
* user sends their first message.
* 2. The followup-list pending window — between trickle completion and the
* server reply with `<followup-list>`.
*/
function useShouldSuppressConciergeIndicators(reportID: string | undefined): boolean {
const isInSidePanel = useIsInSidePanel();
const {sessionStartTime} = useSidePanelState();
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [pendingFollowupList] = useOnyx(`${ONYXKEYS.COLLECTION.CONCIERGE_PENDING_FOLLOWUP_LIST}${reportID}`);

const isConciergeChat = reportID === conciergeReportID;

Expand All @@ -29,6 +33,10 @@ function useShouldSuppressConciergeIndicators(reportID: string | undefined): boo
selector: hasUserSentMessageSelector,
});

if (pendingFollowupList) {
return true;
}

return isConciergeChat && isInSidePanel && !hasUserSentMessage;
}

Expand Down
32 changes: 30 additions & 2 deletions src/libs/actions/Report/SuggestedFollowup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,30 @@ function addOptimisticConciergeActionWithDelay(reportID: string, optimisticConci
* Called when the response has been pending too long (e.g. app was killed and restarted).
*/
function discardPendingConciergeAction(reportID: string | undefined) {
Onyx.set(`${ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE}${reportID}`, null);
Onyx.multiSet({
[`${ONYXKEYS.COLLECTION.PENDING_CONCIERGE_RESPONSE}${reportID}`]: null,
[`${ONYXKEYS.COLLECTION.CONCIERGE_PENDING_FOLLOWUP_LIST}${reportID}`]: null,
});
}

/**
* Clears the pending followup-list marker for a report so the skeleton stops rendering.
*/
function clearPendingFollowupList(reportID: string | undefined) {
if (!reportID) {
return;
}
Onyx.set(`${ONYXKEYS.COLLECTION.CONCIERGE_PENDING_FOLLOWUP_LIST}${reportID}`, null);
}

/**
* Temporarily hides the pending followup-list skeleton.
*/
function hidePendingFollowupList(reportID: string | undefined, hidden: boolean | null) {
if (!reportID) {
return;
}
Onyx.merge(`${ONYXKEYS.COLLECTION.CONCIERGE_PENDING_FOLLOWUP_LIST}${reportID}`, {hidden});
}

/**
Expand All @@ -147,7 +170,12 @@ function applyPendingConciergeAction(reportID: string | undefined, reportAction:
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
value: {[reportAction.reportActionID]: reportAction},
},
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.CONCIERGE_PENDING_FOLLOWUP_LIST}${reportID}`,
value: {reportActionID: reportAction.reportActionID, createdAt: Date.now()},
},
]);
}

export {resolveSuggestedFollowup, discardPendingConciergeAction, applyPendingConciergeAction, CONCIERGE_RESPONSE_DELAY_MS};
export {resolveSuggestedFollowup, discardPendingConciergeAction, applyPendingConciergeAction, clearPendingFollowupList, hidePendingFollowupList, CONCIERGE_RESPONSE_DELAY_MS};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {validTransactionDraftIDsSelector} from '@selectors/TransactionDraft';
import React from 'react';
import type {ActionableItem} from '@components/ReportActionItem/ActionableItemButtons';
import ActionableItemButtons from '@components/ReportActionItem/ActionableItemButtons';
import FollowupListSkeleton from '@components/ReportActionItem/FollowupListSkeleton';
import useActivePolicy from '@hooks/useActivePolicy';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDelegateAccountID from '@hooks/useDelegateAccountID';
Expand Down Expand Up @@ -37,9 +38,10 @@ type ChatActionableButtonsProps = {
action: OnyxTypes.ReportAction;
originalReportID: string | undefined;
reportID: string | undefined;
hasPendingFollowupListSkeleton: boolean;
};

function ChatActionableButtons({action, originalReportID, reportID}: ChatActionableButtonsProps) {
function ChatActionableButtons({action, originalReportID, reportID, hasPendingFollowupListSkeleton}: ChatActionableButtonsProps) {
const styles = useThemeStyles();
const actionOwnerReportID = originalReportID ?? reportID;
const [originalReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(originalReportID)}`);
Expand Down Expand Up @@ -208,6 +210,9 @@ function ChatActionableButtons({action, originalReportID, reportID}: ChatActiona
})();

if (actionableItemButtons.length === 0) {
if (hasPendingFollowupListSkeleton) {
return <FollowupListSkeleton />;
}
return null;
}

Expand Down
11 changes: 10 additions & 1 deletion src/pages/inbox/report/actionContents/ChatMessageContent.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import {hasPendingFollowupListSkeletonSelector} from '@selectors/AgentZeroChat';
import React from 'react';
import {View} from 'react-native';
import {AttachmentContext} from '@components/AttachmentContext';
import Button from '@components/Button';
import MentionReportContext from '@components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer/MentionReportContext';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import {parseFollowupsFromHtml} from '@libs/ReportActionFollowupUtils';
Expand All @@ -19,6 +21,7 @@ import {
import ReportActionItemMessage from '@pages/inbox/report/ReportActionItemMessage';
import ReportActionItemMessageEdit from '@pages/inbox/report/ReportActionItemMessageEdit';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type * as OnyxTypes from '@src/types/onyx';
import ChatActionableButtons from './ChatActionableButtons';

Expand Down Expand Up @@ -47,13 +50,18 @@ function ChatMessageContent({action, policyID, reportID, originalReportID, displ

const {hasBeenFlagged} = getModerationFlagState(action);

const [hasPendingFollowupListSkeleton = false] = useOnyx(`${ONYXKEYS.COLLECTION.CONCIERGE_PENDING_FOLLOWUP_LIST}${reportID}`, {
selector: hasPendingFollowupListSkeletonSelector(action.reportActionID),
});

const messageHtml = getReportActionMessage(action)?.html;
const mayHaveActionableButtons =
isActionableAddPaymentCard(action) ||
isConciergeCategoryOptions(action) ||
isConciergeDescriptionOptions(action) ||
isActionableTrackExpense(action) ||
!!(messageHtml && parseFollowupsFromHtml(messageHtml)?.length);
!!(messageHtml && parseFollowupsFromHtml(messageHtml)?.length) ||
hasPendingFollowupListSkeleton;

return (
<MentionReportContext.Provider value={mentionReportContextValue}>
Expand Down Expand Up @@ -94,6 +102,7 @@ function ChatMessageContent({action, policyID, reportID, originalReportID, displ
action={action}
originalReportID={originalReportID}
reportID={reportID}
hasPendingFollowupListSkeleton={hasPendingFollowupListSkeleton}
/>
)}
</View>
Expand Down
9 changes: 7 additions & 2 deletions src/selectors/AgentZeroChat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import ONYXKEYS from '@src/ONYXKEYS';
import type {AgentPrompt} from '@src/types/onyx';
import type {AgentPrompt, ConciergePendingFollowupList} from '@src/types/onyx';
import type Report from '@src/types/onyx/Report';

const getReportParticipantAccountIDs = (report: OnyxEntry<Report>): number[] => (report?.participants ? Object.keys(report.participants).map(Number) : []);
Expand All @@ -23,4 +23,9 @@ const getAgentAccountIDFlags = (agentPrompts: OnyxCollection<AgentPrompt>): Reco
return flags;
};

export {getReportParticipantAccountIDs, getAgentAccountIDFlags};
const hasPendingFollowupListSkeletonSelector =
(reportActionID: string) =>
(pending: OnyxEntry<ConciergePendingFollowupList>): boolean =>
!pending?.hidden && pending?.reportActionID === reportActionID;

export {getReportParticipantAccountIDs, getAgentAccountIDFlags, hasPendingFollowupListSkeletonSelector};
6 changes: 6 additions & 0 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,12 @@ const staticStyles = (theme: ThemeColors) =>
...wordBreak.breakWord,
},

actionableItemButtonSkeleton: {
alignItems: 'flex-start',
borderRadius: 20,
backgroundColor: theme.buttonDefaultBG,
},

hoveredComponentBG: {
backgroundColor: theme.hoverComponentBG,
},
Expand Down
13 changes: 13 additions & 0 deletions src/types/onyx/ConciergePendingFollowupList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** Marks a Concierge report action whose followup list is still pending arrival from the server */
type ConciergePendingFollowupList = {
/** The reportActionID of the optimistic Concierge action awaiting its followup list */
reportActionID: string;

/** Timestamp (ms) when the pending flag was created, used for TTL cleanup */
createdAt: number;

/** Whether the skeleton should be visually hidden (e.g., user is offline) */
hidden?: boolean;
};

export default ConciergePendingFollowupList;
2 changes: 2 additions & 0 deletions src/types/onyx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type {
} from './CardFeeds';
import type CardOnWaitlist from './CardOnWaitlist';
import type CodingRuleMatchingTransaction from './CodingRuleMatchingTransaction';
import type ConciergePendingFollowupList from './ConciergePendingFollowupList';
import type CopyPolicySettings from './CopyPolicySettings';
import type {CorpayFields, CorpayFormField} from './CorpayFields';
import type {CorpayOnboardingFields} from './CorpayOnboardingFields';
Expand Down Expand Up @@ -267,6 +268,7 @@ export type {
AnyOnyxUpdatesFromServer,
OdometerDraft,
Pages,
ConciergePendingFollowupList,
PendingConciergeResponse,
PersonalBankAccount,
PersonalDetails,
Expand Down
Loading
Loading