refactor: injects browserEnvConfig from DI container#2453
Conversation
📝 WalkthroughWalkthroughReplaces direct imports of browserEnvConfig with runtime-sourced Changes
Sequence Diagram(s)No sequence diagrams generated. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
7d5695f to
35b76e7
Compare
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (25.58%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2453 +/- ##
==========================================
- Coverage 50.97% 50.66% -0.31%
==========================================
Files 1062 1052 -10
Lines 29192 28836 -356
Branches 6446 6363 -83
==========================================
- Hits 14880 14610 -270
+ Misses 13967 13817 -150
- Partials 345 409 +64
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
Fix all issues with AI Agents 🤖
In @apps/deploy-web/src/components/layout/WalletStatus.tsx:
- Line 84: WalletStatus.tsx renders ManagedWalletPopup and
ConnectManagedWalletButton based only on isManaged and !isSignedInWithTrial,
which is inconsistent with GetStartedStepper.tsx and UserProviders.tsx that gate
behavior on publicConfig.NEXT_PUBLIC_BILLING_ENABLED; either update
WalletStatus.tsx to include the billing flag in the render conditions (e.g.,
change both conditions to publicConfig.NEXT_PUBLIC_BILLING_ENABLED && isManaged
and publicConfig.NEXT_PUBLIC_BILLING_ENABLED && !isSignedInWithTrial for
ManagedWalletPopup and ConnectManagedWalletButton respectively) or add a clear
code comment above these renders documenting the intentional decision to ignore
the billing flag so behavior is explicit and consistent with
GetStartedStepper.tsx and UserProviders.tsx.
In @apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx:
- Around line 85-93: CustodialWalletPopup.tsx is inconsistent with
GetStartedStepper.tsx: restore the same NEXT_PUBLIC_BILLING_ENABLED gating
around the ConnectManagedWalletButton so behavior matches; specifically, when
rendering the else branch that currently returns <ConnectManagedWalletButton />,
wrap that rendering in the same environment flag check used in
GetStartedStepper.tsx (e.g., process.env.NEXT_PUBLIC_BILLING_ENABLED === 'true')
so ConnectManagedWalletButton is only shown when billing is enabled, keeping the
existing trial/user sign-in branch unchanged.
🧹 Nitpick comments (1)
apps/deploy-web/src/components/layout/TrackingScripts.tsx (1)
55-55: Consider addingpublicConfigto the dependency array.The
useEffecton line 11 referencespublicConfigvalues but only includesisProductionin its dependency array. IfpublicConfigcan change during runtime, this could lead to stale closures.However, if
publicConfigfrom the DI container is a stable reference that never changes (which is typical for DI patterns), the current implementation is correct.🔎 Proposed fix if publicConfig can change
- }, [isProduction]); + }, [isProduction, publicConfig]);Or if only specific config values matter:
- }, [isProduction]); + }, [isProduction, publicConfig.NEXT_PUBLIC_TRACKING_ENABLED, publicConfig.NEXT_PUBLIC_GROWTH_CHANNEL_TRACKING_ENABLED, publicConfig.NEXT_PUBLIC_GTM_ID]);
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsxapps/deploy-web/src/components/get-started/GetStartedStepper.tsxapps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsxapps/deploy-web/src/components/layout/TrackingScripts.tsxapps/deploy-web/src/components/layout/WalletStatus.tsxapps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsxapps/deploy-web/src/components/shared/TrialDeploymentBadge.tsxapps/deploy-web/src/components/wallet/CustodialWalletPopup.tsxapps/deploy-web/src/config/browser-env.config.tsapps/deploy-web/src/context/FlagProvider/FlagProvider.tsxapps/deploy-web/src/hooks/useAutoTopUpLimits.tsxapps/deploy-web/src/hooks/useFlag.tsxapps/deploy-web/src/hooks/useHasCreditCardBanner.tsapps/deploy-web/src/hooks/useManagedWallet.tsapps/deploy-web/src/hooks/useManagedWalletDenom.ts
💤 Files with no reviewable changes (1)
- apps/deploy-web/src/config/browser-env.config.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/*.{ts,tsx,js}: Never use typeanyor cast to typeany. Always define the proper TypeScript types.
Never use deprecated methods from libraries.
Don't add unnecessary comments to the code.
Files:
apps/deploy-web/src/hooks/useAutoTopUpLimits.tsxapps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsxapps/deploy-web/src/components/layout/WalletStatus.tsxapps/deploy-web/src/components/wallet/CustodialWalletPopup.tsxapps/deploy-web/src/components/layout/TrackingScripts.tsxapps/deploy-web/src/hooks/useManagedWallet.tsapps/deploy-web/src/components/shared/TrialDeploymentBadge.tsxapps/deploy-web/src/hooks/useFlag.tsxapps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsxapps/deploy-web/src/components/get-started/GetStartedStepper.tsxapps/deploy-web/src/hooks/useManagedWalletDenom.tsapps/deploy-web/src/hooks/useHasCreditCardBanner.tsapps/deploy-web/src/context/FlagProvider/FlagProvider.tsxapps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx
🧠 Learnings (3)
📚 Learning: 2025-10-15T16:39:55.348Z
Learnt from: jzsfkzm
Repo: akash-network/console PR: 2039
File: apps/deploy-web/tests/ui/change-wallets.spec.ts:4-10
Timestamp: 2025-10-15T16:39:55.348Z
Learning: In the Akash Console E2E tests using the context-with-extension fixture, the first wallet is automatically created during fixture setup via `importWalletToLeap` in `apps/deploy-web/tests/ui/fixture/wallet-setup.ts`, so tests that call `frontPage.createWallet()` are creating a second wallet to test wallet switching functionality.
Applied to files:
apps/deploy-web/src/hooks/useManagedWallet.ts
📚 Learning: 2025-07-28T10:40:13.595Z
Learnt from: stalniy
Repo: akash-network/console PR: 1480
File: apps/deploy-web/src/hooks/useFlag.tsx:0-0
Timestamp: 2025-07-28T10:40:13.595Z
Learning: In the Akash Network Console project, backend-specific feature flags are intentional and acceptable. The frontend FeatureFlag union type should only include flags that are actually used by the frontend, not all flags defined in the backend. Backend can have internal feature flags for backend-only functionality without requiring frontend synchronization.
Applied to files:
apps/deploy-web/src/hooks/useFlag.tsxapps/deploy-web/src/context/FlagProvider/FlagProvider.tsx
📚 Learning: 2025-11-12T16:36:02.543Z
Learnt from: baktun14
Repo: akash-network/console PR: 2203
File: apps/deploy-web/src/components/onboarding/steps/PaymentMethodContainer/PaymentMethodContainer.tsx:161-168
Timestamp: 2025-11-12T16:36:02.543Z
Learning: In apps/deploy-web/src/components/onboarding/steps/PaymentMethodContainer/PaymentMethodContainer.tsx, the organization field captured during payment method setup is internal metadata. Errors from stripe.updateCustomerOrganization should be logged to Sentry but not surfaced to users, and the flow should continue even if the organization update fails, as it's non-critical and not something users can fix.
Applied to files:
apps/deploy-web/src/components/get-started/GetStartedStepper.tsx
🧬 Code graph analysis (12)
apps/deploy-web/src/hooks/useAutoTopUpLimits.tsx (3)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)apps/deploy-web/src/queries/useExactFeeAllowanceQuery.ts (1)
useExactFeeAllowanceQuery(6-13)apps/deploy-web/src/queries/useExactDeploymentGrantsQuery.ts (1)
useExactDeploymentGrantsQuery(6-16)
apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/components/layout/WalletStatus.tsx (2)
apps/deploy-web/src/components/wallet/ManagedWalletPopup.tsx (1)
ManagedWalletPopup(19-90)apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.tsx (1)
ConnectManagedWalletButton(26-41)
apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx (2)
apps/deploy-web/src/utils/urlUtils.ts (1)
UrlService(16-96)apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.tsx (1)
ConnectManagedWalletButton(26-41)
apps/deploy-web/src/components/layout/TrackingScripts.tsx (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/hooks/useManagedWallet.ts (1)
apps/deploy-web/src/queries/useManagedWalletQuery.ts (1)
useManagedWalletQuery(7-20)
apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/hooks/useFlag.tsx (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx (2)
apps/deploy-web/src/services/analytics/analytics.service.ts (1)
GoogleAnalytics(142-142)apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/hooks/useManagedWalletDenom.ts (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
⏰ 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: validate / validate-app
- GitHub Check: test-build
🔇 Additional comments (14)
apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx (2)
8-8: LGTM! Clean DI integration.The import of
useServicescorrectly supports the refactoring to injectpublicConfigfrom the DI container instead of directly importingbrowserEnvConfig.
19-21: Successful DI migration for feature flag configuration.The refactoring correctly replaces direct
browserEnvConfigimport with context-basedpublicConfigfromuseServices(). This improves testability by allowing the configuration to be mocked throughServicesProvider, aligning with the PR's stated objective.apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx (1)
50-50: LGTM! Clean refactor to DI-based configuration.The migration from
browserEnvConfigtopublicConfigviauseServices()is consistent with the PR objective. The managed wallet denomination is now sourced from the DI container, improving testability without changing behavior.Also applies to: 234-234
apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx (1)
5-5: LGTM! Configuration now sourced from DI container.The Google Analytics flag is now accessed through the
publicConfigfromuseServices(), maintaining the same conditional rendering logic while improving testability.Also applies to: 8-8, 17-17
apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx (1)
7-7: LGTM! Trial duration configuration migrated to DI.The trial duration fallback now reads from
publicConfigviauseServices(), consistent with the broader refactoring. The logic remains unchanged.Also applies to: 27-28
apps/deploy-web/src/hooks/useManagedWalletDenom.ts (1)
1-1: LGTM! Hook now uses context-based configuration.The managed wallet denomination is now sourced from
publicConfigviauseServices(). The conditional logic remains unchanged, and the hook maintains proper type safety.Also applies to: 6-6, 10-10
apps/deploy-web/src/hooks/useManagedWallet.ts (1)
17-17: The billing feature flag gating has been removed from the managed wallet query.The invocation at line 17 is now unconditional, depending only on
user?.idexistence. TheuseManagedWalletQueryimplementation properly handles the null case via itsenabled: !!userIdflag. TheNEXT_PUBLIC_BILLING_ENABLEDflag still exists in the codebase but is now only used inUserProviders.tsxandGetStartedStepper.tsxfor conditional UI rendering—it has been intentionally removed from the managed wallet hook.apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx (1)
11-11: LGTM! Clean refactoring to use DI container.The migration from
browserEnvConfigtopublicConfigviauseServices()is consistent and straightforward, improving testability as stated in the PR objectives.Also applies to: 30-30, 64-64
apps/deploy-web/src/hooks/useAutoTopUpLimits.tsx (1)
6-6: LGTM! Consistent migration to DI container.The wallet address configuration is now properly sourced from
publicConfig, maintaining all existing behavior while improving testability.Also applies to: 12-12, 14-17
apps/deploy-web/src/hooks/useHasCreditCardBanner.ts (2)
14-17: Inconsistent AI summary.The AI summary states "removed requirements for hasManagedWallet, isWalletLoading, and isSignedInWithTrial," but the code on line 15 still checks all these conditions. The actual change appears to be the removal of the
NEXT_PUBLIC_BILLING_ENABLEDflag check only.
14-17: LGTM! Billing flag removal simplifies banner logic.The removal of the billing flag check from
shouldShowBanneris consistent with the PR's objective to removeNEXT_PUBLIC_BILLING_ENABLED. The banner visibility now depends solely on initialization state, wallet status, and trial sign-in state.apps/deploy-web/src/components/layout/TrackingScripts.tsx (1)
4-4: LGTM! Comprehensive migration to DI container.All tracking configuration (GTM ID, feature flags, environment) is now properly sourced from
publicConfigvia theuseServices()hook, maintaining consistent behavior while improving testability.Also applies to: 8-13, 25-25, 32-32
apps/deploy-web/src/hooks/useFlag.tsx (1)
8-12: LGTM! Clean refactor to use DI container.The refactor successfully moves from static import to runtime configuration via
useServices(). The wrapper function pattern ensures a consistent API by always accepting aflagparameter and delegating to the selected hook implementation based onpublicConfig.NEXT_PUBLIC_UNLEASH_ENABLE_ALL.Note that this hook now requires React component context (since
useServices()usesuseContext), but this is appropriate for a React hook.apps/deploy-web/src/components/get-started/GetStartedStepper.tsx (1)
16-16: LGTM! Consistent migration to DI-based configuration.The refactor successfully replaces direct
browserEnvConfigusage withpublicConfigfrom the DI container viauseServices(). The logic remains unchanged—only the configuration source has been updated, which aligns with the PR's objective of enabling better testing through dependency injection.All three usages of
publicConfig.NEXT_PUBLIC_BILLING_ENABLED(lines 80, 84, 147) correctly gate billing-related UI elements.Also applies to: 32-32, 80-80, 84-84, 147-147
35b76e7 to
b483625
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx (1)
14-20: Tests: usequeryBy*in expectations (per repo guidelines).Line 19 uses
getByRolein an expectation. Switch toqueryByRole(still fails clearly viatoBeInTheDocument()if null).Proposed fix
- expect(screen.getByRole("status")).toBeInTheDocument(); + expect(screen.queryByRole("status")).toBeInTheDocument();Also applies to: 56-83
🧹 Nitpick comments (4)
apps/deploy-web/src/hooks/useManagedWalletDenom.ts (1)
6-10: EnsureServicesProvider/publicConfigis always available (and typed), or add a safe fallback.This hook now hard-depends on
useServices()(vs a direct import), so any usage outsideServicesProvider(or tests that don’t wrap it) will crash at runtime; also please ensurepublicConfigisn’t effectivelyany(per TS guideline).Proposed tweak (defensive read + clearer intent)
export const useManagedWalletDenom = () => { const { publicConfig } = useServices(); const wallet = useWallet(); const usdcDenom = useUsdcDenom(); - return wallet.isManaged && publicConfig.NEXT_PUBLIC_MANAGED_WALLET_DENOM === "usdc" ? usdcDenom : "uakt"; + const managedWalletDenom = publicConfig?.NEXT_PUBLIC_MANAGED_WALLET_DENOM; + return wallet.isManaged && managedWalletDenom === "usdc" ? usdcDenom : "uakt"; };apps/deploy-web/src/hooks/useHasCreditCardBanner.ts (1)
14-17: Confirm banner visibility is intentionally “sticky”.
isBannerVisibleis only set totrueand never reset, so once shown it remains visible even ifhasManagedWallet/isSignedInWithTrialflips later.Also applies to: 25-31
apps/deploy-web/src/components/get-started/GetStartedStepper.tsx (1)
72-88: Copy/UX: “Billing is not set up” when wallet isn’t connected may confuse flows.Now that the step always reads “Trial / Billing” and the “Billing is not set up” block shows whenever
!isWalletConnected, consider aligning wording with the actual decision point (connect wallet vs start trial) to avoid implying a billing-account misconfiguration.Also applies to: 137-152
apps/deploy-web/src/components/layout/TrackingScripts.tsx (1)
7-56: Effect deps/cleanup + validate GTM ID before interpolating intoinnerHTML.
- The effect reads
publicConfig.NEXT_PUBLIC_TRACKING_ENABLED,publicConfig.NEXT_PUBLIC_GROWTH_CHANNEL_TRACKING_ENABLED, andpublicConfig.NEXT_PUBLIC_GTM_ID, but only depends onisProduction.- If this effect ever re-runs, the appended
<noscript>isn’t cleaned up.- Since GTM ID is now runtime-sourced, interpolating it into
innerHTMLis riskier unless it’s validated (e.g.,^GTM-[A-Z0-9]+$) at the config/schema layer.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (24)
apps/api/env/.env.functional.testapps/api/env/.env.productionapps/api/env/.env.sampleapps/api/env/.env.stagingapps/api/env/.env.unit.testapps/deploy-web/.env.local.sampleapps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsxapps/deploy-web/src/components/get-started/GetStartedStepper.tsxapps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsxapps/deploy-web/src/components/layout/TrackingScripts.tsxapps/deploy-web/src/components/layout/WalletStatus.tsxapps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsxapps/deploy-web/src/components/shared/TrialDeploymentBadge.tsxapps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsxapps/deploy-web/src/components/user/UserProviders/UserProviders.tsxapps/deploy-web/src/components/wallet/CustodialWalletPopup.tsxapps/deploy-web/src/config/browser-env.config.tsapps/deploy-web/src/config/env-config.schema.tsapps/deploy-web/src/context/FlagProvider/FlagProvider.tsxapps/deploy-web/src/hooks/useAutoTopUpLimits.tsxapps/deploy-web/src/hooks/useFlag.tsxapps/deploy-web/src/hooks/useHasCreditCardBanner.tsapps/deploy-web/src/hooks/useManagedWallet.tsapps/deploy-web/src/hooks/useManagedWalletDenom.ts
💤 Files with no reviewable changes (7)
- apps/api/env/.env.sample
- apps/api/env/.env.staging
- apps/deploy-web/src/config/env-config.schema.ts
- apps/api/env/.env.unit.test
- apps/deploy-web/.env.local.sample
- apps/api/env/.env.functional.test
- apps/deploy-web/src/config/browser-env.config.ts
🚧 Files skipped from review as they are similar to previous changes (6)
- apps/deploy-web/src/hooks/useManagedWallet.ts
- apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx
- apps/deploy-web/src/hooks/useAutoTopUpLimits.tsx
- apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx
- apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx
- apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/*.{ts,tsx,js}: Never use typeanyor cast to typeany. Always define the proper TypeScript types.
Never use deprecated methods from libraries.
Don't add unnecessary comments to the code.
Files:
apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsxapps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsxapps/deploy-web/src/hooks/useFlag.tsxapps/deploy-web/src/components/layout/WalletStatus.tsxapps/deploy-web/src/components/get-started/GetStartedStepper.tsxapps/deploy-web/src/components/shared/TrialDeploymentBadge.tsxapps/deploy-web/src/components/layout/TrackingScripts.tsxapps/deploy-web/src/hooks/useManagedWalletDenom.tsapps/deploy-web/src/hooks/useHasCreditCardBanner.tsapps/deploy-web/src/components/user/UserProviders/UserProviders.tsx
**/*.spec.{ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/no-jest-mock.mdc)
Don't use
jest.mock()in test files. Instead, usejest-mock-extendedto create mocks and pass mocks as dependencies to the service under testUse
setupfunction instead ofbeforeEachin test files. Thesetupfunction must be at the bottom of the rootdescribeblock, should create an object under test and return it, accept a single parameter with inline type definition, avoid shared state, and not have a specified return type.
**/*.spec.{ts,tsx}: Use<Subject>.namein the root describe suite description instead of hardcoded class/service name strings to enable automated refactoring tools to find all references
Use either a method name or a condition starting with 'when' for nested suite descriptions in tests
Use present simple, 3rd person singular for test descriptions without prepending 'should'
Files:
apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx
{apps/deploy-web,apps/provider-console}/**/*.spec.tsx
📄 CodeRabbit inference engine (.cursor/rules/query-by-in-tests.mdc)
Use
queryBymethods instead ofgetBymethods in test expectations
Files:
apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx
🧠 Learnings (12)
📚 Learning: 2025-11-25T17:45:49.180Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-11-25T17:45:49.180Z
Learning: Applies to {apps/deploy-web,apps/provider-console}/**/*.spec.tsx : Use `queryBy` methods instead of `getBy` methods in test expectations
Applied to files:
apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx
📚 Learning: 2025-11-25T17:45:44.790Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/no-jest-mock.mdc:0-0
Timestamp: 2025-11-25T17:45:44.790Z
Learning: Applies to **/*.spec.{ts,tsx} : Don't use `jest.mock()` in test files. Instead, use `jest-mock-extended` to create mocks and pass mocks as dependencies to the service under test
Applied to files:
apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx
📚 Learning: 2025-07-11T10:46:43.711Z
Learnt from: stalniy
Repo: akash-network/console PR: 1660
File: apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx:54-56
Timestamp: 2025-07-11T10:46:43.711Z
Learning: In apps/{deploy-web,provider-console}/**/*.spec.tsx files: Use `getBy` methods instead of `queryBy` methods when testing element presence with `toBeInTheDocument()` because `getBy` throws an error and shows DOM state when element is not found, providing better debugging information than `queryBy` which returns null.
Applied to files:
apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx
📚 Learning: 2025-11-25T17:45:52.965Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/setup-instead-of-before-each.mdc:0-0
Timestamp: 2025-11-25T17:45:52.965Z
Learning: Applies to **/*.spec.{ts,tsx} : Use `setup` function instead of `beforeEach` in test files. The `setup` function must be at the bottom of the root `describe` block, should create an object under test and return it, accept a single parameter with inline type definition, avoid shared state, and not have a specified return type.
Applied to files:
apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx
📚 Learning: 2025-11-19T15:15:07.283Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 2254
File: apps/api/test/functional/sign-and-broadcast-tx.spec.ts:4-4
Timestamp: 2025-11-19T15:15:07.283Z
Learning: In the Akash Network Console project, when tests use native Node.js fetch (available in Node 18+), fetch-mock should be used for HTTP mocking instead of nock, as nock does not support intercepting native fetch calls. This applies to apps/api/test/functional/sign-and-broadcast-tx.spec.ts and any other tests using native fetch.
Applied to files:
apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx
📚 Learning: 2025-08-12T13:52:38.708Z
Learnt from: stalniy
Repo: akash-network/console PR: 1800
File: apps/deploy-web/next.config.js:163-165
Timestamp: 2025-08-12T13:52:38.708Z
Learning: In the Akash Console project, akashnetwork/env-loader is used at the top of next.config.js files to automatically load environment variables from env/.env files into process.env. SENTRY_ORG and SENTRY_PROJECT are stored as public configuration values in apps/deploy-web/env/.env and are loaded this way, while only SENTRY_AUTH_TOKEN is handled as a GitHub secret in workflows.
Applied to files:
apps/api/env/.env.production
📚 Learning: 2025-08-12T13:52:38.708Z
Learnt from: stalniy
Repo: akash-network/console PR: 1800
File: apps/deploy-web/next.config.js:163-165
Timestamp: 2025-08-12T13:52:38.708Z
Learning: In the Akash Console project, SENTRY_ORG and SENTRY_PROJECT are stored as public configuration values in apps/deploy-web/env/.env file and loaded by akashnetwork/env-loader, not as GitHub secrets. Only SENTRY_AUTH_TOKEN should be handled as a secret.
Applied to files:
apps/api/env/.env.production
📚 Learning: 2025-07-28T10:40:13.595Z
Learnt from: stalniy
Repo: akash-network/console PR: 1480
File: apps/deploy-web/src/hooks/useFlag.tsx:0-0
Timestamp: 2025-07-28T10:40:13.595Z
Learning: In the Akash Network Console project, backend-specific feature flags are intentional and acceptable. The frontend FeatureFlag union type should only include flags that are actually used by the frontend, not all flags defined in the backend. Backend can have internal feature flags for backend-only functionality without requiring frontend synchronization.
Applied to files:
apps/deploy-web/src/hooks/useFlag.tsx
📚 Learning: 2025-11-12T16:36:02.543Z
Learnt from: baktun14
Repo: akash-network/console PR: 2203
File: apps/deploy-web/src/components/onboarding/steps/PaymentMethodContainer/PaymentMethodContainer.tsx:161-168
Timestamp: 2025-11-12T16:36:02.543Z
Learning: In apps/deploy-web/src/components/onboarding/steps/PaymentMethodContainer/PaymentMethodContainer.tsx, the organization field captured during payment method setup is internal metadata. Errors from stripe.updateCustomerOrganization should be logged to Sentry but not surfaced to users, and the flow should continue even if the organization update fails, as it's non-critical and not something users can fix.
Applied to files:
apps/deploy-web/src/components/layout/WalletStatus.tsxapps/deploy-web/src/components/get-started/GetStartedStepper.tsx
📚 Learning: 2025-12-29T13:20:43.626Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 2422
File: apps/api/src/billing/services/wallet-settings/wallet-settings.service.ts:124-128
Timestamp: 2025-12-29T13:20:43.626Z
Learning: In the wallet-settings service (apps/api/src/billing/services/wallet-settings/wallet-settings.service.ts), auto-reload jobs are not eagerly canceled when autoReloadEnabled is disabled. Instead, jobs check the autoReloadEnabled flag at execution time and complete early if disabled. This design avoids concurrency issues that could occur with eager cancellation.
Applied to files:
apps/deploy-web/src/components/layout/WalletStatus.tsx
📚 Learning: 2025-10-31T11:26:42.138Z
Learnt from: stalniy
Repo: akash-network/console PR: 2138
File: apps/api/src/billing/lib/batch-signing-client/batch-signing-client.service.ts:379-382
Timestamp: 2025-10-31T11:26:42.138Z
Learning: In TypeScript/JavaScript, the pattern of checking a cached value and then performing an async operation to fetch it without proper synchronization is race condition unsafe:
```typescript
private async getAddress() {
if (!this.address) {
this.address = await this.wallet.getFirstAddress();
}
return this.address;
}
```
Multiple concurrent calls can all pass the `if (!this.address)` check before any of them sets the value, leading to duplicate async operations. This should be flagged as a race condition. Proper synchronization (mutex, atomic promise caching, or guaranteed single-threaded execution) is required.
Applied to files:
apps/deploy-web/src/components/layout/WalletStatus.tsx
📚 Learning: 2025-12-29T12:12:27.886Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 2432
File: apps/api/src/billing/services/tx-manager/tx-manager.service.ts:116-118
Timestamp: 2025-12-29T12:12:27.886Z
Learning: In the Akash Console codebase (akash-network/console), v1 wallets are only used for read-only purposes such as retrieving addresses. All transaction signing operations use v2 wallets exclusively. Therefore, methods like `getDerivedWalletAddress` need to accept `WalletOptions` to support both v1 and v2 address lookups, while transaction signing methods like `signAndBroadcastWithDerivedWallet` correctly default to v2 without requiring a wallet version parameter.
Applied to files:
apps/deploy-web/src/hooks/useManagedWalletDenom.ts
🧬 Code graph analysis (6)
apps/deploy-web/src/hooks/useFlag.tsx (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/components/get-started/GetStartedStepper.tsx (2)
apps/deploy-web/tests/ui/uiState/isWalletConnected.ts (1)
isWalletConnected(3-22)apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.tsx (1)
ConnectManagedWalletButton(26-41)
apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/components/layout/TrackingScripts.tsx (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/hooks/useManagedWalletDenom.ts (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
apps/deploy-web/src/components/user/UserProviders/UserProviders.tsx (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
useServices(33-35)
⏰ 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). (5)
- GitHub Check: validate / validate-app
- GitHub Check: test-build
- GitHub Check: test-build
- GitHub Check: validate / validate-app
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (7)
apps/api/env/.env.production (1)
14-14: BILLING_ENABLED removal is clean with no dangling code references.The
BILLING_ENABLEDflag has been successfully removed from the API's production configuration. A search of the codebase confirms:
- No TypeScript/JavaScript code references to
BILLING_ENABLEDexist- No JSON or YAML configuration files reference this flag
- The removal in the API environment config has no impact on dependent code
Billing infrastructure (
STRIPE_CHECKOUT_REDIRECT_URL) remains properly configured.apps/deploy-web/src/components/layout/WalletStatus.tsx (2)
92-95: Re-validate CTA visibility logic:!isSignedInWithTrialvsisTrialing.
You’re now gating the managed-wallet connect CTA off an atom (isSignedInWithTrial) while the connected-state “Trial” UI usesisTrialingfromuseWallet(). If these can diverge, you may show/hide the CTA incorrectly when disconnected.
82-85: The review concern aboutManagedWalletPopupbilling assumptions is unfounded.
ManagedWalletPopup,CustodialWalletPopup, andConnectManagedWalletButtoncontain no billing-specific dependencies or config assumptions. All components use standard hooks (useWallet(),useSettings(), etc.) and handle missing data gracefully. The components are properly typed with noanytypes and follow all coding guidelines.Likely an incorrect or invalid review comment.
apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx (1)
26-34: The config valueNEXT_PUBLIC_TRIAL_DEPLOYMENTS_DURATION_HOURSis already validated and coerced to anumbertype at the schema layer using Zod (z.number({ coerce: true })), so thetrialDurationvariable is guaranteed to be a number. The proposedNumber()coercion is unnecessary.Likely an incorrect or invalid review comment.
apps/deploy-web/src/hooks/useFlag.tsx (1)
6-14: The Rules of Hooks concern is unfounded.NEXT_PUBLIC_UNLEASH_ENABLE_ALLis a Next.js environment variable set at build time and baked into the bundle—it is immutable throughout the application's runtime. Since the condition on line 10 never changes between renders, the hook selection path remains consistent, and there is no Rules of Hooks violation.Likely an incorrect or invalid review comment.
apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx (1)
5-18: No changes needed—publicConfig.NEXT_PUBLIC_GA_ENABLEDis already a parsed boolean.The config schema in
env-config.schema.tsusescoercedBoolean()which transforms the string values"true"and"false"to booleantrueandfalseat validation time (line 4). Therefore,publicConfig.NEXT_PUBLIC_GA_ENABLEDis already a boolean type, not a string, and the!!operator correctly evaluates it.Additionally, the
event()function fromnextjs-google-analyticsis safe to call unconditionally—it gracefully handles cases where GA is not initialized and does not throw errors. The proposed changes are unnecessary.Likely an incorrect or invalid review comment.
apps/deploy-web/src/components/user/UserProviders/UserProviders.tsx (1)
13-22: LGTM! Clean refactor to use DI for the HTTP client.The simplification removes the conditional billing-flag branch and consistently uses
internalApiHttpClientfrom the DI container. This improves testability by allowing the HTTP client to be mocked through the services context.
Why
better testing
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.