Skip to content

feat: add desktop rewards center#671

Closed
anthhub wants to merge 22 commits intomainfrom
worktree-frolicking-petting-meerkat
Closed

feat: add desktop rewards center#671
anthhub wants to merge 22 commits intomainfrom
worktree-frolicking-petting-meerkat

Conversation

@anthhub
Copy link
Copy Markdown

@anthhub anthhub commented Mar 30, 2026

What

Add a desktop rewards center — users can view cloud balance, claim reward tasks (daily / opensource / social), and connect to Nexu Cloud from the rewards page.

Why

Enable desktop users to earn credits through engagement tasks (GitHub star, social sharing, daily login) and monitor their cloud balance, driving adoption and retention for the Nexu Cloud integration.

How

  • Shared schemas (packages/shared): New Zod schemas for rewards (rewards.ts) and credits (credit.ts) with full type safety
  • Controller services: CloudRewardService for Cloud API communication, QuotaFallbackService for auto-BYOK fallback when balance depleted, new desktop rewards routes
  • Web UI: Rewards page (rewards.tsx), budget warning banner, home rewards teaser, shared useCloudConnect hook for cloud connection flow, useDesktopRewards hook for rewards status
  • i18n: Full English and Chinese localization for all rewards-related strings
  • Auto-fallback: GET rewards status auto-triggers BYOK fallback when managed model balance reaches 0

Affected areas

  • Controller (backend / API)
  • Web dashboard (React UI)
  • Shared schemas / packages

Checklist

  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (631 tests, 59 files)
  • pnpm generate-types run (API routes/schemas changed)
  • No credentials or tokens in code or logs
  • No any types introduced (use unknown with narrowing)

Notes for reviewers

  • rewards.tsx is 600+ lines — consider splitting icons/modal into components/rewards/ in a follow-up
  • GET /api/internal/desktop/rewards has a side effect (auto-fallback trigger) — intentional for seamless UX but worth noting
  • Cloud→Desktop type conversion in nexu-config-store.ts uses as assertions — tracked for future Zod safe-parse migration

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 1, 2026

Deploying nexu-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 783750f
Status: ✅  Deploy successful!
Preview URL: https://1858c740.nexu-docs.pages.dev
Branch Preview URL: https://worktree-frolicking-petting.nexu-docs.pages.dev

View logs

anthhub added 6 commits April 1, 2026 14:25
- Introduced new API endpoints for triggering automatic fallback to BYOK provider and restoring the default model to a managed (cloud) model.
- Updated OpenAPI schema to include new properties related to BYOK usage and fallback status.
- Implemented QuotaFallbackService to handle fallback logic and model restoration.
- Added BudgetWarningBanner component to notify users about credit status in the UI.
- Enhanced existing services and routes to integrate new quota management features.
- Updated the rewards link to use a flex layout for better alignment and spacing.
- Increased the size of the Coins icon for improved visibility.
- Adjusted the display of claimed and total credits to enhance readability.
- Refined the progress bar styling for a more polished appearance.
- Updated OpenAPI schema to include cloud balance properties.
- Implemented CloudRewardService for managing rewards status and claims.
- Enhanced NexuConfigStore to fetch and convert cloud rewards status.
- Added tests for CloudRewardService and updated existing tests for NexuConfigStore.
- Updated UI components to display cloud balance information.
- Localized new cloud balance strings in English and Chinese.
…ity and localization

- Introduced a status configuration for the BudgetWarningBanner to manage different states (warning and depleted) with corresponding styles and texts.
- Updated the component to utilize the new configuration for rendering, improving code readability and maintainability.
- Added new localization strings for budget warning and depleted states in English and Chinese.
- Implemented a debug panel for development purposes to simulate budget banner states.
- Added tests for the BudgetWarningBanner to ensure correct rendering based on status.
…rds status handling

- Added logic to automatically trigger a fallback to BYOK when the managed model's cloud balance is depleted.
- Integrated logging for fallback failures to improve error tracking.
- Created unit tests for the new fallback functionality to ensure reliability.
- Updated the BudgetWarningBanner and related UI components to reflect changes in rewards status and actions.
- Enhanced localization strings for clarity in user messaging regarding rewards and credits.
…rds status handling

- Added logic to automatically trigger a fallback to BYOK when the managed model's cloud balance is depleted.
- Integrated logging for fallback failures to improve error tracking.
- Created a new test suite for desktop rewards routes to validate fallback behavior and status retrieval.
- Updated existing UI components and localization strings to reflect changes in rewards status messaging.
@anthhub anthhub closed this Apr 2, 2026
@anthhub anthhub reopened this Apr 2, 2026
anthhub added 4 commits April 2, 2026 12:33
- Remove 5 investigation markdown files accidentally committed to repo root
- Fix cloudConnecting state not reset in "Connection already in progress" path
- Extract handleCloudConnect + polling effects into shared useCloudConnect hook
- Deduplicate formatRewardAmount by exporting from home-rewards-teaser
- Introduced six new PNG images for reward sharing.
- Created a new module for managing reward share assets, including types and functions for selecting and downloading assets.
- Implemented tests to ensure the integrity of the reward share assets and their download functionality.
- Keep both rewards budget debug panel and seedance promo features
- Fix welcome.tsx merge: replace removed setCloudStatus with refetchDesktopCloudStatus
@nettee nettee marked this pull request as draft April 2, 2026 06:10
anthhub added 8 commits April 2, 2026 14:53
…ling

- Show skeleton placeholders instead of fallback tasks during loading
- Add autoFallbackTriggered flag to rewards status schema
- Display warning toast when BYOK auto-fallback is triggered
- Add refetchInterval: 60s to detect balance changes in background
…new headlines and actions

- Refactored the BudgetWarningBanner to use new headline keys for warning and depleted states.
- Updated the UI to include an upgrade action button and removed the previous earn credits button.
- Enhanced localization strings for better clarity in user messaging regarding budget status.
- Added a new RewardTaskIcon component for rendering task icons dynamically.
- Updated the rewards status hook to disable retries for fetching data.
- Added new localization strings for balance details in English and Chinese.
- Improved the WorkspaceLayout to display rewards balance information with a detailed popup.
- Refactored HomePage to manage session and channel data more effectively, ensuring proper rendering based on session history.
- Added tests to verify the rendering of rewards components and their behavior during loading states.
- Added a new module for handling virtual reward checks, including functions to manage task status and delay.
- Updated localization strings in English and Chinese for task checking and claiming processes.
- Refactored the RewardConfirmModal to utilize the new virtual check functionality, improving user feedback during reward processing.
- Introduced tests to validate the behavior of the virtual reward check and description key retrieval.
…t banner enhancements

- Introduced a new `ensureDesktopControllerReady` function to manage the readiness of the desktop controller, including polling and recovery logic.
- Refactored the `DesktopShell` and `useDesktopRuntimeConfig` to utilize the new controller readiness management.
- Enhanced the budget banner functionality in the `HomePage` to handle dismissal states more effectively, using session storage for tracking.
- Added a new `BudgetDepletedDialog` component to provide user feedback when budget is exhausted.
- Implemented tests for the controller readiness logic and budget banner dismissal behavior to ensure reliability.
- Added a new `GithubStarVerificationService` to manage GitHub star session preparation and verification.
- Enhanced the desktop rewards routes to include a new endpoint for preparing GitHub star verification sessions.
- Updated the claim reward logic to validate proof URLs and GitHub session IDs before processing claims.
- Introduced new localization strings for handling proof URL inputs and GitHub session errors.
- Added tests to ensure the correct behavior of the new verification and proof handling features.
@anthhub anthhub marked this pull request as ready for review April 2, 2026 13:25
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f8c6818b70

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +29 to +31
if (data?.error === "Connection attempt already in progress") {
setCloudConnecting(false);
toast.info(t("welcome.cloudConnectInProgress"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep polling when cloud connect is already in progress

When the backend returns "Connection attempt already in progress", this branch sets cloudConnecting to false and exits, which disables the polling loop that is responsible for detecting when OAuth eventually completes. A common case is reloading the page during an active login flow and clicking connect again: the UI stops polling and can remain "disconnected" indefinitely even after the browser auth succeeds.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in 783750f: keep cloudConnecting true when the backend reports an in-progress connect so polling continues across page reloads.

Comment on lines +97 to +99
const recoveryAttempts =
options.recoveryAttempts ?? (startController === null ? 0 : 1);
const attemptTimeoutMs = options.attemptTimeoutMs ?? 15_000;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid hard-failing controller readiness after fixed timeout

The default readiness logic now only allows two 15s polling windows (initial + one recovery) before returning false. On slower cold starts (e.g., first build or busy machines), startup can legitimately exceed ~30s, so the app marks the controller as failed even though it may become ready shortly after. This creates a false-negative startup failure path instead of continuing to wait.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in 783750f: the final readiness attempt now continues polling instead of hard-failing after a fixed timeout, and the desktop readiness tests were updated to cover the new contract.

anthhub pushed a commit that referenced this pull request Apr 3, 2026
@anthhub anthhub closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant