Skip to content

功能优化 - #27

Merged
CSCITech merged 5 commits into
mainfrom
cscitech
Aug 4, 2026
Merged

CSCITech merged 5 commits into
mainfrom
cscitech

Conversation

@CSCITech

@CSCITech CSCITech commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@CSCITech, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

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 reviews.

How do review 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 refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3efd9c4d-f810-474a-9d15-a6b0505b6c7e

📥 Commits

Reviewing files that changed from the base of the PR and between fa3ed99 and 1e8e5cf.

📒 Files selected for processing (1)
  • service/tiered_settle_test.go

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a streamlined confirmation dialog for status-code risks with clear details, notices, and always-available actions.
    • Improved OAuth callback handling for login and account binding flows, including provider-aware state tracking.
    • Added support for preserving Qwen thinking settings across compatible request formats.
    • Added routing-aware billing preparation and quota updates.
    • DeepSeek Responses requests now support reasoning settings.
  • Bug Fixes

    • User-visible logs now retain stream status information.
  • Tests

    • Expanded coverage for confirmation dialogs, OAuth flows, billing, and model request compatibility.

Walkthrough

The pull request updates status-risk confirmation, selected-group billing, Qwen thinking-budget handling, DeepSeek Responses conversion, OAuth callback routing, and user log metadata.

Changes

Status code risk confirmation

Layer / File(s) Summary
Reusable confirmation content
web/default/src/features/channels/components/dialogs/status-code-risk-dialog.tsx, web/default/src/features/channels/components/dialogs/status-code-risk-dialog.test.tsx
The dialog now renders translated risk notices, detected details, and always-enabled cancel and confirm actions. Checklist, typed confirmation, and input controls were removed. Tests cover the new content.

Selected-group tiered billing

Layer / File(s) Summary
Billing preparation and relay integration
service/tiered_settle.go, service/tiered_settle_test.go, controller/relay.go
Selected-group billing now refreshes quota, updates reservations or pre-consumption, and handles preparation failures in relay and task submission flows.

Thinking budget and DeepSeek Responses

Layer / File(s) Summary
Thinking budget request contracts
dto/openai_request.go, dto/openai_request_zero_value_test.go
General and Responses requests now carry ThinkingBudget. Serialization retains it for Qwen/QwQ models and omits it for other models.
Responses conversion and DeepSeek routing
service/openaicompat/*, relay/channel/deepseek/*
Request conversions preserve thinking settings. DeepSeek now routes Responses requests to /responses and normalizes V4 thinking suffixes and reasoning metadata.

OAuth callback mode

Layer / File(s) Summary
Provider-scoped OAuth state
web/default/src/lib/oauth.ts
OAuth binding state now uses normalized provider and state keys while retaining legacy-key cleanup. OAuth providers record provider-specific state.
Callback mode resolution
web/default/src/features/auth/lib/oauth-callback-mode.*, web/default/src/routes/oauth/$provider.tsx
The callback route now selects login or bind from provider state and the explicit bind query flag. Tests cover matching, fallback, stale, and storage-error cases.

User log metadata

Layer / File(s) Summary
Stream status visibility
model/log.go, model/log_test.go
User log formatting now retains top-level stream_status metadata and verifies its error status.

Estimated code review effort: 4 (Complex) | ~45 minutes

Poem

A rabbit checks the risks with care,
While budgets travel everywhere.
OAuth reads the matching state,
DeepSeek routes requests in place.
Billing settles groups just right,
And logs keep stream status in sight.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.13% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title “功能优化” is generic and does not identify the primary changes across billing, OAuth, request handling, and dialog behavior. Replace the title with a concise summary of the main functional changes, such as billing preparation, OAuth callback handling, and model request compatibility.
Description check ❓ Inconclusive The description contains only an uncompleted template and does not explain the pull request changes, reasons, scope, or validation results. Complete the description with a concise summary of the changes, motivation, affected areas, related issue, and test or validation results.
✅ Passed checks (2 passed)
Check name Status Explanation
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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cscitech

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.

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

Actionable comments posted: 3

🤖 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/default/src/features/channels/components/dialogs/status-code-risk-dialog.test.tsx`:
- Around line 35-57: Rewrite the test around StatusCodeRiskConfirmationContent
to use React Testing Library rendering rather than renderToStaticMarkup, while
preserving the existing risk-notice assertions where applicable. Provide
distinct spies for onCancel and onConfirm, click each corresponding action, and
assert that each callback is invoked. Run the repository type check after
updating the test.

In
`@web/default/src/features/channels/components/dialogs/status-code-risk-dialog.tsx`:
- Around line 109-113: Add aria-hidden="true" to the HugeiconsIcon using
Alert02Icon in the dialog title so assistive technology ignores the decorative
warning icon while preserving the existing DialogTitle content.
- Around line 52-56: Update both StatusCodeRiskConfirmationContent and the
component defined near its sibling signature at lines 96-101 in
web/default/src/features/channels/components/dialogs/status-code-risk-dialog.tsx
to accept a typed props object, access values through props, and declare the
repository-preferred explicit React JSX return type; apply the same change at
both affected sites.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: c80b0b26-cf75-4aab-94c2-e15de5b6803e

📥 Commits

Reviewing files that changed from the base of the PR and between 7d8358f and da143f9.

📒 Files selected for processing (2)
  • web/default/src/features/channels/components/dialogs/status-code-risk-dialog.test.tsx
  • web/default/src/features/channels/components/dialogs/status-code-risk-dialog.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: Frontend checks
  • GitHub Check: Backend checks
🧰 Additional context used
📓 Path-based instructions (2)
web/default/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (web/default/AGENTS.md)

web/default/src/**/*.{ts,tsx}: 前端页面文本与组件内文案必须支持 i18n:React 组件中应使用 useTranslation() 取得 t,并通过 t() 渲染用户可见文本;子组件也应自行使用 useTranslation() 保持独立性。
禁止使用两层及以上嵌套三元表达式;复杂逻辑应改用 if-else、提前返回或抽取函数。
控制函数圈复杂度,复杂逻辑应拆成更小的函数;变量与函数命名应有意义并遵循驼峰等常规命名约定。
TypeScript 代码应避免使用 any,优先使用具体类型或 unknown;参数与返回值应显式标注类型;仅类型用途的导入应使用 import type。
修改 TypeScript 或 TSX 代码后必须执行类型检查,并修复所有类型错误,不得遗留。
对象非必要不要解构,尤其是组件 props;优先直接使用 props.xxx 以保持代码清晰。
组件应使用函数式组件与 Hooks,遵循单一职责;组件 props 必须有明确类型(接口或类型别名)。
单文件超过约 200 行时应考虑拆分子组件或抽取自定义 Hooks;类型定义可与组件同文件或放在同模块的 types 中。
在 React 中应合理使用 useMemo、useCallback、React.memo,避免在渲染路径中创建新对象或数组;必要时进行代码分割与动态 import。
React Query 的数据获取应使用 useQuery、变更应使用 useMutation;每个查询需配置唯一 queryKey,并在成功后对相关查询执行 invalidateQueries;服务端错误应统一交给 handleServerError。
Axios 请求应使用项目统一的 api 实例;GET 请求默认去重,特殊请求可显式关闭;认证与通用错误应在拦截器中统一处理。
服务端错误应统一使用 handleServerError,展示层应使用 toast.error 等统一方式;文案需走 i18n;路由级错误应由 errorComponent 承接;表单错误应通过 form.setError 等方式映射到字段。
样式应以 Tailwind 工具类为主,动态类名使用 cn() 合并;非动态场景避免内联样式;响应式采用移动优先与 Tailwind 断点,主题与暗色模式通过 CSS 变量与 dark: 处理。
应使用语义化 HTML、正确关联 label 与输入、保证键盘可操作与合理焦点顺序;必要时添加 ARIA 属性,装饰性图标应使用 aria-hidden="true"。
认证与权限应在路由与接口层校验;前后端都应做数据校验(如 Zod);敏感信息不得落前端存储;避免使用 dangerouslySetInnerHTML;跨域与 Cookie 需配合 withCredentials 并按后端要求处理 CSRF。
组件测试应使用 React Testing Library,关注交互与行为,避免测试实现细节;关键流程可补充集成与 E2E 测试。
环境变量应通过 .env 读取,并使用 VITE_ 前缀;代码中不得硬编码密钥。

Files:

  • web/default/src/features/channels/components/dialogs/status-code-risk-dialog.test.tsx
  • web/default/src/features/channels/components/dialogs/status-code-risk-dialog.tsx
web/default/src/features/**

📄 CodeRabbit inference engine (web/default/AGENTS.md)

功能模块应放在 src/features/<feature>/,并按需包含 components/、lib/、hooks/、api.ts、types.ts、constants.ts 等;通用组件应放在 src/components/,通用工具与类型应放在 src/lib/。

Files:

  • web/default/src/features/channels/components/dialogs/status-code-risk-dialog.test.tsx
  • web/default/src/features/channels/components/dialogs/status-code-risk-dialog.tsx
🔇 Additional comments (2)
web/default/src/features/channels/components/dialogs/status-code-risk-dialog.tsx (2)

19-20: LGTM!


121-125: LGTM!

Comment thread web/default/src/features/channels/components/dialogs/status-code-risk-dialog.tsx Outdated
@CSCITech

CSCITech commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
✅ 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.

@CSCITech

CSCITech commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
✅ 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

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

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

⚠️ Outside diff range comments (1)
web/default/src/routes/oauth/$provider.tsx (1)

46-50: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Validate OAuth callback search parameters with Zod.

This route currently casts useSearch(...) instead of defining a Zod search schema with validateSearch on Route. Add validation for the expected code/state/redirect/bind shape before runtime code binds it to auth state.

🤖 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/default/src/routes/oauth/`$provider.tsx around lines 46 - 50, Define a
Zod schema for the optional code, state, redirect, and bind search parameters,
then register it through the OAuth provider Route’s validateSearch
configuration. Remove the type cast from useSearch and consume the validated
search result so auth-state binding receives the expected shape.

Source: Coding guidelines

🤖 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 `@service/tiered_settle_test.go`:
- Around line 340-394: Add a test for the free-to-paid branch in
PrepareTieredBillingForSelectedGroup using relayInfo.Billing == nil and a
refreshed non-zero GroupRatio; assert that billing is initialized and
FinalPreConsumedQuota equals the expected pre-consumed quota.

In `@web/default/src/routes/oauth/`$provider.tsx:
- Around line 52-65: Replace the duplicated mode state and synchronization in
web/default/src/routes/oauth/$provider.tsx lines 52-65 with direct derivation
from provider, search.state, and search.bind. In the OAuth exchange effect at
lines 93-99, remove mode from the dependency list while preserving the existing
exchange behavior; both sites are in the same file.

---

Outside diff comments:
In `@web/default/src/routes/oauth/`$provider.tsx:
- Around line 46-50: Define a Zod schema for the optional code, state, redirect,
and bind search parameters, then register it through the OAuth provider Route’s
validateSearch configuration. Remove the type cast from useSearch and consume
the validated search result so auth-state binding receives the expected shape.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: 6947c29e-a045-46aa-bec4-8e6df3dd4b5d

📥 Commits

Reviewing files that changed from the base of the PR and between 6d00d90 and abdb452.

📒 Files selected for processing (16)
  • controller/relay.go
  • dto/openai_request.go
  • dto/openai_request_zero_value_test.go
  • model/log.go
  • model/log_test.go
  • relay/channel/deepseek/adaptor.go
  • relay/channel/deepseek/adaptor_test.go
  • service/openaicompat/chat_to_responses.go
  • service/openaicompat/responses_compat_test.go
  • service/openaicompat/responses_request_to_chat.go
  • service/tiered_settle.go
  • service/tiered_settle_test.go
  • web/default/src/features/auth/lib/oauth-callback-mode.test.ts
  • web/default/src/features/auth/lib/oauth-callback-mode.ts
  • web/default/src/lib/oauth.ts
  • web/default/src/routes/oauth/$provider.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Backend checks
🧰 Additional context used
📓 Path-based instructions (8)
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: In Go business code, all JSON marshal/unmarshal operations must use the wrapper functions in common/json.go (common.Marshal, common.Unmarshal, common.UnmarshalJsonStr, common.DecodeJson, common.GetJsonType) and must not directly call encoding/json for actual encode/decode work.
All database code must be compatible with SQLite, MySQL 5.7.8+, and PostgreSQL 9.6+; prefer GORM abstractions over raw SQL, avoid direct AUTO_INCREMENT/SERIAL, use commonGroupCol/commonKeyCol and commonTrueVal/commonFalseVal for DB-specific SQL, branch with common.UsingPostgreSQL/common.UsingSQLite/common.UsingMySQL, avoid unsupported DB-specific functions/operators without fallback, and make migrations work across all three databases.
When implementing a new relay channel, confirm whether the provider supports StreamOptions; if it does, add that channel to streamSupportedChannels.
For request structs parsed from client JSON and re-marshaled to upstream providers, optional scalar fields must use pointer types with omitempty so explicit zero/false values are preserved instead of dropped.
When working on tiered/dynamic billing expression code, read pkg/billingexpr/expr.md first and follow its documented expression language, architecture, token normalization, quota conversion, and versioning patterns.

**/*.go: All JSON marshal/unmarshal operations in Go business code must use the wrapper functions in common/json.go (common.Marshal, common.Unmarshal, common.UnmarshalJsonStr, common.DecodeJson, common.GetJsonType) instead of directly importing or calling encoding/json for actual marshal/unmarshal work.
All database code in Go must remain compatible with SQLite, MySQL >= 5.7.8, and PostgreSQL >= 9.6; prefer GORM abstractions, avoid raw SQL unless necessary, use the shared DB helper variables for reserved words and boolean literals, branch with the common.UsingPostgreSQL / common.UsingSQLite / common.UsingMySQL flags when need...

Files:

  • relay/channel/deepseek/adaptor_test.go
  • model/log_test.go
  • service/openaicompat/responses_compat_test.go
  • model/log.go
  • service/openaicompat/responses_request_to_chat.go
  • service/tiered_settle.go
  • controller/relay.go
  • service/openaicompat/chat_to_responses.go
  • relay/channel/deepseek/adaptor.go
  • service/tiered_settle_test.go
  • dto/openai_request.go
  • dto/openai_request_zero_value_test.go
relay/channel/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

When implementing a new channel, confirm whether the provider supports StreamOptions; if it does, add the channel to streamSupportedChannels.

Files:

  • relay/channel/deepseek/adaptor_test.go
  • relay/channel/deepseek/adaptor.go
web/default/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (web/default/AGENTS.md)

web/default/src/**/*.{ts,tsx}: 前端页面文本与组件内文案必须支持 i18n:React 组件中应使用 useTranslation() 取得 t,并通过 t() 渲染用户可见文本;子组件也应自行使用 useTranslation() 保持独立性。
禁止使用两层及以上嵌套三元表达式;复杂逻辑应改用 if-else、提前返回或抽取函数。
控制函数圈复杂度,复杂逻辑应拆成更小的函数;变量与函数命名应有意义并遵循驼峰等常规命名约定。
TypeScript 代码应避免使用 any,优先使用具体类型或 unknown;参数与返回值应显式标注类型;仅类型用途的导入应使用 import type。
修改 TypeScript 或 TSX 代码后必须执行类型检查,并修复所有类型错误,不得遗留。
对象非必要不要解构,尤其是组件 props;优先直接使用 props.xxx 以保持代码清晰。
组件应使用函数式组件与 Hooks,遵循单一职责;组件 props 必须有明确类型(接口或类型别名)。
单文件超过约 200 行时应考虑拆分子组件或抽取自定义 Hooks;类型定义可与组件同文件或放在同模块的 types 中。
在 React 中应合理使用 useMemo、useCallback、React.memo,避免在渲染路径中创建新对象或数组;必要时进行代码分割与动态 import。
React Query 的数据获取应使用 useQuery、变更应使用 useMutation;每个查询需配置唯一 queryKey,并在成功后对相关查询执行 invalidateQueries;服务端错误应统一交给 handleServerError。
Axios 请求应使用项目统一的 api 实例;GET 请求默认去重,特殊请求可显式关闭;认证与通用错误应在拦截器中统一处理。
服务端错误应统一使用 handleServerError,展示层应使用 toast.error 等统一方式;文案需走 i18n;路由级错误应由 errorComponent 承接;表单错误应通过 form.setError 等方式映射到字段。
样式应以 Tailwind 工具类为主,动态类名使用 cn() 合并;非动态场景避免内联样式;响应式采用移动优先与 Tailwind 断点,主题与暗色模式通过 CSS 变量与 dark: 处理。
应使用语义化 HTML、正确关联 label 与输入、保证键盘可操作与合理焦点顺序;必要时添加 ARIA 属性,装饰性图标应使用 aria-hidden="true"。
认证与权限应在路由与接口层校验;前后端都应做数据校验(如 Zod);敏感信息不得落前端存储;避免使用 dangerouslySetInnerHTML;跨域与 Cookie 需配合 withCredentials 并按后端要求处理 CSRF。
组件测试应使用 React Testing Library,关注交互与行为,避免测试实现细节;关键流程可补充集成与 E2E 测试。
环境变量应通过 .env 读取,并使用 VITE_ 前缀;代码中不得硬编码密钥。

Files:

  • web/default/src/features/auth/lib/oauth-callback-mode.test.ts
  • web/default/src/features/auth/lib/oauth-callback-mode.ts
  • web/default/src/routes/oauth/$provider.tsx
  • web/default/src/lib/oauth.ts
web/default/src/features/**/lib/**/*.ts

📄 CodeRabbit inference engine (web/default/AGENTS.md)

表单应使用 React Hook Form + Zod:在功能模块的 lib/ 下定义 schema,并用 z.infer 导出表单类型;useForm 应配合 @hookform/resolvers/zod 进行校验。

Files:

  • web/default/src/features/auth/lib/oauth-callback-mode.test.ts
  • web/default/src/features/auth/lib/oauth-callback-mode.ts
web/default/src/features/**

📄 CodeRabbit inference engine (web/default/AGENTS.md)

功能模块应放在 src/features/<feature>/,并按需包含 components/、lib/、hooks/、api.ts、types.ts、constants.ts 等;通用组件应放在 src/components/,通用工具与类型应放在 src/lib/。

Files:

  • web/default/src/features/auth/lib/oauth-callback-mode.test.ts
  • web/default/src/features/auth/lib/oauth-callback-mode.ts
web/default/src/**/*.test.ts

📄 CodeRabbit inference engine (web/default/AGENTS.md)

工具函数与纯逻辑应优先编写单元测试;测试文件应命名为 *.test.ts。

Files:

  • web/default/src/features/auth/lib/oauth-callback-mode.test.ts
web/default/src/routes/**/*.{ts,tsx}

📄 CodeRabbit inference engine (web/default/AGENTS.md)

路由应使用 TanStack Router,并通过 createFileRoute 定义;搜索参数应使用 Zod schema + validateSearch 校验;认证与重定向应放在 beforeLoad 中;导航应优先使用 useNavigate 或 Link,避免直接操作 window.location。

Files:

  • web/default/src/routes/oauth/$provider.tsx
dto/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

For request structs parsed from client JSON and then re-marshaled to upstream providers, especially in relay/convert paths, optional scalar fields must use pointer types with omitempty so that absent fields stay omitted while explicit zero/false values are preserved.

Files:

  • dto/openai_request.go
  • dto/openai_request_zero_value_test.go
🔇 Additional comments (20)
model/log.go (1)

366-366: LGTM!

model/log_test.go (1)

1096-1098: LGTM!

web/default/src/lib/oauth.ts (2)

24-85: LGTM!


175-175: LGTM!

Also applies to: 186-186, 200-200, 211-211

web/default/src/features/auth/lib/oauth-callback-mode.ts (1)

1-11: LGTM!

web/default/src/features/auth/lib/oauth-callback-mode.test.ts (1)

1-105: LGTM!

web/default/src/routes/oauth/$provider.tsx (1)

31-35: LGTM!

dto/openai_request.go (1)

93-93: LGTM!

Also applies to: 112-119, 235-241, 902-914

dto/openai_request_zero_value_test.go (1)

4-4: LGTM!

Also applies to: 54-102, 169-193

service/openaicompat/chat_to_responses.go (1)

389-390: LGTM!

service/openaicompat/responses_request_to_chat.go (1)

66-66: LGTM!

service/openaicompat/responses_compat_test.go (1)

47-71: LGTM!

relay/channel/deepseek/adaptor.go (1)

71-72: LGTM!

Also applies to: 163-189

relay/channel/deepseek/adaptor_test.go (1)

12-53: LGTM!

service/tiered_settle.go (3)

4-11: LGTM!


110-132: 🗄️ Data Integrity & Integration

No change needed.

No repository reader relies on TieredBillingSnapshot.GroupRatio or EstimatedQuotaAfterGroup preserving frozen pre-consume values.


155-165: 🗄️ Data Integrity & Integration

No change needed for FinalPreConsumedQuota.

NewBillingSession already writes relayInfo.FinalPreConsumedQuota with the session-backed pre-consumed quota after preConsume succeeds, so the free-to-paid branch stays synchronized.

			> Likely an incorrect or invalid review comment.
service/tiered_settle_test.go (1)

12-12: LGTM!

controller/relay.go (2)

198-201: LGTM!


574-577: LGTM!

Comment thread service/tiered_settle_test.go
Comment thread web/default/src/routes/oauth/$provider.tsx Outdated
@CSCITech

CSCITech commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
✅ 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

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@service/tiered_settle_test.go`:
- Around line 408-434: Add a test for PrepareTieredBillingForSelectedGroup using
a nil context, relayInfo.Billing set to nil, and a non-zero refreshed GroupRatio
to enter the missing-context branch. Assert that the returned error is a non-nil
*types.MaxAPIError, while preserving the existing tiered billing setup.
🪄 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: ASSERTIVE

Plan: Pro Plus

Run ID: 5fca1d8e-c1ff-4a1a-876a-b2658901016b

📥 Commits

Reviewing files that changed from the base of the PR and between abdb452 and fa3ed99.

📒 Files selected for processing (4)
  • service/tiered_settle_test.go
  • web/default/src/features/auth/lib/oauth-callback-mode.test.ts
  • web/default/src/features/auth/lib/oauth-callback-mode.ts
  • web/default/src/routes/oauth/$provider.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: Backend checks
🧰 Additional context used
📓 Path-based instructions (6)
web/default/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (web/default/AGENTS.md)

web/default/src/**/*.{ts,tsx}: 前端页面文本与组件内文案必须支持 i18n:React 组件中应使用 useTranslation() 取得 t,并通过 t() 渲染用户可见文本;子组件也应自行使用 useTranslation() 保持独立性。
禁止使用两层及以上嵌套三元表达式;复杂逻辑应改用 if-else、提前返回或抽取函数。
控制函数圈复杂度,复杂逻辑应拆成更小的函数;变量与函数命名应有意义并遵循驼峰等常规命名约定。
TypeScript 代码应避免使用 any,优先使用具体类型或 unknown;参数与返回值应显式标注类型;仅类型用途的导入应使用 import type。
修改 TypeScript 或 TSX 代码后必须执行类型检查,并修复所有类型错误,不得遗留。
对象非必要不要解构,尤其是组件 props;优先直接使用 props.xxx 以保持代码清晰。
组件应使用函数式组件与 Hooks,遵循单一职责;组件 props 必须有明确类型(接口或类型别名)。
单文件超过约 200 行时应考虑拆分子组件或抽取自定义 Hooks;类型定义可与组件同文件或放在同模块的 types 中。
在 React 中应合理使用 useMemo、useCallback、React.memo,避免在渲染路径中创建新对象或数组;必要时进行代码分割与动态 import。
React Query 的数据获取应使用 useQuery、变更应使用 useMutation;每个查询需配置唯一 queryKey,并在成功后对相关查询执行 invalidateQueries;服务端错误应统一交给 handleServerError。
Axios 请求应使用项目统一的 api 实例;GET 请求默认去重,特殊请求可显式关闭;认证与通用错误应在拦截器中统一处理。
服务端错误应统一使用 handleServerError,展示层应使用 toast.error 等统一方式;文案需走 i18n;路由级错误应由 errorComponent 承接;表单错误应通过 form.setError 等方式映射到字段。
样式应以 Tailwind 工具类为主,动态类名使用 cn() 合并;非动态场景避免内联样式;响应式采用移动优先与 Tailwind 断点,主题与暗色模式通过 CSS 变量与 dark: 处理。
应使用语义化 HTML、正确关联 label 与输入、保证键盘可操作与合理焦点顺序;必要时添加 ARIA 属性,装饰性图标应使用 aria-hidden="true"。
认证与权限应在路由与接口层校验;前后端都应做数据校验(如 Zod);敏感信息不得落前端存储;避免使用 dangerouslySetInnerHTML;跨域与 Cookie 需配合 withCredentials 并按后端要求处理 CSRF。
组件测试应使用 React Testing Library,关注交互与行为,避免测试实现细节;关键流程可补充集成与 E2E 测试。
环境变量应通过 .env 读取,并使用 VITE_ 前缀;代码中不得硬编码密钥。

Files:

  • web/default/src/features/auth/lib/oauth-callback-mode.test.ts
  • web/default/src/features/auth/lib/oauth-callback-mode.ts
  • web/default/src/routes/oauth/$provider.tsx
web/default/src/features/**/lib/**/*.ts

📄 CodeRabbit inference engine (web/default/AGENTS.md)

表单应使用 React Hook Form + Zod:在功能模块的 lib/ 下定义 schema,并用 z.infer 导出表单类型;useForm 应配合 @hookform/resolvers/zod 进行校验。

Files:

  • web/default/src/features/auth/lib/oauth-callback-mode.test.ts
  • web/default/src/features/auth/lib/oauth-callback-mode.ts
web/default/src/features/**

📄 CodeRabbit inference engine (web/default/AGENTS.md)

功能模块应放在 src/features/<feature>/,并按需包含 components/、lib/、hooks/、api.ts、types.ts、constants.ts 等;通用组件应放在 src/components/,通用工具与类型应放在 src/lib/。

Files:

  • web/default/src/features/auth/lib/oauth-callback-mode.test.ts
  • web/default/src/features/auth/lib/oauth-callback-mode.ts
web/default/src/**/*.test.ts

📄 CodeRabbit inference engine (web/default/AGENTS.md)

工具函数与纯逻辑应优先编写单元测试;测试文件应命名为 *.test.ts。

Files:

  • web/default/src/features/auth/lib/oauth-callback-mode.test.ts
web/default/src/routes/**/*.{ts,tsx}

📄 CodeRabbit inference engine (web/default/AGENTS.md)

路由应使用 TanStack Router,并通过 createFileRoute 定义;搜索参数应使用 Zod schema + validateSearch 校验;认证与重定向应放在 beforeLoad 中;导航应优先使用 useNavigate 或 Link,避免直接操作 window.location。

Files:

  • web/default/src/routes/oauth/$provider.tsx
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: In Go business code, all JSON marshal/unmarshal operations must use the wrapper functions in common/json.go (common.Marshal, common.Unmarshal, common.UnmarshalJsonStr, common.DecodeJson, common.GetJsonType) and must not directly call encoding/json for actual encode/decode work.
All database code must be compatible with SQLite, MySQL 5.7.8+, and PostgreSQL 9.6+; prefer GORM abstractions over raw SQL, avoid direct AUTO_INCREMENT/SERIAL, use commonGroupCol/commonKeyCol and commonTrueVal/commonFalseVal for DB-specific SQL, branch with common.UsingPostgreSQL/common.UsingSQLite/common.UsingMySQL, avoid unsupported DB-specific functions/operators without fallback, and make migrations work across all three databases.
When implementing a new relay channel, confirm whether the provider supports StreamOptions; if it does, add that channel to streamSupportedChannels.
For request structs parsed from client JSON and re-marshaled to upstream providers, optional scalar fields must use pointer types with omitempty so explicit zero/false values are preserved instead of dropped.
When working on tiered/dynamic billing expression code, read pkg/billingexpr/expr.md first and follow its documented expression language, architecture, token normalization, quota conversion, and versioning patterns.

**/*.go: All JSON marshal/unmarshal operations in Go business code must use the wrapper functions in common/json.go (common.Marshal, common.Unmarshal, common.UnmarshalJsonStr, common.DecodeJson, common.GetJsonType) instead of directly importing or calling encoding/json for actual marshal/unmarshal work.
All database code in Go must remain compatible with SQLite, MySQL >= 5.7.8, and PostgreSQL >= 9.6; prefer GORM abstractions, avoid raw SQL unless necessary, use the shared DB helper variables for reserved words and boolean literals, branch with the common.UsingPostgreSQL / common.UsingSQLite / common.UsingMySQL flags when need...

Files:

  • service/tiered_settle_test.go
🔇 Additional comments (5)
web/default/src/features/auth/lib/oauth-callback-mode.ts (1)

1-15: LGTM!

Also applies to: 17-23

web/default/src/features/auth/lib/oauth-callback-mode.test.ts (1)

1-45: LGTM!

Also applies to: 47-108, 110-149

web/default/src/routes/oauth/$provider.tsx (1)

19-49: LGTM!

Also applies to: 76-89, 236-246

service/tiered_settle_test.go (2)

13-13: LGTM!


396-444: 🎯 Functional Correctness

No change needed for the bare test context.

PreConsumeBilling only passes c to NewBillingSession; it does not dereference c.Request, c.Writer, or c.ClientIP.

			> Likely an incorrect or invalid review comment.

Comment thread service/tiered_settle_test.go
@CSCITech

CSCITech commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
✅ 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.

@CSCITech
CSCITech merged commit 4c62e58 into main Aug 4, 2026
3 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Aug 9, 2026
11 tasks
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