Skip to content

feat(onboarding): Revalidate restored SCM messaging destinations - #121187

Draft
jaydgoss wants to merge 5 commits into
feat/vdy-140-treatment-route-statefrom
feat/vdy-140-messaging-revalidation
Draft

feat(onboarding): Revalidate restored SCM messaging destinations#121187
jaydgoss wants to merge 5 commits into
feat/vdy-140-treatment-route-statefrom
feat/vdy-140-messaging-revalidation

Conversation

@jaydgoss

@jaydgoss jaydgoss commented Aug 4, 2026

Copy link
Copy Markdown
Member

TLDR

A messaging destination restored from session storage names an organization-scoped integration and channel that may no longer exist. This revalidates both before treating the destination as usable, and keeps it non-submittable while either query is in flight.

Details

Split out of #120992, which established the treatment route and the session contract. It lands separately because nothing can write a selected destination yet — VDY-143 adds the inline picker and VDY-141 adds Set up later. Until then this logic is unreachable in production, so reviewing it on its own terms is more useful than folding it into the route PR, and #120992 stays focused on the four- versus five-step split.

useScmMessagingSetupValidation re-fetches the saved active integration and, if it resolves, the channel list for it. A missing integration resets state to unconfigured with an explanation. Cached values stay non-submittable while either query is fetching, so a restored destination is never shown as selected on stale cache.

An empty channel list is deliberately not treated as staleness. Every provider helper in organization_integration_channels.py returns [] when its upstream API call fails, so results: [] cannot be distinguished from a deleted channel; resetting on it would discard a valid destination during a transient Slack or Discord outage. Only a populated list that omits the saved channel counts as stale.

The hook is file-local. Exporting it before it has a second consumer trips knip; VDY-143 lifts it out when the picker needs it.

Coverage: revalidation before showing selected, missing integration, missing channel, the empty-list outage case, and a stale query cache.

Refs VDY-140

@linear-code

linear-code Bot commented Aug 4, 2026

Copy link
Copy Markdown

VDY-140

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Aug 4, 2026
@sentry

sentry Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 451 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

@jaydgoss
jaydgoss force-pushed the feat/vdy-140-treatment-route-state branch from 4a1eaad to dd36973 Compare August 4, 2026 18:10
@jaydgoss
jaydgoss force-pushed the feat/vdy-140-messaging-revalidation branch from 75d419a to 6775e19 Compare August 4, 2026 18:10
@jaydgoss
jaydgoss marked this pull request as ready for review August 4, 2026 20:29
@jaydgoss
jaydgoss requested a review from a team as a code owner August 4, 2026 20:29
Comment thread static/app/views/onboarding/scmMessaging.tsx
@jaydgoss
jaydgoss force-pushed the feat/vdy-140-messaging-revalidation branch from 6775e19 to 5a1e02a Compare August 4, 2026 21:15
@jaydgoss
jaydgoss force-pushed the feat/vdy-140-messaging-revalidation branch from 5a1e02a to 1124beb Compare August 4, 2026 21:22
@jaydgoss
jaydgoss force-pushed the feat/vdy-140-treatment-route-state branch from 295494f to 75c146a Compare August 4, 2026 21:24
@jaydgoss
jaydgoss force-pushed the feat/vdy-140-messaging-revalidation branch from 1124beb to 3d4847c Compare August 4, 2026 21:24

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 3d4847c. Configure here.

Comment thread static/app/views/onboarding/scmMessaging.tsx
jaydgoss and others added 2 commits August 4, 2026 16:42
A destination restored from session storage names an organization-scoped
integration and channel that may no longer exist. Revalidate both before
treating it as usable, and keep it non-submittable while either query is
in flight.

An empty channel list is deliberately not treated as staleness: every
provider helper in organization_integration_channels.py returns [] when its
upstream call fails, so `results: []` cannot be told apart from a deleted
channel. Resetting on it would discard a valid destination during a
transient Slack or Discord outage.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Do not clear a restored destination from stale cached integration or channel data while TanStack Query is refetching. Revalidate against the completed response before updating session state.
Validate a restored integration through its direct organization-scoped endpoint and keep a channel omitted from a partial listing in session state. The destination remains non-submittable until it can be verified.

Refs VDY-140
Comment thread static/app/views/onboarding/scmMessaging.tsx
Comment thread static/app/views/onboarding/scmMessaging.tsx
Distinguish disabled or pending-deletion integrations from missing integrations when revalidating a restored messaging destination.

Refs VDY-140
Extract the integration active check and the saved-identifier match into pure module-level functions, and drop both useMemo wrappers. Neither memo was doing anything: one returns the query data object, the other an element of it, and both references are already stable across renders, so the effect dependency identities are unchanged.

Name the two query-settled conditions so the effect guards and the returned flags read the same way, which also shrinks the effect dependency array from eleven entries to eight.

isValid now requires the integration to have resolved rather than just checking the raw query flags, matching how isError and isPending already gate their channels half. Previously a cached channel list plus an integration that returns 200 but disabled would render the inactive warning and the selected state at the same time.

Refs VDY-140
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