Skip to content

为登录后用户补充使用文档入口 [未完成]#1233

Merged
ding113 merged 4 commits into
ding113:devfrom
tesgth032:issue/1232-doc-entry
Jun 11, 2026
Merged

为登录后用户补充使用文档入口 [未完成]#1233
ding113 merged 4 commits into
ding113:devfrom
tesgth032:issue/1232-doc-entry

Conversation

@tesgth032

@tesgth032 tesgth032 commented May 30, 2026

Copy link
Copy Markdown
Contributor

Summary

为已登录用户在两个关键位置补充使用文档入口(/usage-doc),解决只读用户登录后难以找到文档的问题。

Problem

  • 用户(尤其是只能进入「我的用量」页面的只读用户)登录后无法快速找到使用文档入口。
  • /usage-doc 页面已存在,但缺少从用户界面直接跳转的链接。

Related Issues:

Solution

/my-usage 页头与 Dashboard 用户控制区分别新增文档入口,并为所有 5 种语言补齐 i18n 文案。

Changes

Core Changes

  • src/app/[locale]/my-usage/_components/my-usage-header.tsx — 在页头新增「使用文档」按钮(BookOpen 图标),链接至 /usage-doc;同时优化响应式布局(移动端 flex-col,桌面端 flex-row)。
  • src/app/[locale]/dashboard/_components/user-menu.tsx — 在用户控制区新增图标按钮入口,跳转 /usage-doc

Supporting Changes

  • i18n 文案 — 为 messages/{en,zh-CN,zh-TW,ja,ru}/myUsage.json 新增 header.documentation 键,覆盖 5 种语言。
  • 组件测试 — 新增 my-usage-header.test.tsxuser-menu.test.tsx,验证文档入口可见性与链接正确性。
  • i18n key parity 测试 — 新增 tests/unit/i18n/my-usage-keys.test.ts,确保所有语言文件键一致且 documentation 不为空。

Breaking Changes

无。本次仅添加 UI 入口与 i18n 键,未修改现有 API、组件签名或数据结构。

Testing

Automated Tests

  • 新增单元测试:src/app/[locale]/my-usage/_components/my-usage-header.test.tsx
  • 新增单元测试:src/app/[locale]/dashboard/_components/user-menu.test.tsx
  • 新增 i18n 测试:tests/unit/i18n/my-usage-keys.test.ts

Manual Testing

  1. 以只读用户身份登录,进入 /my-usage 页面。
  2. 确认页头出现「使用文档」按钮,点击后跳转 /usage-doc
  3. 进入 Dashboard,确认用户控制区出现文档图标按钮,点击后跳转 /usage-doc

Verification Commands

bun run test -- src/app/[locale]/my-usage/_components/my-usage-header.test.tsx src/app/[locale]/dashboard/_components/user-menu.test.tsx tests/unit/i18n/my-usage-keys.test.ts
bun run typecheck
bun run lint
bun run lint:fix
bun run test
bun run build

:全量测试中 tests/unit/proxy/response-handler-gemini-stream-passthrough-timeouts.test.tselapsed >= 120ms 计时断言因抖动测到 118ms,单独重跑该文件已通过(7/7)。

Checklist

  • 代码遵循项目规范(Biome 格式)
  • 已自查并修复
  • 测试在本地通过
  • i18n 已覆盖全部 5 种语言
  • 无破坏性变更

Description enhanced by Claude AI

Greptile Summary

This PR adds documentation entry points (/usage-doc) in two locations for logged-in users — a "Usage Docs" button in the MyUsageHeader and a BookOpen icon in UserMenu — and fixes the root cause by passing allowReadOnlyAccess: true to getSession() in the usage-doc layout so read-only-key users are no longer redirected away from the page.

  • usage-doc/layout.tsx: switches to getSession({ allowReadOnlyAccess: true }), which is the critical gate that previously blocked read-only users from reaching the page at all.
  • dashboard-header.tsx: introduces canUseDashboard to collapse the nav to only [documentationItem] for read-only sessions, while full-access and admin paths are unchanged.
  • my-usage-header.tsx / user-menu.tsx: each receives a new BookOpen button linking to /usage-doc; myUsage.header.documentation is added to all 5 locale files with a parity test to enforce key completeness.

Confidence Score: 5/5

Safe to merge — changes are additive UI and i18n additions with no modifications to auth logic, APIs, or data structures.

The most impactful change (allowReadOnlyAccess: true in usage-doc/layout.tsx) correctly gates access using existing auth infrastructure. Navigation filtering is straightforward conditional logic. All new i18n keys are covered by a parity test.

No files require special attention.

Important Files Changed

Filename Overview
src/app/[locale]/usage-doc/layout.tsx Adds allowReadOnlyAccess: true to getSession() so read-only-key users can reach the usage-doc page instead of being redirected.
src/app/[locale]/dashboard/_components/dashboard-header.tsx Extracts documentationItem, adds canUseDashboard gate, collapses nav to docs-only for read-only sessions.
src/app/[locale]/dashboard/_components/user-menu.tsx Adds BookOpen icon button to user-control area linking to /usage-doc.
src/app/[locale]/my-usage/_components/my-usage-header.tsx Adds visible Usage Docs button and responsive layout adjustment.
src/app/[locale]/dashboard/_components/dashboard-header.test.tsx New server-component test; namespace-blind mock is a minor fragility.
tests/unit/usage-doc/usage-doc-auth-state.test.tsx New source-text assertion is brittle against reformatting.
tests/unit/i18n/my-usage-keys.test.ts Validates key-set parity across all 5 locales; solid guard.
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
tests/unit/usage-doc/usage-doc-auth-state.test.tsx:125
**Source-text assertion is formatting-sensitive**

The assertion matches a literal substring of `layout.tsx`'s source code. If a formatter ever splits the call across lines, this test will silently start failing even though the behaviour is correct. The rest of the file already uses this pattern, so this is consistent — just worth noting as a known fragility.

### Issue 2 of 2
src/app/[locale]/dashboard/_components/dashboard-header.test.tsx:7-22
**Namespace-blind `getTranslations` mock**

The mock ignores the `namespace` argument. If `t("documentation")` were ever moved to a different namespace, this test would still pass. For server components the mock could at least assert the namespace to catch such regressions.

Reviews (4): Last reviewed commit: "抽取仪表盘文档导航项" | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

在用户菜单与我的用量页新增指向 /usage-doc 的文档按钮,补充 5 种语言的 myUsage.json 文案,新增组件与单元测试,并在 usage-doc 布局中启用 getSession({ allowReadOnlyAccess: true })。

变更说明

文档链接入口功能

Layer / File(s) Summary
多语言文案补充
messages/en/myUsage.json, messages/ja/myUsage.json, messages/ru/myUsage.json, messages/zh-CN/myUsage.json, messages/zh-TW/myUsage.json
在所有 5 种语言的 myUsage.jsonheader 对象下新增 documentation 键及对应翻译(EN: "Usage Docs" / JA: "利用ドキュメント" / RU: "Документация" / ZH-CN: "使用文档" / ZH-TW: "使用文件")。
国际化键一致性验证
tests/unit/i18n/my-usage-keys.test.ts
新增测试:递归提取 JSON 键并以英文为基线验证各语言键集合一致性;断言每种语言的 header.documentation 存在且为非空字符串。
仪表盘用户菜单文档链接
src/app/[locale]/dashboard/_components/user-menu.tsx, src/app/[locale]/dashboard/_components/user-menu.test.tsx
UserMenu 引入 BookOpen 图标与 Link,在用户信息区域后新增指向 /usage-doc 的按钮(使用 t("documentation") 作为 title/aria-label);新增测试覆盖链接存在性与属性,并管理测试生命周期清理。
我的用量页头部文档链接
src/app/[locale]/my-usage/_components/my-usage-header.tsx, src/app/[locale]/my-usage/_components/my-usage-header.test.tsx
MyUsageHeader 引入 BookOpenLink,调整为响应式布局,并在右侧操作区新增指向 /usage-doc 的文档按钮;新增测试断言链接文本和欢迎文案呈现。
usage-doc 布局会话读取
src/app/[locale]/usage-doc/layout.tsx, tests/unit/usage-doc/usage-doc-auth-state.test.tsx
getSession() 改为 getSession({ allowReadOnlyAccess: true }),并新增测试断言验证该调用。
仪表盘头部导航可见性
src/app/[locale]/dashboard/_components/dashboard-header.tsx, src/app/[locale]/dashboard/_components/dashboard-header.test.tsx
新增 canUseDashboard 判定:当有会话但无 dashboard 权限时,仅显示文档链接;测试覆盖只读/完整会话下导航项的差异。

代码审查工作量

🎯 2 (Simple) | ⏱️ ~12 分钟

可能相关的PR

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% 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
Title check ✅ Passed PR 标题清晰准确地反映了主要变更:为已登录用户补充使用文档入口,与提交内容完全对应。
Linked Issues check ✅ Passed PR 完全满足 issue #1232 的所有要求:在 /my-usage 和 Dashboard 用户菜单添加文档入口、覆盖 5 种语言 i18n、并修复 layout 以支持只读用户访问。
Out of Scope Changes check ✅ Passed 所有变更均在 issue #1232 的范围内,新增的导航项、i18n 文案、组件和测试都直接支持为用户添加文档入口的目标,无超出范围的改动。
Description check ✅ Passed PR 描述清晰地关联了本次变更的内容:在用户界面补充 /usage-doc 文档入口,涵盖多个文件修改(my-usage-header.tsx、user-menu.tsx、i18n 文案、测试文件等)。

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@github-actions github-actions Bot added enhancement New feature or request area:UI area:i18n labels May 30, 2026

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request adds a "Usage Docs" link (pointing to /usage-doc) to both the UserMenu and MyUsageHeader components, along with corresponding translations in multiple locales and unit tests. Feedback on the changes highlights two issues: first, in user-menu.tsx, the translation key documentation is called within a namespace that does not contain it, which will result in a missing translation; second, in my-usage-keys.test.ts, accessing data.header directly on a Record<string, unknown> type will cause a TypeScript compilation error, and a type-safe suggestion is provided.

Comment on lines +54 to +55
title={t("documentation")}
aria-label={t("documentation")}

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.

high

翻译键 documentationt 函数中被调用,而该函数初始化时使用的是 dashboard.nav 命名空间(第 18 行)。然而,新添加的翻译键仅在 myUsage.jsonmyUsage.header.documentation 下定义。这将导致 Dashboard 用户菜单中的“使用文档”按钮出现翻译缺失(显示为 key 本身)。请确保在相应的翻译文件(如 dashboard.json)的 dashboard.nav 命名空间中也添加 documentation 键,或者在此处使用 myUsage.header 命名空间。

Comment thread tests/unit/i18n/my-usage-keys.test.ts Outdated

it("defines a documentation label for the readonly usage header", () => {
for (const [locale, data] of Object.entries(locales)) {
const documentation = data.header?.documentation;

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.

medium

由于 data 的类型为 Record<string, unknown>,在严格模式下使用点号访问 data.header 会导致 TypeScript 编译错误。请使用方括号语法和类型断言来安全地访问嵌套属性。

Suggested change
const documentation = data.header?.documentation;
const header = data["header"] as Record<string, unknown> | undefined;
const documentation = header?.["documentation"];

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

Copy link
Copy Markdown

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

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

<div className="flex items-center gap-2">
<div className="flex shrink-0 items-center gap-2">
<Button asChild variant="outline" size="sm" className="gap-2">
<Link href="/usage-doc">

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 Preserve readonly sessions when opening docs

For readonly users this new entry sends them from /my-usage to /usage-doc, but usage-doc/layout.tsx still calls getSession() without allowReadOnlyAccess, and validateKey returns null for keys with canLoginWebUi === false. In that scenario the destination treats an already-authenticated readonly user as anonymous, showing the login header and hiding logged-in quick links instead of preserving their session context; the docs entry should either make the docs layout accept readonly sessions or route to a page that does.

Useful? React with 👍 / 👎.

Comment on lines +13 to +20

vi.mock("next-intl", () => ({
useTranslations: () => (key: string) =>
({
documentation: "Docs",
logout: "Logout",
})[key] ?? key,
}));

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 Namespace-blind useTranslations mock

The mock returns translations by key only and ignores the namespace argument passed to useTranslations. If UserMenu were ever refactored to use a different namespace (e.g. one that lacks documentation), this test would still pass because the mock always resolves "documentation""Docs" regardless. The sibling my-usage-header.test.tsx demonstrates a stronger pattern: it wraps the component in NextIntlClientProvider with real messages, making the test sensitive to the actual namespace the component uses.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/app/[locale]/dashboard/_components/user-menu.test.tsx
Line: 13-20

Comment:
**Namespace-blind `useTranslations` mock**

The mock returns translations by key only and ignores the namespace argument passed to `useTranslations`. If `UserMenu` were ever refactored to use a different namespace (e.g. one that lacks `documentation`), this test would still pass because the mock always resolves `"documentation"``"Docs"` regardless. The sibling `my-usage-header.test.tsx` demonstrates a stronger pattern: it wraps the component in `NextIntlClientProvider` with real messages, making the test sensitive to the actual namespace the component uses.

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@github-actions github-actions Bot added the size/S Small PR (< 200 lines) label May 30, 2026

@github-actions github-actions 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.

Code Review Summary

No significant issues identified in this PR. The changes are well-structured, i18n keys are consistently added across all 5 locales, and the new component tests adequately cover the added documentation entry points.

PR Size: S

  • Lines changed: 222
  • Files changed: 10

Review Coverage

  • Logic and correctness - Clean
  • Security (OWASP Top 10) - Clean
  • Error handling - Clean (no new error paths added)
  • Type safety - Clean
  • Documentation accuracy - Clean
  • Test coverage - Adequate (component tests + i18n key parity test)
  • Code clarity - Good

Notes

  • dashboard.nav.documentation key verified to exist in all locale files (dashboard.json), matching the UserMenu component's useTranslations("dashboard.nav") usage.
  • myUsage.header.documentation key added consistently across all 5 locale files.
  • Button with asChild correctly delegates to the next-intl Link component without leaking variant/size props to the DOM.

Automated review by Claude AI

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/app/[locale]/dashboard/_components/user-menu.test.tsx (1)

1-62: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

测试文件路径/命名不符合仓库约定

当前文件位于 src/.../*.test.tsx,但规则只允许 tests/unit/tests/integration/,或 source-adjacent 的 src/**/*.test.ts。请将该用例迁移到 tests/unit/(保留 .test.tsx)或按规则调整命名/位置。

As per coding guidelines, "Use Vitest for unit testing with tests located in tests/unit/, tests/integration/, or source-adjacent in src/**/*.test.ts".

🤖 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 `@src/app/`[locale]/dashboard/_components/user-menu.test.tsx around lines 1 -
62, The test file for the UserMenu component (user-menu.test.tsx) is placed
outside the allowed test locations; move the test into an allowed location
(e.g., tests/unit/) or make it source-adjacent by renaming/moving it to
src/.../*.test.ts per repository rules, keeping the .test.tsx extension and
preserving the test contents (including imports and mocks for UserMenu,
useTranslations and useRouter); ensure any import paths to UserMenu still
resolve after moving and update test runner config if needed.
🧹 Nitpick comments (1)
src/app/[locale]/my-usage/_components/my-usage-header.test.tsx (1)

10-10: ⚡ Quick win

统一为路径别名导入,避免相对路径。

这里建议改成 @/ 别名导入以保持仓库一致性。

建议修改
-import { MyUsageHeader } from "./my-usage-header";
+import { MyUsageHeader } from "`@/app/`[locale]/my-usage/_components/my-usage-header";

As per coding guidelines: **/*.{ts,tsx,js,jsx}: Use path alias @/ to map to ./src/ for imports

🤖 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 `@src/app/`[locale]/my-usage/_components/my-usage-header.test.tsx at line 10,
The test imports MyUsageHeader using a relative path; update the import to use
the project's path alias (start with "`@/`") instead of a relative path so the
MyUsageHeader import aligns with the repo convention (replace the current import
statement for MyUsageHeader with an alias-based import that resolves to the same
module).
🤖 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.

Outside diff comments:
In `@src/app/`[locale]/dashboard/_components/user-menu.test.tsx:
- Around line 1-62: The test file for the UserMenu component
(user-menu.test.tsx) is placed outside the allowed test locations; move the test
into an allowed location (e.g., tests/unit/) or make it source-adjacent by
renaming/moving it to src/.../*.test.ts per repository rules, keeping the
.test.tsx extension and preserving the test contents (including imports and
mocks for UserMenu, useTranslations and useRouter); ensure any import paths to
UserMenu still resolve after moving and update test runner config if needed.

---

Nitpick comments:
In `@src/app/`[locale]/my-usage/_components/my-usage-header.test.tsx:
- Line 10: The test imports MyUsageHeader using a relative path; update the
import to use the project's path alias (start with "`@/`") instead of a relative
path so the MyUsageHeader import aligns with the repo convention (replace the
current import statement for MyUsageHeader with an alias-based import that
resolves to the same module).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ef55bbec-12bb-4338-a65c-1c51a1f9b027

📥 Commits

Reviewing files that changed from the base of the PR and between ed95b48 and d1e36b7.

📒 Files selected for processing (10)
  • messages/en/myUsage.json
  • messages/ja/myUsage.json
  • messages/ru/myUsage.json
  • messages/zh-CN/myUsage.json
  • messages/zh-TW/myUsage.json
  • src/app/[locale]/dashboard/_components/user-menu.test.tsx
  • src/app/[locale]/dashboard/_components/user-menu.tsx
  • src/app/[locale]/my-usage/_components/my-usage-header.test.tsx
  • src/app/[locale]/my-usage/_components/my-usage-header.tsx
  • tests/unit/i18n/my-usage-keys.test.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/app/[locale]/usage-doc/layout.tsx (1)

42-51: ⚠️ Potential issue | 🟠 Major

补充:只读用户在 usage-doc 会看到完整 Dashboard 导航,但 /dashboard 侧会按 canLoginWebUi 再次拦截

  • src/app/[locale]/usage-doc/layout.tsx 确实会调用 getSession({ allowReadOnlyAccess: true }),因此 canLoginWebUi=false 的“只读会话”在该页会走 session ? <DashboardHeader .../> 分支,出现完整 DashboardHeader
  • src/app/[locale]/dashboard/_components/dashboard-header.tsx 的导航项仅按 session.user.role === "admin" 过滤 adminOnly,未见基于 session.key.canLoginWebUi 的降级/隐藏;因此 /dashboard/dashboard/logs/dashboard/leaderboard/dashboard/users 等对只读用户仍会展示。
  • 同时,代码库里存在针对 canLoginWebUi 的服务器端拦截逻辑(例如 src/app/[locale]/dashboard/layout.tsx 中的 session.key.canLoginWebUi 检查)。因此如果该拦截是“拒绝/报错页/跳转受限”,就会落入原评论担心的“可点击但实际访问被拒”的体验;若是“重定向到只读入口(如 my-usage)”,则现有导航展示影响会减轻。
  • 建议:在 DashboardHeader 的导航构建处同样基于 session.key.canLoginWebUi 做隐藏/禁用,或确保 /dashboard 拦截路径对只读用户是明确的重定向与提示,避免落差体验。
🤖 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 `@src/app/`[locale]/usage-doc/layout.tsx around lines 42 - 51, 在 usage-doc 的
layout.tsx 已以 allowReadOnlyAccess 获取只读会话导致 DashboardHeader
在只读用户也会渲染,为避免出现可点却无法访问的菜单,请在 DashboardHeader(组件名
DashboardHeader,或其构建导航的函数/变量)里基于 session.key.canLoginWebUi
对导航项进行过滤或降级(例如把需登录的条目从导航列表中过滤掉或渲染为不可点状态),或者在 DashboardHeader 根处当
session.key.canLoginWebUi 为 false 时改为渲染简化头部;同时保持 getSession({
allowReadOnlyAccess: true }) 行为不变以支持只读会话。
🤖 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.

Outside diff comments:
In `@src/app/`[locale]/usage-doc/layout.tsx:
- Around line 42-51: 在 usage-doc 的 layout.tsx 已以 allowReadOnlyAccess 获取只读会话导致
DashboardHeader 在只读用户也会渲染,为避免出现可点却无法访问的菜单,请在 DashboardHeader(组件名
DashboardHeader,或其构建导航的函数/变量)里基于 session.key.canLoginWebUi
对导航项进行过滤或降级(例如把需登录的条目从导航列表中过滤掉或渲染为不可点状态),或者在 DashboardHeader 根处当
session.key.canLoginWebUi 为 false 时改为渲染简化头部;同时保持 getSession({
allowReadOnlyAccess: true }) 行为不变以支持只读会话。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 11095ee5-44d8-4c94-881c-cbb5956fb49c

📥 Commits

Reviewing files that changed from the base of the PR and between d1e36b7 and fd9e808.

📒 Files selected for processing (4)
  • src/app/[locale]/dashboard/_components/user-menu.test.tsx
  • src/app/[locale]/usage-doc/layout.tsx
  • tests/unit/i18n/my-usage-keys.test.ts
  • tests/unit/usage-doc/usage-doc-auth-state.test.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/unit/i18n/my-usage-keys.test.ts
  • src/app/[locale]/dashboard/_components/user-menu.test.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/app/[locale]/dashboard/_components/dashboard-header.tsx (1)

36-39: 💤 Low value

只读用户回退导航逻辑正确,可选地复用文档项常量。

逻辑无问题:已登录但无 dashboard 权限时仅保留文档链接,其余情况按 NAV_ITEMS 过滤。第 38 行的 { href: "/usage-doc", label: t("documentation") } 与第 32 行重复,可抽取为常量减少漂移风险,但非必须。

🤖 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 `@src/app/`[locale]/dashboard/_components/dashboard-header.tsx around lines 36
- 39, The conditional that builds items duplicates the documentation link
literal; extract a single constant (e.g., DOCUMENTATION_ITEM = { href:
"/usage-doc", label: t("documentation") }) and use it in the readonly branch
instead of repeating the object, keeping the existing logic that uses session,
canUseDashboard, NAV_ITEMS, and isAdmin unchanged.
🤖 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.

Nitpick comments:
In `@src/app/`[locale]/dashboard/_components/dashboard-header.tsx:
- Around line 36-39: The conditional that builds items duplicates the
documentation link literal; extract a single constant (e.g., DOCUMENTATION_ITEM
= { href: "/usage-doc", label: t("documentation") }) and use it in the readonly
branch instead of repeating the object, keeping the existing logic that uses
session, canUseDashboard, NAV_ITEMS, and isAdmin unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a6dcb8f8-7335-4a51-9b74-7738c0316a61

📥 Commits

Reviewing files that changed from the base of the PR and between fd9e808 and cfc0289.

📒 Files selected for processing (2)
  • src/app/[locale]/dashboard/_components/dashboard-header.test.tsx
  • src/app/[locale]/dashboard/_components/dashboard-header.tsx

@tesgth032

Copy link
Copy Markdown
Contributor Author

本轮已完成 #1232 的文档入口改进,并处理了机器人审阅意见。

主要改动:

  • /my-usage 页头新增可见的使用文档按钮,跳转 /usage-doc
  • 在 Dashboard 用户菜单新增文档图标入口,方便登录后用户随时进入文档。
  • myUsage.header.documentation 补齐 5 种语言文案。
  • /usage-doc 使用 getSession({ allowReadOnlyAccess: true }),保留只读用户会话状态。
  • 对只读会话收敛 Dashboard Header 导航,只显示 /usage-doc,避免展示不可访问的 dashboard 链接。
  • 增加组件测试、i18n key parity 测试、usage-doc 会话断言测试,并补充只读/完整 Web UI 会话的导航测试。

审阅处理:

  • 已修复 Gemini 提到的 myUsage i18n 测试类型安全访问。
  • 已按 Greptile 建议把 UserMenu 测试改为真实 NextIntlClientProvider,避免 namespace-blind mock。
  • 已按 Codex 建议修复只读用户打开文档时会话丢失的问题。
  • 已按 CodeRabbit 建议限制只读用户文档页导航,并抽取复用文档导航项常量。
  • Gemini 关于 dashboard.nav.documentation 缺失的评论是误报:该 key 已存在于全部 5 个 messages/*/dashboard.json 中,自动 Claude review 也已验证。

验证结果:

  • 本地通过 bun run test -- src/app/[locale]/dashboard/_components/dashboard-header.test.tsx
  • 本地通过 bun run typecheck
  • 本地通过 bun run lint(仅保留仓库既有 Biome schema/optional-chain 基线告警)
  • 本地通过 bun run build(仅保留仓库既有 Next/Turbopack 基线告警)
  • 最新 PR checks 全部通过:Code Quality、Docker Build、Unit Tests、API Tests、Integration Tests、Test Summary、CodeRabbit、Greptile。

@ding113
ding113 merged commit 499d925 into ding113:dev Jun 11, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Claude Code Hub Roadmap Jun 11, 2026
@github-actions github-actions Bot mentioned this pull request Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:i18n area:UI enhancement New feature or request size/S Small PR (< 200 lines)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants