-
Notifications
You must be signed in to change notification settings - Fork 3.6k
add Concierge Thinking Indicator v2 with real-time reasoning #82008
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
Conversation
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running: npx ts-node ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
|
@codex review |
| const baseLabelRef = useRef<string>(serverLabel ?? ''); | ||
| const [reasoningHistory, setReasoningHistory] = useState<ReasoningEntry[]>([]); | ||
| const isWaitingForServerRef = useRef(false); | ||
| const previousServerLabelRef = useRef<string | undefined>(serverLabel); |
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.
❌ PERF-12 (docs)
The Pusher subscription in this useEffect lacks a cleanup mechanism. The subscription persists after the component unmounts, potentially causing memory leaks and unexpected behavior when reasoning events arrive for unmounted components.
Fix: Add the cleanup function return value:
useEffect(() => {
if (\!isConciergeChat || \!reportID) {
return;
}
Report.subscribeToReportReasoningEvents(reportID);
return () => {
Report.unsubscribeFromReportReasoningChannel(reportID);
};
}, [isConciergeChat, reportID]);This ensures proper cleanup when the component unmounts or dependencies change.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| {isExpanded && hasReasoningHistory && ( | ||
| <View style={[styles.mt2, styles.gap2]}> | ||
| {reasoningHistory.map((entry, index) => ( | ||
| <View |
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.
❌ CONSISTENCY-5 (docs)
The ESLint disable comment lacks justification for why the rule is being disabled. Clear documentation ensures team members understand exceptions and promotes better maintainability.
Fix: Add a comment explaining why using array index as a key is acceptable here:
// eslint-disable-next-line react/no-array-index-key -- Index is stable since reasoning entries are append-only and never reordered
key={`reasoning-${entry.timestamp}-${index}`}Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| * Hook for managing AgentZero (Concierge AI) status indicator and reasoning display. | ||
| * | ||
| * Shows real-time thinking status with: | ||
| * - Optimistic "Thinking..." immediately when user sends a message |
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.
❌ PERF-14 (docs)
This useEffect + setState pattern subscribes to an external store (ConciergeReasoningStore) and directly mirrors its value. This approach misses React's concurrent rendering guarantees and causes an extra render pass.
Fix: Use useSyncExternalStore for reading from the external store:
import {useSyncExternalStore} from 'react';
const reasoningHistory = useSyncExternalStore(
ConciergeReasoningStore.subscribe,
() => ConciergeReasoningStore.getReasoningHistory(reportID),
() => [] // Server snapshot (empty for client-only store)
);This provides better concurrent rendering support and eliminates the extra render cycle.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4f8d18b3d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| setOptimisticLabel(translate('common.thinking')); | ||
| isWaitingForServerRef.current = true; |
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.
Reset reasoning history when kicking off a new request
When kickoffWaitingIndicator() starts a new Concierge run, it only sets the optimistic label and leaves prior reasoningHistory intact, so the UI can show the previous request's reasoning under the new "Thinking..." state until the first new conciergeReasoning event arrives. Because clearing is currently only done in unsubscribeFromReportReasoningChannel(), this stale-history window appears on every back-to-back Concierge request in the same chat.
Useful? React with 👍 / 👎.
| const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID, {canBeMissing: true}); | ||
|
|
||
| const isConciergeChat = reportIDFromRoute === conciergeReportID; | ||
| const {isProcessing, reasoningHistory, statusLabel, kickoffWaitingIndicator} = useAgentZeroStatusIndicator(reportIDFromRoute ?? '', isConciergeChat); |
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.
Avoid passing an empty report ID into the status hook
Using reportIDFromRoute ?? '' here means the hook receives an empty string while reportID is still unset, and inside the hook that builds an Onyx key with REPORT_NAME_VALUE_PAIRS + reportID; an empty ID subscribes to the collection prefix rather than a single report key. This can happen on the route path where reportID is populated later, and it causes unnecessary collection-wide updates and mismatched data shape for this hook during initial render.
Useful? React with 👍 / 👎.
|
Updating.... |
…nking-indicator-v2
…nking-indicator-v2
|
On it |
…nking-indicator-v2
Explanation of Change
Fixed Issues
$ #81771
PROPOSAL:
Tests
Same QA step
Offline tests
QA Steps
Precondition:
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari