Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1959,6 +1959,8 @@ const translations: TranslationDeepObject<typeof en> = {
offline: 'Offline',
syncing: 'Synchronisierung',
profileAvatar: 'Profil-Avatar',
customInstructions: 'Benutzerdefinierte Anweisungen',
copilotIntoAccount: 'Copilot in Konto',
publicSection: {
title: 'Öffentlich',
subtitle: 'Diese Angaben werden in deinem öffentlichen Profil angezeigt. Jede:r kann sie sehen.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,8 @@ const translations = {
offline: 'Offline',
syncing: 'Syncing',
profileAvatar: 'Profile avatar',
customInstructions: 'Custom instructions',
copilotIntoAccount: 'Copilot into account',
publicSection: {
title: 'Public',
subtitle: 'These details are displayed on your public profile. Anyone can see them.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,8 @@ const translations: TranslationDeepObject<typeof en> = {
offline: 'Desconectado',
syncing: 'Sincronizando',
profileAvatar: 'Perfil avatar',
customInstructions: 'Instrucciones personalizadas',
copilotIntoAccount: 'Copilot a la cuenta',
publicSection: {
title: 'Público',
subtitle: 'Estos detalles se muestran en tu perfil público, a disposición de los demás.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,8 @@ const translations: TranslationDeepObject<typeof en> = {
offline: 'Hors ligne',
syncing: 'Synchronisation en cours',
profileAvatar: 'Avatar de profil',
customInstructions: 'Instructions personnalisées',
copilotIntoAccount: 'Copilot dans le compte',
publicSection: {
title: 'Public',
subtitle: 'Ces informations sont affichées sur votre profil public. Tout le monde peut les voir.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,8 @@ const translations: TranslationDeepObject<typeof en> = {
offline: 'Offline',
syncing: 'Sincronizzazione',
profileAvatar: 'Avatar profilo',
customInstructions: 'Istruzioni personalizzate',
copilotIntoAccount: "Copilot nell'account",
publicSection: {
title: 'Pubblico',
subtitle: 'Questi dettagli vengono visualizzati nel tuo profilo pubblico. Chiunque può vederli.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,8 @@ const translations: TranslationDeepObject<typeof en> = {
offline: 'オフライン',
syncing: '同期中',
profileAvatar: 'プロフィールアバター',
customInstructions: 'カスタム指示',
copilotIntoAccount: 'アカウントにCopilot',
publicSection: {
title: '公開',
subtitle: 'これらの詳細はあなたの公開プロフィールに表示され、誰でも閲覧できます。',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,8 @@ const translations: TranslationDeepObject<typeof en> = {
offline: 'Offline',
syncing: 'Synchroniseren',
profileAvatar: 'Profielavatar',
customInstructions: 'Aangepaste instructies',
copilotIntoAccount: 'Copilot naar account',
publicSection: {
title: 'Openbaar',
subtitle: 'Deze gegevens worden weergegeven op je openbare profiel. Iedereen kan ze zien.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,8 @@ const translations: TranslationDeepObject<typeof en> = {
offline: 'Offline',
syncing: 'Synchronizowanie',
profileAvatar: 'Awatar profilu',
customInstructions: 'Niestandardowe instrukcje',
copilotIntoAccount: 'Copilot do konta',
publicSection: {
title: 'Public',
subtitle: 'Te dane są wyświetlane w Twoim publicznym profilu. Każdy może je zobaczyć.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,8 @@ const translations: TranslationDeepObject<typeof en> = {
offline: 'Offline',
syncing: 'Sincronizando',
profileAvatar: 'Avatar do perfil',
customInstructions: 'Instruções personalizadas',
copilotIntoAccount: 'Copilot na conta',
publicSection: {
title: 'Público',
subtitle: 'Esses detalhes são exibidos no seu perfil público. Qualquer pessoa pode vê-los.',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,8 @@ const translations: TranslationDeepObject<typeof en> = {
offline: '离线',
syncing: '正在同步',
profileAvatar: '个人头像',
customInstructions: '自定义指令',
copilotIntoAccount: 'Copilot 到账户',
publicSection: {
title: '公开',
subtitle: '这些详细信息会显示在你的公开资料中,任何人都可以看到。',
Expand Down
36 changes: 35 additions & 1 deletion src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import useDynamicBackPath from '@hooks/useDynamicBackPath';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import useSwitchToDelegator from '@hooks/useSwitchToDelegator';
import useThemeStyles from '@hooks/useThemeStyles';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import Navigation from '@libs/Navigation/Navigation';
Expand All @@ -41,6 +42,7 @@ import {isAgentEmail} from '@libs/SessionUtils';
import {generateAccountID} from '@libs/UserUtils';
import {isValidAccountRoute} from '@libs/ValidationUtils';
import type {ProfileNavigatorParamList} from '@navigation/types';
import {openAgentsPage} from '@userActions/Agent';
import {openExternalLink} from '@userActions/Link';
import {openPublicProfilePage} from '@userActions/PersonalDetails';
import {hasErrorInPrivateNotes} from '@userActions/Report';
Expand Down Expand Up @@ -82,9 +84,11 @@ function ProfilePage({route}: ProfilePageProps) {
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
const switchToDelegator = useSwitchToDelegator();
const guideCalendarLink = account?.guideDetails?.calendarLink ?? '';
const expensifyIcons = useMemoizedLazyExpensifyIcons(['Bug', 'Pencil', 'Phone']);
const expensifyIcons = useMemoizedLazyExpensifyIcons(['Bug', 'Pencil', 'Phone', 'UserPlus']);
const accountID = Number(route.params?.accountID ?? CONST.DEFAULT_NUMBER_ID);
const [agentPrompt] = useOnyx(`${ONYXKEYS.COLLECTION.SHARED_NVP_AGENT_PROMPT}${accountID}`);
const isCurrentUser = currentUserAccountID === accountID;
const reportID = isCurrentUser ? findSelfDMReportID() : getChatByParticipants(currentUserAccountID ? [accountID, currentUserAccountID] : [], reports)?.reportID;
const reportKey = isAnonymousUserSession() || !reportID ? (`${ONYXKEYS.COLLECTION.REPORT}0` as const) : (`${ONYXKEYS.COLLECTION.REPORT}${reportID}` as const);
Expand Down Expand Up @@ -146,6 +150,8 @@ function ProfilePage({route}: ProfilePageProps) {
const hasStatus = !!statusEmojiCode;
const statusContent = `${statusEmojiCode} ${statusText}`;

const isOwnedAgent = !isCurrentUser && isAgentEmail(login) && !!agentPrompt;

const notificationPreferenceValue = getReportNotificationPreference(report);

const shouldShowNotificationPreference = !isEmptyObject(report) && !isCurrentUser && !isReportHiddenForCurrentUser(notificationPreferenceValue);
Expand All @@ -162,6 +168,13 @@ function ProfilePage({route}: ProfilePageProps) {
}
}, [accountID, loginParams, isConcierge]);

useEffect(() => {
if (isCurrentUser || !isAgentEmail(login)) {
return;
}
openAgentsPage();
}, [isCurrentUser, login]);

const promotedActions: PromotedAction[] = [];
if (report) {
promotedActions.push(PromotedActions.pin(report));
Expand Down Expand Up @@ -260,6 +273,27 @@ function ProfilePage({route}: ProfilePageProps) {
onPress={() => Navigation.navigate(ROUTES.SETTINGS_PROFILE.getRoute(Navigation.getActiveRoute()))}
/>
)}
{isOwnedAgent && (
<OfflineWithFeedback
errors={agentPrompt?.promptErrors}
errorRowStyles={[styles.mh5, styles.mb2]}
>
<MenuItemWithTopDescription
description={translate('profilePage.customInstructions')}
title={agentPrompt?.prompt?.trim() ?? ''}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.SETTINGS_AGENTS_EDIT_PROMPT.getRoute(accountID))}
numberOfLinesTitle={2}
/>
</OfflineWithFeedback>
)}
{isOwnedAgent && (
<MenuItem
title={translate('profilePage.copilotIntoAccount')}
icon={expensifyIcons.UserPlus}
onPress={callFunctionIfActionIsAllowed(() => switchToDelegator(login))}
/>
)}
{shouldShowNotificationPreference && (
<MenuItemWithTopDescription
shouldShowRightIcon
Expand Down
5 changes: 2 additions & 3 deletions src/pages/settings/Agents/Fields/EditPromptPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavig
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/EditAgentPromptForm';

Expand All @@ -39,7 +38,7 @@ function EditPromptPage({route}: EditPromptPageProps) {

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();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When opened via deeplink, it has the Agents page in the background and is not dependent on profile page. This would work fine.

};

useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER, (e) => {
Expand Down Expand Up @@ -69,7 +68,7 @@ function EditPromptPage({route}: EditPromptPageProps) {
>
<HeaderWithBackButton
title={translate('editAgentPromptPage.title')}
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_AGENTS_EDIT.getRoute(accountID))}
onBackButtonPress={() => Navigation.goBack()}
/>
<FormProvider
formID={ONYXKEYS.FORMS.EDIT_AGENT_PROMPT_FORM}
Expand Down
Loading