合入两处 Jules 改进,并补齐评审发现的缺口

Closed
JU
5d ago
+144-27

User description

这是 #2281 的循环重开:内容与 #2281 相同,另修评审与 CI 指出的真问题。

一是 #2276:给 YAML 行扫描加冒号前置检查、行内集合名改借用切片;评审一致指出的二次方开销问题已修:跟踪集合改回哈希表(借用切片保留),笔记里不实的“16 个上限”“零分配”说法也已纠正。

二是 #2275:给订阅 User-Agent 加长度与控制字符校验,入口与 HTTP 客户端两处都拦;评审指出的两处真问题已修:被后端拒绝的值不再静默留在本地冒充生效(恢复后端现值并提示),长度报错里的“512 字符”改成“512 字节”以符实际按字节计的口径。

本轮另修:

  • CI 的类型检查报错:回滚分支里直接对 getElementById 的结果取 value,现按文件既有写法转成 HTMLInputElement。
  • 回滚逻辑重做:只在校验拒绝时回滚,且恢复的是发送前快照(启用、类型、自定义文本三项齐全),不再把后端原始 UA 字符串硬塞进自定义框(预设用户切自定义后被拒会丢掉原自定义文本);非校验失败(IPC、落盘)不再冒充“被拒绝”,改为保留用户修改并提示下次修改时重试;发送后用户已输入新值或已有更新的同步在途时,旧失败不再覆盖新草稿;也不再用一次额外的 GET_SETTINGS 做恢复(那次往返本身就会竞态、失败时还会谎称已恢复)。
  • userAgentRejected 补上中英文翻译,此前所有语言都回落到英文硬编码;操作失败提示也补了中英文。
  • 订阅端对已存但超 512 字节的 UA 不再静默换成默认 UA:换之前记一条告警。

未改的一项:行扫描里锚点名按空白切分的旧逻辑(&a, 这类情形)是 #2276 改动之外的既有解析行为,是否真算非法 YAML 尚需对照解析器确认,留作单独立项,不塞进本轮。


CodeAnt-AI Description

Validate subscription User-Agent values and speed up YAML scanning

What Changed

  • Custom subscription User-Agent values with control characters or more than 512 bytes are rejected before saving, and the previous saved value is restored with a localized message.
  • If syncing fails for another reason, the edit is kept and users are told it will retry on their next change. Older failures no longer overwrite newer edits.
  • Subscription downloads use the default User-Agent when a previously saved value is invalid, with a warning instead of silently failing.
  • YAML configuration scans skip unnecessary work on lines without mapping separators, while keeping anchor checks efficient for large files.

Impact

✅ Fewer subscription download failures from invalid saved User-Agents
✅ Rejected User-Agent edits return to the saved value
✅ Faster scans of large YAML configurations

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.