Skip to content

Conversation

@Roffenlund
Copy link
Contributor

@Roffenlund Roffenlund commented Nov 7, 2025

  • Use loader for inital data fetch in Settings.tsx
  • Use clientLoader and getSessionCurrentUser for subsequent page loads
  • Revalidate the page after successfully disconnecting a social auth account
  • Implement helper functions in Settings.tsx for getting session id's and tab classes in Settings.tsx
  • Disable the switch in UI if there is only one social auth account left in order to prevent unnecessary API calls
  • Improve error messaging
  • Add proper success message with provider name

Fix how the error message is fetched and displayed when disconnecting
a social auth account.

Refs. TS-2758
@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Walkthrough

Connections.tsx: added a ref (disconnectingProviderRef) to track pending disconnects, uses react-router's revalidator to refresh data after disconnects, computes onlyOneConnected and getConnection helpers, updates onSubmit success/error to show contextual toasts and handle ApiError field messages, removes explicit logged-in throws, and disables connection switches when only one provider remains. Settings.tsx: introduced a server-side loader and clientLoader, switched to a Suspense/Await pattern with SkeletonBox fallback, added tabClass helper, and resolves currentUser before supplying outlet context. Connection.tsx: added a public boolean disabled prop and forwards it to the switch control.

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix disconnect social auth bugs' directly addresses the primary objective of the PR, which is fixing issues related to disconnecting social auth accounts.
Description check ✅ Passed The description comprehensively outlines all major changes including loader implementation, clientLoader usage, revalidation, helper functions, UI disable logic, and improved messaging—all aligned with the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-disconnect-social-auth-bugs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Roffenlund Roffenlund marked this pull request as draft November 7, 2025 10:22
@codecov
Copy link

codecov bot commented Nov 7, 2025

Codecov Report

❌ Patch coverage is 0% with 80 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.87%. Comparing base (41d8862) to head (003bebd).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
...emix/app/settings/user/Connections/Connections.tsx 0.00% 47 Missing ⚠️
...ps/cyberstorm-remix/app/settings/user/Settings.tsx 0.00% 30 Missing ⚠️
...mix/app/commonComponents/Connection/Connection.tsx 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #1600      +/-   ##
=========================================
- Coverage    9.88%   9.87%   -0.02%     
=========================================
  Files         308     308              
  Lines       22502   22540      +38     
  Branches      404     404              
=========================================
  Hits         2225    2225              
- Misses      20277   20315      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86d570d and 57b7d24.

📒 Files selected for processing (2)
  • apps/cyberstorm-remix/app/settings/user/Connections/Connections.tsx (2 hunks)
  • apps/cyberstorm-remix/app/settings/user/Settings.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
apps/cyberstorm-remix/app/settings/user/Settings.tsx (3)
apps/cyberstorm-remix/app/root.tsx (1)
  • OutletContextShape (84-89)
apps/cyberstorm-remix/cyberstorm/security/publicEnvVariables.ts (1)
  • getPublicEnvVariables (19-48)
packages/dapper-ts/src/index.ts (1)
  • DapperTs (38-96)
apps/cyberstorm-remix/app/settings/user/Connections/Connections.tsx (1)
packages/thunderstore-api/src/errors.ts (1)
  • ApiError (14-64)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Generate visual diffs
  • GitHub Check: Build

@Roffenlund Roffenlund force-pushed the fix-disconnect-social-auth-bugs branch from 57b7d24 to 1663a1d Compare November 7, 2025 14:32
@Roffenlund Roffenlund marked this pull request as ready for review November 7, 2025 14:36
@Roffenlund Roffenlund changed the title Fix disconnect social auth bugs - WIP Fix disconnect social auth bugs Nov 7, 2025
Copy link
Contributor

@anttimaki anttimaki left a comment

Choose a reason for hiding this comment

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

I think there's a bug on "prevent removing last connection".

Other comments are not blockers, they're mostly focused on finding common practices that should be made code base wide.

return { currentUser };
}

export function HydrateFallback() {
Copy link
Contributor

Choose a reason for hiding this comment

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

In #1604 I addressed why using HydrateFallback seems like a suboptimal solution for a page with tabs. Should Suspense+Await be used here too?

Copy link
Contributor

Choose a reason for hiding this comment

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

While Suspense+Await is now in place, the main issue isn't fixed yet. If getSessionCurrentUser is changed to sleep a few seconds, when moving between Settings and Account tabs there's no indication of registering the click, like rendering the skeleton box. Instead, the whole section is rendered only after the promise resolves. This is likely caused by the fact that in user settings the currentUser is fetched on the parent component, whereas on the team settings each tab has their own clientLoader implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will look into which pattern is recommended for this architecture.

Comment on lines 48 to 23
const tools = getSessionTools();
const currentUser = await tools.getSessionCurrentUser(true);
return { currentUser };
Copy link
Contributor

Choose a reason for hiding this comment

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

Only check for the ´currentUser.usernameand thrown an error, if it'sundefined. There's no need to return the currentUser` as it's not used in the layout(template in django).

And it's not used in there, because you are checking for the session already in the clientLoader.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The currentUser variable is used in several places in the child components of this page.

Implement a flag to disable a connection switch in the common
Connection component.

Refs. TS-2758
- Implement clientLoader for fetching currentUser
- clientLoader always fetches and updates a fresh user from API
- Use helper function for getting tab classes
- Use HydrateFallback for rendering a loading message

Refs. TS-2758
- Disable switching off the last active social auth account
- Update success message when user disconnects social auth
- Implement helper function for getting connection
- Implement helper function for checking if user has only one connection
- Simplify component logic

Refs. TS-2758
- Remove HydrateFallback
- Use Suspense/Await pattern
- Return promise from clientLoader instead of resolved data

Refs. TS-2758
@Roffenlund Roffenlund force-pushed the fix-disconnect-social-auth-bugs branch from 1663a1d to 003bebd Compare November 11, 2025 13:10
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1663a1d and 003bebd.

📒 Files selected for processing (3)
  • apps/cyberstorm-remix/app/commonComponents/Connection/Connection.tsx (2 hunks)
  • apps/cyberstorm-remix/app/settings/user/Connections/Connections.tsx (3 hunks)
  • apps/cyberstorm-remix/app/settings/user/Settings.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
apps/cyberstorm-remix/app/settings/user/Connections/Connections.tsx (4)
apps/cyberstorm-remix/app/root.tsx (1)
  • OutletContextShape (84-89)
packages/thunderstore-api/src/errors.ts (1)
  • ApiError (14-64)
apps/cyberstorm-remix/app/commonComponents/Connection/Connection.tsx (1)
  • Connection (17-48)
apps/cyberstorm-remix/cyberstorm/utils/ThunderstoreAuth.tsx (1)
  • buildAuthLoginUrl (8-14)
apps/cyberstorm-remix/app/settings/user/Settings.tsx (4)
apps/cyberstorm-remix/app/root.tsx (1)
  • OutletContextShape (84-89)
apps/cyberstorm-remix/cyberstorm/security/publicEnvVariables.ts (1)
  • getSessionTools (50-67)
packages/cyberstorm/src/index.ts (2)
  • Tabs (109-109)
  • SkeletonBox (92-92)
packages/cyberstorm/src/newComponents/Tabs/Tabs.tsx (1)
  • Tabs (18-40)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test
  • GitHub Check: Generate visual diffs

Comment on lines +54 to +57
const getConnection = (provider: ProvidersType) =>
outletContext.currentUser?.connections?.find(
(c) => c.provider?.toLowerCase() === provider.identifier
);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix provider typing in getConnection.

Parameter is typed as ProvidersType (the whole array), so identifier is missing and the file won’t compile. Please type it as a single provider entry instead.

-  const getConnection = (provider: ProvidersType) =>
+  const getConnection = (provider: ProvidersType[number]) =>
🤖 Prompt for AI Agents
In apps/cyberstorm-remix/app/settings/user/Connections/Connections.tsx around
lines 54 to 57, the getConnection parameter is incorrectly typed as the whole
ProvidersType array; change the parameter to represent a single provider entry
(e.g. ProvidersType[number] or the specific Provider type used in the codebase)
so provider.identifier exists and the file compiles, then keep the comparison
logic (provider.identifier) as-is.

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.

4 participants