Skip to content
Draft
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
19 changes: 16 additions & 3 deletions apps/web/src/app/(onboarding)/setup/SetupBootstrapFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
getBootstrapStepFromSetupStepParam,
getBootstrapStepAfterWelcome,
getNextBootstrapStep,
clearSetupEmailPasswordAuthSelected,
markSetupEmailPasswordAuthSelected,
type BootstrapStep,
} from './bootstrapFlow';
import { useSetupFlow } from './hooks';
Expand Down Expand Up @@ -123,6 +125,15 @@ export function SetupBootstrapFlow() {

useRedirectToSignIn(shouldRedirectToSignIn);

useEffect(() => {
if (
bootstrapStep === 'auth-provider' ||
bootstrapStep === 'auth-env-vars'
) {
clearSetupEmailPasswordAuthSelected();
}
}, [bootstrapStep]);

// Setup docs are server-rendered from this query parameter. Keep the
// effective provider in the URL while signed out just as the signed-in flow
// does, so provider-specific bootstrap instructions remain visible.
Expand Down Expand Up @@ -241,14 +252,16 @@ export function SetupBootstrapFlow() {
{bootstrapStep === 'email-account' && (
<StepBootstrapAccount
onUseProviderSignIn={(provider) => {
clearSetupEmailPasswordAuthSelected();
setPendingAuthProvider(provider);
setBootstrapStepWithTransition(
getNextBootstrapStep(bootstrapStatus.authSetup, provider),
);
}}
onUseEmailPassword={() =>
setBootstrapStepWithTransition('email-password')
}
onUseEmailPassword={() => {
markSetupEmailPasswordAuthSelected();
setBootstrapStepWithTransition('email-password');
}}
/>
)}
{bootstrapStep === 'email-password' && (
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/app/(onboarding)/setup/SetupSignedInFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { StepRepoSelection, type SetupRetryReason } from './StepRepoSelection';
import { StepAutomationRecommendations } from './StepAutomationRecommendations';
import { getSetupStepPath } from './types';
import { LoadingSetupFlow, stepTransitionVariants } from './SetupBootstrapFlow';
import { consumeSetupEmailPasswordAuthSelection } from './bootstrapFlow';

function getSetupRetryReason(status: {
onboardingFailed: boolean;
Expand Down Expand Up @@ -81,6 +82,9 @@ export function SetupSignedInFlow() {
useState<ComputeProvider | null>(null);
const [pendingModelProvider, setPendingModelProvider] =
useState<SetupModelProviderId | null>(null);
const [communicationAfterSourceControl] = useState(
consumeSetupEmailPasswordAuthSelection,

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.

Consuming this flag on the first signed-in mount means it is gone after any full-page setup redirect. Source-control setup deliberately redirects to OAuth and returns to /setup?step=source-control-connect; on that return the default communications-first sequence is selected, so the deep link is clamped to the still-pending communication chooser. Preserve the email-flow ordering for the signed-in setup session (or through the source-control redirect) so email users can complete source-control setup before communications.

);
const trackWelcomeSeen = useMutation(
trpc.setupNew.trackWelcomeSeen.mutationOptions(),
);
Expand All @@ -97,6 +101,7 @@ export function SetupSignedInFlow() {
const flow = useSetupFlow({
enabled: isSignedIn && isAdmin,
pendingAuthProvider: pendingSetupAuthProvider,
communicationAfterSourceControl,
});
const {
step,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions apps/web/src/app/(onboarding)/setup/bootstrapFlow.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
import type { SetupAuthProviderId, SetupAuthStatus } from '@roomote/types';

const SETUP_ACCOUNT_AUTH_METHOD_KEY = 'roomote.setup.account-auth-method';

export function markSetupEmailPasswordAuthSelected() {
window.sessionStorage.setItem(
SETUP_ACCOUNT_AUTH_METHOD_KEY,
'email-password',
);
}

export function clearSetupEmailPasswordAuthSelected() {
if (typeof window !== 'undefined') {
window.sessionStorage.removeItem(SETUP_ACCOUNT_AUTH_METHOD_KEY);
}
}

export function consumeSetupEmailPasswordAuthSelection() {
const selected =
typeof window !== 'undefined' &&
window.sessionStorage.getItem(SETUP_ACCOUNT_AUTH_METHOD_KEY) ===
'email-password';

clearSetupEmailPasswordAuthSelected();
return selected;
}

export type BootstrapStep =
| 'welcome'
| 'email-account'
Expand Down
65 changes: 57 additions & 8 deletions apps/web/src/app/(onboarding)/setup/hooks.client.test.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading