Repository navigation
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (1)**/*.go📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🔇 Additional comments (13)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change adds OpenAI Alpha Search support through ChangesOpenAI Alpha Search
Billing display validation
Health check endpoints
User deletion cleanup
Midjourney custom ID validation
Estimated code review effort: 5 (Critical) | ~100 minutes Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant Client
participant RelayRouter
participant AlphaSearchHelper
participant CodexAdaptor
participant UpstreamAlphaSearch
participant QuotaService
Client->>RelayRouter: POST /v1/alpha/search
RelayRouter->>AlphaSearchHelper: Validate AlphaSearchRequest
AlphaSearchHelper->>CodexAdaptor: Build and send mapped JSON
CodexAdaptor->>UpstreamAlphaSearch: POST /backend-api/codex/alpha/search
UpstreamAlphaSearch-->>AlphaSearchHelper: Return non-streaming response
AlphaSearchHelper->>QuotaService: Record web-search usage and consume quota
AlphaSearchHelper-->>Client: Forward response
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@relay/alpha_search_handler.go`:
- Around line 92-110: Move the web-search usage initialization for
dto.BuildInToolWebSearchPreview and the service.PostTextConsumeQuota call in the
Alpha Search handler to immediately after the successful upstream status check,
before c.Writer.WriteHeader and io.Copy. Ensure billing is settled even when
response-body copying fails, while preserving the existing usage metadata and
error return behavior.
- Line 58: Replace the complete request-body logging in the Alpha Search handler
with debug metadata only, such as the model name and serialized body size; do
not pass jsonData or any equivalent prompt/request contents to logger.LogDebug.
🪄 Autofix
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: 3e339a67-d6ae-4cee-bc9f-07939537e3ea
📒 Files selected for processing (37)
common/endpoint_defaults.gocommon/endpoint_type.gocommon/endpoint_type_test.goconstant/endpoint_type.gocontroller/channel-test.gocontroller/channel_test_internal_test.gocontroller/relay.godto/alpha_search_request.gorelay/alpha_search_handler.gorelay/alpha_search_handler_test.gorelay/channel/codex/adaptor.gorelay/channel/codex/adaptor_test.gorelay/common/relay_info.gorelay/constant/relay_mode.gorelay/constant/relay_mode_test.gorelay/helper/alpha_search_request_test.gorelay/helper/valid_request.gorouter/relay-router.gorouter/relay_router_test.goservice/alpha_search_billing.goservice/alpha_search_billing_test.goservice/text_quota.goservice/text_quota_test.goservice/tiered_settle.gotypes/relay_format.goweb/default/src/features/channels/components/dialogs/channel-test-dialog.tsxweb/default/src/features/channels/lib/advanced-custom.test.tsweb/default/src/features/channels/lib/advanced-custom.tsweb/default/src/features/pricing/components/model-details-api.tsxweb/default/src/features/pricing/constants.tsweb/default/src/features/pricing/lib/model-metadata.tsweb/default/src/i18n/locales/en.jsonweb/default/src/i18n/locales/fr.jsonweb/default/src/i18n/locales/ja.jsonweb/default/src/i18n/locales/ru.jsonweb/default/src/i18n/locales/vi.jsonweb/default/src/i18n/locales/zh.json
📜 Review details
🧰 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 incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) and must not directly callencoding/jsonfor 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 directAUTO_INCREMENT/SERIAL, usecommonGroupCol/commonKeyColandcommonTrueVal/commonFalseValfor DB-specific SQL, branch withcommon.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 supportsStreamOptions; if it does, add that channel tostreamSupportedChannels.
For request structs parsed from client JSON and re-marshaled to upstream providers, optional scalar fields must use pointer types withomitemptyso explicit zero/false values are preserved instead of dropped.
When working on tiered/dynamic billing expression code, readpkg/billingexpr/expr.mdfirst 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 incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) instead of directly importing or callingencoding/jsonfor 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 thecommon.UsingPostgreSQL/common.UsingSQLite/common.UsingMySQLflags when need...
Files:
relay/constant/relay_mode_test.gorouter/relay_router_test.gocommon/endpoint_type_test.gocommon/endpoint_defaults.gotypes/relay_format.gocommon/endpoint_type.gorouter/relay-router.gorelay/channel/codex/adaptor_test.gorelay/constant/relay_mode.goservice/text_quota_test.gorelay/common/relay_info.gorelay/channel/codex/adaptor.gorelay/alpha_search_handler.godto/alpha_search_request.gocontroller/channel_test_internal_test.gorelay/helper/alpha_search_request_test.goservice/alpha_search_billing.gocontroller/relay.gorelay/alpha_search_handler_test.gocontroller/channel-test.goservice/text_quota.gorelay/helper/valid_request.goconstant/endpoint_type.goservice/alpha_search_billing_test.goservice/tiered_settle.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/pricing/lib/model-metadata.tsweb/default/src/features/channels/lib/advanced-custom.test.tsweb/default/src/features/channels/lib/advanced-custom.tsweb/default/src/features/channels/components/dialogs/channel-test-dialog.tsxweb/default/src/features/pricing/constants.tsweb/default/src/features/pricing/components/model-details-api.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/pricing/lib/model-metadata.tsweb/default/src/features/channels/lib/advanced-custom.test.tsweb/default/src/features/channels/lib/advanced-custom.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/pricing/lib/model-metadata.tsweb/default/src/features/channels/lib/advanced-custom.test.tsweb/default/src/features/channels/lib/advanced-custom.tsweb/default/src/features/channels/components/dialogs/channel-test-dialog.tsxweb/default/src/features/pricing/constants.tsweb/default/src/features/pricing/components/model-details-api.tsx
web/default/src/**/*.test.ts
📄 CodeRabbit inference engine (web/default/AGENTS.md)
工具函数与纯逻辑应优先编写单元测试;测试文件应命名为
*.test.ts。
Files:
web/default/src/features/channels/lib/advanced-custom.test.ts
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 tostreamSupportedChannels.
Files:
relay/channel/codex/adaptor_test.gorelay/channel/codex/adaptor.go
web/default/src/features/**/constants.ts
📄 CodeRabbit inference engine (web/default/AGENTS.md)
各 feature 的
constants.ts中,成功/错误/提示类消息常量应仅保存 i18n 键,展示时必须通过t()渲染;状态/选项的 label 应统一使用labelKey或label(二选一且同一 feature 内保持一致);新增此类常量时应同步登记翻译键。
Files:
web/default/src/features/pricing/constants.ts
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
omitemptyso that absent fields stay omitted while explicit zero/false values are preserved.
Files:
dto/alpha_search_request.go
🔇 Additional comments (36)
constant/endpoint_type.go (1)
9-9: LGTM!common/endpoint_defaults.go (1)
23-23: LGTM!common/endpoint_type.go (1)
33-38: LGTM!common/endpoint_type_test.go (1)
1-16: LGTM!relay/helper/alpha_search_request_test.go (1)
13-38: LGTM!relay/channel/codex/adaptor_test.go (1)
12-26: LGTM!controller/channel-test.go (1)
200-201: LGTM!Also applies to: 239-241, 382-396, 485-510, 786-803
controller/channel_test_internal_test.go (1)
8-10: LGTM!Also applies to: 86-98
controller/relay.go (1)
52-53: LGTM!Also applies to: 160-173
types/relay_format.go (1)
11-11: LGTM!relay/constant/relay_mode.go (1)
55-55: LGTM!Also applies to: 80-81
relay/constant/relay_mode_test.go (1)
9-20: LGTM!dto/alpha_search_request.go (1)
12-38: LGTM!relay/helper/valid_request.go (1)
40-41: LGTM!Also applies to: 59-77
relay/alpha_search_handler_test.go (1)
10-48: LGTM!relay/channel/codex/adaptor.go (1)
115-127: LGTM!Also applies to: 139-148
router/relay-router.go (1)
107-109: LGTM!router/relay_router_test.go (1)
11-25: LGTM!relay/alpha_search_handler.go (1)
21-56: LGTM!Also applies to: 66-87, 114-127
service/alpha_search_billing.go (1)
16-49: LGTM!service/alpha_search_billing_test.go (1)
18-96: LGTM!service/text_quota.go (1)
60-62: LGTM!Also applies to: 306-328, 418-419
service/text_quota_test.go (1)
9-9: LGTM!Also applies to: 767-823
service/tiered_settle.go (1)
11-11: LGTM!Also applies to: 151-184
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx (1)
137-140: LGTM!Also applies to: 159-159
web/default/src/features/channels/lib/advanced-custom.ts (1)
95-98: LGTM!web/default/src/features/channels/lib/advanced-custom.test.ts (1)
1-23: LGTM!web/default/src/features/pricing/constants.ts (1)
67-78: LGTM!Also applies to: 84-99
web/default/src/features/pricing/components/model-details-api.tsx (1)
167-224: LGTM!Also applies to: 496-497
web/default/src/features/pricing/lib/model-metadata.ts (1)
36-44: LGTM!web/default/src/i18n/locales/en.json (1)
3240-3241: LGTM!web/default/src/i18n/locales/fr.json (1)
3240-3241: LGTM!web/default/src/i18n/locales/ja.json (1)
3240-3241: LGTM!web/default/src/i18n/locales/ru.json (1)
3240-3241: LGTM!web/default/src/i18n/locales/vi.json (1)
3240-3241: LGTM!web/default/src/i18n/locales/zh.json (1)
3240-3241: LGTM!
There was a problem hiding this comment.
Actionable comments posted: 1
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/features/pricing/components/model-details-api.tsx (1)
168-226: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd direct tests for
buildAlphaSearchSample.
model-details-api.test.tsonly testsbuildResponsesCompactSample. It does not verify the Alpha Search endpoint,search_querypayload, or authentication syntax for curl, Python, and JavaScript.Move
buildAlphaSearchSampletomodel-details-api-samples.ts, or export an equivalent pure builder. Add focused assertions for/v1/alpha/searchand the generated request body in each supported language.As per coding guidelines, “工具函数与纯逻辑应优先编写单元测试;测试文件应命名为
*.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 `@web/default/src/features/pricing/components/model-details-api.tsx` around lines 168 - 226, Make buildAlphaSearchSample directly testable by moving it to model-details-api-samples.ts or exporting an equivalent pure builder, then add focused model-details-api.test.ts coverage for curl, Python, and JavaScript. Assert each output targets /v1/alpha/search, includes the search_query payload, and uses the expected language-specific authentication syntax and request body.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 `@model/channel_selection_test.go`:
- Around line 162-200: Extend
TestAlphaSearchSelectionUsesOnlySupportedChannelTypes with an Advanced Custom
channel configured with a validated /v1/alpha/search route, then verify it is
selected by both GetChannel and GetRandomSatisfiedChannel. Keep the existing
OpenAI rejection and Codex assertions, and ensure the added direct and cached
cases exercise the route-specific support branch.
---
Outside diff comments:
In `@web/default/src/features/pricing/components/model-details-api.tsx`:
- Around line 168-226: Make buildAlphaSearchSample directly testable by moving
it to model-details-api-samples.ts or exporting an equivalent pure builder, then
add focused model-details-api.test.ts coverage for curl, Python, and JavaScript.
Assert each output targets /v1/alpha/search, includes the search_query payload,
and uses the expected language-specific authentication syntax and request body.
🪄 Autofix
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: 05c0825e-fee5-49d1-8fd6-4041f0cbc0a2
📒 Files selected for processing (14)
common/endpoint_defaults.gomodel/ability.gomodel/channel_cache.gomodel/channel_selection_test.gomodel/pricing.gomodel/pricing_test.gorelay/alpha_search_handler.gorelay/alpha_search_handler_test.goservice/text_quota.goservice/text_quota_test.gotools/jsonwrapcheck/allowlist.txtweb/default/src/features/pricing/components/model-details-api-samples.tsweb/default/src/features/pricing/components/model-details-api.test.tsweb/default/src/features/pricing/components/model-details-api.tsx
💤 Files with no reviewable changes (1)
- tools/jsonwrapcheck/allowlist.txt
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Backend checks
🧰 Additional context used
📓 Path-based instructions (4)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: In Go business code, all JSON marshal/unmarshal operations must use the wrapper functions incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) and must not directly callencoding/jsonfor 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 directAUTO_INCREMENT/SERIAL, usecommonGroupCol/commonKeyColandcommonTrueVal/commonFalseValfor DB-specific SQL, branch withcommon.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 supportsStreamOptions; if it does, add that channel tostreamSupportedChannels.
For request structs parsed from client JSON and re-marshaled to upstream providers, optional scalar fields must use pointer types withomitemptyso explicit zero/false values are preserved instead of dropped.
When working on tiered/dynamic billing expression code, readpkg/billingexpr/expr.mdfirst 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 incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) instead of directly importing or callingencoding/jsonfor 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 thecommon.UsingPostgreSQL/common.UsingSQLite/common.UsingMySQLflags when need...
Files:
model/pricing_test.gomodel/channel_selection_test.gocommon/endpoint_defaults.gorelay/alpha_search_handler_test.gomodel/ability.goservice/text_quota_test.gomodel/channel_cache.goservice/text_quota.gomodel/pricing.gorelay/alpha_search_handler.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/pricing/components/model-details-api.test.tsweb/default/src/features/pricing/components/model-details-api.tsxweb/default/src/features/pricing/components/model-details-api-samples.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/pricing/components/model-details-api.test.tsweb/default/src/features/pricing/components/model-details-api.tsxweb/default/src/features/pricing/components/model-details-api-samples.ts
web/default/src/**/*.test.ts
📄 CodeRabbit inference engine (web/default/AGENTS.md)
工具函数与纯逻辑应优先编写单元测试;测试文件应命名为
*.test.ts。
Files:
web/default/src/features/pricing/components/model-details-api.test.ts
🔇 Additional comments (12)
web/default/src/features/pricing/components/model-details-api-samples.ts (1)
1-65: LGTM!web/default/src/features/pricing/components/model-details-api.test.ts (1)
1-26: LGTM!web/default/src/features/pricing/components/model-details-api.tsx (1)
57-57: LGTM!Also applies to: 497-500
common/endpoint_defaults.go (1)
37-45: LGTM!model/ability.go (1)
257-262: LGTM!Also applies to: 278-287
model/channel_cache.go (1)
249-254: LGTM!Also applies to: 271-284
model/pricing.go (1)
12-12: LGTM!Also applies to: 131-198, 293-298, 313-313, 357-357
model/pricing_test.go (1)
1-42: LGTM!relay/alpha_search_handler.go (1)
58-58: LGTM!Also applies to: 89-116
relay/alpha_search_handler_test.go (1)
4-56: LGTM!Also applies to: 97-160
service/text_quota.go (1)
16-16: LGTM!Also applies to: 61-68, 177-182, 312-341, 431-432
service/text_quota_test.go (1)
15-18: LGTM!Also applies to: 799-835, 939-965
There was a problem hiding this comment.
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 `@web/default/src/features/pricing/components/model-details-api-samples.ts`:
- Around line 114-125: Update the Alpha Search sample generation near the
response parsing to check response.ok and handle non-success responses
consistently with buildResponsesCompactSample before reading or logging the
response body. Add matching TypeScript and JavaScript coverage in
model-details-api.test.ts for the non-success branch, preserving existing
successful-response behavior.
🪄 Autofix
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: 1721c87c-3888-4be3-b8ac-f9ee5a941286
📒 Files selected for processing (4)
model/channel_selection_test.goweb/default/src/features/pricing/components/model-details-api-samples.tsweb/default/src/features/pricing/components/model-details-api.test.tsweb/default/src/features/pricing/components/model-details-api.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Backend checks
🧰 Additional context used
📓 Path-based instructions (4)
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/pricing/components/model-details-api.tsxweb/default/src/features/pricing/components/model-details-api.test.tsweb/default/src/features/pricing/components/model-details-api-samples.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/pricing/components/model-details-api.tsxweb/default/src/features/pricing/components/model-details-api.test.tsweb/default/src/features/pricing/components/model-details-api-samples.ts
web/default/src/**/*.test.ts
📄 CodeRabbit inference engine (web/default/AGENTS.md)
工具函数与纯逻辑应优先编写单元测试;测试文件应命名为
*.test.ts。
Files:
web/default/src/features/pricing/components/model-details-api.test.ts
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: In Go business code, all JSON marshal/unmarshal operations must use the wrapper functions incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) and must not directly callencoding/jsonfor 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 directAUTO_INCREMENT/SERIAL, usecommonGroupCol/commonKeyColandcommonTrueVal/commonFalseValfor DB-specific SQL, branch withcommon.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 supportsStreamOptions; if it does, add that channel tostreamSupportedChannels.
For request structs parsed from client JSON and re-marshaled to upstream providers, optional scalar fields must use pointer types withomitemptyso explicit zero/false values are preserved instead of dropped.
When working on tiered/dynamic billing expression code, readpkg/billingexpr/expr.mdfirst 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 incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) instead of directly importing or callingencoding/jsonfor 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 thecommon.UsingPostgreSQL/common.UsingSQLite/common.UsingMySQLflags when need...
Files:
model/channel_selection_test.go
🔇 Additional comments (4)
model/channel_selection_test.go (1)
175-189: LGTM!Also applies to: 203-222
web/default/src/features/pricing/components/model-details-api-samples.ts (1)
7-65: LGTM!web/default/src/features/pricing/components/model-details-api.test.ts (1)
3-28: LGTM!Also applies to: 30-58
web/default/src/features/pricing/components/model-details-api.tsx (1)
57-60: LGTM!Also applies to: 441-444
|
@coderabbitai review |
|
|
@coderabbitai review |
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@controller/billing.go`:
- Around line 23-24: Validate operation_setting.USDExchangeRate before the CNY
conversion in the quota calculation, rejecting zero, negative, NaN, and infinite
values through the same error path used for invalid QuotaPerUnit. Preserve the
existing conversion for valid rates, and add table-driven cases covering each
invalid USDExchangeRate with QuotaDisplayTypeCNY.
In `@service/midjourney.go`:
- Around line 122-127: Update the variation handling branch in the action parser
to reject unsupported action values: when strings.Contains(action, "variation")
matches but action is not an exact supported variation action, return the
existing unknown_action response instead of succeeding with no action set. Also
add MJ::JOB::unsupported_variation::1 to the malformed-ID test cases.
🪄 Autofix
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: 45a68fbb-4ad3-405e-8e68-0a4c8270c631
📒 Files selected for processing (4)
controller/billing.gocontroller/billing_test.goservice/midjourney.goservice/midjourney_test.go
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: Backend checks
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: In Go business code, all JSON marshal/unmarshal operations must use the wrapper functions incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) and must not directly callencoding/jsonfor 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 directAUTO_INCREMENT/SERIAL, usecommonGroupCol/commonKeyColandcommonTrueVal/commonFalseValfor DB-specific SQL, branch withcommon.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 supportsStreamOptions; if it does, add that channel tostreamSupportedChannels.
For request structs parsed from client JSON and re-marshaled to upstream providers, optional scalar fields must use pointer types withomitemptyso explicit zero/false values are preserved instead of dropped.
When working on tiered/dynamic billing expression code, readpkg/billingexpr/expr.mdfirst 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 incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) instead of directly importing or callingencoding/jsonfor 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 thecommon.UsingPostgreSQL/common.UsingSQLite/common.UsingMySQLflags when need...
Files:
controller/billing_test.goservice/midjourney_test.goservice/midjourney.gocontroller/billing.go
🔇 Additional comments (3)
controller/billing.go (1)
47-76: LGTM!Also applies to: 88-88, 99-122
controller/billing_test.go (1)
12-47: LGTM!service/midjourney_test.go (1)
13-14: LGTM!Also applies to: 87-119
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@controller/billing.go`:
- Around line 57-75: In controller/billing.go, update all token, quota, and
used-quota lookup error branches at lines 57-75 and 106-117 to log the original
errors server-side, while passing the same fixed client-safe billing retrieval
message to writeBillingOpenAIError instead of err.Error().
In `@service/midjourney.go`:
- Around line 105-113: Update the parseIndex closure to reject parsed indexes
less than 1 before returning or assigning midjRequest.Index, preserving the
existing index_parse_failed error for invalid values. Add malformed custom-ID
coverage for upsample IDs containing index 0 and -1.
🪄 Autofix
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: 2632ce46-9c11-4b57-b378-7b1c711260a8
⛔ Files ignored due to path filters (1)
web/default/public/favicon.icois excluded by!**/*.ico
📒 Files selected for processing (4)
controller/billing.gocontroller/billing_test.goservice/midjourney.goservice/midjourney_test.go
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: In Go business code, all JSON marshal/unmarshal operations must use the wrapper functions incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) and must not directly callencoding/jsonfor 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 directAUTO_INCREMENT/SERIAL, usecommonGroupCol/commonKeyColandcommonTrueVal/commonFalseValfor DB-specific SQL, branch withcommon.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 supportsStreamOptions; if it does, add that channel tostreamSupportedChannels.
For request structs parsed from client JSON and re-marshaled to upstream providers, optional scalar fields must use pointer types withomitemptyso explicit zero/false values are preserved instead of dropped.
When working on tiered/dynamic billing expression code, readpkg/billingexpr/expr.mdfirst 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 incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) instead of directly importing or callingencoding/jsonfor 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 thecommon.UsingPostgreSQL/common.UsingSQLite/common.UsingMySQLflags when need...
Files:
controller/billing.goservice/midjourney.gocontroller/billing_test.goservice/midjourney_test.go
🔇 Additional comments (2)
controller/billing.go (1)
4-47: LGTM!Also applies to: 77-81, 95-95, 119-129
controller/billing_test.go (1)
1-118: LGTM!
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
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 (2)
service/midjourney.go (2)
118-124: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winReject unsupported upsample action tokens.
At Line 118,
strings.Contains(action, "upsample")acceptsunsupported_upsample. The parser then setsconstant.MjActionUpscaleand returns success.Use an exact comparison or an explicit allow-list for supported upsample actions. Add
MJ::JOB::unsupported_upsample::1to the malformed-ID tests.🤖 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 `@service/midjourney.go` around lines 118 - 124, Update the upsample branch in the action parser to match only explicitly supported upsample action tokens, rather than using strings.Contains, so unsupported_upsample is rejected as malformed. Add MJ::JOB::unsupported_upsample::1 to the malformed-ID test cases and preserve valid upsample parsing.
104-115: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winDerive
indexPositionfromactionIndex.At Line 104,
indexPositionis hard-coded to3. ForMJ::upsample::2::task-id,actionIndexis1, so the index is atsplits[2]. The parser readssplits[3](task-id) and returnsindex_parse_failed. This breaks the legacy upsample test inservice/midjourney_test.goLines 124-132.Set
indexPosition := actionIndex + 1.Proposed fix
- indexPosition := 3 + indexPosition := actionIndex + 1🤖 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 `@service/midjourney.go` around lines 104 - 115, Update indexPosition in the parseIndex logic to derive it from actionIndex by setting it to the action index plus one, so legacy upsample actions parse the numeric index from the correct splits element.
🤖 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 `@controller/misc.go`:
- Around line 68-75: Update GetHealthReady to use a dedicated uncached database
readiness probe instead of healthReadyPingDB/model.PingDB, ensuring every
readiness request checks the database directly and returns HTTP 503 on failure.
Preserve the throttled PingDB behavior for non-readiness status checks, and add
a test covering a database failure immediately after a successful check.
In `@model/user_delete_test.go`:
- Around line 82-85: Strengthen the assertions in model/user_delete_test.go at
lines 82-85 and 131-134: capture timestamps immediately before and after each
deletion, then verify the stored subscription EndTime falls within that
interval, proving cancellation updates it rather than retaining the original
expiration. Apply this to both the soft-deletion and hard-deletion test paths.
---
Outside diff comments:
In `@service/midjourney.go`:
- Around line 118-124: Update the upsample branch in the action parser to match
only explicitly supported upsample action tokens, rather than using
strings.Contains, so unsupported_upsample is rejected as malformed. Add
MJ::JOB::unsupported_upsample::1 to the malformed-ID test cases and preserve
valid upsample parsing.
- Around line 104-115: Update indexPosition in the parseIndex logic to derive it
from actionIndex by setting it to the action index plus one, so legacy upsample
actions parse the numeric index from the correct splits element.
🪄 Autofix
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: 2a9e219e-ad1c-40ef-8808-cf546fe0643b
📒 Files selected for processing (10)
controller/billing.gocontroller/misc.gocontroller/misc_test.gomodel/task_cas_test.gomodel/user.gomodel/user_delete_test.gorouter/api-router.gorouter/api_router_test.goservice/midjourney.goservice/midjourney_test.go
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: In Go business code, all JSON marshal/unmarshal operations must use the wrapper functions incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) and must not directly callencoding/jsonfor 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 directAUTO_INCREMENT/SERIAL, usecommonGroupCol/commonKeyColandcommonTrueVal/commonFalseValfor DB-specific SQL, branch withcommon.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 supportsStreamOptions; if it does, add that channel tostreamSupportedChannels.
For request structs parsed from client JSON and re-marshaled to upstream providers, optional scalar fields must use pointer types withomitemptyso explicit zero/false values are preserved instead of dropped.
When working on tiered/dynamic billing expression code, readpkg/billingexpr/expr.mdfirst 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 incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) instead of directly importing or callingencoding/jsonfor 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 thecommon.UsingPostgreSQL/common.UsingSQLite/common.UsingMySQLflags when need...
Files:
router/api-router.gorouter/api_router_test.gomodel/task_cas_test.gomodel/user_delete_test.gomodel/user.goservice/midjourney.goservice/midjourney_test.gocontroller/billing.gocontroller/misc_test.gocontroller/misc.go
🔇 Additional comments (12)
model/user.go (1)
1306-1355: LGTM!model/task_cas_test.go (1)
58-58: LGTM!Also applies to: 90-90
model/user_delete_test.go (1)
7-7: LGTM!Also applies to: 37-80, 88-129
controller/misc.go (1)
43-66: LGTM!router/api-router.go (1)
15-17: LGTM!controller/misc_test.go (1)
15-78: LGTM!router/api_router_test.go (1)
118-140: LGTM!controller/billing.go (4)
15-15: LGTM!
60-78: LGTM!
100-100: LGTM!
112-122: LGTM!service/midjourney_test.go (1)
13-14: LGTM!Also applies to: 87-112, 114-122, 124-132
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
model/main.go (1)
1142-1155: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winUse a bounded timeout for the readiness database ping.
PingDBUncachedcallssqlDB.Ping(), and/health/readymaps this directly to every readiness check. A stalled connection or driver ping can hold the handler until the request times out. Change readiness to create a short timeout context and callPingContext; add a test that simulates timeout failure.🤖 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 `@model/main.go` around lines 1142 - 1155, Update PingDBUncached to create a short, bounded timeout context and use sqlDB.PingContext instead of sqlDB.Ping, preserving the existing error logging and return behavior. Add a test covering a simulated ping timeout failure and verify the readiness check returns the resulting error promptly.
🤖 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/midjourney.go`:
- Around line 104-125: The fallback in parseIndex must handle the legacy
upsample format by trying splits[indexPosition+1] when actionIndex is 1 and the
first candidate at indexPosition is non-numeric. Relax the current guard so this
fallback is reached for the legacy field layout, while preserving normal parsing
and bounds validation through parseIndexAt.
---
Outside diff comments:
In `@model/main.go`:
- Around line 1142-1155: Update PingDBUncached to create a short, bounded
timeout context and use sqlDB.PingContext instead of sqlDB.Ping, preserving the
existing error logging and return behavior. Add a test covering a simulated ping
timeout failure and verify the readiness check returns the resulting error
promptly.
🪄 Autofix
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: 2d7b3194-4fec-48aa-af09-cec528893b2e
📒 Files selected for processing (6)
controller/misc.gocontroller/misc_test.gomodel/main.gomodel/user_delete_test.goservice/midjourney.goservice/midjourney_test.go
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.go: In Go business code, all JSON marshal/unmarshal operations must use the wrapper functions incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) and must not directly callencoding/jsonfor 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 directAUTO_INCREMENT/SERIAL, usecommonGroupCol/commonKeyColandcommonTrueVal/commonFalseValfor DB-specific SQL, branch withcommon.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 supportsStreamOptions; if it does, add that channel tostreamSupportedChannels.
For request structs parsed from client JSON and re-marshaled to upstream providers, optional scalar fields must use pointer types withomitemptyso explicit zero/false values are preserved instead of dropped.
When working on tiered/dynamic billing expression code, readpkg/billingexpr/expr.mdfirst 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 incommon/json.go(common.Marshal,common.Unmarshal,common.UnmarshalJsonStr,common.DecodeJson,common.GetJsonType) instead of directly importing or callingencoding/jsonfor 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 thecommon.UsingPostgreSQL/common.UsingSQLite/common.UsingMySQLflags when need...
Files:
controller/misc_test.gocontroller/misc.gomodel/main.goservice/midjourney_test.goservice/midjourney.gomodel/user_delete_test.go
🔇 Additional comments (6)
model/user_delete_test.go (1)
7-7: LGTM!Also applies to: 36-89, 91-141
controller/misc.go (1)
58-58: LGTM!Also applies to: 69-69
controller/misc_test.go (1)
63-68: LGTM!Also applies to: 80-108
model/main.go (1)
1133-1140: LGTM!service/midjourney.go (1)
87-103: LGTM!Also applies to: 126-147, 171-171, 180-190
service/midjourney_test.go (1)
13-14: LGTM!Also applies to: 87-115, 117-125, 127-165, 167-185
|
@coderabbitai review |
✅ Action performedReview finished.
|
Important
📝 变更描述 / Description
(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)