Repository navigation
[NoQA] [Insights] Add the Explain button and pass the Insights scope to Concierge #104862
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
luacmartins
merged 14 commits into
Expensify:main
from
software-mansion-labs:insights/ai-explain-buttons
Nov 4, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c6422ab
[Insights] Add the Explain button and pass the Insights scope to
mhawryluk dabc597
Add the Explain button to charts
mhawryluk fd940b1
Fix spellcheck
mhawryluk 095de95
Update the explainChartPrompt
mhawryluk 40fd14e
Merge branch 'main' into insights/ai-explain-buttons
mhawryluk 5d6a165
Update ai card skeleton to include the button
mhawryluk 3aea88f
Update translation keys
mhawryluk 39a4b85
Update comments
mhawryluk 2b893c7
Fix button position in the card
mhawryluk 740afaa
Add translations
mhawryluk e62edb3
Add a unit test
mhawryluk 510f172
Stop rerendering Explain buttons on Concierge replies
mhawryluk f0cdca4
Update comment in InsightsExplainButton
mhawryluk fd16c73
Merge branch 'main' into insights/ai-explain-buttons
mhawryluk 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
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
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,58 @@ | ||
| import Button from '@components/Button'; | ||
| import useAskConcierge from '@components/Search/SearchRouter/useAskConcierge'; | ||
|
|
||
| import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
| import type {InsightsScope} from '@src/types/onyx'; | ||
|
|
||
| import React from 'react'; | ||
|
|
||
| type InsightsExplainButtonProps = { | ||
| /** Message sent to Concierge on press */ | ||
| explainPrompt: string; | ||
|
|
||
| /** Dashboard and filters sent with the prompt so Concierge explains the data the user sees */ | ||
| insightsScope: InsightsScope; | ||
|
|
||
| /** Tints the glyph and label with the link color instead of the muted one */ | ||
| isAccented?: boolean; | ||
| }; | ||
|
|
||
| /** Asks Concierge to explain an AI insight or chart, sending along the dashboard filters so the answer covers the data on screen. */ | ||
| function InsightsExplainButton({explainPrompt, insightsScope, isAccented = false}: InsightsExplainButtonProps) { | ||
| const styles = useThemeStyles(); | ||
| const theme = useTheme(); | ||
| const {translate} = useLocalize(); | ||
| const icons = useMemoizedLazyExpensifyIcons(['Sparkles']); | ||
| const {askConcierge, shouldShowAskConcierge} = useAskConcierge({forceConcierge: true}); | ||
|
mhawryluk marked this conversation as resolved.
Resolved
|
||
|
|
||
| if (!shouldShowAskConcierge) { | ||
| return null; | ||
| } | ||
|
|
||
| const glyphColor = isAccented ? theme.link : theme.icon; | ||
|
|
||
| return ( | ||
| <Button | ||
| size={CONST.BUTTON_SIZE.SMALL} | ||
| onPress={() => askConcierge(explainPrompt, {insightsScope})} | ||
| sentryLabel={CONST.SENTRY_LABEL.INSIGHTS.AI_EXPLAIN} | ||
| style={styles.alignSelfStart} | ||
| innerStyles={styles.bgTransparent} | ||
| hoverStyles={styles.hoveredComponentBG} | ||
| > | ||
| <Button.Icon | ||
| src={icons.Sparkles} | ||
| fill={glyphColor} | ||
| hoverFill={glyphColor} | ||
| /> | ||
| <Button.Text style={[styles.textMicroBold, isAccented ? styles.link : styles.textSupporting]}>{translate('insightsPage.explain')}</Button.Text> | ||
| </Button> | ||
| ); | ||
| } | ||
|
|
||
| export default InsightsExplainButton; | ||
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.