Repository navigation
Add ask Concierge screen #100552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rushatgabhane
wants to merge
110
commits into
Expensify:main
Choose a base branch
from
rushatgabhane:concierge-ask-design
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,334
−160
Open
Add ask Concierge screen #100552
Changes from all commits
Commits
Show all changes
110 commits
Select commit
Hold shift + click to select a range
cdea881
Ask Concierge design
rushatgabhane f6bb415
Fix CI failures
rushatgabhane 40ce940
Merge main
rushatgabhane 60fe442
Fix Button import
rushatgabhane 95be964
Remove quick actions
rushatgabhane a666030
Center welcome layout
rushatgabhane 7329000
Responsive column width
rushatgabhane 8260e1f
Remove top margin
rushatgabhane dbbb733
Rotate placeholder
rushatgabhane 82a7efd
Reuse existing placeholders
rushatgabhane 47eb7f4
Remove list padding
rushatgabhane 43392ff
Fix history toggle
rushatgabhane 05f6511
Fix title line height
rushatgabhane b44fa4c
Own welcome typography
rushatgabhane 25df82d
Always show toggle
rushatgabhane 405db86
Space welcome divider
rushatgabhane 6a5df9b
Fix session race
rushatgabhane ea11c45
Add placeholder rotation
rushatgabhane eca32a2
Revert "Fix session race"
rushatgabhane f68bab5
Reapply "Fix session race"
rushatgabhane c5c9975
Fix CI checks
rushatgabhane c278aec
Drop CSV placeholder
rushatgabhane 134ddab
Revert "Drop CSV placeholder"
rushatgabhane 0f7309a
Fix history toggle
rushatgabhane 75caf8d
Drop comment
rushatgabhane 3e8dfe7
Welcome instead of skeleton
rushatgabhane dbb3eee
Keep onboarding passthrough
rushatgabhane 7c9c6bd
Remove unused asset
rushatgabhane df8069e
Rename welcome component
rushatgabhane 9e7242b
Add regression test
rushatgabhane 7b057b0
Drop comments
rushatgabhane 16d4486
Drop comment
rushatgabhane 5faf565
Fix review findings
rushatgabhane c6aeb51
Test side panel button
rushatgabhane bc17861
Test toggle and empty state
rushatgabhane fa10412
Fix mock scope
rushatgabhane f693e6d
Fix toggle label source
rushatgabhane b84021c
Hide locked toggle
rushatgabhane 56522fb
Unlock history toggle
rushatgabhane 5bf9f36
Hide returns to empty state
rushatgabhane 4c25305
Restore welcome toggle
rushatgabhane a384472
Load locale in tests
rushatgabhane ca23148
Single history source
rushatgabhane ce51952
Test ask state hook
rushatgabhane 841e68a
Keep hide working
rushatgabhane 298843a
Fix CI failures
rushatgabhane b0ccfb3
Fix landscape layout
rushatgabhane c39ff93
Fix CI failures
rushatgabhane c472804
Merge branch 'Expensify:main' into concierge-ask-design
rushatgabhane e88ee96
Address review feedback
rushatgabhane a0a44ba
Improve comments
rushatgabhane fd9b205
Fix welcome layout
rushatgabhane b35ad4c
Add concierge welcome tests
rushatgabhane ac2a83c
Fix lint errors
rushatgabhane 1ef742b
Dock composer bottom
rushatgabhane afa8d95
Merge remote-tracking branch 'upstream/main' into concierge-ask-design
rushatgabhane 066d51b
Mock useConciergeAskState in ReportActionsListPaddingView test
rushatgabhane e4b314e
Center welcome only on wide layout
rushatgabhane 6b32d8e
Keep welcome while question opens its thread
rushatgabhane 1ee6a03
Pad welcome description
rushatgabhane 81a90ff
Keep Concierge welcome consistent and pad welcome description
MelvinBot 6b155cc
Merge remote-tracking branch 'origin/main' into concierge-ask-design
MelvinBot 1a099e8
Address review comments on the Ask Concierge screen
rushatgabhane 0bfc66a
Merge remote-tracking branch 'upstream/main' into concierge-ask-design
rushatgabhane fcc7c62
Rename the history check to fix spellcheck
rushatgabhane 360eee2
Return a route from the useRoute mock in ReportActionsListTest
rushatgabhane f68ae5e
Merge branch 'Expensify:main' into concierge-ask-design
rushatgabhane d50e8b8
Remove the conciergeRespondInThread beta
rushatgabhane 3233984
Drop the conciergeRespondInThread beta checks from the Ask Concierge …
rushatgabhane f2e0cca
Update Ask Concierge tests for the removed beta
rushatgabhane e434431
Hide the Concierge greeting in the main Concierge chat
rushatgabhane 840e6e0
Drop the beta from the Ask Concierge state doc comment
rushatgabhane ec355e8
Revert "Hide the Concierge greeting in the main Concierge chat"
rushatgabhane 616c0a6
Merge remote-tracking branch 'origin/main' into concierge-ask-design
MelvinBot 5039f13
Merge remote-tracking branch 'origin/main' into concierge-ask-design
MelvinBot 6d108a8
Update useAskConcierge tests for removed Concierge thread beta
MelvinBot 78f08c1
Show the New chat button only on Concierge chat threads
rushatgabhane 9c9df70
Keep the Concierge welcome after creating a task in the chat
rushatgabhane 8a96c8d
Revert "Show the New chat button only on Concierge chat threads"
rushatgabhane 38515ce
Merge remote-tracking branch 'origin/concierge-ask-design' into conci…
rushatgabhane 78c1e5d
Document the Concierge tests with Given, When and Then
rushatgabhane ef562c5
Keep the Concierge welcome while older messages are still unloaded
rushatgabhane f3acff1
Drop manual memoization from resetSession
rushatgabhane a71596c
Fix the grammar of the reimbursement prompt
rushatgabhane 6914c25
Show the chat history after creating a task in Concierge
rushatgabhane a1b5ff3
Merge remote-tracking branch 'origin/main' into concierge-ask-design
MelvinBot 7b28190
Show the chat history after sending several attachments to Concierge
rushatgabhane 4735764
Keep an open Concierge task on screen instead of the welcome
rushatgabhane 675535b
Hide the Ask a new question label while the composer is full size
rushatgabhane e24e81c
Start a new Concierge thread from Search while the side panel shows a…
rushatgabhane 48e768b
Merge remote-tracking branch 'upstream/main' into concierge-ask-design
rushatgabhane 20ab913
Return to the Concierge welcome when hiding history after sending sev…
rushatgabhane 9a8cf01
Use a camelCase error key in the Concierge ask state test
rushatgabhane 427f1aa
Build optimistic comments with several attachments
rushatgabhane 1c872d5
Send extra attachments in the same AddAttachment request
rushatgabhane 9c3556f
Open a Concierge thread for messages with several attachments
rushatgabhane 70bc106
Re-read every attachment file for requests queued offline
rushatgabhane 623ee00
Test that several attachments open one Concierge thread
rushatgabhane a84b7bc
Reconcile every queued attachment when editing a message
rushatgabhane ca486db
Space out file attachments in a message
rushatgabhane e87d4d0
Drop the chat history toggle for attachments that stay in the Concier…
rushatgabhane bcd753a
Revert "Use a camelCase error key in the Concierge ask state test"
rushatgabhane 1053614
Revert "Return to the Concierge welcome when hiding history after sen…
rushatgabhane 727b7bc
Read the Concierge history flag straight from the session in the list…
rushatgabhane 4f220af
Fold the side panel check into the Concierge check
rushatgabhane de7c33d
Drop the isAskConciergeEnabled alias in the header
rushatgabhane 1538cae
Merge branch 'Expensify:main' into concierge-ask-design
rushatgabhane 64f75c7
Match extra attachment file keys with one shared regex
rushatgabhane 529469c
Simplify rewriting a queued request's attachments after an edit
rushatgabhane 804aff5
Fix ESLint errors in queued attachment edit handling
MelvinBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; | ||
| import type {ReportsSplitNavigatorParamList} from '@libs/Navigation/types'; | ||
| import {isCreatedAction, isCurrentUserPendingAddAction} from '@libs/ReportActionsUtils'; | ||
|
|
||
| import {useConciergeSessionState} from '@pages/inbox/ConciergeSessionContext'; | ||
|
|
||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type SCREENS from '@src/SCREENS'; | ||
| import type {ReportActions} from '@src/types/onyx/ReportAction'; | ||
|
|
||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
|
|
||
| import {useRoute} from '@react-navigation/native'; | ||
|
|
||
| import {isOpenChildTaskAction} from './useConciergeSidePanelReportActions'; | ||
| import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails'; | ||
| import useIsInSidePanel from './useIsInSidePanel'; | ||
| import useOnyx from './useOnyx'; | ||
| import useResponsiveLayout from './useResponsiveLayout'; | ||
|
|
||
| type ConciergeAskState = { | ||
| /** Whether this is the Concierge chat in the Inbox */ | ||
| isAskConciergeChat: boolean; | ||
|
|
||
| /** Whether the messages from before this session are shown */ | ||
| isHistoryExpanded: boolean; | ||
|
|
||
| /** Whether to show the `Ask me anything!` welcome screen in place of the messages */ | ||
| shouldShowWelcome: boolean; | ||
|
|
||
| /** Whether the welcome screen and the composer are centered together on the screen */ | ||
| shouldCenterWelcomeWithComposer: boolean; | ||
|
|
||
| /** Whether to show `Ask a new question` above the composer */ | ||
| shouldLabelComposerAsNewQuestion: boolean; | ||
| }; | ||
|
|
||
| function useConciergeAskState(reportID: string | undefined): ConciergeAskState { | ||
| const isInSidePanel = useIsInSidePanel(); | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
| const route = useRoute<PlatformStackRouteProp<ReportsSplitNavigatorParamList, typeof SCREENS.REPORT>>(); | ||
| const {sessionStartTime, showFullHistory} = useConciergeSessionState(); | ||
| const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails(); | ||
| const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID); | ||
|
|
||
| const hasSessionActivitySelector = (actions: OnyxEntry<ReportActions>) => { | ||
| if (!actions || !sessionStartTime) { | ||
| return false; | ||
| } | ||
| return Object.values(actions).some((action) => { | ||
| // The list pins a still-open task, so it stays on screen in every session. | ||
| if (isOpenChildTaskAction(action, currentUserAccountID)) { | ||
| return true; | ||
| } | ||
|
|
||
| // An action that opens its own report, like a question's thread or a task, keeps the welcome both while sending and once sent. | ||
| // Otherwise reconnecting would switch this chat to a partial view that `Hide chat history` can't return to. | ||
| if (action.actorAccountID === currentUserAccountID && !!action.childReportID) { | ||
| return false; | ||
| } | ||
| return isCurrentUserPendingAddAction(action, currentUserAccountID) || (!isCreatedAction(action) && action.created >= sessionStartTime); | ||
| }); | ||
| }; | ||
| const [hasSessionActivity] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { | ||
| selector: hasSessionActivitySelector, | ||
| }); | ||
|
|
||
| // `View chat history` only appears once the user has messaged Concierge, so earlier messages without one stay on screen. | ||
| const hasHistoryWithoutUserMessageSelector = (actions: OnyxEntry<ReportActions>) => { | ||
| if (!actions || !sessionStartTime) { | ||
| return false; | ||
| } | ||
| const allActions = Object.values(actions); | ||
|
|
||
| // Until the chat's first action is loaded, the user's earlier messages may be on an older page. | ||
| if (!allActions.some((action) => isCreatedAction(action))) { | ||
| return false; | ||
| } | ||
| const previousActions = allActions.filter((action) => !isCreatedAction(action) && action.created < sessionStartTime); | ||
| return previousActions.length > 0 && !previousActions.some((action) => action.actorAccountID === currentUserAccountID); | ||
| }; | ||
| const [hasHistoryWithoutUserMessage] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { | ||
| selector: hasHistoryWithoutUserMessageSelector, | ||
| }); | ||
|
|
||
| const isAskConciergeChat = !!reportID && reportID === conciergeReportID && !isInSidePanel; | ||
|
|
||
| const hasSessionBoundary = isAskConciergeChat && !!sessionStartTime; | ||
|
|
||
| // A linked action opens the report at that message, so the earlier conversation is on screen either way. | ||
| const isHistoryExpanded = showFullHistory || !!route.params?.reportActionID; | ||
|
|
||
| const shouldShowWelcome = hasSessionBoundary && !isHistoryExpanded && !hasSessionActivity && !hasHistoryWithoutUserMessage; | ||
|
rushatgabhane marked this conversation as resolved.
|
||
|
|
||
| return { | ||
| isAskConciergeChat, | ||
| isHistoryExpanded, | ||
| shouldShowWelcome, | ||
| shouldCenterWelcomeWithComposer: shouldShowWelcome && !shouldUseNarrowLayout, | ||
| shouldLabelComposerAsNewQuestion: hasSessionBoundary && showFullHistory && !hasSessionActivity, | ||
| }; | ||
| } | ||
|
|
||
| export default useConciergeAskState; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.