Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(email): init email link for new users who skip the login route (#4365)

Evan Hutnikb09da0327b86
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsx
index 6f1ca0803b..a6d7b19bd4 100644
--- a/js/app/packages/app/component/Root.tsx
+++ b/js/app/packages/app/component/Root.tsx
@@ -22,6 +22,7 @@ import {
useUserId,
useUserInfo,
} from '@core/context/user';
+import { initAndStartEmailSync } from '@core/email-link';
import { IosPushNotificationModal } from '@core/mobile/IosPushNotificationModal';
import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import { createBlockOrchestrator } from '@core/orchestrator';
@@ -489,6 +490,28 @@ function InitialInteractiveOnboardingModal() {
}
});
+ // First-time users (tutorial not yet completed) reach the app without passing
+ // through a login route that inits the email link — e.g. marketing SSO returns to
+ // /app, not /login — so kick off email sync once here. Idempotent on the backend;
+ // AlreadyInitialized is ignored. Keyed by user id (not a bare flag) so a native
+ // mobile logout→login of a different user in the same session still inits.
+ let emailInitForUserId: string | undefined;
+ createEffect(() => {
+ const data = userInfoQuery.data;
+ if (data?.authenticated !== true || data.tutorialComplete !== false) return;
+ if (emailInitForUserId === data.id) return;
+ emailInitForUserId = data.id;
+
+ void initAndStartEmailSync().match(
+ () => {},
+ (err) => {
+ if (err.tag !== 'AlreadyInitialized') {
+ console.error('Failed to init email link for new user', err);
+ }
+ }
+ );
+ });
+
const handleOpenChange = (nextOpen: boolean) => {
setOpen(nextOpen);
if (!nextOpen) {