Skip to content

feat(onboarding): trial credit + client tutorials + wallet B2C hints - #4

Merged
hades217 merged 1 commit into
mainfrom
feat/onboarding-tutorials
May 16, 2026
Merged

feat(onboarding): trial credit + client tutorials + wallet B2C hints#4
hades217 merged 1 commit into
mainfrom
feat/onboarding-tutorials

Conversation

@hades217

Copy link
Copy Markdown

Summary

打通 B2C funnel 的 3 个最大堵点(注册 → 充值 → 创建 Key → 接入客户端 → 首次成功调用)。PR #1-#3 收口了已有界面;这个 PR 补完后续步骤。

4.B 注册赠送试用额度(半天)

机制其实已经全部存在 —— model/user.go:410 在 Insert 里设置 user.Quota = common.QuotaForNewUser,line 441 也已经写好"新用户注册赠送 ¥X"日志。唯一缺的就是默认值 0

common.QuotaForNewUser 默认从 0 改成 500_000(= $1 USD ≈ 500K token ≈ 200 次平均对话)。运营可以在 System Settings → Operations 改回 0。

4.A 客户端教程页(4 天)

PR #2 的 Success Dialog 里 6 个 chip 链向 /onboarding/{cherry-studio,chatbox,lobechat,cursor,claude-code,code} 这些路由根本不存在,用户拿到 key 立刻 404

新增:

  • 动态路由 /onboarding/$slug
  • features/onboarding/ 目录 + 6 个 TS 教程模块(每个都是 en+zh markdown body 函数,渲染时插入当前 base URL 和推荐模型名)
  • 页面布局:返回 /keys 面包屑 + 头卡(icon + 标签 + 描述 + "去 Playground 试试" CTA + Cherry Studio 带"推荐"徽标)+ 顶部 Base URL + Model 一键复制区 + markdown 主体(复用 components/ui/markdown.tsx
  • 全部 6 个教程都是纯文字步骤。截图占位给 platform 团队补,markdown 是 single source。

4.C 钱包 / 充值 B2C 提示(3 天)

  • 新建 lib/usage-estimate.tsestimateChats / estimateImages / estimateVideoClips / estimateAudioMinutes —— quota → "约能聊 N 次"友好换算(基于中等模型均价,营销级而非账单级精度)
  • WalletStatsCard "当前余额" 卡片副标题从"剩余配额" → "≈ 还能聊 200 次"。零余额状态:「充值后开始使用 AI 模型」
  • RechargeFormCard 每个预设档加第三行:"≈ 6k chats" 用 preset.value 估算
  • 钱包页副标题改写突出试用额度

i18n: 17 个新 en + zh key。

Test plan

  • bun run typecheck 通过
  • bunx eslint <touched> 0 error / 0 warning
  • 注册新账号 → 跳 /sign-in → 登录 → 看到 user.quota > 0(约 $1)
  • 钱包页:余额卡显示"≈ N chats remaining"
  • 预设充值按钮显示 "≈ X chats" 第三行
  • /keys 创建 Simple Key → Success Dialog → 点 Cherry Studio chip → /onboarding/cherry-studio 正常打开
  • 其他 5 个 chip 各自跳对应教程页都正常
  • 教程页顶部 Base URL + Model 可点 Copy
  • 切到 zh,所有新文案翻译显示

文件清单

修改(7 file):

  • common/constants.goQuotaForNewUser = 500_000
  • web/default/src/features/wallet/index.tsx — hero description
  • web/default/src/features/wallet/components/wallet-stats-card.tsx — chats-remaining 副标题
  • web/default/src/features/wallet/components/recharge-form-card.tsx — preset 第三行
  • web/default/src/i18n/locales/{en,zh}.json — 17 keys
  • web/default/src/routeTree.gen.ts — TanStack Router regen

新增(10 file):

  • web/default/src/lib/usage-estimate.ts
  • web/default/src/features/onboarding/index.tsx
  • web/default/src/features/onboarding/tutorials/registry.ts
  • web/default/src/features/onboarding/tutorials/{cherry-studio,chatbox,lobechat,cursor,claude-code,code}.ts
  • web/default/src/routes/onboarding/\$slug.tsx

17 files changed.

🤖 Generated with Claude Code

Closes the three biggest gaps between signup and first-successful-call
identified in the user-journey audit. Existing PRs (#1#3) shipped the
end-user-facing surfaces; this PR closes the funnel.

4.B — Trial credit on signup:
- All the wiring already existed (model/user.go:410 sets
  `user.Quota = common.QuotaForNewUser` inside Insert, line 441 logs
  "新用户注册赠送" when QuotaForNewUser > 0). The default was 0.
- Bump common.QuotaForNewUser from 0 → 500_000 (= $1 USD = ~500K tokens
  ≈ 200 chats of average cost). Operators who don't want trial credits
  can override to 0 in System Settings → Operations, same as today.
- No new endpoint, no migration. Comment explains the rationale.

4.A — Client tutorial pages at /onboarding/{slug}:
- The Key creation Success Dialog (shipped in PR #2) links 6 client
  chips to /onboarding/{cherry-studio,chatbox,lobechat,cursor,
  claude-code,code} — those routes 404'd. Users got a key and got
  stuck.
- New dynamic route `/onboarding/$slug` + new feature dir
  `features/onboarding/` with 6 tutorial modules. Each tutorial is a
  TS module exposing a per-language markdown body (en + zh) so we
  can interpolate the current base URL + recommended model name at
  render time.
- Page layout: breadcrumb back to /keys, header card (icon + label +
  description + "Try in Playground" CTA + "Recommended" badge for
  Cherry Studio), top-of-page Base URL + Model copy block, then the
  markdown body via the existing components/ui/markdown.tsx renderer
  (react-markdown + remarkGfm + rehypeRaw).
- All 6 tutorials ship text-only steps. Screenshots are tagged as a
  follow-up for platform team — markdown is the single source of
  truth so they slot in without code changes.

4.C — Wallet / topup B2C hints:
- New lib/usage-estimate.ts: estimateChats/estimateImages/
  estimateVideoClips/estimateAudioMinutes — quota→human-friendly
  counts using mid-tier-model averages. Marketing-grade estimates,
  not billing-grade.
- WalletStatsCard: "Current Balance" sub-label changed from
  "Remaining quota" to "≈ 200 chats remaining". Zero-balance state
  shows "Top up to start using AI models".
- RechargeFormCard preset buttons get a third line: "≈ 6k chats"
  derived from preset.value. Helps non-tech users gauge value at a
  glance.
- Wallet page hero description rewritten to mention trial credit.

i18n: 17 new en + zh keys for tutorial framing, recharge hints, and
balance descriptions. Auto-sorted alphabetically.

Reuse (no duplication):
- components/ui/markdown.tsx::Markdown
- routes/about/ pattern (single-file route → feature component)
- lib/format.ts::formatQuota for currency display

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@hades217
hades217 merged commit 716cbab into main May 16, 2026
1 check passed
hades217 added a commit that referenced this pull request May 16, 2026
Sprint 3 — final B2C polish on the three remaining surfaces.

6.B Pricing page ratio cleanup:
- Hide `{ratio}x` multipliers from the per-group pricing table and
  pricing breakdown for non-admin users (features/pricing/components/
  model-details.tsx). Same useIsAdmin gate pattern as Create Key form
  + Usage Logs. Final per-token prices stay visible — only the
  multiplier (operator concept) is hidden.
- pricing-sidebar.tsx filter chips no longer append "x1.2" suffixes
  to group names for non-admin viewers.

6.A Dashboard hero:
- summary-cards.tsx hero block: title "Usage at a glance" → "Your AI
  usage"; description rewritten in plain language. Credit-remaining
  card replaces "Displayed in CNY" technical sub-label with friendly
  "≈ 200 chats remaining" estimate (or "Top up to start using AI
  models." when balance is zero). Math is inlined since this PR is
  branched independently of PR #4's lib/usage-estimate.ts — they'll
  produce identical content when both merge.

6.D First-call celebration:
- Pure frontend, no backend `first_call_at` field needed. SummaryCards
  useEffect watches user.request_count; when it flips from 0 to 1+ on
  any dashboard mount, fires a single sonner toast "🎉 Your first API
  call worked!" + sets localStorage flag `dr_first_call_celebrated`
  so it never repeats per browser.
- Acknowledges the magic moment regardless of where the user made
  the call (Cherry Studio, Cursor, curl, Playground).

6.C Recharge history polish:
- billing-history-dialog.tsx empty state copy differentiates "no
  search results" (keyword present) from "you haven't recharged yet"
  (first-time user). Friendlier than the generic "No billing records
  found".

i18n: 8 new en + zh keys.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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