Skip to content

feat(dashboard): add cyber dino usage mascot#637

Open
awsl233777 wants to merge 8 commits into
mainfrom
feat/cyber-dino-usage-mascot
Open

feat(dashboard): add cyber dino usage mascot#637
awsl233777 wants to merge 8 commits into
mainfrom
feat/cyber-dino-usage-mascot

Conversation

@awsl233777

@awsl233777 awsl233777 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a cyber dino usage mascot to the dashboard overview
  • show a header mini badge plus a full monthly token burn card
  • aggregate current-month input, output, cache read, and cache write tokens from usage stats
  • support persisted dino material, flame material, and motion preferences via localStorage
  • add zh/en translations and pure helper coverage for monthly usage, burn levels, and preference validation

Validation

  • pnpm --dir web test -- src/pages/overview/components/cyber-dino-usage.test.ts (ran 10 frontend test files, 53 tests)
  • pnpm --dir web typecheck
  • pnpm --dir web lint
  • pnpm --dir web build
  • git diff --check

Screenshot / observation boundary

  • Rendered locally with Vite at 127.0.0.1:9896 and captured a screenshot using Playwright.
  • The screenshot used mocked providers/dashboard/usage-stats responses only in the browser test script so the mascot card would be visible; no fake usage data was written to the repository or backend.

Summary by CodeRabbit

  • 新功能
    • 概览页新增“Cyber Dino”用量展示:顶部徽标与页面内卡片,展示本月输入/输出/缓存读写/请求、燃烧等级与距离下一等级进度,以及重置提示;支持恐龙/火焰材质与运动模式外观偏好联动。
    • 补充英文/中文面板文案与枚举词条(材质、等级/动效开关、token 单位、缓存读写提示等),并保留原“成本”。
  • 测试
    • 新增单元测试:月度使用窗口生成、月度聚合统计、燃烧等级/进度计算、偏好回退逻辑。

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@awsl233777, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 52 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 74337710-3489-456c-8de9-062db0fc72e6

📥 Commits

Reviewing files that changed from the base of the PR and between e2ea6b3 and 9f949b9.

📒 Files selected for processing (3)
  • web/src/locales/en.json
  • web/src/locales/zh.json
  • web/src/pages/overview/components/cyber-dino-usage-card.tsx
📝 Walkthrough

Walkthrough

概览页新增 CyberDino 用量展示,补充了中英文文案、月度统计计算、偏好存储与页面挂载。

Changes

CyberDino 仪表板

Layer / File(s) Summary
文案与数据契约
web/src/pages/overview/components/cyber-dino-usage.ts, web/src/locales/en.json, web/src/locales/zh.json
新增 CyberDino 用量相关类型、材料常量、默认偏好,并补充英文与中文 dashboard 文案键。
月度汇总与燃烧分级
web/src/pages/overview/components/cyber-dino-usage.ts, web/src/pages/overview/components/cyber-dino-usage.test.ts
新增当前月窗口、月度用量聚合、燃烧等级和进度计算,并用单元测试覆盖这些辅助函数。
偏好存储与月度数据
web/src/pages/overview/components/cyber-dino-usage-card.tsx, web/src/pages/overview/components/cyber-dino-usage.ts, web/src/pages/overview/components/cyber-dino-usage.test.ts
新增本地偏好读取与写入、归一化、素材查找,以及按当前月份窗口拉取并汇聚月度总计的逻辑,并用测试覆盖未知值回退。
组件渲染与页面挂载
web/src/pages/overview/components/cyber-dino-usage-card.tsx, web/src/pages/overview.tsx
新增 CyberDino SVG、材料选择器、徽标、主卡片和基础指标组件,并把它们挂到 OverviewPage 的页眉和主体区域。

Sequence Diagram(s)

sequenceDiagram
  participant OverviewPage
  participant CyberDinoUsageBadge
  participant CyberDinoUsageCard
  participant useUsageStats
  participant localStorage

  OverviewPage->>CyberDinoUsageBadge: render PageHeader actions
  OverviewPage->>CyberDinoUsageCard: render usage card in main content
  CyberDinoUsageCard->>useUsageStats: query current month usage window
  useUsageStats-->>CyberDinoUsageCard: daily usage stats
  CyberDinoUsageCard->>localStorage: read and persist preferences
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

(_/)
(•_•) 兔兔来报喜,
/ >🌟 小恐龙亮起火焰衣;
tokens 跳呀跳,
徽标闪闪,卡片也欢喜,
胡萝卜都跟着暖洋洋。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了为仪表板新增 Cyber Dino 用量吉祥物这一主要改动。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cyber-dino-usage-mascot

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@awsl233777

Copy link
Copy Markdown
Collaborator Author

Implemented the cyber dino usage mascot for the dashboard.

What changed:

  • Added a dashboard header mini badge for current-month token burn.
  • Added a full cyber dino usage card in the overview page.
  • Current-month usage is queried from usage-stats and aggregates input/output/cache read/cache write tokens.
  • Added persisted appearance preferences for dino material, flame material, and motion mode via localStorage.
  • Added zh/en i18n copy and pure helper tests for month window, token aggregation, burn levels, progress, and preference normalization.

Validation run:

  • pnpm --dir web test -- src/pages/overview/components/cyber-dino-usage.test.ts (10 frontend test files, 53 tests passed)
  • pnpm --dir web typecheck
  • pnpm --dir web lint
  • pnpm --dir web build
  • git diff --check

Screenshot boundary:

  • I rendered the page locally with Vite and captured a Playwright screenshot.
  • The screenshot used mocked browser responses for providers/dashboard/usage-stats so the dashboard card would be visible; no fake usage data was written to the repo or backend.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@awsl233777 I'll review the changes now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/pages/overview.tsx`:
- Around line 345-348: The top-of-page ordering in overview should keep the
cooldown alert banner above the main content instead of being pushed down by the
decorative CyberDino card. Update the render order in the overview page so the
active cooldowns banner is placed before CyberDinoUsageCard, and keep the banner
logic tied to activeCooldowns.length > 0 while preserving the existing section
structure.

In `@web/src/pages/overview/components/cyber-dino-usage-card.tsx`:
- Around line 63-69: The monthly usage query in useMonthlyUsageTotals is using a
time-based window that can differ by milliseconds between component instances,
causing duplicate useUsageStats requests and inconsistent totals between the
badge and the main card. Make the month window stable by deriving it once from a
shared source or moving the query to a parent and passing the result down, and
use the same start/end values consistently wherever useMonthlyUsageTotals or the
related overview components are rendered.
- Around line 49-60: The shared preference state is currently duplicated because
both CyberDinoUsageBadge and CyberDinoUsageCard call
useCyberDinoUsagePreferences independently, so updates only affect one component
until refresh. Refactor the preference source into a shared parent or Context,
or switch useCyberDinoUsagePreferences to a single subscribed store with
useSyncExternalStore so both consumers read and update the same state. Keep the
loadPreferences and STORAGE_KEY flow centralized so theme/material/motion
changes stay synchronized across the badge and card.
- Around line 30-31: The usage card still mixes browser locale output and
hardcoded English units, so localize both the reset date and token units
consistently. Update formatResetDate() in cyber-dino-usage-card.tsx to accept
and use i18n.language instead of the default browser locale, and replace the
hardcoded "tokens" text at the affected render sites with translation keys so
the card reads naturally in Chinese and other locales. Use the existing i18n
usage in the component to wire this through the date/label formatting paths.

In `@web/src/pages/overview/components/cyber-dino-usage.ts`:
- Around line 12-19: The MonthlyUsageTotals aggregation is collapsing the
upstream cache breakdown into a single cacheTokens field, which loses the
separate cacheRead and cacheWrite values needed by the overview cards. Update
the MonthlyUsageTotals type and the related aggregation logic in
cyber-dino-usage.ts to keep cacheRead and cacheWrite as distinct fields, and
compute totalTokens from all usage parts instead of from the merged cache value.
Make sure any consumers of MonthlyUsageTotals are updated to use the new fields
so the monthly UI can display both cache metrics separately.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb03d27d-491c-4466-a01b-34b24706884d

📥 Commits

Reviewing files that changed from the base of the PR and between 1b2aec6 and 694569d.

📒 Files selected for processing (6)
  • web/src/locales/en.json
  • web/src/locales/zh.json
  • web/src/pages/overview.tsx
  • web/src/pages/overview/components/cyber-dino-usage-card.tsx
  • web/src/pages/overview/components/cyber-dino-usage.test.ts
  • web/src/pages/overview/components/cyber-dino-usage.ts

Comment thread web/src/pages/overview.tsx Outdated
Comment thread web/src/pages/overview/components/cyber-dino-usage-card.tsx Outdated
Comment thread web/src/pages/overview/components/cyber-dino-usage-card.tsx
Comment on lines +63 to +69
function useMonthlyUsageTotals() {
const windowRange = useMemo(() => getCurrentMonthUsageWindow(), []);
const { data: stats, isLoading } = useUsageStats({
granularity: 'day',
start: windowRange.start.toISOString(),
end: windowRange.end.toISOString(),
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

稳定并共享月度用量查询。

徽标和主卡都会调用 useMonthlyUsageTotals(),而这里每个实例都会用当前时间生成不同的 end。这会让 useUsageStats 的 query key 可能相差毫秒级,导致重复请求和徽标/卡片总量短暂不一致。建议用稳定的月份窗口,或在父级只查询一次后传给两个组件。

Also applies to: 215-250

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/pages/overview/components/cyber-dino-usage-card.tsx` around lines 63
- 69, The monthly usage query in useMonthlyUsageTotals is using a time-based
window that can differ by milliseconds between component instances, causing
duplicate useUsageStats requests and inconsistent totals between the badge and
the main card. Make the month window stable by deriving it once from a shared
source or moving the query to a parent and passing the result down, and use the
same start/end values consistently wherever useMonthlyUsageTotals or the related
overview components are rendered.

Comment thread web/src/pages/overview/components/cyber-dino-usage.ts
@awsl233777

Copy link
Copy Markdown
Collaborator Author

Updated the mascot visual after design feedback.

What changed in the follow-up commit:

  • Replaced the noisy low-poly dinosaur drawing with a smoother, rounded cyber mascot silhouette.
  • Reduced visual clutter in the stage/background.
  • Kept the same usage data model, burn levels, material preferences, and localStorage behavior.
  • The change is limited to web/src/pages/overview/components/cyber-dino-usage-card.tsx.

Validation rerun:

  • pnpm --dir web test -- src/pages/overview/components/cyber-dino-usage.test.ts (10 frontend test files, 53 tests passed)
  • pnpm --dir web typecheck
  • pnpm --dir web lint
  • pnpm --dir web build
  • git diff --check

Screenshot boundary:

  • New local screenshot: /home/moltbot/clawd-wechat/tmp/maxx-cyber-dino-live-v2.png
  • As before, the screenshot uses mocked Playwright responses only to make the dashboard usage card visible; no fake backend/repo data was written.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@awsl233777 I'll review the updated mascot changes now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@awsl233777

Copy link
Copy Markdown
Collaborator Author

Refined the mascot again after design feedback.

What changed:

  • Shifted the visual language from a large illustrative dinosaur to a restrained product badge / mascot emblem.
  • Reduced visual clutter and made the mascot sit inside a darker dashboard-style glass panel.
  • Kept the dino readable through tail, spikes, visor, feet, and token-burn flame glyphs.
  • Preserved the same usage aggregation, burn levels, material preferences, motion preferences, and localStorage behavior.
  • Change remains limited to web/src/pages/overview/components/cyber-dino-usage-card.tsx.

Validation rerun:

  • pnpm --dir web test -- src/pages/overview/components/cyber-dino-usage.test.ts (10 frontend test files, 53 tests passed)
  • pnpm --dir web typecheck
  • pnpm --dir web lint
  • pnpm --dir web build
  • git diff --check

Screenshot boundary:

  • New local screenshot: /home/moltbot/clawd-wechat/tmp/maxx-cyber-dino-live-v3.png
  • The screenshot still uses mocked Playwright responses only to make the dashboard card visible; no fake backend/repo data was written.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@awsl233777 I'll review the latest mascot refinements now.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@awsl233777

Copy link
Copy Markdown
Collaborator Author

Addressed the earlier review feedback while keeping the refined product-badge mascot direction.

Fixes included:

  • Moved CyberDinoUsageCard after the active cooldown alert so warning banners keep top priority.
  • Made the monthly usage window stable as [month start, next month start) to avoid duplicate usage queries from millisecond-different query keys.
  • Added same-page preference synchronization for the header badge and full card via a local custom event plus storage handling.
  • Preserved cacheRead and cacheWrite separately in MonthlyUsageTotals and displays them as separate metrics.
  • Localized the reset date by i18n.language and moved the token unit into i18n.

Validation rerun:

  • pnpm --dir web test -- src/pages/overview/components/cyber-dino-usage.test.ts (10 frontend test files, 53 tests passed)
  • pnpm --dir web typecheck
  • pnpm --dir web lint
  • pnpm --dir web build
  • git diff --check

Screenshot boundary:

  • New local screenshot: /home/moltbot/clawd-wechat/tmp/maxx-cyber-dino-live-v4.png
  • Screenshot uses mocked Playwright responses only to make the dashboard card visible; no fake backend/repo data was written.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@awsl233777 Thanks for the detailed update — I’ll review the latest changes now.


If you found this review helpful, would you consider giving us a shout-out on X%E9%81%BF%E5%85%8D%E9%87%8D%E5%A4%8D%E6%9F%A5%E8%AF%A2%EF%BC%8C%E5%90%8C%E9%A1%B5%E5%81%8F%E5%A5%BD%E7%94%A8%E4%BA%8B%E4%BB%B6%E5%90%8C%E6%AD%A5%EF%BC%8CcacheRead%2FcacheWrite%E5%88%86%E5%BC%80%E7%BB%9F%E8%AE%A1%EF%BC%8Ci18n%E4%B9%9F%E6%9B%B4%E7%A8%B3%E3%80%82%E5%BC%BA%E7%83%88%E6%8E%A8%E8%8D%90%E8%AF%95%E8%AF%95%F0%9F%9A%80%E2%9C%A8&url=https%3A%2F%2Fgithub.com%2Fawsl-project%2Fmaxx%2Fpull%2F637)?

Thank you for using CodeRabbit!

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@awsl233777

Copy link
Copy Markdown
Collaborator Author

Updated the preview branding assets to use the low-fi routing gremlin direction instead of the previous polished fantasy-style mascot.

Changed assets:

  • web/public/logo.png
  • web/public/favicon.ico
  • web/public/preview.png

Validation performed locally against the production build:

  • pnpm --dir web run build
  • Production preview served from web/dist
  • HTTP smoke: /, /favicon.ico, /logo.png, /preview.png all returned 200 with expected content types ✅
  • Playwright browser E2E screenshots for:
    • root app page
    • direct /preview.png rendering
    • asset harness covering logo at 16/32/64/128px plus preview image ✅

Remaining risk: GitHub PR checks and CodeRabbit are still re-running for commit e2ea6b3, so merge readiness should wait for those remote gates.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

@awsl233777 I’ll review the latest branding asset updates now, with extra attention on the preview/logo/favicon changes and any downstream impact on the dashboard/app shell.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@awsl233777

Copy link
Copy Markdown
Collaborator Author

Follow-up fix: the previous asset update replaced logo.png / favicon.ico / preview.png, but the dashboard usage mascot still rendered its old inline Cyber Dino SVG. This commit replaces that in-page mascot with the same /logo.png gremlin mark and updates the user-facing copy from Dino to Routing Gremlin.

Changed files:

  • web/src/pages/overview/components/cyber-dino-usage-card.tsx
  • web/src/locales/en.json
  • web/src/locales/zh.json

Local validation performed:

  • pnpm --dir web run typecheck
  • pnpm --dir web exec vitest run src/pages/overview/components/cyber-dino-usage.test.ts ✅ (5/5)
  • pnpm --dir web run build
  • Production preview + Playwright E2E screenshot check ✅
    • verified Routing Gremlin text is visible
    • verified old Cyber Dino / 赛博小恐龙 title is not visible
    • verified /logo.png renders in the page, including the usage badge and main mascot panel

Remote checks are re-running for c5e5ae3.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

@awsl233777 I’ll review the latest Routing Gremlin follow-up now, with attention on the shared /logo.png usage and the copy update from Cyber Dino to Routing Gremlin.


✏️ Learnings added
Learnt from: awsl233777
URL: https://github.com/awsl-project/maxx/pull/637

Timestamp: 2026-06-28T09:42:16.536Z
Learning: In the dashboard overview usage mascot UI, `web/src/pages/overview/components/cyber-dino-usage-card.tsx` now uses the shared `web/public/logo.png` gremlin mark instead of an inline Cyber Dino SVG, and the user-facing branding/copy has been renamed from "Cyber Dino" to "Routing Gremlin" in `web/src/locales/en.json` and `web/src/locales/zh.json`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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