Skip to content

fix(onboarding): Preserve user-entered project slug during platform selection#109609

Open
sentry[bot] wants to merge 1 commit intomasterfrom
seer/fix/project-creation-slug-overwrite
Open

fix(onboarding): Preserve user-entered project slug during platform selection#109609
sentry[bot] wants to merge 1 commit intomasterfrom
seer/fix/project-creation-slug-overwrite

Conversation

@sentry
Copy link
Contributor

@sentry sentry bot commented Feb 27, 2026

This PR addresses a bug where a user-entered project slug would be overwritten when a platform was selected during the project creation onboarding flow.

Problem:
Previously, the logic in handlePlatformChange attempted to determine if the project name was user-modified by comparing formData.projectName with formData.platform?.key. This heuristic was flawed:

  1. If a user typed a project name that happened to match the currently selected platform's key, the system would incorrectly assume it was an auto-generated name and overwrite it if a different platform was subsequently selected.
  2. The useEffect that synced initialData to formData could also inadvertently reset the projectName field if initialData re-evaluated (e.g., due to asynchronous loading of teams), clobbering user input.

Solution:

  1. Introduced a useRef, hasUserModifiedProjectName, to explicitly track whether the user has manually typed into the project slug input field. This provides a reliable signal that the user intends to keep their custom name.
  2. The onChange handler for the project name input now sets hasUserModifiedProjectName.current = true when the user types. It also resets this ref to false if the user clears the input, allowing the platform-based auto-fill to take over again.
  3. handlePlatformChange now uses hasUserModifiedProjectName.current to decide whether to overwrite the projectName with the selected platform's ID, ensuring user input is respected.

Tests:
Added new test cases to createProject.spec.tsx to cover:

  • Ensuring a user-entered name (even one matching a platform key) is preserved when switching platforms.
  • Verifying that clearing the project name input allows platform selection to re-populate the field.

Ref NEW-769

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 27, 2026
@billyvg billyvg added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Feb 27, 2026
@sentry sentry bot changed the title fix(project-creation): Preserve user-entered project slug during onboarding fix(onboarding): Preserve user-entered project slug during creation Feb 27, 2026
@sentry sentry bot force-pushed the seer/fix/project-creation-slug-overwrite branch from e8f4af1 to 9a11c80 Compare February 27, 2026 20:38
@github-actions github-actions bot removed the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Feb 27, 2026
@sentry sentry bot force-pushed the seer/fix/project-creation-slug-overwrite branch from 9a11c80 to b0c0b94 Compare February 27, 2026 20:42
@sentry sentry bot changed the title fix(onboarding): Preserve user-entered project slug during creation fix(onboarding): Preserve user-entered project slug during platform selection Feb 27, 2026
@linear
Copy link

linear bot commented Feb 27, 2026

@billyvg billyvg marked this pull request as ready for review February 27, 2026 20:43
@billyvg billyvg requested a review from a team as a code owner February 27, 2026 20:43
@billyvg billyvg self-assigned this Feb 27, 2026
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


const [formData, setFormData] = useState<FormData>(initialData);
const pickerKeyRef = useRef<'create-project' | 'auto-fill'>('create-project');
const hasUserModifiedProjectName = useRef(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ref not reset when useEffect clobbers project name

Medium Severity

The hasUserModifiedProjectName ref can desync from actual form state. The existing useEffect (lines 247–251) resets formData.projectName to '' whenever initialData changes (e.g., when defaultTeam updates due to async team loading), but does not reset hasUserModifiedProjectName. After this, the ref is true while the project name is empty, so subsequent platform selection preserves the empty string instead of auto-filling the platform name — a regression from the old behavior which would auto-fill for empty names.

Additional Locations (2)

Fix in Cursor Fix in Web

const userModifiedName =
!!formData.projectName && formData.projectName !== formData.platform?.key;
const newName = userModifiedName ? formData.projectName : value.id;
const newName = hasUserModifiedProjectName.current ? formData.projectName : value.id;
Copy link
Contributor

Choose a reason for hiding this comment

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

AutoFill project name overwritten on platform change

Low Severity

When autoFill is active (user navigated back from getting-started), the initialData pre-fills projectName from the previously created project (e.g., "my-cool-app"). However, hasUserModifiedProjectName starts as false and is only set true by typing in the input — not by programmatic pre-filling. So if the user changes the platform, handlePlatformChange treats the auto-filled name as auto-generated and overwrites it with the new platform key. The old heuristic (projectName !== platform.key) would have preserved it since the project name typically differs from the platform key.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant