-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Hide the chat history when Concierge is opened up in the right hand pane #81807
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
Merged
marcaaron
merged 56 commits into
Expensify:main
from
Krishna2323:krishna2323/issue/81587
Mar 11, 2026
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
1286948
Hide the chat history when Concierge is opened up in the right hand p…
Krishna2323 e521788
Hide the chat history when Concierge is opened up in the right hand p…
Krishna2323 eed8e6a
minor updates.
Krishna2323 dad0a06
fix prettier.
Krishna2323 102d51c
add tests.
Krishna2323 81b087d
remove eslint-disable-next-line.
Krishna2323 3eee30b
hide status indicators.
Krishna2323 1fbd89b
fix prettier.
Krishna2323 7fd7a97
handle offline scenarios.
Krishna2323 0975dd4
Merge branch 'Expensify:main' into krishna2323/issue/81587
Krishna2323 60d90d1
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 a12b77d
Merge branch 'Expensify:main' into krishna2323/issue/81587
Krishna2323 1ed1f3e
show created action after user adds comment.
Krishna2323 5a30653
update tests.
Krishna2323 d11109c
fix prettier.
Krishna2323 9532219
add icon.
Krishna2323 87c53be
address codex review comments.
Krishna2323 94e9163
remove ConciergeSidePanelWelcome.
Krishna2323 b155bc1
fix tests.
Krishna2323 b89ce01
add temporary action.
Krishna2323 fed3df5
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 655510e
hide context menu for fake action.
Krishna2323 da72c6c
add useConciergeSidePanelReportActions hook.
Krishna2323 2364166
fix offline case.
Krishna2323 a09e808
fix tests.
Krishna2323 a64b2c9
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 9971c97
show history for brand-new account.
Krishna2323 29ef491
Merge branch 'Expensify:main' into krishna2323/issue/81587
Krishna2323 1b49d19
Merge branch 'Expensify:main' into krishna2323/issue/81587
Krishna2323 b6db3ce
Merge branch 'Expensify:main' into krishna2323/issue/81587
Krishna2323 85a33df
add translations.
Krishna2323 a428769
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 52bf372
fix created header not shown.
Krishna2323 7a6e932
udpate tests.
Krishna2323 1cede40
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 ef6bc7e
fix ESLint.
Krishna2323 130905c
fix hide history condition.
Krishna2323 f87f1dd
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 68756ae
Add missing import.
Krishna2323 6aed048
fix old messages not hidden.
Krishna2323 a38e1a6
fix ESLint.
Krishna2323 8dece91
Refactor session start time tracking into SidePanelContextProvider
Krishna2323 7425d32
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 efab4a6
fix showFullHistory state.
Krishna2323 0533bee
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 bde223a
fix history visible.
Krishna2323 f2dbefd
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 399fc6f
fix hadUserMessageAtSessionStart condition.
Krishna2323 d581b12
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 53bc6bd
Show skeleton in Concierge side panel until report data is loaded
Krishna2323 8c3a0e9
fix tests.
Krishna2323 a5d66d6
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 7d0b4c6
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 e478675
Merge branch 'main' into krishna2323/issue/81587
Krishna2323 4c97a01
Merge remote-tracking branch 'origin/main' into krishna2323/issue/81587
Krishna2323 202c8d8
Merge upstream/main and resolve conflict in ReportActionsList.tsx
Krishna2323 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
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,150 @@ | ||||
| import {useCallback, useMemo, useState} from 'react'; | ||||
| import DateUtils from '@libs/DateUtils'; | ||||
| import {isCreatedAction} from '@libs/ReportActionsUtils'; | ||||
| import {buildConciergeGreetingReportAction} from '@libs/ReportUtils'; | ||||
| import type * as OnyxTypes from '@src/types/onyx'; | ||||
|
|
||||
| type UseConciergeSidePanelReportActionsParams = { | ||||
| report: OnyxTypes.Report; | ||||
| reportActions: OnyxTypes.ReportAction[]; | ||||
| visibleReportActions: OnyxTypes.ReportAction[]; | ||||
| isConciergeSidePanel: boolean; | ||||
| hasUserSentMessage: boolean; | ||||
| hasOlderActions: boolean; | ||||
| sessionStartTime: string | null; | ||||
| currentUserAccountID: number; | ||||
| greetingText: string; | ||||
| loadOlderChats: (force?: boolean) => void; | ||||
| }; | ||||
|
|
||||
| function useConciergeSidePanelReportActions({ | ||||
| report, | ||||
| reportActions, | ||||
| visibleReportActions, | ||||
| isConciergeSidePanel, | ||||
| hasUserSentMessage, | ||||
| hasOlderActions, | ||||
| sessionStartTime, | ||||
| currentUserAccountID, | ||||
| greetingText, | ||||
| loadOlderChats, | ||||
| }: UseConciergeSidePanelReportActionsParams) { | ||||
| const [showFullHistory, setShowFullHistory] = useState(false); | ||||
| const [prevSessionStartTime, setPrevSessionStartTime] = useState(sessionStartTime); | ||||
| const [prevHasUserSentMessage, setPrevHasUserSentMessage] = useState(hasUserSentMessage); | ||||
|
|
||||
| if (prevSessionStartTime !== sessionStartTime) { | ||||
| setPrevSessionStartTime(sessionStartTime); | ||||
| setShowFullHistory(false); | ||||
| } else if (prevHasUserSentMessage && !hasUserSentMessage) { | ||||
| setPrevHasUserSentMessage(hasUserSentMessage); | ||||
| setShowFullHistory(false); | ||||
| } else if (prevHasUserSentMessage !== hasUserSentMessage) { | ||||
| setPrevHasUserSentMessage(hasUserSentMessage); | ||||
| } | ||||
|
|
||||
| // Check if the user had sent any message BEFORE this session started. | ||||
| // Uses sessionStartTime as the boundary — any user message created before the | ||||
| // panel opened is a pre-session message, regardless of when it was loaded. | ||||
| // | ||||
| // When no user message is found in the loaded set, hasOlderActions indicates | ||||
| // whether there is unloaded history. On a new account all onboarding messages | ||||
| // fit in a single page (hasOlderActions=false). On an existing account with | ||||
| // prior interactions the history spans multiple pages (hasOlderActions=true). | ||||
| // | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB
Suggested change
|
||||
| const hadUserMessageAtSessionStart = useMemo(() => { | ||||
| if (!isConciergeSidePanel || !sessionStartTime) { | ||||
| return false; | ||||
| } | ||||
| const hasUserMessageInLoadedSet = visibleReportActions.some( | ||||
| (action) => !isCreatedAction(action) && action.actorAccountID === currentUserAccountID && action.created < sessionStartTime, | ||||
| ); | ||||
| return hasUserMessageInLoadedSet || hasOlderActions; | ||||
| }, [isConciergeSidePanel, visibleReportActions, currentUserAccountID, sessionStartTime, hasOlderActions]); | ||||
|
|
||||
| const hasPreviousMessages = useMemo(() => { | ||||
| if (!isConciergeSidePanel || !hadUserMessageAtSessionStart || !sessionStartTime) { | ||||
| return false; | ||||
| } | ||||
| return visibleReportActions.some((action) => !isCreatedAction(action) && action.created < sessionStartTime); | ||||
| }, [isConciergeSidePanel, visibleReportActions, sessionStartTime, hadUserMessageAtSessionStart]); | ||||
|
|
||||
| const showConciergeSidePanelWelcome = isConciergeSidePanel && hadUserMessageAtSessionStart && !hasUserSentMessage && !showFullHistory; | ||||
| const showConciergeGreeting = isConciergeSidePanel && hadUserMessageAtSessionStart && !showFullHistory; | ||||
|
|
||||
| const conciergeGreetingAction = useMemo(() => { | ||||
| if (!showConciergeGreeting) { | ||||
| return undefined; | ||||
| } | ||||
| return buildConciergeGreetingReportAction(report.reportID, greetingText, report.lastReadTime ?? DateUtils.getDBTime()); | ||||
| }, [showConciergeGreeting, report.reportID, report.lastReadTime, greetingText]); | ||||
|
|
||||
| const firstUserMessageCreated = useMemo(() => { | ||||
| if (showConciergeSidePanelWelcome || !isConciergeSidePanel || !hasUserSentMessage || !sessionStartTime) { | ||||
| return undefined; | ||||
| } | ||||
| return reportActions.reduce<string | undefined>((earliest, action) => { | ||||
| if (isCreatedAction(action) || action.created < sessionStartTime || action.actorAccountID !== currentUserAccountID) { | ||||
| return earliest; | ||||
| } | ||||
| return !earliest || action.created < earliest ? action.created : earliest; | ||||
| }, undefined); | ||||
| }, [showConciergeSidePanelWelcome, isConciergeSidePanel, hasUserSentMessage, sessionStartTime, reportActions, currentUserAccountID]); | ||||
|
|
||||
| const isCurrentSessionAction = useCallback( | ||||
| (action: OnyxTypes.ReportAction): boolean => { | ||||
| if (!firstUserMessageCreated || !sessionStartTime) { | ||||
| return false; | ||||
| } | ||||
| return isCreatedAction(action) || (action.created >= sessionStartTime && action.created >= firstUserMessageCreated); | ||||
| }, | ||||
| [firstUserMessageCreated, sessionStartTime], | ||||
| ); | ||||
|
|
||||
| const filterActions = useCallback( | ||||
| (actions: OnyxTypes.ReportAction[]): OnyxTypes.ReportAction[] => { | ||||
| if (showConciergeSidePanelWelcome && conciergeGreetingAction) { | ||||
| const createdAction = actions.find(isCreatedAction); | ||||
| return createdAction ? [conciergeGreetingAction, createdAction] : [conciergeGreetingAction]; | ||||
| } | ||||
| if (!isConciergeSidePanel || showFullHistory) { | ||||
| return actions; | ||||
| } | ||||
| if (!sessionStartTime) { | ||||
| return actions.filter(isCreatedAction); | ||||
| } | ||||
| if (!hadUserMessageAtSessionStart) { | ||||
| return actions; | ||||
| } | ||||
| const filtered = actions.filter(isCurrentSessionAction); | ||||
| if (filtered.length === 0) { | ||||
| return actions; | ||||
| } | ||||
| if (conciergeGreetingAction) { | ||||
| const createdIndex = filtered.findIndex(isCreatedAction); | ||||
| filtered.splice(createdIndex === -1 ? filtered.length : createdIndex, 0, conciergeGreetingAction); | ||||
| } | ||||
| return filtered; | ||||
| }, | ||||
| [showConciergeSidePanelWelcome, conciergeGreetingAction, isConciergeSidePanel, showFullHistory, sessionStartTime, isCurrentSessionAction, hadUserMessageAtSessionStart], | ||||
| ); | ||||
|
|
||||
| const filteredVisibleActions = useMemo(() => filterActions(visibleReportActions), [filterActions, visibleReportActions]); | ||||
| const filteredReportActions = useMemo(() => filterActions(reportActions), [filterActions, reportActions]); | ||||
|
|
||||
| const handleShowPreviousMessages = useCallback(() => { | ||||
| setShowFullHistory(true); | ||||
| loadOlderChats(true); | ||||
| }, [loadOlderChats]); | ||||
|
|
||||
| return { | ||||
| filteredVisibleActions, | ||||
| filteredReportActions, | ||||
| showConciergeSidePanelWelcome, | ||||
| showFullHistory, | ||||
| hasPreviousMessages, | ||||
| handleShowPreviousMessages, | ||||
| }; | ||||
| } | ||||
|
|
||||
| export default useConciergeSidePanelReportActions; | ||||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just false.