Skip to content

Conversation

@baktun14
Copy link
Contributor

@baktun14 baktun14 commented Nov 8, 2025

closes #2174

  • improve api key ux with link to docs
  • enable top up for all accounts

Summary by CodeRabbit

  • New Features

    • Added an API Keys documentation banner linking to usage guides.
    • Added trial deployment time tracker with remaining-time display and badge.
  • Bug Fixes / Improvements

    • Auto top‑up control now appears for managed wallets (no longer gated).
    • Email verification now redirects to the onboarding flow after completion.
    • Billing error messages clarified for insufficient funds.
    • Onboarding completion errors are now handled without propagating.

@baktun14 baktun14 requested a review from a team as a code owner November 8, 2025 01:47
@coderabbitai
Copy link

coderabbitai bot commented Nov 8, 2025

Walkthrough

Adds a static API keys documentation banner and renders it in the API key list, removes the isTrialing check and an env flag from auto top-up gating, surfaces trial timing and badge in deployment UI, changes verification "Continue" navigation to onboarding, updates two billing error messages, and adjusts onboarding error handling/cleanup.

Changes

Cohort / File(s) Summary
API Keys UI
apps/deploy-web/src/components/api-keys/ApiKeyDocsBanner.tsx, apps/deploy-web/src/components/api-keys/ApiKeyList.tsx
Add ApiKeyDocsBanner component (static Alert with book icon and external docs link) and render it after the API keys table.
Auto top-up / Wallet gating
apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx
Remove isTrialing from useWallet() destructure and from auto top-up conditional; auto top-up UI now shown based solely on isManaged.
Trial deployment display
apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx
Add trial-related imports and logic (useTrialDeploymentTimeRemaining, TrialDeploymentBadge) and display trial time remaining alongside existing time-left UI.
Browser env config & schema
apps/deploy-web/src/config/browser-env.config.ts, apps/deploy-web/src/config/env-config.schema.ts
Remove NEXT_PUBLIC_AUTO_TOP_UP_ENABLED from browser env config and from browser env schema/validation.
Email verification flow
apps/deploy-web/src/pages/user/verify-email/index.tsx
Rename handler to gotoOnboarding and change navigation to UrlService.onboarding() so "Continue" navigates to onboarding.
Billing messages & tests
apps/api/src/billing/services/managed-signer/managed-signer.service.ts, apps/api/src/billing/services/managed-signer/managed-signer.service.spec.ts
Update assertion error messages for fee/deployment allowance checks and update corresponding tests' expected messages (text-only changes).
Onboarding error handling / cleanup
apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.tsx, apps/deploy-web/src/components/onboarding/steps/WelcomeStep/WelcomeStep.tsx
Stop re-throwing errors after showing snackbar in OnboardingContainer; change try/catch to try/finally in WelcomeStep to always reset deploying flags and allow errors to propagate after cleanup.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EmailVerifyPage as Email Verify Page
    participant UrlService
    participant Onboarding as Onboarding Flow

    User->>EmailVerifyPage: Click "Continue"
    EmailVerifyPage->>UrlService: Request onboarding URL (UrlService.onboarding())
    UrlService-->>EmailVerifyPage: Return onboarding URL
    EmailVerifyPage->>Onboarding: Navigate to onboarding
    Onboarding-->>User: Show onboarding flow
    Note over EmailVerifyPage: Replaces previous flow that used UrlService.home()
Loading
sequenceDiagram
    autonumber
    participant DeploymentUI as Deployment UI
    participant WalletHook as useWallet()
    rect rgb(238,246,255)
      note over DeploymentUI,WalletHook: Auto top-up gating — Before vs After
    end
    DeploymentUI->>WalletHook: read isManaged, isTrialing, env flag (before)
    alt Before
        WalletHook-->>DeploymentUI: isManaged + isTrialing + env flag
        DeploymentUI->>DeploymentUI: Render auto top-up only if isManaged && isTrialing && env flag
    else After
        WalletHook-->>DeploymentUI: isManaged
        DeploymentUI->>DeploymentUI: Render auto top-up if isManaged
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Files that may need extra attention:
    • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx — correctness of trial timing calculations and conditional rendering.
    • apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx — ensure removal of isTrialing doesn't break other consumers.
    • Search for remaining references to NEXT_PUBLIC_AUTO_TOP_UP_ENABLED across repo after schema/config removal.
    • Onboarding error handling changes — confirm intended error propagation behavior.

Possibly related PRs

Suggested reviewers

  • stalniy
  • ygrishajev

Poem

🐇
I hopped a banner, bright and neat,
A tiny book to guide each key,
Badges count the trial-time beat,
Onboarding's path now true and sweet,
A rabbit cheers — code tidy and free! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'feat(deployment): enable top up free trial' does not align with the primary objective from linked issue #2174, which is fixing verification email links to continue onboarding. Consider aligning the title with the main objective, such as 'feat(onboarding): fix verification email to continue onboarding' or split into multiple PRs with focused titles.
Out of Scope Changes check ⚠️ Warning Multiple changes appear out-of-scope: API key documentation banner [ApiKeyDocsBanner.tsx], removal of auto top-up configuration [env-config.schema.ts, browser-env.config.ts, DeploymentDetailTopBar.tsx], error message updates in managed-signer service, and onboarding error handling changes. Separate out-of-scope changes into distinct PRs: (1) API keys documentation, (2) auto top-up feature removal, (3) billing error messages, (4) onboarding error handling, keeping only the verify-email fix for issue #2174.
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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Changes address the core requirement from #2174 by redirecting verify-email navigation from gotoHome to gotoOnboarding [#2174], ensuring users continue onboarding instead of exiting to console.
✨ 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 features/enable-top-up-free-trial

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d8327d6 and 479afb0.

📒 Files selected for processing (1)
  • apps/api/src/billing/services/managed-signer/managed-signer.service.spec.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/no-jest-mock.mdc)

Don't use jest.mock() to mock dependencies in test files. Instead, use jest-mock-extended to create mocks and pass mocks as dependencies to the service under test.

**/*.spec.{ts,tsx}: Use setup function instead of beforeEach in test files
setup function must be at the bottom of the root describe block in test files
setup function creates an object under test and returns it
setup function should accept a single parameter with inline type definition
Don't use shared state in setup function
Don't specify return type of setup function

Files:

  • apps/api/src/billing/services/managed-signer/managed-signer.service.spec.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/api/src/billing/services/managed-signer/managed-signer.service.spec.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/api/src/billing/services/managed-signer/managed-signer.service.spec.ts
⏰ 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). (4)
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
🔇 Additional comments (1)
apps/api/src/billing/services/managed-signer/managed-signer.service.spec.ts (1)

74-74: LGTM! Improved error messaging.

The updated error messages are more user-friendly and clearly communicate the issue to end users. These test expectations correctly align with the implementation changes.

Also applies to: 94-94


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

@codecov
Copy link

codecov bot commented Nov 8, 2025

Codecov Report

❌ Patch coverage is 10.00000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.36%. Comparing base (cd46e86) to head (479afb0).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...src/components/deployments/DeploymentSubHeader.tsx 0.00% 9 Missing ⚠️
...y-web/src/components/api-keys/ApiKeyDocsBanner.tsx 0.00% 4 Missing ⚠️
.../components/deployments/DeploymentDetailTopBar.tsx 0.00% 2 Missing ⚠️
...s/deploy-web/src/pages/user/verify-email/index.tsx 0.00% 2 Missing ⚠️
.../deploy-web/src/components/api-keys/ApiKeyList.tsx 0.00% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) 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    #2175      +/-   ##
==========================================
- Coverage   46.70%   46.36%   -0.35%     
==========================================
  Files        1019     1010       -9     
  Lines       28929    28589     -340     
  Branches     7515     7471      -44     
==========================================
- Hits        13512    13255     -257     
+ Misses      15103    14148     -955     
- Partials      314     1186     +872     
Flag Coverage Δ *Carryforward flag
api 81.89% <100.00%> (+0.06%) ⬆️
deploy-web 25.25% <0.00%> (-0.01%) ⬇️
log-collector ?
notifications 88.11% <ø> (ø) Carriedforward from d8327d6
provider-console 81.48% <ø> (ø) Carriedforward from d8327d6
provider-proxy 85.28% <ø> (ø) Carriedforward from d8327d6

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

Files with missing lines Coverage Δ
.../services/managed-signer/managed-signer.service.ts 98.73% <100.00%> (ø)
...arding/OnboardingContainer/OnboardingContainer.tsx 80.15% <ø> (+0.63%) ⬆️
...nents/onboarding/steps/WelcomeStep/WelcomeStep.tsx 0.00% <ø> (ø)
apps/deploy-web/src/config/browser-env.config.ts 100.00% <ø> (ø)
apps/deploy-web/src/config/env-config.schema.ts 71.42% <ø> (ø)
.../deploy-web/src/components/api-keys/ApiKeyList.tsx 0.00% <0.00%> (ø)
.../components/deployments/DeploymentDetailTopBar.tsx 0.00% <0.00%> (ø)
...s/deploy-web/src/pages/user/verify-email/index.tsx 0.00% <0.00%> (ø)
...y-web/src/components/api-keys/ApiKeyDocsBanner.tsx 0.00% <0.00%> (ø)
...src/components/deployments/DeploymentSubHeader.tsx 0.00% <0.00%> (ø)

... and 232 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

@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

🧹 Nitpick comments (1)
apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx (1)

40-45: Normalize env-derived trial duration before using it

browserEnvConfig surfaces env vars as strings, so feeding trialDuration straight into useTrialDeploymentTimeRemaining relies on implicit coercion. If the value ever ships with whitespace or units (e.g. "48 " or "48h"), calculateTrialTimeRemaining will end up with NaN, and the trial countdown quietly disappears. Please normalize to a finite number (or fall back to undefined) before passing it along.

Apply this diff:

-  const trialDuration = browserEnvConfig.NEXT_PUBLIC_TRIAL_DEPLOYMENTS_DURATION_HOURS;
-  const { timeRemainingText: trialTimeRemaining } = useTrialDeploymentTimeRemaining({
+  const trialDurationEnv = browserEnvConfig.NEXT_PUBLIC_TRIAL_DEPLOYMENTS_DURATION_HOURS;
+  const trialDuration =
+    trialDurationEnv !== undefined ? Number(trialDurationEnv) : undefined;
+  const normalizedTrialDuration = Number.isFinite(trialDuration) ? trialDuration : undefined;
+  const { timeRemainingText: trialTimeRemaining } = useTrialDeploymentTimeRemaining({
     createdHeight: deployment.createdAt,
-    trialDurationHours: trialDuration,
+    trialDurationHours: normalizedTrialDuration,
     averageBlockTime: 6
   });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd46e86 and 43e322f.

📒 Files selected for processing (7)
  • apps/deploy-web/src/components/api-keys/ApiKeyDocsBanner.tsx (1 hunks)
  • apps/deploy-web/src/components/api-keys/ApiKeyList.tsx (2 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx (2 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx (3 hunks)
  • apps/deploy-web/src/config/browser-env.config.ts (0 hunks)
  • apps/deploy-web/src/config/env-config.schema.ts (0 hunks)
  • apps/deploy-web/src/pages/user/verify-email/index.tsx (2 hunks)
💤 Files with no reviewable changes (2)
  • apps/deploy-web/src/config/browser-env.config.ts
  • apps/deploy-web/src/config/env-config.schema.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/deploy-web/src/components/api-keys/ApiKeyDocsBanner.tsx
  • apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx
  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx
  • apps/deploy-web/src/components/api-keys/ApiKeyList.tsx
  • apps/deploy-web/src/pages/user/verify-email/index.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/deploy-web/src/components/api-keys/ApiKeyDocsBanner.tsx
  • apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx
  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx
  • apps/deploy-web/src/components/api-keys/ApiKeyList.tsx
  • apps/deploy-web/src/pages/user/verify-email/index.tsx
🧬 Code graph analysis (4)
apps/deploy-web/src/components/api-keys/ApiKeyDocsBanner.tsx (1)
apps/provider-console/src/components/shared/ExternalLink.tsx (1)
  • ExternalLink (10-19)
apps/deploy-web/src/components/deployments/DeploymentDetailTopBar.tsx (1)
apps/deploy-web/src/context/WalletProvider/WalletProvider.tsx (1)
  • useWallet (355-357)
apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx (2)
apps/deploy-web/src/config/browser-env.config.ts (1)
  • browserEnvConfig (4-41)
apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.ts (1)
  • useTrialDeploymentTimeRemaining (65-91)
apps/deploy-web/src/components/api-keys/ApiKeyList.tsx (1)
apps/deploy-web/src/components/api-keys/ApiKeyDocsBanner.tsx (1)
  • ApiKeyDocsBanner (6-20)
⏰ 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 (1)
apps/deploy-web/src/pages/user/verify-email/index.tsx (1)

19-40: Redirect now preserves onboarding flow

Thanks for swapping the handler to use UrlService.onboarding()—this keeps verified users inside the onboarding experience instead of dumping them back at the console.

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: 0

🧹 Nitpick comments (2)
apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx (2)

39-46: Consider conditional hook execution for performance.

The useTrialDeploymentTimeRemaining hook is called unconditionally, even when !isAnonymousFreeTrialEnabled && isTrialing is false (lines 144, 154). This means the hook fetches block data and performs calculations that won't be used.

Apply this diff to call the hook conditionally:

  const { isCustodial, isTrialing } = useWallet();
  const isAnonymousFreeTrialEnabled = useFlag("anonymous_free_trial");
  const { appConfig } = useServices();

+  const shouldShowTrialInfo = !isAnonymousFreeTrialEnabled && isTrialing;
  const trialDuration = appConfig.NEXT_PUBLIC_TRIAL_DEPLOYMENTS_DURATION_HOURS;
  const { timeRemainingText: trialTimeRemaining } = useTrialDeploymentTimeRemaining({
    createdHeight: deployment.createdAt,
    trialDurationHours: trialDuration,
-    averageBlockTime: 6
+    averageBlockTime: 6,
+    dependencies: shouldShowTrialInfo ? undefined : { useBlock: () => ({ data: null }) }
  });

Alternatively, conditionally call the hook:

  const { isCustodial, isTrialing } = useWallet();
  const isAnonymousFreeTrialEnabled = useFlag("anonymous_free_trial");
  const { appConfig } = useServices();

+  const shouldShowTrialInfo = !isAnonymousFreeTrialEnabled && isTrialing;
  const trialDuration = appConfig.NEXT_PUBLIC_TRIAL_DEPLOYMENTS_DURATION_HOURS;
-  const { timeRemainingText: trialTimeRemaining } = useTrialDeploymentTimeRemaining({
+  const { timeRemainingText: trialTimeRemaining } = shouldShowTrialInfo ? useTrialDeploymentTimeRemaining({
    createdHeight: deployment.createdAt,
    trialDurationHours: trialDuration,
    averageBlockTime: 6
-  });
+  }) : { timeRemainingText: null };

Note: The second approach violates React's rules of hooks if the condition changes during component lifecycle. The first approach or memoization would be safer.


144-144: Extract repeated condition to improve maintainability.

The condition !isAnonymousFreeTrialEnabled && isTrialing is duplicated on lines 144 and 154. This violates the DRY principle and makes future updates more error-prone.

Apply this diff to extract the condition:

  const { isCustodial, isTrialing } = useWallet();
  const isAnonymousFreeTrialEnabled = useFlag("anonymous_free_trial");
  const { appConfig } = useServices();
+  const shouldShowTrialInfo = !isAnonymousFreeTrialEnabled && isTrialing;

  const trialDuration = appConfig.NEXT_PUBLIC_TRIAL_DEPLOYMENTS_DURATION_HOURS;
  const { timeRemainingText: trialTimeRemaining } = useTrialDeploymentTimeRemaining({
    createdHeight: deployment.createdAt,
    trialDurationHours: trialDuration,
    averageBlockTime: 6
  });

  return (
    <div className="grid grid-cols-2 gap-4 p-4">
      ...
-              {!isAnonymousFreeTrialEnabled && isTrialing && <TrialDeploymentBadge createdHeight={deployment.createdAt} />}
+              {shouldShowTrialInfo && <TrialDeploymentBadge createdHeight={deployment.createdAt} />}
      ...
-              {!isAnonymousFreeTrialEnabled && isTrialing && trialTimeRemaining && <span className="text-xs text-primary">(Trial: {trialTimeRemaining})</span>}
+              {shouldShowTrialInfo && trialTimeRemaining && <span className="text-xs text-primary">(Trial: {trialTimeRemaining})</span>}

Also applies to: 154-154

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43e322f and dc77cfc.

📒 Files selected for processing (2)
  • apps/deploy-web/src/components/api-keys/ApiKeyDocsBanner.tsx (1 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/deploy-web/src/components/api-keys/ApiKeyDocsBanner.tsx
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

Never use type any or cast to type any. Always define the proper TypeScript types.

Files:

  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code

Files:

  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx
🧠 Learnings (1)
📚 Learning: 2025-06-05T21:07:51.985Z
Learnt from: baktun14
Repo: akash-network/console PR: 1432
File: apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentCloseAlert.tsx:38-38
Timestamp: 2025-06-05T21:07:51.985Z
Learning: The ContactPointSelect component in apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx uses the useFormContext hook internally to connect to React Hook Form, so it doesn't need to be wrapped in a FormField component.

Applied to files:

  • apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx
🧬 Code graph analysis (1)
apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx (2)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (30-32)
apps/deploy-web/src/hooks/useTrialDeploymentTimeRemaining.ts (1)
  • useTrialDeploymentTimeRemaining (65-91)
⏰ 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 (1)
apps/deploy-web/src/components/deployments/DeploymentSubHeader.tsx (1)

8-8: LGTM! Imports are properly used.

All new imports are utilized within the component and follow the project's import path conventions.

Also applies to: 13-14, 18-18

@baktun14 baktun14 merged commit 825b24a into main Nov 10, 2025
61 of 62 checks passed
@baktun14 baktun14 deleted the features/enable-top-up-free-trial branch November 10, 2025 15:39
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.

Verification Email Link should strictly "continue" onboarding

3 participants