fix(settings): Defer sentry app form mount until data loads#115162
Conversation
📊 Type Coverage Diff✅ No new type safety issues introduced. Coverage: 93.47% |
2c02e1b to
34fb535
Compare
34fb535 to
a5a77ae
Compare
a5a77ae to
1628e9d
Compare
1628e9d to
f972007
Compare
f972007 to
f9918f7
Compare
1f7ef6a to
e78739d
Compare
The Sentry App edit page mounted `useScrapsForm` before the app data had finished loading, so the form's internal state was initialized from empty/default values. When the data arrived the form re-rendered but TanStack Form does not pick up new `defaultValues` after init, causing visible flashes (e.g. the Alert Rule Action switch flicking from off to on) and a risk of saving stale values. Extract the form into `SentryApplicationFormBody`, which the parent only mounts once the app query resolves (or for the new-app route), so `useScrapsForm` is initialized with the real values on first render. Tokens are still prefetched in parallel from the parent so the credentials panel renders without waiting on a second roundtrip. Refs #114138
e78739d to
39a785e
Compare
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 39a785e. Configure here.
The detail useQuery uses placeholderData to instantly seed the page from the list cache (so the breadcrumb name does not flicker). With placeholderData set, the query reports isLoading=false on first render, so the form mounted with stale list values. TanStack Form snapshots defaultValues on mount, so the form ignored the real response when it arrived and could save stale data. Also gate the form on isPlaceholderData so it only mounts once the real fetch resolves. The breadcrumb still uses app?.name from the placeholder, preserving the no-flicker UX. Refs #114138
This assessment is wrong. The flickering happens precisely because TanStack Form does pick up defaultValues after init - they have reactive defaultValues. So yes, the fix is to not render the form if you don’t want to init the form with fallback values that later update themselves, but the statement is not correct (I guess it’s AI?) |
yes it was auto-generated. Thanks for reading and correcting 🙏 I updated the description |
…-app-form-default-values # Conflicts: # static/app/views/settings/organizationDeveloperSettings/sentryApplicationDetails.tsx
The Sentry App edit page mounted
useScrapsFormbefore the app data had finished loading, so the form's internal state was initialized from empty/default values.When the data arrived the form re-rendered, but TanStack Form does not pick up new defaultValues after init — so the rendered values lagged behind the realTanStack Form's defaultValues are reactive — when the real data arrived the form picked up the new defaults and re-rendered, whichdata, briefly flashing (e.g. the Alert Rule Action switch flicking from off to on when opening an integration URL directly) and risking a save that overwrote
real values with empty ones.
is exactly what produced the visible flicker (e.g. the Alert Rule Action switch flipping from off to on when opening an integration URL directly) and risked a
save that overwrote real values with empty ones if the user interacted before the update landed.
Extract the form into a
SentryApplicationFormchild that the parent only mounts once the app query resolves (or for the new-app route), souseScrapsFormis initialized with the real values on its first render. Tokens are still prefetched in parallel from the parent so the credentials/tokens panel is ready by the time the form mounts.Before
Screen.Recording.2026-05-08.at.11.30.34.mov
After
Screen.Recording.2026-05-08.at.11.31.09.mov