Skip to content

refactor: injects browserEnvConfig from DI container#2453

Merged
stalniy merged 2 commits intomainfrom
refactor/browser-config
Jan 12, 2026
Merged

refactor: injects browserEnvConfig from DI container#2453
stalniy merged 2 commits intomainfrom
refactor/browser-config

Conversation

@stalniy
Copy link
Contributor

@stalniy stalniy commented Jan 5, 2026

Why

better testing

Summary by CodeRabbit

  • Refactor
    • Moved runtime configuration access to a context-based service provider across the app, centralizing config usage.
    • Removed the billing feature flag and related gating, simplifying wallet/connect and billing-related UI and logic.
    • Cleaned up environment samples and deployment envs to remove the deprecated billing flag.

✏️ Tip: You can customize this high-level summary in your review settings.

@stalniy stalniy requested a review from a team as a code owner January 5, 2026 22:05
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

Replaces direct imports of browserEnvConfig with runtime-sourced publicConfig from useServices() across deploy-web, removes the NEXT_PUBLIC_BILLING_ENABLED env flag and related billing-gated UI/logic, and adjusts hooks and feature-flag wiring to evaluate flags at runtime.

Changes

Cohort / File(s) Summary
Config schema & browser env
apps/deploy-web/src/config/env-config.schema.ts, apps/deploy-web/src/config/browser-env.config.ts
Removed NEXT_PUBLIC_BILLING_ENABLED from browser env schema and validated config; browserEnvConfig no longer exposes that flag.
Services / Flag provider
apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx, apps/deploy-web/src/components/user/UserProviders/UserProviders.tsx
FlagProvider and UserProviders updated to read publicConfig via useServices(); feature-flag fetch logic wired to runtime publicConfig (unified provider path; removed billing-based branch).
Tracking / analytics
apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx, apps/deploy-web/src/components/layout/TrackingScripts.tsx
Switched GA/GTM/track feature flags and NODE_ENV checks to publicConfig from useServices(); GTM IDs and tracking flags now read at runtime.
UI components (config migration)
apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx, apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx, apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx
Replaced browserEnvConfig imports with useServices() and publicConfig reads for various env keys (denom, CI/CD image name, trial duration).
Get-started / onboarding
apps/deploy-web/src/components/get-started/GetStartedStepper.tsx
Removed branching on NEXT_PUBLIC_BILLING_ENABLED; step labels and gating simplified to rely on wallet/trial state only.
Wallet & custodial UI (billing gating removal)
apps/deploy-web/src/components/layout/WalletStatus.tsx, apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx
Removed billing-flag imports and gating; visibility for ManagedWalletPopup/ConnectManagedWalletButton now depends on runtime wallet/trial state only.
Hooks — config migration & behavior changes
apps/deploy-web/src/hooks/useAutoTopUpLimits.tsx, apps/deploy-web/src/hooks/useManagedWalletDenom.ts, apps/deploy-web/src/hooks/useFlag.tsx, apps/deploy-web/src/hooks/useHasCreditCardBanner.ts, apps/deploy-web/src/hooks/useManagedWallet.ts
Hooks now obtain publicConfig via useServices() instead of static import; useFlag signature changed to useFlag(flag) and delegates at runtime based on publicConfig.NEXT_PUBLIC_UNLEASH_ENABLE_ALL; billing-guard logic removed from several hooks (unconditional queries/creation and simplified banner logic).
Env files (removed billing flag)
apps/api/env/.env.*, apps/deploy-web/.env.local.sample
Removed BILLING_ENABLED / NEXT_PUBLIC_BILLING_ENABLED entries from sample, staging, production, unit/functional test env files.
Tests
apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx
Test fixture updated to remove mocked NEXT_PUBLIC_BILLING_ENABLED from services setup.

Sequence Diagram(s)

No sequence diagrams generated.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ygrishajev
  • baktun14

Poem

🐰 Hop, hop — the configs found a home,

From files to services they now roam.
Billing gates tucked gently away,
Wallets and flags live for the day.
A tiny rabbit cheers this tidy code bouquet. 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring effort: migrating from direct browserEnvConfig imports to dependency injection via useServices().

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

@stalniy stalniy force-pushed the refactor/browser-config branch from 7d5695f to 35b76e7 Compare January 5, 2026 22:06
@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 25.58140% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.66%. Comparing base (a0947b0) to head (b483625).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/deploy-web/src/hooks/useAutoTopUpLimits.tsx 0.00% 6 Missing ⚠️
...ploy-web/src/components/layout/TrackingScripts.tsx 16.66% 5 Missing ⚠️
...eb/src/components/layout/CustomGoogleAnalytics.tsx 0.00% 3 Missing ⚠️
...onents/remote-deploy/update/RemoteDeployUpdate.tsx 0.00% 3 Missing ⚠️
apps/deploy-web/src/hooks/useFlag.tsx 40.00% 3 Missing ⚠️
.../components/deployments/DeploymentDetailTopBar.tsx 0.00% 2 Missing ⚠️
...b/src/components/get-started/GetStartedStepper.tsx 0.00% 2 Missing ⚠️
.../deploy-web/src/components/layout/WalletStatus.tsx 0.00% 2 Missing ⚠️
...web/src/components/wallet/CustodialWalletPopup.tsx 0.00% 2 Missing ⚠️
apps/deploy-web/src/hooks/useManagedWalletDenom.ts 33.33% 2 Missing ⚠️
... and 2 more

❌ 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.
❌ Your project status has failed because the head coverage (79.67%) is below the target coverage (80.00%). You can increase the head 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     
Flag Coverage Δ *Carryforward flag
api 79.67% <ø> (ø)
deploy-web 31.01% <25.58%> (-0.03%) ⬇️
log-collector ?
notifications 87.94% <ø> (ø) Carriedforward from a0947b0
provider-console 81.48% <ø> (ø) Carriedforward from a0947b0
provider-proxy 84.35% <ø> (ø) Carriedforward from a0947b0

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...web/src/components/shared/TrialDeploymentBadge.tsx 100.00% <100.00%> (ø)
...rc/components/user/UserProviders/UserProviders.tsx 100.00% <100.00%> (ø)
apps/deploy-web/src/config/browser-env.config.ts 100.00% <ø> (ø)
apps/deploy-web/src/config/env-config.schema.ts 72.72% <ø> (ø)
...ploy-web/src/context/FlagProvider/FlagProvider.tsx 44.11% <100.00%> (+1.69%) ⬆️
...pps/deploy-web/src/hooks/useHasCreditCardBanner.ts 25.00% <0.00%> (-6.82%) ⬇️
apps/deploy-web/src/hooks/useManagedWallet.ts 20.93% <0.00%> (-3.07%) ⬇️
.../components/deployments/DeploymentDetailTopBar.tsx 0.00% <0.00%> (ø)
...b/src/components/get-started/GetStartedStepper.tsx 0.00% <0.00%> (ø)
.../deploy-web/src/components/layout/WalletStatus.tsx 38.46% <0.00%> (-3.01%) ⬇️
... and 7 more

... and 59 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@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: 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 adding publicConfig to the dependency array.

The useEffect on line 11 references publicConfig values but only includes isProduction in its dependency array. If publicConfig can change during runtime, this could lead to stale closures.

However, if publicConfig from 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

📥 Commits

Reviewing files that changed from the base of the PR and between 74f586b and 35b76e7.

📒 Files selected for processing (15)
  • apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx
  • apps/deploy-web/src/components/get-started/GetStartedStepper.tsx
  • apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx
  • apps/deploy-web/src/components/layout/TrackingScripts.tsx
  • apps/deploy-web/src/components/layout/WalletStatus.tsx
  • apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx
  • apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx
  • apps/deploy-web/src/config/browser-env.config.ts
  • apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx
  • apps/deploy-web/src/hooks/useAutoTopUpLimits.tsx
  • apps/deploy-web/src/hooks/useFlag.tsx
  • apps/deploy-web/src/hooks/useHasCreditCardBanner.ts
  • apps/deploy-web/src/hooks/useManagedWallet.ts
  • apps/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 type any or cast to type any. 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.tsx
  • apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx
  • apps/deploy-web/src/components/layout/WalletStatus.tsx
  • apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx
  • apps/deploy-web/src/components/layout/TrackingScripts.tsx
  • apps/deploy-web/src/hooks/useManagedWallet.ts
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx
  • apps/deploy-web/src/hooks/useFlag.tsx
  • apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx
  • apps/deploy-web/src/components/get-started/GetStartedStepper.tsx
  • apps/deploy-web/src/hooks/useManagedWalletDenom.ts
  • apps/deploy-web/src/hooks/useHasCreditCardBanner.ts
  • apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx
  • apps/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.tsx
  • apps/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 useServices correctly supports the refactoring to inject publicConfig from the DI container instead of directly importing browserEnvConfig.


19-21: Successful DI migration for feature flag configuration.

The refactoring correctly replaces direct browserEnvConfig import with context-based publicConfig from useServices(). This improves testability by allowing the configuration to be mocked through ServicesProvider, 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 browserEnvConfig to publicConfig via useServices() 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 publicConfig from useServices(), 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 publicConfig via useServices(), 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 publicConfig via useServices(). 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?.id existence. The useManagedWalletQuery implementation properly handles the null case via its enabled: !!userId flag. The NEXT_PUBLIC_BILLING_ENABLED flag still exists in the codebase but is now only used in UserProviders.tsx and GetStartedStepper.tsx for 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 browserEnvConfig to publicConfig via useServices() 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_ENABLED flag check only.


14-17: LGTM! Billing flag removal simplifies banner logic.

The removal of the billing flag check from shouldShowBanner is consistent with the PR's objective to remove NEXT_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 publicConfig via the useServices() 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 a flag parameter and delegating to the selected hook implementation based on publicConfig.NEXT_PUBLIC_UNLEASH_ENABLE_ALL.

Note that this hook now requires React component context (since useServices() uses useContext), 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 browserEnvConfig usage with publicConfig from the DI container via useServices(). 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

baktun14
baktun14 previously approved these changes Jan 6, 2026
Copy link
Contributor

@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: 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: use queryBy* in expectations (per repo guidelines).

Line 19 uses getByRole in an expectation. Switch to queryByRole (still fails clearly via toBeInTheDocument() 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: Ensure ServicesProvider/publicConfig is always available (and typed), or add a safe fallback.

This hook now hard-depends on useServices() (vs a direct import), so any usage outside ServicesProvider (or tests that don’t wrap it) will crash at runtime; also please ensure publicConfig isn’t effectively any (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”.

isBannerVisible is only set to true and never reset, so once shown it remains visible even if hasManagedWallet / isSignedInWithTrial flips 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 into innerHTML.

  • The effect reads publicConfig.NEXT_PUBLIC_TRACKING_ENABLED, publicConfig.NEXT_PUBLIC_GROWTH_CHANNEL_TRACKING_ENABLED, and publicConfig.NEXT_PUBLIC_GTM_ID, but only depends on isProduction.
  • If this effect ever re-runs, the appended <noscript> isn’t cleaned up.
  • Since GTM ID is now runtime-sourced, interpolating it into innerHTML is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 35b76e7 and b483625.

📒 Files selected for processing (24)
  • apps/api/env/.env.functional.test
  • apps/api/env/.env.production
  • apps/api/env/.env.sample
  • apps/api/env/.env.staging
  • apps/api/env/.env.unit.test
  • apps/deploy-web/.env.local.sample
  • apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx
  • apps/deploy-web/src/components/get-started/GetStartedStepper.tsx
  • apps/deploy-web/src/components/layout/CustomGoogleAnalytics.tsx
  • apps/deploy-web/src/components/layout/TrackingScripts.tsx
  • apps/deploy-web/src/components/layout/WalletStatus.tsx
  • apps/deploy-web/src/components/remote-deploy/update/RemoteDeployUpdate.tsx
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx
  • apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx
  • apps/deploy-web/src/components/user/UserProviders/UserProviders.tsx
  • apps/deploy-web/src/components/wallet/CustodialWalletPopup.tsx
  • apps/deploy-web/src/config/browser-env.config.ts
  • apps/deploy-web/src/config/env-config.schema.ts
  • apps/deploy-web/src/context/FlagProvider/FlagProvider.tsx
  • apps/deploy-web/src/hooks/useAutoTopUpLimits.tsx
  • apps/deploy-web/src/hooks/useFlag.tsx
  • apps/deploy-web/src/hooks/useHasCreditCardBanner.ts
  • apps/deploy-web/src/hooks/useManagedWallet.ts
  • apps/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 type any or cast to type any. 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.tsx
  • apps/deploy-web/src/components/user/UserProviders/UserProviders.spec.tsx
  • apps/deploy-web/src/hooks/useFlag.tsx
  • apps/deploy-web/src/components/layout/WalletStatus.tsx
  • apps/deploy-web/src/components/get-started/GetStartedStepper.tsx
  • apps/deploy-web/src/components/shared/TrialDeploymentBadge.tsx
  • apps/deploy-web/src/components/layout/TrackingScripts.tsx
  • apps/deploy-web/src/hooks/useManagedWalletDenom.ts
  • apps/deploy-web/src/hooks/useHasCreditCardBanner.ts
  • apps/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, use jest-mock-extended to create mocks and pass mocks as dependencies to the service under test

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.

**/*.spec.{ts,tsx}: Use <Subject>.name in 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 queryBy methods instead of getBy methods 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.tsx
  • apps/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_ENABLED flag has been successfully removed from the API's production configuration. A search of the codebase confirms:

  • No TypeScript/JavaScript code references to BILLING_ENABLED exist
  • 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: !isSignedInWithTrial vs isTrialing.
You’re now gating the managed-wallet connect CTA off an atom (isSignedInWithTrial) while the connected-state “Trial” UI uses isTrialing from useWallet(). If these can diverge, you may show/hide the CTA incorrectly when disconnected.


82-85: The review concern about ManagedWalletPopup billing assumptions is unfounded.

ManagedWalletPopup, CustodialWalletPopup, and ConnectManagedWalletButton contain 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 no any types 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 value NEXT_PUBLIC_TRIAL_DEPLOYMENTS_DURATION_HOURS is already validated and coerced to a number type at the schema layer using Zod (z.number({ coerce: true })), so the trialDuration variable is guaranteed to be a number. The proposed Number() 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_ALL is 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_ENABLED is already a parsed boolean.

The config schema in env-config.schema.ts uses coercedBoolean() which transforms the string values "true" and "false" to boolean true and false at validation time (line 4). Therefore, publicConfig.NEXT_PUBLIC_GA_ENABLED is already a boolean type, not a string, and the !! operator correctly evaluates it.

Additionally, the event() function from nextjs-google-analytics is 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 internalApiHttpClient from the DI container. This improves testability by allowing the HTTP client to be mocked through the services context.

@stalniy stalniy merged commit 869b02a into main Jan 12, 2026
63 of 65 checks passed
@stalniy stalniy deleted the refactor/browser-config branch January 12, 2026 10:55
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.

2 participants

Comments