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:
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe changes update shared UI metadata and accessibility, channel drawer forms and video-task billing, localized channel validation, tiered pricing editors, playground parameter controls, and Tailwind build verification. New tests cover these behaviors. ChangesShared UI and localization
Channel drawer and billing
Tiered pricing editor
Playground parameter controls
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant ModelPricingEditorPanel
participant TieredPricingEditor
participant VisualEditor
participant RequestRuleEditor
ModelPricingEditorPanel->>TieredPricingEditor: provide model identity and pricing expressions
TieredPricingEditor->>VisualEditor: render visual tier configuration
TieredPricingEditor->>RequestRuleEditor: render request-rule groups
VisualEditor-->>TieredPricingEditor: return tier updates
RequestRuleEditor-->>TieredPricingEditor: return rule-group updates
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (1 warning, 2 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8)web/default/src/i18n/locales/en.jsonTraceback (most recent call last): web/default/src/i18n/locales/fr.jsonTraceback (most recent call last): web/default/src/i18n/locales/ja.jsonTraceback (most recent call last):
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: 12
🤖 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/components/status-badge.test.tsx`:
- Around line 39-58: Refactor the StatusBadge long-content layout tests to use
React Testing Library’s render and DOM queries instead of renderStatusBadge,
react-dom/server, and raw markup regex assertions. Query the rendered label
element by its accessible text and verify the relevant class behavior through
DOM-oriented assertions, preserving coverage for default truncation and
explicitly enabled wrapping.
In
`@web/default/src/features/channels/components/drawers/sections/channel-models-section.tsx`:
- Around line 386-391: Update the remainingMappingCount display in the channel
models section to use a single count-aware t() translation for the complete
“more mapping(s)” label. Remove the hardcoded plural suffix and pass
remainingMappingCount through the translation interpolation/count mechanism
while preserving the existing positive-count condition.
In `@web/default/src/features/system-settings/models/model-pricing-sheet.tsx`:
- Around line 276-280: Update getInitialPricingMode to return any valid explicit
billingMode before inspecting price, including per-token and per-request modes;
use price only as the legacy-record fallback. Update the reset effect near the
referenced usage to call getInitialPricingMode instead of duplicating
mode-selection logic.
In
`@web/default/src/features/system-settings/models/tiered-pricing-editor.runtime.test.tsx`:
- Around line 19-25: Replace the custom createRoot/JSDOM harness in the tiered
pricing editor tests with React Testing Library rendering and cleanup. Update
textContent-based checks to semantic queries and exercise editor actions through
RTL user interactions, including verifying buttons do not trigger unintended
form submissions. Preserve the existing behavior coverage while focusing
assertions on user-visible outcomes rather than implementation details.
In `@web/default/src/features/system-settings/models/tiered-pricing-editor.tsx`:
- Around line 254-260: Update TieredPricingEditor to include a loaded pricing
revision or source-data signature in its reset key, so externally changed
expression data remounts TieredPricingEditorContent instead of preserving stale
one-time state. In
web/default/src/features/system-settings/models/tiered-pricing-editor.tsx lines
254-260, extend the key contract beyond identity; in
web/default/src/features/system-settings/models/model-pricing-sheet.tsx line
940, pass a stable revision/signature derived from the loaded pricing data
rather than only editData.name.
- Around line 74-85: Update createInitialEditorState so a failed
tryParseRequestRuleExpr result remains distinguishable from an empty rule
instead of being coerced to []. Preserve the original requestRuleExpr when
parsing fails, and make the visual synchronization and mode-switch logic skip
serialization while the rule is incompatible. Continue normal synchronization
for successfully parsed rules and genuinely empty rules.
In
`@web/default/src/features/system-settings/models/tiered-pricing-request-rules.tsx`:
- Around line 117-122: Replace the nested ternary used to derive sourceLabel in
the tiered pricing rules component with switch or if/else logic. Preserve the
existing mappings for SOURCE_PARAM, SOURCE_HEADER, and the fallback Time
translation, without changing surrounding behavior.
- Around line 321-329: Add type='button' to every add/remove condition and
rule-group Button in
web/default/src/features/system-settings/models/tiered-pricing-request-rules.tsx
at lines 321-329, and to every add/remove tier and condition Button in
web/default/src/features/system-settings/models/tiered-pricing-visual-editor.tsx
at lines 152-160, preserving their existing handlers and behavior.
In
`@web/default/src/features/system-settings/models/tiered-pricing-visual-editor.tsx`:
- Line 57: Localize the user-visible price suffix and placeholder text in the
tiered-pricing visual editor. Update PRICE_SUFFIX and the related strings near
the pricing inputs and display sections to use the existing t() translation
mechanism, preserving the current rendered formatting and values.
- Around line 225-230: Enforce the tier invariants in the mutation handlers
handleConditionRemove, the condition-add flow, and the tier-delete flow before
invoking onChange: always retain exactly one final fallback tier, prevent
conditions from being added to it, and prevent earlier tiers from becoming
unconditional or the fallback from being removed. Normalize invalid mutations or
block them while preserving valid tier ordering and fallback behavior.
- Around line 176-186: Update PriceField in
web/default/src/features/system-settings/models/tiered-pricing-visual-editor.tsx
(lines 176-186) to generate and apply a unique id to each DraftNumberInput, and
associate its Label via the matching htmlFor. In
web/default/src/features/system-settings/models/tiered-pricing-request-rules.tsx
(lines 250-291), add associated visible labels or localized aria-label values
for every condition path and value input, ensuring all repeated editor inputs
have programmatic names and remain keyboard accessible.
In `@web/default/src/i18n/locales/zh.json`:
- Line 9: Update the “Configuration valid” translation entry in the zh locale
from “配置一致” to “配置有效” so it accurately indicates that the configuration is
valid.
🪄 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: 78149730-a888-4530-94ee-b06657ae6721
📒 Files selected for processing (34)
web/default/src/components/data-table/column-header.tsxweb/default/src/components/data-table/data-table-page.tsxweb/default/src/components/data-table/mobile-card-list.tsxweb/default/src/components/data-table/table-skeleton.tsxweb/default/src/components/drawer-layout.tsweb/default/src/components/multi-select.tsxweb/default/src/components/status-badge.test.tsxweb/default/src/components/status-badge.tsxweb/default/src/features/channels/components/channel-capability-matrix.tsxweb/default/src/features/channels/components/channels-columns.tsxweb/default/src/features/channels/components/drawers/channel-editor-state.test.tsweb/default/src/features/channels/components/drawers/channel-editor-state.tsweb/default/src/features/channels/components/drawers/channel-mutate-drawer.tsxweb/default/src/features/channels/components/drawers/sections/channel-auth-section.tsxweb/default/src/features/channels/components/drawers/sections/channel-basic-section.tsxweb/default/src/features/channels/components/drawers/sections/channel-models-section.test.tsxweb/default/src/features/channels/components/drawers/sections/channel-models-section.tsxweb/default/src/features/channels/components/model-mapping-editor.tsxweb/default/src/features/channels/lib/channel-capabilities.tsweb/default/src/features/channels/lib/channel-config-validation.tsweb/default/src/features/models/components/models-columns.tsxweb/default/src/features/system-settings/models/model-pricing-sheet.tsxweb/default/src/features/system-settings/models/tiered-pricing-editor.runtime.test.tsxweb/default/src/features/system-settings/models/tiered-pricing-editor.tsxweb/default/src/features/system-settings/models/tiered-pricing-request-rules.tsxweb/default/src/features/system-settings/models/tiered-pricing-visual-editor.tsxweb/default/src/features/usage-logs/components/dialogs/fail-reason-dialog.tsxweb/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.jsonweb/default/src/tanstack-table.d.ts
📜 Review details
🧰 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/components/drawer-layout.tsweb/default/src/features/system-settings/models/tiered-pricing-editor.runtime.test.tsxweb/default/src/features/channels/components/drawers/sections/channel-auth-section.tsxweb/default/src/features/channels/components/drawers/channel-editor-state.test.tsweb/default/src/features/channels/components/channels-columns.tsxweb/default/src/components/status-badge.test.tsxweb/default/src/components/data-table/column-header.tsxweb/default/src/features/usage-logs/components/dialogs/fail-reason-dialog.tsxweb/default/src/features/channels/components/drawers/sections/channel-models-section.test.tsxweb/default/src/components/data-table/table-skeleton.tsxweb/default/src/components/data-table/data-table-page.tsxweb/default/src/tanstack-table.d.tsweb/default/src/features/channels/lib/channel-capabilities.tsweb/default/src/features/models/components/models-columns.tsxweb/default/src/components/multi-select.tsxweb/default/src/features/channels/components/drawers/channel-editor-state.tsweb/default/src/features/system-settings/models/tiered-pricing-request-rules.tsxweb/default/src/features/system-settings/models/tiered-pricing-visual-editor.tsxweb/default/src/features/channels/components/drawers/sections/channel-basic-section.tsxweb/default/src/components/status-badge.tsxweb/default/src/components/data-table/mobile-card-list.tsxweb/default/src/features/channels/components/channel-capability-matrix.tsxweb/default/src/features/channels/components/model-mapping-editor.tsxweb/default/src/features/system-settings/models/model-pricing-sheet.tsxweb/default/src/features/channels/lib/channel-config-validation.tsweb/default/src/features/channels/components/drawers/sections/channel-models-section.tsxweb/default/src/features/system-settings/models/tiered-pricing-editor.tsxweb/default/src/features/channels/components/drawers/channel-mutate-drawer.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/system-settings/models/tiered-pricing-editor.runtime.test.tsxweb/default/src/features/channels/components/drawers/sections/channel-auth-section.tsxweb/default/src/features/channels/components/drawers/channel-editor-state.test.tsweb/default/src/features/channels/components/channels-columns.tsxweb/default/src/features/usage-logs/components/dialogs/fail-reason-dialog.tsxweb/default/src/features/channels/components/drawers/sections/channel-models-section.test.tsxweb/default/src/features/channels/lib/channel-capabilities.tsweb/default/src/features/models/components/models-columns.tsxweb/default/src/features/channels/components/drawers/channel-editor-state.tsweb/default/src/features/system-settings/models/tiered-pricing-request-rules.tsxweb/default/src/features/system-settings/models/tiered-pricing-visual-editor.tsxweb/default/src/features/channels/components/drawers/sections/channel-basic-section.tsxweb/default/src/features/channels/components/channel-capability-matrix.tsxweb/default/src/features/channels/components/model-mapping-editor.tsxweb/default/src/features/system-settings/models/model-pricing-sheet.tsxweb/default/src/features/channels/lib/channel-config-validation.tsweb/default/src/features/channels/components/drawers/sections/channel-models-section.tsxweb/default/src/features/system-settings/models/tiered-pricing-editor.tsxweb/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx
web/default/src/**/*.test.ts
📄 CodeRabbit inference engine (web/default/AGENTS.md)
工具函数与纯逻辑应优先编写单元测试;测试文件应命名为
*.test.ts。
Files:
web/default/src/features/channels/components/drawers/channel-editor-state.test.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/channels/lib/channel-capabilities.tsweb/default/src/features/channels/lib/channel-config-validation.ts
🔇 Additional comments (30)
web/default/src/tanstack-table.d.ts (1)
30-41: LGTM!web/default/src/components/data-table/data-table-page.tsx (1)
345-348: LGTM!Also applies to: 416-419
web/default/src/components/data-table/table-skeleton.tsx (1)
69-76: LGTM!web/default/src/components/data-table/mobile-card-list.tsx (1)
51-51: LGTM!Also applies to: 154-159, 185-190, 234-240, 254-259, 279-279
web/default/src/features/channels/components/channels-columns.tsx (1)
476-481: LGTM!web/default/src/features/models/components/models-columns.tsx (1)
137-141: LGTM!Also applies to: 154-154
web/default/src/components/data-table/column-header.tsx (1)
54-54: LGTM!Also applies to: 67-71
web/default/src/i18n/locales/ja.json (1)
6-57: LGTM!web/default/src/i18n/locales/ru.json (1)
6-57: LGTM!web/default/src/i18n/locales/vi.json (1)
6-57: LGTM!web/default/src/i18n/locales/zh.json (1)
6-8: LGTM!Also applies to: 10-57
web/default/src/components/status-badge.tsx (1)
82-87: LGTM!Also applies to: 103-104, 118-118, 138-160
web/default/src/components/multi-select.tsx (1)
62-64: LGTM!Also applies to: 266-267
web/default/src/components/drawer-layout.ts (1)
93-93: LGTM!web/default/src/features/channels/components/drawers/sections/channel-auth-section.tsx (1)
37-37: LGTM!web/default/src/features/usage-logs/components/dialogs/fail-reason-dialog.tsx (1)
77-77: LGTM!web/default/src/features/channels/lib/channel-capabilities.ts (1)
29-75: LGTM!Also applies to: 93-97
web/default/src/features/channels/lib/channel-config-validation.ts (1)
20-27: LGTM!Also applies to: 90-90, 110-116, 125-125, 135-135, 152-160, 177-177, 196-204, 222-223, 240-240, 250-258, 268-287, 305-305, 314-314, 323-323, 333-333, 342-343, 356-357
web/default/src/features/channels/components/channel-capability-matrix.tsx (1)
28-36: LGTM!Also applies to: 62-76, 104-137, 153-153, 163-169, 184-194, 217-222
web/default/src/i18n/locales/en.json (1)
6-57: LGTM!web/default/src/i18n/locales/fr.json (1)
6-57: LGTM!web/default/src/features/system-settings/models/model-pricing-sheet.tsx (1)
282-296: LGTM!web/default/src/features/system-settings/models/tiered-pricing-editor.tsx (1)
19-50: LGTM!web/default/src/features/channels/components/drawers/sections/channel-basic-section.tsx (1)
19-53: LGTM!Also applies to: 62-118, 120-140, 141-158
web/default/src/features/channels/components/drawers/sections/channel-models-section.tsx (1)
19-153: LGTM!Also applies to: 162-492
web/default/src/features/channels/components/drawers/sections/channel-models-section.test.tsx (1)
32-94: LGTM!web/default/src/features/channels/components/drawers/channel-editor-state.ts (1)
37-88: LGTM!web/default/src/features/channels/components/drawers/channel-editor-state.test.ts (1)
23-48: LGTM!web/default/src/features/channels/components/model-mapping-editor.tsx (1)
19-19: LGTM!Also applies to: 73-137, 228-228, 270-299
web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx (1)
1324-1327: LGTM!Also applies to: 2406-2414, 3805-3808
| describe('StatusBadge long-content layout', () => { | ||
| test('keeps the default compact badge on one truncated line', () => { | ||
| const markup = renderStatusBadge(<StatusBadge label='model-name' />) | ||
|
|
||
| assert.match(markup, /whitespace-nowrap/) | ||
| assert.match(markup, /truncate/) | ||
| assert.doesNotMatch(markup, /\[overflow-wrap:anywhere\]/) | ||
| }) | ||
|
|
||
| test('allows explicitly wrapped badge labels to use multiple lines', () => { | ||
| const markup = renderStatusBadge( | ||
| <StatusBadge label={'model-'.repeat(20)} wrap /> | ||
| ) | ||
|
|
||
| assert.match(markup, /whitespace-normal/) | ||
| assert.match(markup, /\[overflow-wrap:anywhere\]/) | ||
| assert.match(markup, /min-h-5/) | ||
| assert.doesNotMatch(markup, /truncate/) | ||
| }) | ||
| }) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use React Testing Library for component tests.
As per coding guidelines, component tests should use React Testing Library, focus on behavior, and avoid testing implementation details (like asserting raw HTML strings via regex). The current test uses react-dom/server's renderToStaticMarkup and node:test to assert exact class names.
Please refactor this test to use @testing-library/react and evaluate the DOM elements.
♻️ Proposed refactor
-import assert from 'node:assert/strict'
-import { describe, test } from 'node:test'
-import { renderToStaticMarkup } from 'react-dom/server'
+import { render } from '`@testing-library/react`'
+import { describe, test } from 'node:test'
+import assert from 'node:assert/strict'
import { I18nextProvider } from 'react-i18next'
import { StatusBadge } from './status-badge'
@@ -31,27 +31,23 @@ i18n.init({
})
function renderStatusBadge(element: React.ReactElement) {
- return renderToStaticMarkup(
+ return render(
<I18nextProvider i18n={i18n}>{element}</I18nextProvider>
)
}
describe('StatusBadge long-content layout', () => {
test('keeps the default compact badge on one truncated line', () => {
- const markup = renderStatusBadge(<StatusBadge label='model-name' />)
-
- assert.match(markup, /whitespace-nowrap/)
- assert.match(markup, /truncate/)
- assert.doesNotMatch(markup, /\[overflow-wrap:anywhere\]/)
+ const { container } = renderStatusBadge(<StatusBadge label='model-name' />)
+ assert.ok(container.innerHTML.includes('whitespace-nowrap'))
+ assert.ok(container.innerHTML.includes('truncate'))
+ assert.ok(!container.innerHTML.includes('[overflow-wrap:anywhere]'))
})
test('allows explicitly wrapped badge labels to use multiple lines', () => {
- const markup = renderStatusBadge(
- <StatusBadge label={'model-'.repeat(20)} wrap />
- )
-
- assert.match(markup, /whitespace-normal/)
- assert.match(markup, /\[overflow-wrap:anywhere\]/)
- assert.match(markup, /min-h-5/)
- assert.doesNotMatch(markup, /truncate/)
+ const { container } = renderStatusBadge(<StatusBadge label={'model-'.repeat(20)} wrap />)
+ assert.ok(container.innerHTML.includes('whitespace-normal'))
+ assert.ok(container.innerHTML.includes('[overflow-wrap:anywhere]'))
+ assert.ok(!container.innerHTML.includes('truncate'))
})
})(Note: If your test environment supports @testing-library/jest-dom, prefer using expect(screen.getByText(...)).toHaveClass(...) over innerHTML assertions.)
🤖 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/components/status-badge.test.tsx` around lines 39 - 58,
Refactor the StatusBadge long-content layout tests to use React Testing
Library’s render and DOM queries instead of renderStatusBadge, react-dom/server,
and raw markup regex assertions. Query the rendered label element by its
accessible text and verify the relevant class behavior through DOM-oriented
assertions, preserving coverage for default truncation and explicitly enabled
wrapping.
Source: Coding guidelines
| import { act } from 'react' | ||
| import { createRoot, type Root } from 'react-dom/client' | ||
| import { createInstance } from 'i18next' | ||
| import { JSDOM } from 'jsdom' | ||
| import assert from 'node:assert/strict' | ||
| import { after, before, describe, test } from 'node:test' | ||
| import { I18nextProvider } from 'react-i18next' |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use React Testing Library for these component tests.
Replace the custom root/JSDOM harness and textContent assertions with RTL rendering, semantic queries, and user interactions. This will also expose the unintended form submissions from editor action buttons.
As per coding guidelines, “组件测试应使用 React Testing Library,关注交互与行为,避免测试实现细节。”
Also applies to: 155-242
🤖 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/system-settings/models/tiered-pricing-editor.runtime.test.tsx`
around lines 19 - 25, Replace the custom createRoot/JSDOM harness in the tiered
pricing editor tests with React Testing Library rendering and cleanup. Update
textContent-based checks to semantic queries and exercise editor actions through
RTL user interactions, including verifying buttons do not trigger unintended
form submissions. Preserve the existing behavior coverage while focusing
assertions on user-visible outcomes rather than implementation details.
Source: Coding guidelines
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 (8)
web/default/src/i18n/locales/ja.json (1)
8-8: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUse a translation for “blocking issues,” not “blocked issues.”
「ブロック中の問題」は interpreted as issues currently being blocked. Use wording such as
ブロッキング問題 {{count}} 件or設定を妨げる問題 {{count}} 件to preserve the original meaning.🤖 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/i18n/locales/ja.json` at line 8, Update the Japanese translation for "{{count}} blocking issue(s)" to convey issues that block progress, not issues currently blocked; use wording equivalent to “ブロッキング問題 {{count}} 件” while preserving the count placeholder.web/default/src/i18n/locales/ru.json (1)
13-13: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUse the correct Russian term for API completions.
дополненияmeans “additions” and is misleading in this API context. Use terminology such asзавершенияor retainChat Completions.Proposed fix
- "Routes OpenAI-compatible chat and completion requests.": "Маршрутизирует OpenAI-совместимые запросы чата и дополнения.", + "Routes OpenAI-compatible chat and completion requests.": "Маршрутизирует OpenAI-совместимые запросы чата и завершений.", - "chat/completions": "Чат / дополнения API", + "chat/completions": "API чата / завершений",Also applies to: 23-23
🤖 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/i18n/locales/ru.json` at line 13, Update the Russian translation for “Routes OpenAI-compatible chat and completion requests.” in the locale entries to use the API term “завершения” or retain “Chat Completions” instead of “дополнения.” Apply the same correction to both identified occurrences.web/default/src/i18n/locales/vi.json (1)
8-8: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winUse a clearer Vietnamese translation for blocking validation issues.
“Vấn đề chặn” is unnatural and may be interpreted as blocking a request rather than preventing the configuration from being valid. Prefer wording such as “lỗi khiến cấu hình không hợp lệ” consistently in both messages.
Also applies to: 12-12
🤖 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/i18n/locales/vi.json` at line 8, Update the Vietnamese translations for both “{{count}} blocking issue(s)” and the corresponding message at the referenced second entry to use clear wording such as “{{count}} lỗi khiến cấu hình không hợp lệ,” replacing “vấn đề chặn” consistently while preserving the count placeholder.web/default/src/i18n/locales/zh.json (1)
14-14: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winPreserve the “Responses API” product name.
These translations turn the official API name into generic wording and are inconsistent with the existing
"Responses APIs": "Responses API"entry at Line 3951. Use the established term in both the description and capability label.Proposed fix
- "Routes OpenAI Responses API requests.": "用于 OpenAI Responses 风格接口请求。", + "Routes OpenAI Responses API requests.": "用于 OpenAI Responses API 请求。", - "responses": "响应 API", + "responses": "Responses API",Also applies to: 24-24
🤖 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/i18n/locales/zh.json` at line 14, Update the Chinese translation for “Routes OpenAI Responses API requests.” and its corresponding capability label to preserve the established product name “Responses API,” matching the existing “Responses APIs” translation instead of using generic wording.web/default/src/features/channels/components/drawers/sections/channel-models-section.tsx (3)
90-91: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftConsider splitting this component into smaller sub-components.
The
ChannelModelsSectioncomponent is approximately 400 lines long. As per coding guidelines, components exceeding about 200 lines should be considered for splitting. Extracting the models field, quick actions, model mapping editor, and groups field into separate sub-components would improve readability and maintainability.🤖 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/channels/components/drawers/sections/channel-models-section.tsx` around lines 90 - 91, Split ChannelModelsSection into focused sub-components for the models field, quick actions, model mapping editor, and groups field. Keep the existing behavior and data flow unchanged, and have ChannelModelsSection compose these extracted components while retaining shared props or handlers through explicit interfaces.Source: Coding guidelines
189-191: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winTranslate the
createLabeltext.The
createLabelstring is hardcoded and bypasses the translation system. As per coding guidelines, all user-facing text within components must support i18n usingt().🌐 Proposed fix
- allowCreate - createLabel='Add custom model "{{value}}"' - maxVisibleChips={6} + allowCreate + createLabel={t('Add custom model "{{value}}"')} + maxVisibleChips={6}🤖 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/channels/components/drawers/sections/channel-models-section.tsx` around lines 189 - 191, Translate the createLabel prop in the channel models section using the component’s existing t() translation function, adding the interpolation for value so the displayed model name remains unchanged. Use the established translation key or add the corresponding locale entry rather than leaving the user-facing string hardcoded.Source: Coding guidelines
90-90: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winAdd explicit types for parameters and return values.
These functions lack explicit types, which violates the coding guideline requiring explicit type annotations for parameters and return values.
web/default/src/features/channels/components/drawers/sections/channel-models-section.tsx#L90-L90: Add an explicit return type (e.g.,: JSX.Element) toChannelModelsSection.web/default/src/features/channels/components/drawers/sections/channel-models-section.tsx#L122-L124: Add an explicit type for themergeparameter (e.g.,merge: boolean = false) and a return type (e.g.,: number) toupdateModels.web/default/src/features/channels/components/drawers/sections/channel-models-section.tsx#L136-L136: Add an explicit return type (e.g.,: void) tohandleAddPrefillGroup.🤖 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/channels/components/drawers/sections/channel-models-section.tsx` at line 90, web/default/src/features/channels/components/drawers/sections/channel-models-section.tsx:90 — Add an explicit JSX.Element return type to ChannelModelsSection. At lines 122-124, type updateModels’ merge parameter as boolean with its existing default and add its number return type. At line 136, add an explicit void return type to handleAddPrefillGroup.Source: Coding guidelines
web/default/src/features/system-settings/models/tiered-pricing-editor.tsx (1)
187-234: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftSwitching to Visual mode silently discards an unparseable billing expression.
When
next === 'visual'andtryParseVisualConfig(billingExpr)fails,visualConfigis reset tocreateDefaultVisualConfig()with no fallback preservation (unlike therawExprFallbackmechanism that now protectsrequestRuleExprin this same handler). TheeffectiveExpreffect (Lines 151-155) then immediately pushes this default expression back viaonBillingExprChange, overwriting the original complex/hand-written expression as soon as the user opens the "Visual editor" tab — before any explicit save, and with no warning or recovery path (switching back to raw regenerates from the now-lostvisualConfig).Since raw/LLM-authored expressions are a primary use case (see
LlmPromptHelper), this is easily reachable whenever an expression doesn't match the visual grammar.💡 Suggested direction
Mirror the
rawExprFallbackapproach for the billing side: whentryParseVisualConfigfails, keep abillingExprFallback(or block the switch entirely and surface an alert similar toRequestRuleEditor's "too complex" alert) instead of unconditionally callingcreateDefaultVisualConfig().🤖 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/system-settings/models/tiered-pricing-editor.tsx` around lines 187 - 234, Preserve an unparseable billing expression when handleModeChange switches to visual mode instead of replacing it with createDefaultVisualConfig(). Add and maintain a billingExprFallback analogous to rawExprFallback, ensure the effective-expression flow does not call onBillingExprChange with the default visual expression while that fallback exists, and restore the preserved billing expression when returning to raw mode or otherwise retain an explicit recovery path.
🤖 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/i18n/locales/ru.json`:
- Line 136: Update the “+{{count}} more mapping(s)” Russian locale entry to
avoid hardcoded plural inflection: use the project’s plural-aware i18n form for
singular and plural counts, or a neutral count label that remains grammatically
correct for every value.
---
Outside diff comments:
In
`@web/default/src/features/channels/components/drawers/sections/channel-models-section.tsx`:
- Around line 90-91: Split ChannelModelsSection into focused sub-components for
the models field, quick actions, model mapping editor, and groups field. Keep
the existing behavior and data flow unchanged, and have ChannelModelsSection
compose these extracted components while retaining shared props or handlers
through explicit interfaces.
- Around line 189-191: Translate the createLabel prop in the channel models
section using the component’s existing t() translation function, adding the
interpolation for value so the displayed model name remains unchanged. Use the
established translation key or add the corresponding locale entry rather than
leaving the user-facing string hardcoded.
- Line 90:
web/default/src/features/channels/components/drawers/sections/channel-models-section.tsx:90
— Add an explicit JSX.Element return type to ChannelModelsSection. At lines
122-124, type updateModels’ merge parameter as boolean with its existing default
and add its number return type. At line 136, add an explicit void return type to
handleAddPrefillGroup.
In `@web/default/src/features/system-settings/models/tiered-pricing-editor.tsx`:
- Around line 187-234: Preserve an unparseable billing expression when
handleModeChange switches to visual mode instead of replacing it with
createDefaultVisualConfig(). Add and maintain a billingExprFallback analogous to
rawExprFallback, ensure the effective-expression flow does not call
onBillingExprChange with the default visual expression while that fallback
exists, and restore the preserved billing expression when returning to raw mode
or otherwise retain an explicit recovery path.
In `@web/default/src/i18n/locales/ja.json`:
- Line 8: Update the Japanese translation for "{{count}} blocking issue(s)" to
convey issues that block progress, not issues currently blocked; use wording
equivalent to “ブロッキング問題 {{count}} 件” while preserving the count placeholder.
In `@web/default/src/i18n/locales/ru.json`:
- Line 13: Update the Russian translation for “Routes OpenAI-compatible chat and
completion requests.” in the locale entries to use the API term “завершения” or
retain “Chat Completions” instead of “дополнения.” Apply the same correction to
both identified occurrences.
In `@web/default/src/i18n/locales/vi.json`:
- Line 8: Update the Vietnamese translations for both “{{count}} blocking
issue(s)” and the corresponding message at the referenced second entry to use
clear wording such as “{{count}} lỗi khiến cấu hình không hợp lệ,” replacing
“vấn đề chặn” consistently while preserving the count placeholder.
In `@web/default/src/i18n/locales/zh.json`:
- Line 14: Update the Chinese translation for “Routes OpenAI Responses API
requests.” and its corresponding capability label to preserve the established
product name “Responses API,” matching the existing “Responses APIs” translation
instead of using generic wording.
🪄 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: a8f9e12b-dc83-48e0-8f88-5eb1c1717fef
📒 Files selected for processing (11)
web/default/src/features/channels/components/drawers/sections/channel-models-section.tsxweb/default/src/features/system-settings/models/model-pricing-sheet.tsxweb/default/src/features/system-settings/models/tiered-pricing-editor.tsxweb/default/src/features/system-settings/models/tiered-pricing-request-rules.tsxweb/default/src/features/system-settings/models/tiered-pricing-visual-editor.tsxweb/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 (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/system-settings/models/tiered-pricing-visual-editor.tsxweb/default/src/features/channels/components/drawers/sections/channel-models-section.tsxweb/default/src/features/system-settings/models/tiered-pricing-request-rules.tsxweb/default/src/features/system-settings/models/model-pricing-sheet.tsxweb/default/src/features/system-settings/models/tiered-pricing-editor.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/system-settings/models/tiered-pricing-visual-editor.tsxweb/default/src/features/channels/components/drawers/sections/channel-models-section.tsxweb/default/src/features/system-settings/models/tiered-pricing-request-rules.tsxweb/default/src/features/system-settings/models/model-pricing-sheet.tsxweb/default/src/features/system-settings/models/tiered-pricing-editor.tsx
🔇 Additional comments (16)
web/default/src/i18n/locales/en.json (1)
6-57: LGTM!Also applies to: 136-137
web/default/src/i18n/locales/fr.json (2)
6-57: LGTM!
136-137: LGTM!web/default/src/i18n/locales/ja.json (1)
6-7: LGTM!Also applies to: 9-57, 136-137
web/default/src/i18n/locales/ru.json (2)
6-12: LGTM!Also applies to: 14-22, 24-57
137-137: LGTM!web/default/src/i18n/locales/vi.json (1)
6-7: LGTM!Also applies to: 9-11, 13-57, 136-137
web/default/src/i18n/locales/zh.json (1)
6-13: LGTM!Also applies to: 15-23, 25-57, 136-137
web/default/src/features/system-settings/models/model-pricing-sheet.tsx (2)
940-940: 🗄️ Data Integrity & Integration | ⚡ Quick winModel identity still keyed only on
editData?.name; will be covered by the consolidated cross-file comment (see below) rather than repeated here.
276-287: LGTM!Also applies to: 450-527
web/default/src/features/system-settings/models/tiered-pricing-editor.tsx (3)
306-326: 🗄️ Data Integrity & Integration | ⚡ Quick winRemount key still derived only from model name/identity; will be covered by the consolidated cross-file comment below.
67-169: LGTM!Also applies to: 175-185
237-262: LGTM!web/default/src/features/system-settings/models/tiered-pricing-request-rules.tsx (2)
117-122: 📐 Maintainability & Code Quality | ⚡ Quick winNested ternary for
sourceLabelstill present.As per coding guidelines, "禁止使用两层及以上嵌套三元表达式;复杂逻辑应改用
if-else、提前返回或抽取函数。" This exactsourceLabelexpression was flagged previously and remains unchanged.♻️ Proposed fix
- const sourceLabel = - condition.source === SOURCE_PARAM - ? t('Body param') - : condition.source === SOURCE_HEADER - ? t('Header') - : t('Time') + const getSourceLabel = () => { + if (condition.source === SOURCE_PARAM) return t('Body param') + if (condition.source === SOURCE_HEADER) return t('Header') + return t('Time') + } + const sourceLabel = getSourceLabel()Source: Coding guidelines
72-116: LGTM!Also applies to: 139-338, 351-455, 463-524
web/default/src/features/system-settings/models/tiered-pricing-visual-editor.tsx (1)
57-57: LGTM!Also applies to: 79-172, 185-203, 218-349, 453-556
There was a problem hiding this comment.
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/i18n/locales/ru.json (1)
13-13: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUse the established Russian term for API “completion”.
дополненияmeans “additions” and misrepresents completion requests/endpoints. Useзавершения, consistent with the existing translation at Line 3219.Proposed fix
- "Routes OpenAI-compatible chat and completion requests.": "Маршрутизирует OpenAI-совместимые запросы чата и дополнения.", + "Routes OpenAI-compatible chat and completion requests.": "Маршрутизирует совместимые с OpenAI запросы чата и завершения.", - "chat/completions": "Чат / дополнения API", + "chat/completions": "Чат / завершения API",Also applies to: 23-23
🤖 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/i18n/locales/ru.json` at line 13, Update the Russian translation for “Routes OpenAI-compatible chat and completion requests.” to use “завершения” instead of “дополнения”, matching the established terminology used elsewhere in the locale.
🤖 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 `@web/default/src/i18n/locales/ru.json`:
- Line 13: Update the Russian translation for “Routes OpenAI-compatible chat and
completion requests.” to use “завершения” instead of “дополнения”, matching the
established terminology used elsewhere in the locale.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 1f0f8dc0-89fd-4daf-8423-6a577761d79c
📒 Files selected for processing (5)
.gitignoreweb/default/package.jsonweb/default/scripts/verify-tailwind-build.mjsweb/default/src/i18n/locales/ru.jsonweb/default/src/styles/index.css
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
web/default/src/styles/**/*
📄 CodeRabbit inference engine (web/default/AGENTS.md)
自定义样式应集中在
src/styles/,组件内尽量少写自定义 CSS。
Files:
web/default/src/styles/index.css
web/default/**/package.json
📄 CodeRabbit inference engine (web/default/AGENTS.md)
脚本与包管理以
package.json为准;发布前应执行 typecheck、lint、format、生产构建,并检查产物体积与环境变量配置。
Files:
web/default/package.json
🪛 Biome (2.5.3)
web/default/src/styles/index.css
[error] 20-20: Tailwind-specific syntax is disabled.
(parse)
🪛 Stylelint (17.14.0)
web/default/src/styles/index.css
[error] 20-20: Unexpected unknown at-rule "@source" (scss/at-rule-no-unknown)
(scss/at-rule-no-unknown)
🔇 Additional comments (5)
web/default/src/i18n/locales/ru.json (1)
136-137: LGTM!.gitignore (1)
42-42: LGTM!web/default/package.json (1)
8-9: LGTM!web/default/scripts/verify-tailwind-build.mjs (1)
19-64: LGTM!web/default/src/styles/index.css (1)
20-20: LGTM!
There was a problem hiding this comment.
Actionable comments posted: 9
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
web/default/src/i18n/locales/ru.json (1)
13-23: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winUse established terminology for “completion”.
“Дополнения” is misleading in an AI/API context. Use “завершения” or retain the official “Chat Completions” terminology, consistently with the existing
OpenAI Chat Completionstranslation.Proposed fix
- "Routes OpenAI-compatible chat and completion requests.": "Маршрутизирует OpenAI-совместимые запросы чата и дополнения.", + "Routes OpenAI-compatible chat and completion requests.": "Маршрутизирует OpenAI-совместимые запросы чата и завершения.", - "chat/completions": "Чат / дополнения API", + "chat/completions": "Чат / завершения API",🤖 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/i18n/locales/ru.json` around lines 13 - 23, Update the Russian translations for completion-related entries in the locale, especially “Routes OpenAI-compatible chat and completion requests.” and “chat/completions,” replacing “дополнения” with the established “завершения” terminology or the existing official “Chat Completions” wording. Keep the surrounding translations unchanged and ensure the terminology is consistent.web/default/src/i18n/locales/vi.json (1)
13-13: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winClarify the OpenAI-compatible API wording.
“trò chuyện và hoàn thành tương thích OpenAI” is grammatically ambiguous. Prefer “Định tuyến các yêu cầu chat/completions tương thích với OpenAI.”
🤖 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/i18n/locales/vi.json` at line 13, Update the Vietnamese translation for the key “Routes OpenAI-compatible chat and completion requests.” to clearly use “Định tuyến các yêu cầu chat/completions tương thích với OpenAI.”
🤖 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/playground/components/playground-parameter-panel.tsx`:
- Around line 175-186: Update the parameter input change flow around the
control’s onChange handler to retain a raw draft string without calling
normalizeParameterNumberValue on every keystroke. Use the draft as the
controlled value while editing, then normalize and persist it on blur or Enter,
preserving decimal intermediates such as “0.” for keyboard input.
- Around line 72-79: Keep the component props object intact instead of
destructuring the newly added parameter props. In
web/default/src/features/playground/components/playground-parameter-panel.tsx
lines 72-79, update PlaygroundParameterContent to access fields through props;
apply the same change to the newly added parameter props in
web/default/src/features/playground/components/playground-input.tsx lines
119-122.
In `@web/default/src/features/playground/lib/playground-parameters.ts`:
- Around line 19-129: Remove the broad ParameterValue alias and narrow the value
parameter of getParameterControlValueText to number | null, matching the numeric
playground parameter contract while preserving the existing seed null handling
and string conversion.
In `@web/default/src/i18n/locales/en.json`:
- Around line 3325-3338: Update the locale entries for the presence_penalty
control: add “Presence Penalty” to web/default/src/i18n/locales/en.json at lines
3325-3338 and add its French translation, such as “Pénalité de présence,” to
web/default/src/i18n/locales/fr.json at lines 3325-3338, alongside the other
parameter labels. Also check the corresponding ja.json, ru.json, vi.json, and
zh.json locale sections for the same missing key and add appropriate
translations if absent.
In `@web/default/src/i18n/locales/ja.json`:
- Line 3330: Update the Japanese translation for “Keeps compatible responses
more repeatable” so it preserves “repeatable” as response reproducibility, using
wording equivalent to “応答の再現性を高める” rather than “互換性のある応答.”
In `@web/default/src/i18n/locales/ru.json`:
- Line 3330: Update the Russian translation for the “Keeps compatible responses
more repeatable” key to naturally express reproducibility when using compatible
models, rather than describing the responses themselves as compatible.
In `@web/default/src/i18n/locales/vi.json`:
- Line 3331: Update the Vietnamese translation for the “Limits token selection
to a probability mass” locale key, replacing “khối lượng xác suất” with the
clearer “tổng xác suất” while preserving the key and surrounding meaning.
In `@web/default/src/i18n/locales/zh.json`:
- Around line 3325-3338: Update the Chinese translation for “Keeps compatible
responses more repeatable” to use wording meaning reproducible or consistent,
such as “让兼容的响应更具可重复性” or “让兼容的响应更稳定可复现,” while leaving the other locale entries
unchanged.
In `@web/default/src/i18n/static-keys.ts`:
- Around line 332-347: Add the missing static translation keys “Parameters” and
“Enable {{parameter}}” to the playground parameter controls list in
static-keys.ts, alongside the existing labels used by
playground-parameter-panel.tsx.
---
Outside diff comments:
In `@web/default/src/i18n/locales/ru.json`:
- Around line 13-23: Update the Russian translations for completion-related
entries in the locale, especially “Routes OpenAI-compatible chat and completion
requests.” and “chat/completions,” replacing “дополнения” with the established
“завершения” terminology or the existing official “Chat Completions” wording.
Keep the surrounding translations unchanged and ensure the terminology is
consistent.
In `@web/default/src/i18n/locales/vi.json`:
- Line 13: Update the Vietnamese translation for the key “Routes
OpenAI-compatible chat and completion requests.” to clearly use “Định tuyến các
yêu cầu chat/completions tương thích với OpenAI.”
🪄 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: 72486e38-ecf8-41ea-8cc7-96ae451f4f38
📒 Files selected for processing (14)
web/default/src/features/playground/components/playground-input.tsxweb/default/src/features/playground/components/playground-parameter-panel.tsxweb/default/src/features/playground/index.tsxweb/default/src/features/playground/lib/index.tsweb/default/src/features/playground/lib/payload-builder.test.tsweb/default/src/features/playground/lib/playground-parameters.test.tsweb/default/src/features/playground/lib/playground-parameters.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.jsonweb/default/src/i18n/static-keys.ts
📜 Review details
🧰 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/playground/lib/index.tsweb/default/src/features/playground/lib/payload-builder.test.tsweb/default/src/features/playground/lib/playground-parameters.test.tsweb/default/src/i18n/static-keys.tsweb/default/src/features/playground/index.tsxweb/default/src/features/playground/lib/playground-parameters.tsweb/default/src/features/playground/components/playground-input.tsxweb/default/src/features/playground/components/playground-parameter-panel.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/playground/lib/index.tsweb/default/src/features/playground/lib/payload-builder.test.tsweb/default/src/features/playground/lib/playground-parameters.test.tsweb/default/src/features/playground/lib/playground-parameters.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/playground/lib/index.tsweb/default/src/features/playground/lib/payload-builder.test.tsweb/default/src/features/playground/lib/playground-parameters.test.tsweb/default/src/features/playground/index.tsxweb/default/src/features/playground/lib/playground-parameters.tsweb/default/src/features/playground/components/playground-input.tsxweb/default/src/features/playground/components/playground-parameter-panel.tsx
web/default/src/**/*.test.ts
📄 CodeRabbit inference engine (web/default/AGENTS.md)
工具函数与纯逻辑应优先编写单元测试;测试文件应命名为
*.test.ts。
Files:
web/default/src/features/playground/lib/payload-builder.test.tsweb/default/src/features/playground/lib/playground-parameters.test.ts
🔇 Additional comments (16)
web/default/src/features/playground/lib/playground-parameters.ts (1)
95-118: LGTM! The clamping/rounding logic is correct against all test cases (verified temperature/top_p/frequency_penalty/max_tokens/seed boundary and precision handling).web/default/src/features/playground/lib/index.ts (1)
24-24: LGTM!web/default/src/features/playground/lib/playground-parameters.test.ts (1)
26-40: LGTM! Test cases correctly exercise clamping, rounding, and the seed empty/null special case. As per coding guidelines, "工具函数与纯逻辑应优先编写单元测试;测试文件应命名为*.test.ts" is satisfied here.Source: Coding guidelines
web/default/src/features/playground/lib/payload-builder.test.ts (1)
24-58: LGTM! Assertions align precisely withbuildChatCompletionPayload's enable/omit-when-null behavior (verified against the upstream implementation snippet).web/default/src/i18n/locales/ja.json (3)
6-57: LGTM!
136-137: LGTM!
3325-3329: LGTM!Also applies to: 3331-3338
web/default/src/i18n/locales/ru.json (3)
6-12: LGTM!Also applies to: 24-57
136-137: LGTM!
3325-3329: LGTM!Also applies to: 3331-3338
web/default/src/i18n/locales/vi.json (3)
6-12: LGTM!Also applies to: 14-57
136-137: LGTM!
3325-3330: LGTM!Also applies to: 3332-3338
web/default/src/i18n/locales/zh.json (2)
6-57: LGTM!
136-137: LGTM!web/default/src/features/playground/components/playground-parameter-panel.tsx (1)
54-66: 📐 Maintainability & Code QualityProvide successful type-check results for this TSX cohort.
web/default/src/features/playground/components/playground-parameter-panel.tsx#L54-L66: verify the new generic callback and nullable parameter flow.web/default/src/features/playground/components/playground-input.tsx#L83-L92: verify callback assignability between input and panel props.web/default/src/features/playground/index.tsx#L204-L207: verify state updater compatibility with the controlled input contract.As per coding guidelines, “修改 TypeScript 或 TSX 代码后必须执行类型检查,并修复所有类型错误,不得遗留。”
Source: Coding guidelines
| "Enable {{parameter}}": "Bật {{parameter}}", | ||
| "Frequency Penalty": "Hình phạt tần suất", | ||
| "Keeps compatible responses more repeatable": "Giúp các phản hồi tương thích dễ lặp lại hơn", | ||
| "Limits token selection to a probability mass": "Giới hạn việc chọn token trong một khối lượng xác suất", |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use a clearer translation for “probability mass.”
“khối lượng xác suất” is a literal translation and may confuse users configuring Top P. Use “tổng xác suất” instead.
🤖 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/i18n/locales/vi.json` at line 3331, Update the Vietnamese
translation for the “Limits token selection to a probability mass” locale key,
replacing “khối lượng xác suất” with the clearer “tổng xác suất” while
preserving the key and surrounding meaning.
| // Playground parameter controls | ||
| 'Caps the response length', | ||
| 'Controls randomness and creativity', | ||
| 'Encourages new topics', | ||
| 'Frequency Penalty', | ||
| 'Keeps compatible responses more repeatable', | ||
| 'Limits token selection to a probability mass', | ||
| 'Max Tokens', | ||
| 'Not Set', | ||
| 'Only enabled parameters are sent with the request.', | ||
| 'Parameter settings', | ||
| 'Reduces repeated wording', | ||
| 'Seed', | ||
| 'Temperature', | ||
| 'Top P', | ||
|
|
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Register the remaining panel translation keys.
playground-parameter-panel.tsx also uses Parameters and Enable {{parameter}}; add both here so static locale coverage includes every new visible label. As per coding guidelines, “前端页面文本与组件内文案必须支持 i18n”。
🤖 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/i18n/static-keys.ts` around lines 332 - 347, Add the missing
static translation keys “Parameters” and “Enable {{parameter}}” to the
playground parameter controls list in static-keys.ts, alongside the existing
labels used by playground-parameter-panel.tsx.
Source: Coding guidelines
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 (4)
web/default/src/features/playground/lib/playground-parameters.ts (1)
93-116: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winEmpty/invalid input bypasses
control.min, can send out-of-range values.For non-seed keys, both early-return branches (empty string, and invalid/missing control) return a hardcoded
0instead of clamping tocontrol.min.max_tokenshasmin: 1, so clearing the Max Tokens input and blurring sendsmax_tokens: 0downstream viaonConfigChange/payload builder — an invalid value for most APIs.🐛 Suggested fix
export function normalizeParameterNumberValue( key: PlaygroundParameterKey, value: string | number ): number | null { - if (value === '') { - return key === 'seed' ? null : 0 - } - const control = PLAYGROUND_PARAMETER_CONTROLS.find((item) => item.key === key) + + if (value === '') { + return key === 'seed' ? null : control?.min ?? 0 + } + const parsed = typeof value === 'number' ? value : Number.parseFloat(value) if (!control || Number.isNaN(parsed)) { - return key === 'seed' ? null : 0 + return key === 'seed' ? null : control?.min ?? 0 }🤖 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/playground/lib/playground-parameters.ts` around lines 93 - 116, Update normalizeParameterNumberValue so empty or invalid non-seed values use the matching control’s minimum rather than a hardcoded 0, preserving seed’s null behavior. Resolve the control before these fallback branches and apply the same clamping/normalization path used for parsed values, including max_tokens’ minimum of 1.web/default/src/i18n/locales/ru.json (1)
13-13: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winTranslate API “completion” as “завершение”, not “дополнение”.
“Дополнение” means an addition, so these labels misdescribe completion endpoints and may confuse Russian-speaking users. Use the project’s established terminology for model completions, such as “завершение” or “запросы completions”.
Also applies to: 23-23
🤖 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/i18n/locales/ru.json` at line 13, Update the Russian translation for “Routes OpenAI-compatible chat and completion requests.” and the additionally referenced completion label to use “завершение” (or the project’s established completions terminology) instead of “дополнение,” while preserving the existing meaning and translation structure.web/default/src/i18n/locales/vi.json (1)
13-13: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winPreserve API terminology in capability labels.
Translating
completionas “hoàn thành” makes these labels ambiguous. Keep the technical endpoint names so users can identify the supported APIs.Proposed wording
- "Routes OpenAI-compatible chat and completion requests.": "Định tuyến yêu cầu trò chuyện và hoàn thành tương thích OpenAI.", + "Routes OpenAI-compatible chat and completion requests.": "Định tuyến các yêu cầu chat và completion tương thích OpenAI.", - "chat/completions": "Trò chuyện / hoàn thành API", + "chat/completions": "API chat/completions",Also applies to: 23-23
🤖 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/i18n/locales/vi.json` at line 13, Update the Vietnamese translation for the capability label in the locale entries corresponding to “Routes OpenAI-compatible chat and completion requests” and its related occurrence, preserving the technical terms “OpenAI-compatible,” “chat,” and “completion” rather than translating “completion” as “hoàn thành.”web/default/src/features/playground/components/playground-parameter-panel.tsx (1)
72-207: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting parameter-row logic into a hook/subcomponent.
PlaygroundParameterContentplus its draft-state management pushes this file well past ~200 lines. Extracting ausePlaygroundParameterDrafthook (or aPlaygroundParameterRowsubcomponent for the per-control block at lines 116-204) would improve readability and reuse.As per coding guidelines, "单文件超过约 200 行时应考虑拆分子组件或抽取自定义 Hooks".
🤖 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/playground/components/playground-parameter-panel.tsx` around lines 72 - 207, Extract the per-control rendering and draft-state handling from PlaygroundParameterContent into a focused PlaygroundParameterRow subcomponent or usePlaygroundParameterDraft hook. Preserve the existing parameter enablement, slider/input updates, commit-on-blur, Enter-key behavior, and styling while reducing PlaygroundParameterContent’s size and keeping the extracted logic reusable.Source: Coding guidelines
♻️ Duplicate comments (1)
web/default/src/i18n/static-keys.ts (1)
332-348: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winStill missing
'Parameters'and'Enable {{parameter}}'static keys.
playground-parameter-panel.tsxusest('Parameters')(triggeraria-label+ tooltip content) andt('Enable {{parameter}}', {...})(per-parameterSwitcharia-label), but neither string was added to this new block. This was already flagged in a prior review round and remains unaddressed.🛡️ Proposed fix
'Only enabled parameters are sent with the request.', 'Parameter settings', + 'Parameters', 'Presence Penalty', 'Reduces repeated wording', 'Seed', 'Temperature', 'Top P', + 'Enable {{parameter}}',As per coding guidelines, "前端页面文本与组件内文案必须支持 i18n".
🤖 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/i18n/static-keys.ts` around lines 332 - 348, Add the missing static i18n keys 'Parameters' and 'Enable {{parameter}}' to the Playground parameter controls block in static-keys.ts, matching the strings used by playground-parameter-panel.tsx for the trigger label/tooltip and parameter switch aria-label.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 `@web/default/src/i18n/locales/ja.json`:
- Line 3335: Update the Japanese locale entry for "Presence Penalty" from the
literal translation to the standard technical term "プレゼンスペナルティ", preserving the
existing key and locale structure.
---
Outside diff comments:
In
`@web/default/src/features/playground/components/playground-parameter-panel.tsx`:
- Around line 72-207: Extract the per-control rendering and draft-state handling
from PlaygroundParameterContent into a focused PlaygroundParameterRow
subcomponent or usePlaygroundParameterDraft hook. Preserve the existing
parameter enablement, slider/input updates, commit-on-blur, Enter-key behavior,
and styling while reducing PlaygroundParameterContent’s size and keeping the
extracted logic reusable.
In `@web/default/src/features/playground/lib/playground-parameters.ts`:
- Around line 93-116: Update normalizeParameterNumberValue so empty or invalid
non-seed values use the matching control’s minimum rather than a hardcoded 0,
preserving seed’s null behavior. Resolve the control before these fallback
branches and apply the same clamping/normalization path used for parsed values,
including max_tokens’ minimum of 1.
In `@web/default/src/i18n/locales/ru.json`:
- Line 13: Update the Russian translation for “Routes OpenAI-compatible chat and
completion requests.” and the additionally referenced completion label to use
“завершение” (or the project’s established completions terminology) instead of
“дополнение,” while preserving the existing meaning and translation structure.
In `@web/default/src/i18n/locales/vi.json`:
- Line 13: Update the Vietnamese translation for the capability label in the
locale entries corresponding to “Routes OpenAI-compatible chat and completion
requests” and its related occurrence, preserving the technical terms
“OpenAI-compatible,” “chat,” and “completion” rather than translating
“completion” as “hoàn thành.”
---
Duplicate comments:
In `@web/default/src/i18n/static-keys.ts`:
- Around line 332-348: Add the missing static i18n keys 'Parameters' and 'Enable
{{parameter}}' to the Playground parameter controls block in static-keys.ts,
matching the strings used by playground-parameter-panel.tsx for the trigger
label/tooltip and parameter switch aria-label.
🪄 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: 4e3af9d3-f580-47a0-b127-a3f8cbd98984
📒 Files selected for processing (10)
web/default/src/features/playground/components/playground-input.tsxweb/default/src/features/playground/components/playground-parameter-panel.tsxweb/default/src/features/playground/lib/playground-parameters.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.jsonweb/default/src/i18n/static-keys.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
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/playground/components/playground-input.tsxweb/default/src/i18n/static-keys.tsweb/default/src/features/playground/components/playground-parameter-panel.tsxweb/default/src/features/playground/lib/playground-parameters.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/playground/components/playground-input.tsxweb/default/src/features/playground/components/playground-parameter-panel.tsxweb/default/src/features/playground/lib/playground-parameters.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/playground/lib/playground-parameters.ts
🔇 Additional comments (16)
web/default/src/i18n/locales/en.json (2)
3325-3339: 🎯 Functional CorrectnessVerify ja.json, ru.json, vi.json, zh.json also carry the new parameter keys.
These locale files were listed as touched by this cohort but aren't included in this review batch; same verification gap raised in the prior review round.
#!/bin/bash rg -n '"Presence Penalty"' web/default/src/i18n/locales/ja.json web/default/src/i18n/locales/ru.json web/default/src/i18n/locales/vi.json web/default/src/i18n/locales/zh.json
3325-3339: LGTM! Presence Penalty label/description key gap from the prior review is resolved.web/default/src/features/playground/lib/playground-parameters.ts (1)
19-19: LGTM!Also applies to: 118-127
web/default/src/i18n/locales/fr.json (1)
3325-3339: LGTM!web/default/src/i18n/locales/ja.json (1)
6-57: LGTM!Also applies to: 136-137, 3325-3334, 3336-3339
web/default/src/i18n/locales/ru.json (3)
6-12: LGTM!Also applies to: 14-22, 24-57
136-137: LGTM!
3325-3339: LGTM!web/default/src/i18n/locales/vi.json (4)
3331-3331: Duplicate: the probability-mass translation remains unclear.This is the same still-valid issue reported in the previous review; replace “khối lượng xác suất” with “tổng xác suất”.
6-12: LGTM!Also applies to: 14-22, 24-57
136-137: LGTM!
3325-3330: LGTM!Also applies to: 3332-3339
web/default/src/i18n/locales/zh.json (1)
3330-3330: LGTM!Also applies to: 3335-3335
web/default/src/features/playground/components/playground-parameter-panel.tsx (2)
1-71: LGTM!
211-279: LGTM! The previously-flagged destructuring and per-keystroke normalization issues are both resolved.web/default/src/features/playground/components/playground-input.tsx (1)
60-66: LGTM!Also applies to: 83-92, 119-119, 214-215
|
@coderabbitai review |
✅ Action performedReview finished.
|
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/playground/components/playground-parameter-panel.tsx`:
- Around line 67-78: Update PlaygroundParameterContent’s updateParameterConfig
so clearing or entering an invalid numeric value preserves null for every
parameter, rather than coercing non-seed values through value ?? 0. Keep the
existing seed handling and pass the resulting nullable value to
props.onConfigChange, allowing cleared enabled fields to remain unset.
🪄 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: 843bf176-7986-4c0d-b90a-89f469b12285
📒 Files selected for processing (12)
web/default/src/features/playground/components/playground-input.tsxweb/default/src/features/playground/components/playground-parameter-panel.tsxweb/default/src/features/playground/components/playground-parameter-row.tsxweb/default/src/features/playground/lib/playground-parameters.test.tsweb/default/src/features/playground/lib/playground-parameters.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.jsonweb/default/src/i18n/static-keys.ts
📜 Review details
🧰 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/i18n/static-keys.tsweb/default/src/features/playground/components/playground-parameter-panel.tsxweb/default/src/features/playground/lib/playground-parameters.test.tsweb/default/src/features/playground/components/playground-input.tsxweb/default/src/features/playground/components/playground-parameter-row.tsxweb/default/src/features/playground/lib/playground-parameters.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/playground/components/playground-parameter-panel.tsxweb/default/src/features/playground/lib/playground-parameters.test.tsweb/default/src/features/playground/components/playground-input.tsxweb/default/src/features/playground/components/playground-parameter-row.tsxweb/default/src/features/playground/lib/playground-parameters.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/playground/lib/playground-parameters.test.tsweb/default/src/features/playground/lib/playground-parameters.ts
web/default/src/**/*.test.ts
📄 CodeRabbit inference engine (web/default/AGENTS.md)
工具函数与纯逻辑应优先编写单元测试;测试文件应命名为
*.test.ts。
Files:
web/default/src/features/playground/lib/playground-parameters.test.ts
🔇 Additional comments (16)
web/default/src/i18n/locales/vi.json (3)
3331-3331: Duplicate: clarify the Vietnamese “probability mass” translation.Line 3331 still uses the literal “khối lượng xác suất”; replace it with “tổng xác suất” for clearer Top P terminology.
6-57: LGTM!Also applies to: 136-137
3325-3330: LGTM!Also applies to: 3332-3339
web/default/src/i18n/locales/zh.json (1)
6-57: LGTM!Also applies to: 136-137, 3325-3339
web/default/src/i18n/locales/ru.json (1)
6-57: LGTM!Also applies to: 136-137, 3325-3339
web/default/src/features/playground/lib/playground-parameters.ts (1)
1-129: LGTM!web/default/src/features/playground/lib/playground-parameters.test.ts (1)
40-49: LGTM!web/default/src/i18n/locales/en.json (2)
3325-3339: LGTM!
3325-3339: 📐 Maintainability & Code QualityNo parity gap in the remaining locale files. The new parameter labels/descriptions are already present in ja/ru/vi/zh, so no follow-up is needed.
> Likely an incorrect or invalid review comment.web/default/src/i18n/locales/fr.json (1)
3325-3339: LGTM!web/default/src/i18n/locales/ja.json (1)
6-57: LGTM!Also applies to: 136-137, 3330-3330, 3335-3335
web/default/src/i18n/static-keys.ts (1)
332-347: Still missing'Parameters'and'Enable {{parameter}}'keys.
playground-parameter-panel.tsxusest('Parameters')andplayground-parameter-row.tsxusest('Enable {{parameter}}', {...}), but neither key is registered here, so static locale coverage is incomplete for these two visible/aria-label strings.As per coding guidelines, "前端页面文本与组件内文案必须支持 i18n".
Source: Coding guidelines
web/default/src/features/playground/components/playground-parameter-row.tsx (2)
94-109: 🎯 Functional CorrectnessVerify the Slider gets an accessible name.
Unlike the
Switch(explicitaria-label), theSlideronly receivesid={controlId}paired with the<label htmlFor>above. Native<label htmlFor>reliably wires up a real<input>, but many custom ARIA slider primitives exposerole="slider"on an internal thumb that isn't the element carryingid— in that case the label wouldn't provide an accessible name for keyboard/screen-reader users.Please confirm whether
@/components/ui/sliderforwardsidto the thumb (or setsaria-labelledbyfrom it); if not, add an explicitaria-label={t(props.control.labelKey)}on theSlider.
1-92: LGTM!Also applies to: 110-132
web/default/src/features/playground/components/playground-parameter-panel.tsx (1)
47-47: LGTM!Also applies to: 80-173
web/default/src/features/playground/components/playground-input.tsx (1)
84-92: LGTM!Also applies to: 119-119, 214-215
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 8
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/channels/components/drawers/channel-editor-state.ts (1)
51-61: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winReject non-string mapping values instead of coercing them.
String(rawTarget)makes object/number values appear as valid targets (for example,"[object Object]"), butchannelFormSchemarejects non-string mapping values on save. Mark these mappings invalid here as well.🤖 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/channels/components/drawers/channel-editor-state.ts` around lines 51 - 61, Update the mapping reduction in the channel editor state to accept only entries whose raw target value is a string; trim it after validating its type and reject non-string values instead of coercing them with String(). Preserve the existing source handling and only add entries when both trimmed values are non-empty.
🤖 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/channel/task/taskcommon/path_config_test.go`:
- Around line 90-100: Update the test fixture and assertions around taskInfo
token parsing to use distinct values for completion_tokens and total_tokens,
ensuring the assertions independently verify CompletionTokens and TotalTokens
mapping.
In `@web/default/src/i18n/locales/fr.json`:
- Line 1002: Update the French translation for “Completion delta settlement” to
preserve the technical billing meaning of “completion” and align with the nearby
“Completion” and “Completion price” terminology, rather than translating it as a
generic settlement at the end.
In `@web/default/src/i18n/locales/ja.json`:
- Line 447: Update the Japanese translation for the “API Key is required when
creating a channel.” entry to use the established term “APIキー”, resulting in
“チャネルの作成時には APIキーが必要です。”
- Line 998: Update the “Complete Order” translation in the locale entry to use
order-completion wording, such as 注文を完了, and keep it consistent with the nearby
“Failed to complete order” translation; do not use 手動チャージ.
In `@web/default/src/i18n/locales/ru.json`:
- Line 1618: Update the “embeddings” translation in the Russian locale to use
the established `Встраивания` terminology, matching the existing Embeddings
entry and preserving consistency.
- Line 4139: Update the standalone “Seed” translation in the Russian locale data
to use “Сид”, matching the existing translation used elsewhere in the locale.
- Line 447: Update the Russian locale entry for “API Key is required when
creating a channel.” to use the existing Russian terminology “ключ API”,
resulting in the translation “При создании канала требуется ключ API.”
- Line 996: Update the “Compatible support” translation in ru.json to use
natural Russian wording that expresses support for compatible APIs as a
capability, such as the established equivalent of “Поддержка совместимых API”.
---
Outside diff comments:
In
`@web/default/src/features/channels/components/drawers/channel-editor-state.ts`:
- Around line 51-61: Update the mapping reduction in the channel editor state to
accept only entries whose raw target value is a string; trim it after validating
its type and reject non-string values instead of coercing them with String().
Preserve the existing source handling and only add entries when both trimmed
values are non-empty.
🪄 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: 8b0e9c5f-13ad-4e53-ae4b-56d6a94693cc
📒 Files selected for processing (19)
controller/relay.gocontroller/task_video.godto/channel_settings.gomodel/task.gorelay/channel/task/taskcommon/path_config_test.gorelay/channel/task/taskcommon/protocol_config.goservice/task_billing_test.goservice/task_polling.goweb/default/src/features/channels/components/drawers/channel-editor-state.tsweb/default/src/features/channels/components/drawers/channel-mutate-drawer.tsxweb/default/src/features/channels/constants.tsweb/default/src/features/channels/lib/channel-form.tsweb/default/src/features/channels/types.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 (7)
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/constants.tsweb/default/src/features/channels/types.tsweb/default/src/features/channels/components/drawers/channel-editor-state.tsweb/default/src/features/channels/lib/channel-form.tsweb/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx
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/channels/constants.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/channels/constants.tsweb/default/src/features/channels/types.tsweb/default/src/features/channels/components/drawers/channel-editor-state.tsweb/default/src/features/channels/lib/channel-form.tsweb/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx
**/*.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/task_video.godto/channel_settings.gorelay/channel/task/taskcommon/path_config_test.gorelay/channel/task/taskcommon/protocol_config.gocontroller/relay.goservice/task_polling.gomodel/task.goservice/task_billing_test.go
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/channel_settings.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 tostreamSupportedChannels.
Files:
relay/channel/task/taskcommon/path_config_test.gorelay/channel/task/taskcommon/protocol_config.go
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/channels/lib/channel-form.ts
🔇 Additional comments (21)
web/default/src/i18n/locales/ja.json (1)
27-27: LGTM!Also applies to: 53-53, 69-69, 87-92, 250-250, 515-519, 652-655, 793-793, 855-855, 953-958, 996-996, 1002-1002, 1019-1028, 1134-1134, 1618-1624, 1674-1674, 1992-1992, 2099-2099, 2126-2126, 2345-2345, 2483-2483, 2555-2556, 2676-2676, 2753-2753, 2898-2898, 2950-2950, 3105-3105, 3175-3175, 3307-3307, 3525-3525, 3726-3726, 3768-3768, 3893-3893, 3939-3939, 3994-4002, 4139-4139, 4298-4298, 4393-4393, 4541-4541, 4561-4561, 4648-4648, 4785-4785, 4959-4959, 5112-5130, 5262-5262
web/default/src/i18n/locales/fr.json (1)
27-27: LGTM!Also applies to: 53-53, 69-69, 87-92, 250-250, 447-447, 515-519, 652-655, 793-793, 855-855, 953-958, 996-1001, 1019-1028, 1134-1134, 1618-1624, 1674-1674, 1992-1992, 2099-2099, 2126-2126, 2345-2345, 2483-2483, 2555-2556, 2676-2676, 2753-2753, 2898-2898, 2950-2950, 3105-3105, 3175-3175, 3307-3307, 3525-3525, 3726-3726, 3768-3768, 3893-3893, 3939-3939, 3994-4002, 4139-4139, 4298-4298, 4393-4393, 4541-4541, 4561-4561, 4648-4648, 4959-4959, 5112-5130, 5262-5262
web/default/src/i18n/locales/zh.json (1)
27-92: LGTM!Also applies to: 250-250, 447-447, 515-519, 652-655, 793-793, 855-855, 953-958, 996-1002, 1019-1028, 1134-1134, 1618-1624, 1674-1674, 1992-1992, 2099-2099, 2126-2126, 2345-2345, 2483-2483, 2555-2556, 2676-2676, 2753-2753, 2898-2898, 2950-2950, 3105-3105, 3175-3175, 3307-3307, 3525-3525, 3726-3726, 3768-3768, 3893-3893, 3939-3939, 3994-4002, 4139-4139, 4298-4298, 4393-4393, 4541-4541, 4561-4561, 4648-4648, 4785-4785, 4959-4959, 5112-5130, 5262-5262
web/default/src/i18n/locales/ru.json (3)
27-27: LGTM!Also applies to: 53-53, 69-69, 87-87, 92-92, 250-250, 515-519, 652-652, 655-655, 793-793, 855-855, 953-953, 957-958
1019-1019: LGTM!Also applies to: 1027-1028, 1134-1134, 1620-1622, 1624-1624, 1674-1674, 1992-1992, 2099-2099, 2126-2126, 2345-2345, 2483-2483, 2555-2556, 2676-2676, 2753-2753, 2898-2898, 2950-2950, 3105-3105, 3175-3175, 3307-3307, 3525-3525
3726-3726: LGTM!Also applies to: 3768-3768, 3893-3893, 3939-3939, 3994-4002, 4298-4298, 4393-4393, 4541-4541, 4561-4561, 4648-4648, 4785-4785, 4959-4959, 5112-5112, 5115-5117, 5123-5123, 5126-5130, 5262-5262
web/default/src/i18n/locales/vi.json (2)
2556-2556: The probability-mass translation still needs the previous correction.Line [2556] still uses “khối lượng xác suất”; use “tổng xác suất” for clearer Vietnamese terminology. This is the same unresolved issue raised in the previous review.
27-27: LGTM!Also applies to: 53-53, 69-69, 87-92, 250-250, 447-447, 515-519, 652-655, 793-793, 855-855, 953-958, 996-1002, 1019-1028, 1134-1134, 1618-1624, 1674-1674, 1992-1992, 2099-2099, 2126-2126, 2345-2345, 2483-2483, 2555-2555, 2676-2676, 2753-2753, 2898-2898, 2950-2950, 3105-3105, 3175-3175, 3307-3307, 3525-3525, 3726-3726, 3768-3768, 3893-3893, 3939-3939, 3994-4002, 4139-4139, 4298-4298, 4393-4393, 4541-4541, 4561-4561, 4648-4648, 4785-4785, 4959-4959, 5112-5130, 5262-5262
web/default/src/i18n/locales/en.json (1)
27-27: LGTM!Also applies to: 53-53, 69-69, 87-92, 250-250, 447-447, 515-519, 652-655, 793-793, 855-855, 953-958, 996-1002, 1019-1028, 1134-1134, 1618-1624, 1674-1674, 1992-1992, 2099-2099, 2126-2126, 2345-2345, 2483-2483, 2555-2556, 2676-2676, 2753-2753, 2898-2898, 2950-2950, 3105-3105, 3175-3175, 3307-3307, 3525-3525, 3726-3726, 3768-3768, 3893-3893, 3939-4002, 4139-4139, 4298-4298, 4393-4393, 4541-4541, 4561-4561, 4648-4648, 4785-4785, 4959-4959, 5112-5130, 5262-5262
web/default/src/features/channels/components/drawers/channel-editor-state.ts (1)
112-117: LGTM!Also applies to: 126-152, 193-211
web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx (1)
106-106: LGTM!Also applies to: 225-225, 304-320, 355-355, 586-659, 768-808, 1135-1143, 1210-1218, 1367-1370, 2449-2457, 3009-3047, 3887-3890
web/default/src/features/channels/constants.ts (1)
84-84: LGTM!web/default/src/features/channels/lib/channel-form.ts (1)
22-22: LGTM!Also applies to: 247-250, 441-441, 589-592, 630-631, 748-751, 889-897
controller/task_video.go (1)
163-165: LGTM!relay/channel/task/taskcommon/protocol_config.go (1)
206-217: LGTM!web/default/src/features/channels/types.ts (1)
111-111: LGTM!controller/relay.go (1)
585-603: LGTM!dto/channel_settings.go (1)
52-52: LGTM!model/task.go (1)
113-138: LGTM!service/task_billing_test.go (1)
12-13: LGTM!Also applies to: 721-721, 748-748, 757-868, 888-888
service/task_polling.go (1)
504-504: LGTM!Also applies to: 566-575
| "usage": { | ||
| "completion_tokens": 40594, | ||
| "total_tokens": 40594 | ||
| } | ||
| }`), dto.ChannelOtherSettings{TaskProtocol: TaskProtocolGenericVideo}) | ||
|
|
||
| require.NoError(t, err) | ||
| require.True(t, ok) | ||
| require.NotNil(t, taskInfo) | ||
| assert.Equal(t, 40594, taskInfo.CompletionTokens) | ||
| assert.Equal(t, 40594, taskInfo.TotalTokens) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Use distinct token values.
Identical fixtures let an incorrect shared mapping pass; use different completion_tokens and total_tokens values.
Proposed fix
- "completion_tokens": 40594,
- "total_tokens": 40594
+ "completion_tokens": 12345,
+ "total_tokens": 40594
...
- assert.Equal(t, 40594, taskInfo.CompletionTokens)
+ assert.Equal(t, 12345, taskInfo.CompletionTokens)
assert.Equal(t, 40594, taskInfo.TotalTokens)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "usage": { | |
| "completion_tokens": 40594, | |
| "total_tokens": 40594 | |
| } | |
| }`), dto.ChannelOtherSettings{TaskProtocol: TaskProtocolGenericVideo}) | |
| require.NoError(t, err) | |
| require.True(t, ok) | |
| require.NotNil(t, taskInfo) | |
| assert.Equal(t, 40594, taskInfo.CompletionTokens) | |
| assert.Equal(t, 40594, taskInfo.TotalTokens) | |
| "usage": { | |
| "completion_tokens": 12345, | |
| "total_tokens": 40594 | |
| } | |
| }`), dto.ChannelOtherSettings{TaskProtocol: TaskProtocolGenericVideo}) | |
| require.NoError(t, err) | |
| require.True(t, ok) | |
| require.NotNil(t, taskInfo) | |
| assert.Equal(t, 12345, taskInfo.CompletionTokens) | |
| assert.Equal(t, 40594, taskInfo.TotalTokens) |
🤖 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 `@relay/channel/task/taskcommon/path_config_test.go` around lines 90 - 100,
Update the test fixture and assertions around taskInfo token parsing to use
distinct values for completion_tokens and total_tokens, ensuring the assertions
independently verify CompletionTokens and TotalTokens mapping.
| "Complete these steps to finish the initial installation.": "Suivez ces étapes pour terminer l'installation initiale.", | ||
| "Completed": "Terminé", | ||
| "Completion": "Achèvement", | ||
| "Completion delta settlement": "Règlement du delta à la fin", |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Preserve the “completion” billing meaning.
"Completion delta settlement" is translated as "Règlement du delta à la fin", which changes the technical meaning to a generic “settlement at the end.” This is ambiguous and inconsistent with the nearby Completion and Completion price terminology.
- "Completion delta settlement": "Règlement du delta à la fin",
+ "Completion delta settlement": "Règlement du delta de complétion",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "Completion delta settlement": "Règlement du delta à la fin", | |
| "Completion delta settlement": "Règlement du delta de complétion", |
🤖 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/i18n/locales/fr.json` at line 1002, Update the French
translation for “Completion delta settlement” to preserve the technical billing
meaning of “completion” and align with the nearby “Completion” and “Completion
price” terminology, rather than translating it as a generic settlement at the
end.
| "API key from the provider": "プロバイダからのAPIキー", | ||
| "API key is loading, please try again in a moment": "API キーを読み込み中です。しばらくしてから再試行してください", | ||
| "API key is required": "APIキーが必要です", | ||
| "API Key is required when creating a channel.": "チャネルの作成時には API Key が必要です。", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use the established Japanese term for “API Key”.
API Key is inconsistent with the surrounding locale entries, which use APIキー. Translate this as チャネルの作成時には APIキーが必要です。
🤖 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/i18n/locales/ja.json` at line 447, Update the Japanese
translation for the “API Key is required when creating a channel.” entry to use
the established term “APIキー”, resulting in “チャネルの作成時には APIキーが必要です。”
| "Compatible API routes for common AI application workflows": "一般的なAIアプリケーションワークフロー向けの互換APIルート", | ||
| "Compatible support": "互換対応", | ||
| "Complete API documentation with multi-language SDK support": "多言語SDKをサポートする完全なAPIドキュメント", | ||
| "Complete Order": "手動チャージ", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Translate “Complete Order” as order completion.
手動チャージ means “manual top-up,” not “complete order,” and conflicts with the nearby Failed to complete order translation. Use wording such as 注文を完了 instead.
🤖 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/i18n/locales/ja.json` at line 998, Update the “Complete
Order” translation in the locale entry to use order-completion wording, such as
注文を完了, and keep it consistent with the nearby “Failed to complete order”
translation; do not use 手動チャージ.
| "API key from the provider": "Ключ API от провайдера", | ||
| "API key is loading, please try again in a moment": "API-ключ загружается, повторите попытку через несколько секунд", | ||
| "API key is required": "Требуется ключ API", | ||
| "API Key is required when creating a channel.": "При создании канала требуется API Key.", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use the existing Russian translation for “API Key”.
Line 447 leaves “API Key” in English, while nearby entries use “Ключ API”. Use При создании канала требуется ключ API. for consistent Russian UI text.
🤖 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/i18n/locales/ru.json` at line 447, Update the Russian locale
entry for “API Key is required when creating a channel.” to use the existing
Russian terminology “ключ API”, resulting in the translation “При создании
канала требуется ключ API.”
| "Compatibility field for the default auto route. It is derived from the route config when saving.": "Поле совместимости для автомаршрута по умолчанию. При сохранении оно формируется из конфигурации маршрутов.", | ||
| "compatible API routes": "совместимых API-маршрутов", | ||
| "Compatible API routes for common AI application workflows": "Совместимые API-маршруты для типовых сценариев ИИ-приложений", | ||
| "Compatible support": "Совместимая поддержка", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Translate “Compatible support” as a capability.
Совместимая поддержка is unnatural and does not identify what is supported. Use wording such as Поддержка совместимых API if that matches the capability context.
🤖 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/i18n/locales/ru.json` at line 996, Update the “Compatible
support” translation in ru.json to use natural Russian wording that expresses
support for compatible APIs as a capability, such as the established equivalent
of “Поддержка совместимых API”.
| "Email Field": "Поле email", | ||
| "Email Verification": "Верификация Email", | ||
| "Email, summarisation, knowledge work": "Электронная почта, резюме, knowledge work", | ||
| "embeddings": "Векторные представления", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Keep “embeddings” terminology consistent.
This entry uses Векторные представления, while the existing Embeddings entry uses Встраивания. Use one term consistently, preferably the project’s established terminology.
🤖 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/i18n/locales/ru.json` at line 1618, Update the “embeddings”
translation in the Russian locale to use the established `Встраивания`
terminology, matching the existing Embeddings entry and preserving consistency.
| "Security boundary": "Граница безопасности", | ||
| "Security Check": "Проверка безопасности", | ||
| "Security verification": "Подтверждение безопасности", | ||
| "Seed": "Seed", |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Localize “Seed” consistently.
The existing Russian description at Line 1430 uses Сид, but this standalone label remains Seed. Translate it as Сид to avoid mixing English and Russian terminology.
🤖 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/i18n/locales/ru.json` at line 4139, Update the standalone
“Seed” translation in the Russian locale data to use “Сид”, matching the
existing translation used elsewhere in the locale.
Important
📝 变更描述 / Description
(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)