Skip to content

refactor(forntend): improve providers table#5033

Open
jog1t wants to merge 1 commit into
05-11-fix_frontend_missing_provider_configuration_right_after_adding_itfrom
05-11-refactor_forntend_improve_providers_table
Open

refactor(forntend): improve providers table#5033
jog1t wants to merge 1 commit into
05-11-fix_frontend_missing_provider_configuration_right_after_adding_itfrom
05-11-refactor_forntend_improve_providers_table

Conversation

@jog1t
Copy link
Copy Markdown
Contributor

@jog1t jog1t commented May 11, 2026

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 11, 2026

Code Review: refactor(frontend): improve providers table

The PR title has a typo: forntend should be frontend.

Overview

This PR decouples RunnerConfigsTable from routing and data-fetching dependencies by introducing callback props (renderRegion, onEditConfig, onDeleteConfig, totalDatacenterCount). The provider if-chain is replaced with lookup maps, tooltips now show per-datacenter detail, Ladle stories cover realistic fixtures, and the auth module gains a from-based post-login redirect.


Bugs

1. NaN risk in totalDatacenterCount reducer (settings.tsx)

If page.datacenters is undefined, undefined?.length is undefined and acc + undefined === NaN. The Global label silently disappears because regions.length === NaN is always false. This was pre-existing in Regions but the PR is the first to surface the result as a prop. Fix: acc + (page.datacenters?.length ?? 0).

2. Inconsistent from path validation between email login and Google OAuth (login.tsx)

Login delegates to redirectToOrganization which calls isSafeInternalPath (blocks /login, /join, /verify-email-pending, /forgot-password). LoginWithGoogle uses a looser inline check that skips those exclusions. With ?from=/login, a successful Google OAuth round-trip redirects back to the login page -- a loop. Export isSafeInternalPath from auth.ts and use it in LoginWithGoogle instead of the inline check.


Code Quality

3. Fragile Set first-element access

breakdown.kinds.values().next().value as RunnerKind silently produces undefined if the set is somehow empty. Prefer [...breakdown.kinds][0] as RunnerKind -- clearer and consistent with how the rest of the file destructures iterables.

4. Ping animation inlined instead of the shared Ping component

The success branch in StatusCell duplicates the Ping design-system component inline. If Ping gets dark-mode, theming, or accessibility updates, this copy will not follow. Ping is already available via the @/components barrel imported here.


Minor

  • totalDatacenterCount flash: no loading state means the label reads "Multiple regions" on first render and flips to "Global" once the datacenter query resolves.
  • useSearch({ strict: false }) as { from?: string }: a validateSearch on the route gives proper type inference at no extra cost.
  • PROVIDER_LABELS and PROVIDER_ICONS are parallel maps on the same keys; a single Record<string, { label: string; icon: IconDefinition }> would prevent a provider being added to one map but missed in the other.

Positives

  • Dependency injection (renderRegion, action callbacks) makes the table genuinely testable in isolation; the stories file demonstrates this directly.
  • Stories cover realistic data shapes (empty, error, loading, single vs. multi-endpoint, mixed kinds, runner pool error) rather than prop permutations, consistent with the updated CLAUDE.md guidance.
  • Lookup maps replacing the provider if-chain make adding a new provider a one-liner.
  • Per-datacenter tooltip rows are a real UX improvement over the old comma-list.

Summary

Two bugs worth fixing before merge: the NaN accumulator in the datacenter count reducer, and the inconsistent from-path validation for Google OAuth. The Ping inlining and Set iteration patterns are lower-priority cleanup items.

@jog1t jog1t force-pushed the 05-11-fix_frontend_missing_provider_configuration_right_after_adding_it branch from f633f55 to c64f1b8 Compare May 11, 2026 18:49
@jog1t jog1t force-pushed the 05-11-refactor_forntend_improve_providers_table branch from 223bdc0 to 2b7c11e Compare May 11, 2026 18:49
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