Repository navigation
fix(input): 输入翻译不看输入长度,一万字照样整段送出 → 超过阅读侧单个翻译单元的上限(MAX_TEXT,3072 字符)时不发请求、不分段,提示删减后再试(#643) - #701
Merged
Merged
Conversation
…发请求、不分段,提示删减后再试(#643) Co-Authored-By: zhexuancai-uts <261878103+zhexuancai-uts@users.noreply.github.com>
Co-Authored-By: zhexuancai-uts <261878103+zhexuancai-uts@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
输入翻译不看输入有多长,粘一万字进去点圆点照样整段送出。这既花掉远超正常的配额,又可能撞上引擎的长度限制。阅读侧对单个翻译单元早有上限,输入翻译这一侧没有。
根因
translateInput()拿到框里的文字后直接走判定链和单文本入口,中间没有任何长度判断。阅读侧的上限MAX_TEXT(3072 字符)只用在页面分段采集里。修复
decideInputLength()(src/ui/input-length.ts)MAX_TEXT,计数方式也相同:去掉首尾空白后的长度{ ok: false, reason: 'too-long', limit }messages.json末尾新增toastInputTooLong(带limit占位符)验证
input-length.test.ts,5 条MAX_TEXT同一个常量chrome.i18n.getMessage计算pnpm test115 个文件 1417 条全绿;pnpm typecheck通过;pnpm build通过pnpm test:e2e:core89 过、2 跳过、1 不稳定:TC-E2E-105 是 DeepSeek 权限的整页翻译路径,与本票无关Closes #643