Skip to content

perf(Onboarding): Show the page while setup runs - #9234

Open
talissoncosta wants to merge 2 commits into
perf/onboarding-parallel-setupfrom
perf/onboarding-show-page-during-setup
Open

talissoncosta wants to merge 2 commits into
perf/onboarding-parallel-setupfrom
perf/onboarding-show-page-during-setup

Conversation

@talissoncosta

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to ENG-1258. Stacked on #9200.

The onboarding page showed a loader until setup finished, about 3.4s after #9200. The goal is for the page to feel ready in under a second.

  • Show the page straight away. Only what setup creates waits for it. The organisation, project and flag names, the wire snippet, the AI prompt and the flag row show placeholders. Their copy buttons stay disabled until setup finishes. The SDK picker, install command and console work from the start.
  • Create Production after the flag. The page only needs Development, so the critical path is now organisation, project, Development (with the tag), then the flag. Production is created afterwards and not awaited. A new environment copies every existing flag's state (create_initial_feature_states_for_environment), so it still gets the flag.

Trade-off: if creating Production fails, it fails silently, and resuming doesn't recreate it. Resuming only ensures Development, because creating a missing Production would add one to returning users' projects that use their own environment names.

How did you test this code?

  • On localhost against the staging API, with every project, environment, tag and feature request delayed by 2.5s:
    • The page rendered straight away with placeholders.
    • The wire copy button was disabled.
    • Once setup finished, the names, key and code filled in, and copy turned on.
  • Checked in dark mode. The accessible names are "Creating your organisation" and so on.
  • Not run end to end: Production being created after the flag on a brand-new organisation. Free plans allow one project, and every test account already has one. I confirmed the backend copies existing flags into a new environment (Environment.create_feature_states).
  • The onboarding unit tests pass.

@talissoncosta
talissoncosta requested a review from a team as a code owner December 3, 2026 16:40
@talissoncosta
talissoncosta removed the request for review from a team December 3, 2026 16:40
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
flagsmith-frontend-preview Ready Ready Preview Dec 3, 2026 7:34pm UTC
flagsmith-frontend-staging Ready Ready Preview Dec 3, 2026 7:34pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
docs Ignored Ignored Preview Dec 3, 2026 7:34pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 10 files

Confidence score: 3/5

  • The detached request can race the organisation refresh in bootstrapOnboarding.ts, leaving the legacy ProjectStore without Production when the user enters the app. Ensure bootstrap waits for the request or refreshes the legacy store after it completes.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="frontend/web/components/pages/onboarding/hooks/bootstrapOnboarding.ts">

<violation number="1" location="frontend/web/components/pages/onboarding/hooks/bootstrapOnboarding.ts:161">
P2: The detached request can finish after `bootstrapOnboarding` refreshes the organisation; entering the app then leaves the legacy `ProjectStore` without Production. The mutation only invalidates RTK environment tags, so this store stays stale until another project reload; refresh it when Production creation completes.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment on lines +161 to +163
createEnvironment(store, project.id, PROD_ENVIRONMENT_NAME).catch(() => {
// A missing Production environment doesn't block onboarding.
})

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: The detached request can finish after bootstrapOnboarding refreshes the organisation; entering the app then leaves the legacy ProjectStore without Production. The mutation only invalidates RTK environment tags, so this store stays stale until another project reload; refresh it when Production creation completes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At frontend/web/components/pages/onboarding/hooks/bootstrapOnboarding.ts, line 161:

<comment>The detached request can finish after `bootstrapOnboarding` refreshes the organisation; entering the app then leaves the legacy `ProjectStore` without Production. The mutation only invalidates RTK environment tags, so this store stays stale until another project reload; refresh it when Production creation completes.</comment>

<file context>
@@ -157,6 +157,10 @@ async function setUpNewProject(
   })
   API.trackEvent(Constants.events.CREATE_FIRST_FEATURE)
+  // Not awaited: the page only needs Development.
+  createEnvironment(store, project.id, PROD_ENVIRONMENT_NAME).catch(() => {
+    // A missing Production environment doesn't block onboarding.
+  })
</file context>
Suggested change
createEnvironment(store, project.id, PROD_ENVIRONMENT_NAME).catch(() => {
// A missing Production environment doesn't block onboarding.
})
createEnvironment(store, project.id, PROD_ENVIRONMENT_NAME)
.then(() => AppActions.getProject(project.id))
.catch(() => {
// A missing Production environment doesn't block onboarding.
})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changing this one. ProjectStore only loads a project when the user enters it, and fetches its environments fresh then. It's stale only if the user enters the project in the second or so before Production finishes, and the next project load fixes it. Refreshing the Flux store from onboarding could swap in the wrong project, which is worse.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No blocking issues remain. Requires human review: Onboarding now renders immediately with placeholders while setup runs, but Production environment creation becomes fire-and-forget, accepting silent failure and no recreation on resume; the stale ProjectStore finding is disputed rather than fixed.

- Disable Skip until setup is ready, so it can't fall back to /
- Report Production environment failures to Sentry
- Render inline skeletons as span with role=status

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 4 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Turn on auto-fix | Re-trigger cubic

This branch was successfully deployed

2 active deployments
Preview – flagsmith-frontend-staging — 54009b2b Deployed Dec 3, 2026 by vercel[bot]
Preview – flagsmith-frontend-preview — 54009b2b Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant