Repository navigation
chore(sync): merge upstream - #25
Conversation
* fix(middleware): 隐藏无可用渠道错误中的任务插件标识 * fix(middleware): keep task-plugin context in no-channel error without plugin keys The fully generic message from #7414 left callers and operators unable to tell whether a task plugin was involved at all. Restore the group, model and plugin-claimed wording in the 503 body, but keep the plugin keys and the admin fix hint out of it; the candidate plugin keys stay in the warn log under the request id so operators can correlate. --------- Co-authored-by: CaIon <i@caion.me>
…iltered AI text (#7438)
OpenaiImageHandler and the JSON-to-SSE fallback billed the gjson data.# element count. An object-shaped data yielded 0 and kept the requested n while the SSE fallback dropped the image and sent only [DONE]; one image split into a url entry and a b64_json entry billed twice; entries carrying only revised_prompt billed as images. Count images by payload: an object with url or b64_json is one image and arrays bill max(url entries, b64_json entries). The SSE fallback forwards one completed event per image payload for both shapes. xAI inherits the fix through OpenaiImageHandler.
AGENTS.md was too large to keep growing. Move the billing expression, built-in pricing and billing safety invariant rules into .agents/rules/billing.md and add the rule for deriving billable image counts from upstream responses. AGENTS.md keeps a mandatory read gate with concrete trigger paths and concepts: matching tasks must read the file in full before planning, coding or reviewing; unrelated tasks may skip it. CLAUDE.md mirrors the gate next to the existing web/AGENTS.md line.
Model redirects for relay upstreams were split from the model list and took a tab switch per model. This adds a redirect workflow that stays with the fetched upstream list and scales to channels with hundreds of models. - Floating redirect panel on wide screens built on a new generic FloatingWindow (draggable, resizable from any edge, collapsible, position and size persisted); narrow viewports keep the routing-tab flow - Naming pattern detection (relay suffixes, date suffixes, vendor prefixes, dotted versions) offered as one-click suggestion chips; verified aliases apply directly from a fetched model's row - Batch mapping dialog derives request or upstream names by rule with preview, conflict reporting and optional model-list sync - Mapping editor: searchable model comboboxes, row filter, draft rows, commit hook; ComboboxInput dropdowns portal so scroll containers no longer clip them; model picker options carry redirect hints - Fetched list shows alias badges and keeps its active tab; guardrail alerts link across tabs; routing tab shows mapping count - Quick options render as a compact header toolbar on wide screens
Let adaptors mark a response as completed, failed, incomplete or cancelled from the events they already parse, keep the first terminal state unless a failure follows, and expose a snapshot for classification without carrying upstream messages.
Group sensitive-word checks, channel selection, retries and channel health under one "Request policies" settings area with a session rules editor, per-rule session modes (inherit/off/prefer/strict) and a global default. Record routing decisions per attempt into log admin info, expose GET/PATCH /api/option/request_policy with whole-policy validation, and redirect the legacy settings URLs to the new sections.
Return conversion diagnostics from explicit reasoning intent parsing and Gemini thinking-control conversion, collect them through a context collector, and record them on the relay info so best-effort conversions are visible instead of silently dropped.
…sify stream results Sample each relay once when the request finishes instead of inside the billing paths, classify the protocol outcome (completed, failed, incomplete, cancelled) on the stream status from events the adaptors already parse, and show response status and success-rate windows in the dashboard and model cards.
…response outcome Track in-flight reservations in the memory limiter and count a request as successful only when its response outcome completed, instead of relying on the HTTP status code alone.
Parse the stream identity from the WebSocket envelope, echo it on create and error events, attribute upstream errors to the pending control or the active response, and record routing decisions and relay metrics for WebSocket calls.
List system tasks by type, status and scope with paging, show a history table beside the active task panel, and add DELETE /api/system-task/history to purge finished entries.
Only MiniMax-H3 charges for input media and each family renders its own set of output resolutions, so build the usage schema per model instead of sharing one schema across the plugin.
Enforce toIntlLocale() for every Intl call through a project oxlint plugin with its own tests, adopt it in the billing time fields, add the missing floating-window labels, and refresh the agent instructions.
Lay out the channel health form with the shared settings grid so switch rows span the full width and inputs align in two columns instead of a fixed three-column grid that stretched the switches. Nest the test mode and interval under the scheduled tests switch, make the mode select fill its column, and replace the alert boxes and channels link at the top with plain hint text. Add a layout regression test and the new group label translation.
Allow Advanced Custom, Sub2API and New API channels for Responses WebSocket when the per-channel toggle is on. Advanced Custom requires a converter-free /v1/responses route, and editing the route's upstream path, conversion or credential placement forces a reconnect. Match token model limits the same way HTTP does, share channel selection and used-channel tracking between the distributor and the WebSocket session, record channel affinity on the first accepted upstream event, parse the create envelope once, restore the default type for synthesized upstream errors, fold proxy, request context and handshake status into DoWssRequest, send the upstream close frame on policy close, drop the unobservable policy defer lines and cover the control and late-error branches that had no tests.
…sub2api and new-api channels Gate the toggle, the quick option and the configuration marker through one shared predicate that mirrors the backend allow list, add the Sub2API channel type constant, and explain under the toggle that advanced custom channels only use converter-free /v1/responses routes.
* fix: subscription log * fix(usage-logs): hide wallet labels when subscriptions are unavailable
* feat(log): flag upstream response model mismatches * fix(log): refine response model mismatch warnings * fix(log): skip model details when no mapping or response difference exists * fix(log): omit redundant response model metadata
…7427) Tool-call argument, reasoning and refusal deltas now feed the completion estimate, and a stream that produced any upstream event bills its estimated prompt tokens unless upstream reported an explicit failure. Responses streams interrupted before response.completed no longer settle at zero and refund the whole pre-consume. Inspired by #7195. Refs #7062.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 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 |
|
PR Title: chore(sync): merge upstream Commit: 整体评估本次变更是一个大型的请求路由/重试/计费与可观测性重构,涉及约 224 个文件。核心改动包括:统一渠道选择与重试决策(service.SelectChannelForRequest、service.DecideRelayRetry 与 PolicyDecision)、请求策略快照与选项更新(model/request_policy.go、model/option.go 的 requestPolicyOptionMutex 加锁路径)、Responses 的 HTTP SSE 与 WebSocket 双传输计费累加器(service/responses_usage.go)、流状态分类(relay/common.StreamStatus、pkg/perf_metrics 的 ClassifyRelayOutcome)、渠道亲和会话模式(ChannelAffinitySetting.SessionMode)、内存限流预留(common.InMemoryRateLimiter.Reserve/Complete)以及前端 request-policies 设置页。 我重点核对了以下高风险点且未发现缺陷:前端下发的所有请求策略选项键均包含在 model.IsRequestPolicyOption 白名单内,PATCH /api/option/request_policy 位于 RootAuth 之下,不存在越权或保存即 400 的问题;requestPolicyOptionMutex 与 OptionMapRWMutex 之间不存在锁序死锁,updateOptionMap/handleConfigUpdate 不会重入请求策略锁;DecideRelayRetry 对 504/524 的 always-skip 判断与旧逻辑行为等价(ShouldRetryByStatusCode 已内置该检查,新增显式判断仅为冗余);RateLimitReservation.Complete 使用 sync.Once 且对 nil 接收者安全,modelRequestSucceeded 亦为 nil 安全;perf_metrics 的 RecordRelayResult 同步完成结果分类后再交给 gopool 异步写 Redis,不依赖请求上下文,避免了请求结束后 ctx 被取消导致样本丢失;StreamStatus 的全部方法均为 nil 安全。 唯一确认的问题是 controller/relay.go 中 RelayMidjourney 新增的失败记录守卫存在逻辑缺陷(详见 finding):其成功路径从不设置 Successful=true,且 Midjourney 经由 Distribute 选路不会调用 BeginAttempt,使该守卫要么恒不执行、要么在成功后误报失败。 总结整体设计自洽、边界处理(nil 安全、sync.Once、锁粒度)较为严谨,未发现安全、计费或数据完整性方面的高置信度严重缺陷。需要修复的是 RelayMidjourney 的 request_policy 终止记录守卫(低严重度,影响诊断日志的正确性)。受审查规模限制(约 31% 文件、51% 变更行),仍有部分改动未逐行覆盖,建议对未覆盖的 relay 渠道实现与前端组件补充针对性测试与人工复核。 Findings (1)
Prompt To Fix All With AI |
| if policy.Attempts > 0 && !policy.Successful { | ||
| service.RecordRequestPolicyTermination(c, types.NewErrorWithStatusCode(errors.New("Midjourney submission failed"), types.ErrorCodeBadResponseStatusCode, http.StatusBadGateway, types.ErrOptionWithSkipRetry())) | ||
| } | ||
| }() |
There was a problem hiding this comment.
🟢 RelayMidjourney 的失败记录守卫恒不成立,成功路径也从不置 Successful=true
Category: 功能正确性
RelayMidjourney 新增的 defer 以 policy.Attempts > 0 && !policy.Successful 为条件调用 RecordRequestPolicyTermination,意在把失败的 Midjourney 提交写入 request_policy 终止事件。但 Midjourney 路由(router/relay-router.go 的 registerMjRouterGroup)走的是 middleware.TokenAuth() + middleware.Distribute(),Distribute 只通过 SetupContextForSelectedChannel 选定渠道,并不调用 service.RequestPolicy(c).BeginAttempt,只有 controller/relay.go 的 getChannel 与 responses WebSocket 路径会调用它。因此 Midjourney 请求的 policy.Attempts 恒为 0,该 defer 永远不会执行,预期的失败终止记录实际上从未产生。更严重的是,该函数的成功分支从不把 policy.Successful 设为 true,只有错误分支会写 policy.Successful = false(第 334 行);这意味着一旦将来有路径让 Attempts 变为 > 0,守卫在请求成功时也会成立,从而为成功的 Midjourney 请求写入一条 Midjourney submission failed 的终止事件,产生误导性的诊断日志。无论 Attempts 是否为 0,这段守卫的语义都不可靠。
Problem code:
Lines 301 to 306 in 3524fe0
Recommendation:
二选一:若确实要为 Midjourney 记录 request_policy 终止事件,则在 Midjourney 流程中也调用 service.RequestPolicy(c).BeginAttempt(...)(或复用统一选路逻辑),并在成功路径显式设置 policy.Successful = true;若不打算记录,则删除该 defer,避免留下一个看似生效、实则失灵的守卫。
Prompt To Fix All With AI
This is a comment left during a code review.
Repository: https://github.com/Chloemlla/new-api
Path: controller/relay.go
Line: 301-306
Comment:
RelayMidjourney 的失败记录守卫恒不成立,成功路径也从不置 Successful=true
RelayMidjourney 新增的 defer 以 policy.Attempts > 0 && !policy.Successful 为条件调用 RecordRequestPolicyTermination,意在把失败的 Midjourney 提交写入 request_policy 终止事件。但 Midjourney 路由(router/relay-router.go 的 registerMjRouterGroup)走的是 middleware.TokenAuth() + middleware.Distribute(),Distribute 只通过 SetupContextForSelectedChannel 选定渠道,并不调用 service.RequestPolicy(c).BeginAttempt,只有 controller/relay.go 的 getChannel 与 responses WebSocket 路径会调用它。因此 Midjourney 请求的 policy.Attempts 恒为 0,该 defer 永远不会执行,预期的失败终止记录实际上从未产生。更严重的是,该函数的成功分支从不把 policy.Successful 设为 true,只有错误分支会写 policy.Successful = false(第 334 行);这意味着一旦将来有路径让 Attempts 变为 > 0,守卫在请求成功时也会成立,从而为成功的 Midjourney 请求写入一条 Midjourney submission failed 的终止事件,产生误导性的诊断日志。无论 Attempts 是否为 0,这段守卫的语义都不可靠。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
…indings Legacy GitHub bindings stored the login name, while current bindings store the numeric account ID. A legacy match no longer signs the user in on its own. When the account has two-factor or a passkey, the binding is rewritten only after that verification completes, inside the transaction that issues the session. Otherwise it is rewritten when one of the GitHub account's verified emails matches the account email. Without either, the login is declined with guidance to sign in another way and relink GitHub in account settings. All-digit login names never take part in the comparison, the bind flow no longer compares login names, and every migration or declined attempt is recorded as an account binding audit event.
|
PR Title: chore(sync): merge upstream Commit: 整体评估本轮增量只包含一个提交(2906e4f,fix(oauth): require account evidence before migrating legacy GitHub bindings),共 18 个文件。它把 GitHub 旧绑定(github_id 存的是登录名)的处理从"命中即自动登录并改写绑定"改为"必须先取得账号归属证据":有 2FA 或 passkey 时把改写挂起到登录验证阶段、在签发会话的同一事务内写入;没有第二因素时要求 GitHub 的已验证邮箱与账号邮箱匹配;两者都不满足则拒绝登录并提示改用其他方式登录后手动绑定。改写目标行带 github_id 原值匹配与占用冲突检查,失败即整体回滚;新增 VerifiedEmailProvider 接口、MigrateLegacyGitHubBindingWithTx 以及对应的拒绝文案。我逐行核对了事务边界、并发冲突、审计与通知路径、跨 provider 影响,未发现可被利用的接管路径或数据完整性问题。 总结本轮未发现需要修复的高置信度缺陷:原本"旧 GitHub 用户名被他人重新注册即可接管账号"的路径已被证据校验(第二因素或已验证邮箱)封堵,2FA/passkey 路径的改写与会话签发保持同一事务、冲突时回滚,邮箱路径在写库前完成匹配且不落库任何邮箱明文,全部内置 provider 中只有 GitHub 会产出 legacy_id,因此不会出现跨 provider 误改 github_id。需要关注的行为变化是:无第二因素且账号邮箱不在其 GitHub 已验证邮箱列表中的旧绑定用户不再自动登录,而是收到"无法自动关联"的提示,运营方应确认这部分用户仍能通过邮箱找回或密码登录,避免访问受阻。上一轮那条低危项位于 controller/relay.go,不在本轮 18 个改动文件之内,本轮未作重复评估。 |
|
PR Title: chore(sync): merge upstream Commit: 整体评估本轮增量在本轮范围(7209b6d..3e8c358)内只有一个提交生效到最终 diff:3e8c358(fix: forward reasoning_effort to zhipu upstream (QuantumNous#7124)),只改了 relay/channel/zhipu_4v/relay-zhipu_v4.go,在 requestOpenAI2Zhipu 构造下游请求时补上 ReasoningEffort 透传,其余行是 gofmt 对齐。上一轮(2906e4f,GitHub 旧绑定迁移需账号归属证据)的结论继续成立,其 18 个文件不在本轮 diff 内,本轮不重复评估。改动方向与仓库中其它 OpenAI 兼容渠道的做法一致(relay/channel/openai/adaptor.go 明确"原生顶层 reasoning_effort 在无转换时原样保留并记入 RelayInfo"),整体是补齐既有白名单拷贝遗漏的参数,未发现新增风险。 总结智谱适配器此前在 requestOpenAI2Zhipu 里逐字段拷贝请求,reasoning_effort 被静默丢弃,导致模型名思考后缀/显式 reasoning_effort 无法到达上游;本次把它加入拷贝字段即可修复,且只做字符串赋值,不影响 THINKING 等既有字段或其它 relay 格式(图片/响应接口不走该函数)。未发现正确性、安全或数据完整性层面的缺陷,无需修复项。可留意:该函数仍是逐字段白名单拷贝,每新增一个上游支持的参数都需要同步维护,否则会再次出现参数被静默丢弃的情况。 |
* perf: avoid repeated Claude tool-name lookups * refactor(relaykit): name tool-result backfill type and drop unused lookup Replace the repeated anonymous struct in the Claude-to-chat converter with a local named type, and remove SearchToolNameByToolCallId now that the converter resolves tool names in a single pass and nothing else calls it.
|
PR Title: chore(sync): merge upstream Commit: 整体评估本轮增量范围 7209b6d..946c730 内最终 diff 只保留了最后一个提交 946c730(perf: avoid repeated Claude tool-name lookups (QuantumNous#7447)),上一轮(3e8c358 智谱 reasoning_effort 透传)的结论继续成立且不在本轮 diff 内。本次改动把 Claude→OpenAI Chat 转换中「每个无名 tool_result 都全量扫描一次消息列表」的查找,改为在单遍遍历中构建 Id→Name 映射、循环结束后统一回填,并删除已无调用方的 dto.ClaudeRequest.SearchToolNameByToolCallId,附带了覆盖乱序/重复/缺失 call id 的新测试。整体是一次语义保持的性能优化,方向合理。 总结未发现需要修复的正确性、安全或数据完整性问题,可以合并。改动等价性经核对:新映射的「首次出现优先」与原 SearchToolNameByToolCallId 的「按消息顺序返回第一个 Id 匹配块的 Name」语义一致,且回填在整表遍历之后执行,因此 tool_result 早于对应 tool_use 出现(前向引用)时仍能解析出名称,缺失 id 时回填为空字符串,与旧行为相同;回填写指针的目标也是各消息独立的 Name 变量,不存在别名问题。测试覆盖了乱序、重复 call id 与未知 id 三类边界。需要留意的是,删除的是 relaykit/dto 包中的导出方法,若仓库外还有消费者会构成破坏性接口变更,而本仓库内的调用方已随本次改动清理。 |
|
PR Title: chore(sync): merge upstream Commit: 整体评估本轮增量范围(7209b6d..ea336ed)内最终 diff 只保留最后一个提交 ea336ed(fix(log): hide funding source labels when subscriptions are not in play (QuantumNous#7450)),它是在上一提交 9e905a8(refactor: show subscription deductions and improve cost display)基础上的收敛式重构:把「支出来源标签」的可见性判断抽成纯函数 shouldShowBillingSource,并把原先只管钱包标签的 showWalletSource 全面改名为 showBillingSource,使订阅标签同样受该开关约束。改动方向与上一轮的角色一致,接线完整且有单测覆盖,整体可以接受。 总结未发现需要修复的正确性、安全或数据完整性问题,可以合并。核对了各接线点:usage-logs-table.tsx 管理员路径改用 getAdminPlans() 并复用新的判断函数,普通用户路径新增 getPublicPlans() 与 getSelfSubscriptionFull() 并行请求,字段名 showWalletSource 已在 7 个文件中全部改名(仓库内搜索无残留)。log-cost-display.tsx 中金额计算仍由 isSubscription(billing_source === 'subscription')决定,只有标签被 showBillingSource 门控,因此标签隐藏时仍显示订阅扣减额,新增测试正是锁定这一行为。移动端卡片通过 flexRender 复用同一列定义,无需单独传参,不会出现标签不一致。可见性不变式自洽:标签被隐藏的情形只可能是「系统无启用套餐」或「当前用户从未购买过订阅」,这两类场景下不可能存在订阅扣费的日志,故不会出现把订阅扣费金额误当成钱包消费的情况。唯一需留意的是语义收紧:管理员侧由「存在任意套餐(含禁用)」变为「存在启用套餐」,普通用户侧由「本人有订阅」变为「本人有订阅且系统有启用套餐」,属于本次刻意的产品决策,已在测试中固化。新增纯函数与单测覆盖了无套餐、全部禁用、接口失败、无购买与有购买等边界,未发现遗漏的高风险回归面。 |
* refactor(log): restore compact cost bubbles and source icons * Delete .github/pr-previews/usage-log-cost-bubbles.png
|
PR Title: chore(sync): merge upstream Commit: 整体评估本轮增量范围(7209b6d..96b0da2)内最终只保留最后一个提交 96b0da2(refactor(log): 恢复费用气泡并用图标区分订阅来源 (QuantumNous#7451)),它是在上一轮 ea336ed(fix(log): hide funding source labels when subscriptions are not in play)之上的呈现层收敛:把费用单元格的 Wallet/Subscription 文字标签改回紧凑气泡,改用 Crown/Wallet 图标加 Tooltip 表达来源,并顺带收紧了自助日志的可见性判据。改动方向与上一轮一致,接线与单测(含新增的组件级可见性测试)覆盖完整,整体可以接受。 总结未发现安全或数据完整性问题,本次属于可控的 UI 重构,但有一处边界行为需要确认:自助日志路径不再回退读取 all_subscriptions、只按 subscriptions 数组长度判定,于是“订阅已过期但日志仍在保留期内”的用户会看到无来源图标的订阅扣减金额(findings:订阅已失效的用户会被隐藏来源图标,但其日志仍按订阅扣减显示金额),这与该功能“用来源图标消除金额歧义”的初衷相冲突,建议在合并前确认是否要把曾经持有的订阅重新纳入判断。除此之外,管理员侧仍需存在启用套餐、普通用户侧只看自身有效订阅这一语义变化已在单测中固化,属于刻意的产品决策;上一轮提到的改名与接线完整性在本轮未出现回退。 Findings (1)
Prompt To Fix All With AI |
| plans: undefined, | ||
| subscriptions: selfResult.success | ||
| ? selfResult.data?.subscriptions | ||
| : undefined, |
There was a problem hiding this comment.
🟢 订阅已失效的用户会被隐藏来源图标,但其日志仍按订阅扣减显示金额
Category: 功能正确性
本轮把自助日志(非管理员)的可见性判断改成只读取 /api/subscription/self 的 subscriptions 字段(按新注释即“当前有效订阅”),并删除了原先的 all_subscriptions ?? subscriptions 回退与“系统存在启用套餐”前置条件;而 log-cost-display.tsx 中金额仍由 other.billing_source === 'subscription' 决定,props.showBillingSource 只门控图标。两者叠加后出现一个此前不可达的状态:订阅已过期(或被管理员作废)但日志仍在保留期内的用户,其订阅计费日志的费用单元格会显示 subscription_consumed 的金额,却不再显示任何 Wallet/Subscription 图标——用户既无法判断这笔金额是钱包消费还是订阅扣减,又会被“无图标即钱包”的直觉误导。改动前该场景因 all_subscriptions 回退而携带已过期订阅、仍会显示标签,因此这个组合状态是本轮收紧判据后新引入的回归面(新增组件测试“hides both source icons for a user with only expired subscriptions”与既有测试“keeps the subscription deduction when its source icon is hidden”恰好分别固化了这两半行为)。另外,该判断完全依赖后端 subscriptions 字段恰好是“有效订阅”这一未被前端校验的语义,实现里只判断数组长度,一旦后端字段含义变化就会静默错显。
Problem code:
new-api/web/src/features/usage-logs/components/usage-logs-table.tsx
Lines 112 to 115 in 96b0da2
Recommendation:
让可见性判断与实际计费来源保持一致:自助日志下继续把用户“曾经持有”的订阅(all_subscriptions)纳入判断,或在 showBillingSource 为 false 且日志 billing_source 为 subscription 时回退到按 log.quota 展示/保留一个可辨识的标记,避免出现无来源标识的订阅扣减金额;同时建议不要只凭 subscriptions 数组长度判断“有效”,必要时按 subscription.status 过滤,并在注释中明确该字段的后端语义。
Prompt To Fix All With AI
This is a comment left during a code review.
Repository: https://github.com/Chloemlla/new-api
Path: web/src/features/usage-logs/components/usage-logs-table.tsx
Line: 112-115
Comment:
订阅已失效的用户会被隐藏来源图标,但其日志仍按订阅扣减显示金额
本轮把自助日志(非管理员)的可见性判断改成只读取 /api/subscription/self 的 subscriptions 字段(按新注释即“当前有效订阅”),并删除了原先的 all_subscriptions ?? subscriptions 回退与“系统存在启用套餐”前置条件;而 log-cost-display.tsx 中金额仍由 other.billing_source === 'subscription' 决定,props.showBillingSource 只门控图标。两者叠加后出现一个此前不可达的状态:订阅已过期(或被管理员作废)但日志仍在保留期内的用户,其订阅计费日志的费用单元格会显示 subscription_consumed 的金额,却不再显示任何 Wallet/Subscription 图标——用户既无法判断这笔金额是钱包消费还是订阅扣减,又会被“无图标即钱包”的直觉误导。改动前该场景因 all_subscriptions 回退而携带已过期订阅、仍会显示标签,因此这个组合状态是本轮收紧判据后新引入的回归面(新增组件测试“hides both source icons for a user with only expired subscriptions”与既有测试“keeps the subscription deduction when its source icon is hidden”恰好分别固化了这两半行为)。另外,该判断完全依赖后端 subscriptions 字段恰好是“有效订阅”这一未被前端校验的语义,实现里只判断数组长度,一旦后端字段含义变化就会静默错显。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
|
PR Title: chore(sync): merge upstream Commit: 整体评估本轮增量(7209b6d..1ea24a0)实际只包含最后一个提交 1ea24a0「docs: refresh project README across languages」,是纯文档改动:重写 6 个 README(README.md、README.en.md、README.zh_CN.md、README.zh_TW.md、README.fr.md、README.ja.md),统一为「定位介绍 → Capabilities/协议与接口表 → Quick start → Deployment/存储与环境变量 → Development → Documentation」的新结构,并补充了显式语言切换链接与 总结本次为文档刷新,未发现需要合并前修复的问题,也没有安全或数据完整性影响。关键事实已抽样核对且一致:docker-compose.yml 默认确为 New API + PostgreSQL + Redis 并附 MySQL/ClickHouse 示例;引用的相对路径(./.env.example、./docs/authentication.md、./docs/plugin-api/v1.md、./relaykit/README.md、./docker-compose.dev.yml、./makefile、./web/AGENTS.md、./electron/README.md、./AGENTS.md、./.github/SECURITY.md、./NOTICE)均存在;文档域名 docs.newapi.ai 与仓库 issue 模板一致; |
* fix(web): accept fractional group ratios and tool prices * fix(web): mask portaled group options in usage log privacy mode * fix(web): limit pricing input steps to four decimal places
|
PR Title: chore(sync): merge upstream Commit: 整体评估上一轮增量为纯文档刷新(1ea24a0 重写多语言 README,无问题),本轮新增的实际代码提交是 e04c05c(fix(web): 修复小数输入限制和日志分组选项未遮挡的问题 QuantumNous#7453),共 8 个文件、+117/-6,集中在价格/比率输入精度与组合框弹层样式透传两处前端改动,并配套补充/调整了测试。改动局部、与既有组件约定一致,未发现安全或数据完整性问题,整体风险可控。 总结修复方向正确:step 收紧为 0.0001 让 0.04、0.0001 等四位小数通过原生校验;popupClassName 经 combobox 的 searchable 分支(combobox-input 弹层 div)与 OptionCombobox 分支(ComboboxContent)正确透传,使用日志筛选栏因此能把 portal 到 body/dialog 的分组下拉一并套上隐私遮罩,group-filter 断言也随之调整。唯一需要关注的一点:价格与比率输入的“四位小数”上限只落在原生 step 校验层,保存路径的 parseToolPrice/normalizeRatio 仍接受任意精度(0.00001 仍可写入),且极小的 step 同时把数字输入的上下箭头微调步长从 0.5/0.1 变成 0.0001,建议在保存/序列化处显式校验精度或采用更合适的 step 策略,以免约束形同虚设并保留原有的粗调能力。除此之外未发现需要合并前修复的问题。 Findings (1)
Prompt To Fix All With AI |
|
PR Title: chore(sync): merge upstream Commit: 整体评估本轮增量(7209b6d..b0bf258)覆盖 6 个 README 文件,是上一轮文档刷新的延续与修订。上一轮(1ea24a0)已把各语言 README 重排为统一结构;本轮提交 b0bf258「docs: restore README badge and partner placement」把 badge 徽章块、Project Description、Trusted Partners、Special Thanks 这几个板块移回文件顶部,并同步删除原先位于文末的重复内容,属于纯文档的版式还原。 总结整体改动为机械式的内容搬移,无功能、安全或数据完整性影响,未发现需要在合并前修复的问题。逐文件核对了 README.md、README.en.md、README.fr.md 的折叠区段,确认顶部新增板块与文末删除板块内容一一对应,未出现内容丢失或重复;引用路径与锚点(#capabilities、#quick-start、#deployment、#development、#documentation)仍然有效。仅存在既有的排版差异(README.en.md 的合作伙伴列表不含 Aion UI,各文件 |
| @@ -330,7 +330,7 @@ export const ToolPriceSettings = memo(function ToolPriceSettings({ | |||
| <Input | |||
| type='number' | |||
| min={0} | |||
| step={0.5} | |||
| step={0.0001} | |||
There was a problem hiding this comment.
🟢 价格与比率输入的 step 收紧到 0.0001 后,四位小数上限未在保存路径生效,同时数字输入的微调步长被一并改变
Category: 功能正确性
tool-price-settings.tsx 第 333 行以及 group-ratio-visual-editor.tsx 第 562、578 行把 的 step 从 0.5 / 0.1 改为 0.0001。step 不只决定原生校验粒度,也决定数字输入上下箭头与键盘的微调量:空值按上键现在得到 0.0001(原先为 0.5 / 0.1),原本可用的粗调能力被破坏。更关键的是,提交信息所称的“限制为四位小数”只存在于浏览器原生校验层——保存路径 rowsToObject/parseToolPrice 只判断 Number.isFinite 且 >= 0,group-ratio-visual-editor 的 normalizeRatio 也只做 Number 解析,都不限制小数位;新增测试同样只断言 stepMismatch,未断言保存被阻止。因此用户仍可输入并保存 0.00001 这类超出四位小数的值,且界面不会给出任何错误提示(tool-price-settings 的 FieldError 仅由 parseToolPrice 返回 null 触发),四位小数约束实际未被强制。
Problem code:
Recommendation:
若确实要限制四位小数,请在保存/序列化路径显式校验精度(parseToolPrice、normalizeRatio 或提交前统一校验),并在不合规时用 FieldError 提示;同时不要把 step 设得远小于常规调增量,可用 step={0.1}(或 step='any')配合显式精度校验,避免上下箭头微调失效。
Prompt To Fix All With AI
This is a comment left during a code review.
Repository: https://github.com/Chloemlla/new-api
Path: web/src/features/system-settings/models/tool-price-settings.tsx
Line: 333
Comment:
价格与比率输入的 step 收紧到 0.0001 后,四位小数上限未在保存路径生效,同时数字输入的微调步长被一并改变
tool-price-settings.tsx 第 333 行以及 group-ratio-visual-editor.tsx 第 562、578 行把 <Input type='number'> 的 step 从 0.5 / 0.1 改为 0.0001。step 不只决定原生校验粒度,也决定数字输入上下箭头与键盘的微调量:空值按上键现在得到 0.0001(原先为 0.5 / 0.1),原本可用的粗调能力被破坏。更关键的是,提交信息所称的“限制为四位小数”只存在于浏览器原生校验层——保存路径 rowsToObject/parseToolPrice 只判断 Number.isFinite 且 >= 0,group-ratio-visual-editor 的 normalizeRatio 也只做 Number 解析,都不限制小数位;新增测试同样只断言 stepMismatch,未断言保存被阻止。因此用户仍可输入并保存 0.00001 这类超出四位小数的值,且界面不会给出任何错误提示(tool-price-settings 的 FieldError 仅由 parseToolPrice 返回 null 触发),四位小数约束实际未被强制。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Automated upstream sync by fork-sync.
QuantumNousmainChloemlla/new-apimainIf this PR has conflicts, please resolve manually. Clean PRs are auto-merged.