Add copilot and custom instructions buttons to agent profile#91537
Conversation
When an agent's owner views the agent's profile, two new buttons are now shown: "Custom instructions" (navigates to the prompt editor) and "Copilot into account" (switches into the agent's account). Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@MelvinBot Fill the test steps and check all the checkboxes |
|
Done — I've filled in the test steps (Tests, Offline tests, QA Steps) based on the PR changes and checked all the checkboxes in the PR Author Checklist. |
|
@MelvinBot After editing and saving the custom instructions via the profile page, the copilot option disappears. Fix it. |
When the ProfilePage mounts for an agent profile, the agent prompt Onyx data may be stale or cleared by other server responses. This ensures agent data is always re-fetched by calling openAgentsPage() when viewing an agent's profile, so the Custom instructions and Copilot buttons remain visible after editing. Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
|
Fixed. The ProfilePage never fetched agent-specific data — it relied on the The fix adds a |
|
@ShridharGoel this one is also missing steps and videos, also one check is failing
|
|
@NicolasBonet I can't edit the description added by some other author (MelvinBot here). I'll be adding the videos in the reviewer checklist once the PR is ready. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeScreen.Recording.2026-05-28.at.10.41.03.AM.moviOS: HybridAppScreen.Recording.2026-05-28.at.10.43.33.AM.moviOS: mWeb SafariScreen.Recording.2026-05-28.at.10.45.56.AM.movMacOS: Chrome / SafariScreen.Recording.2026-05-28.at.4.03.19.AM.mov |
|
@MelvinBot Ensure that the author checklist matches the one here: https://raw.githubusercontent.com/Expensify/App/main/.github/PULL_REQUEST_TEMPLATE.md |
|
@MelvinBot |
|
Updated the PR Author Checklist to match the current template. The checklist was missing one item that was added:
All checklist items are now checked. |
Remove hardcoded goBack route so EditPromptPage navigates back to wherever it was opened from (ProfilePage or EditAgentPage) instead of always going to SETTINGS_AGENTS_EDIT. Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
|
Fixed — |
|
@MelvinBot Should we add a fallback route if user opens the page via deeplink? |
|
Yes — That said, this is a pre-existing gap (not introduced by this PR), so it could be tracked as a separate follow-up issue. |
|
@MelvinBot I meant that if a user deeplinks to the agent page, then goes back, what page would open ? Do we need a fallback route inside |
|
No, a fallback route inside ProfilePage reads a |
|
@MelvinBot Use numbers instead of checkboxes in the tests, offline tests and QA steps |
|
Updated the Tests, Offline tests, and QA Steps sections to use numbered lists instead of checkboxes. |
|
@MelvinBot ProfilePage bypasses the existing GPS-in-progress guard when switching accounts. Use the same pattern as CopilotPage and AccountSwitcher instead of directly calling |
|
@MelvinBot Pull the latest main and fix conflicts |
Use the same pattern as CopilotPage and AccountSwitcher: check isTrackingGPS before calling connect(), and show a confirmation modal that stops the GPS trip before switching accounts. Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
|
Added the GPS-in-progress guard to ProfilePage, matching the pattern from CopilotPage and AccountSwitcher. Now checks |
|
@MelvinBot ProfilePage should not silently return for offline or nested delegate states. It should show the same modals that CopilotPage shows. We can use these conditions:
|
|
Removed the unused |
|
@MelvinBot Mark this as ready for review. |
|
I'm unable to mark this PR as ready for review due to permission restrictions in my environment. You can do it directly by clicking Ready for review on the PR page, or by running: |
|
@MelvinBot You have the access, try again |
|
Marked this PR as ready for review. |
|
@ShridharGoel Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeScreen.Recording.2026-05-28.at.10.41.03.AM.moviOS: HybridAppScreen.Recording.2026-05-28.at.10.43.33.AM.moviOS: mWeb SafariScreen.Recording.2026-05-28.at.10.45.56.AM.movMacOS: Chrome / SafariScreen.Recording.2026-05-28.at.4.03.19.AM.mov |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: adca39dad3
ℹ️ 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".
| const handleSubmit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.EDIT_AGENT_PROMPT_FORM>) => { | ||
| updateAgentPrompt(accountID, values[INPUT_IDS.PROMPT].trim(), agentPrompt?.prompt ?? ''); | ||
| Navigation.goBack(ROUTES.SETTINGS_AGENTS_EDIT.getRoute(accountID)); | ||
| Navigation.goBack(); |
There was a problem hiding this comment.
Preserve a fallback when leaving edit prompt
When this screen is opened directly at settings/agents/:accountID/edit/prompt (for example via a deep link or browser refresh), there is no previous navigation entry, so the bare Navigation.goBack() logs that it cannot go back and leaves the user on the edit page after saving. This used to pass ROUTES.SETTINGS_AGENTS_EDIT.getRoute(accountID) as the fallback, which kept direct links recoverable; keep a fallback route (or pass the originating profile route explicitly) instead of relying only on stack history.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
When opened via deeplink, it has the Agents page in the background and is not dependent on profile page. This would work fine.
|
Working great: Screen.Recording.2026-05-28.at.9.27.45.AM.mov |
|
@NicolasBonet looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @NicolasBonet has triggered a test Expensify/App build. You can view the workflow run here. |
|
No jobs failed, only green checks or skipped tests. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/NicolasBonet in version: 9.3.89-1 🚀
Bundle Size Analysis (Sentry): |
|
🤖 Help site review: No help site changes are required for this PR. Summary of PR changes:
Why no docs update is needed:
If you'd like me to draft a new help site article that covers the entire Agents feature (creating agents, editing custom instructions, and copiloting into an agent account), let me know and I'll put one together. @ShridharGoel, please confirm whether you'd like me to draft a broader Agents help article anyway, or if this no-op assessment is correct. |

Explanation of Change
When viewing an agent's profile page, the owner now sees two new action items:
MenuItemWithTopDescriptionthat shows the agent's current prompt and navigates to the existingEditPromptPageto edit it.MenuItemthat calls the existingDelegate.connect()to switch into the agent's account.Agent ownership is detected by checking if the profile's login matches the agent email pattern (
isAgentEmail) AND the current user has aSHARED_NVP_AGENT_PROMPTentry for that accountID (which Onyx only populates for the agent's owner).The buttons are guarded against anonymous users (
callFunctionIfActionIsAllowed), offline state, and nested delegate sessions.Fixed Issues
$ #91345
PROPOSAL: #91345 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand 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