feat: 翻译任务支持按任务选词库并通读摘要 - #436
Open
MaurUppi wants to merge 12 commits into
Open
Conversation
任务可显式选用参与匹配的词库,不再只能跟随全局 enabled 开关。
- core: 新增 resolveTaskGlossaryEntries(glossaries, ids)。筛选发生在
normalizeGlossaries 之后、enabled 过滤之前:给了 ids 就按 ids 取(忽略
enabled,关掉的库仍可被显式勾上),没给就按 enabled。两条路径都保持全局
order 排序与「同原文首个胜出」语义,冲突判定不随勾选顺序变化。
- core: 新增纯函数 describeGlossarySource() 生成来源标注,
logGlossaryConflicts / logGlossaryMatches 的 context 追加「任务词库 N 个」
或「全局已启用」,便于排查未命中原因。
- glossaryManager: 新增 getTaskGlossaryResolution(ids);
resolveEnabledGlossaryEntries / getActiveGlossaryResolution 保留为等价包装,
校对链路调用点不受影响。
- translateWithProvider: 已有 10 个位置参数,扩参走尾部 options 对象
({ glossaryIds }),避免错位;未传 options 的调用点日志字节级不变。
- types: IFormData.glossaryIds?: string[]。undefined = 回落全部已启用(旧配方
与历史快照的语义),[] = 明确不用词库,两者全链路不得互相塌缩;非数组的畸形
输入按 undefined 走旧行为。
- renderer: 新增 GlossarySelectControl 配置条多选,未建库时显示「去词库」链接
且不挡开始;停用库标注「已停用」仍可勾选;提供「恢复默认」写回 undefined。
- test: scripts/test-glossary.ts 扩 testTaskGlossarySelection,覆盖 undefined /
[] / 指定 id / 勾中 disabled 库 / order 不随勾选顺序变 / 未知与重复 id /
畸形输入 / 入参不被改写。63 → 87 passed。
任务选用的词库随 sidecar 落盘,校对台的单条优化 / 批量优化 / 重翻失败 三条链路都按任务词库工作,而不再固定读全局已启用。 - types/proofreadData: ProofreadDataMeta 增加 glossaryIds?: string[];meta 归一化 抽出 normalizeProofreadMeta + 纯函数 normalizeMetaGlossaryIds 做边界校验。 非数组 → undefined(旧 sidecar 回落全局已启用),数组只保留字符串成员, [] 保持 [](明确不用词库)。旧 sidecar 归一化后不写出显式 undefined 键。 PROOFREAD_DATA_VERSION 保持 2:meta 是展开合并、未知字段原样保留,无需 bump。 - proofreadData: writeProofreadDataFromFiles 增加 glossaryIds 参数,条件展开写入 meta;fileProcessor 调用点传 formData?.glossaryIds。 - subtitleCorrectionService: CorrectionParams 增加 glossaryIds?, getActiveGlossaryResolution() 改为 getTaskGlossaryResolution(params.glossaryIds); 不传时语义与此前完全一致。correctionRunner 从 formData 透传。 - ipcProofreadHandlers: 三个 handler 的 payload 增加 proofreadDataFile?, 经 readSidecarGlossaryIds 读取 meta.glossaryIds。无路径或读取失败 → 记 warning 并回落 undefined,独立校对模式(直接拖字幕进校对台)行为不变。 - renderer: ProofreadEditor 把 file.proofreadDataFile 透传给 SubtitleEditToolbar、 BatchAiOptimizeDialog 与 useRetranslateFailed,三处 invoke 带上该路径。 - test: 新增 scripts/test-proofread-data.ts 与 yarn test:proofread-data,覆盖 保留显式 id / 保留 [] / 旧 v1 与 v2 sidecar 无该键 / 五种畸形输入 / 非字符串 成员剔除 / 未知 meta 字段前后兼容。32 passed。
Product-level defaultSummaryPrompt plus settings.summaryPrompt with a restore-to-factory control. Translation page is now providers + summary panel. Empty stored drafts fall back to the factory template.
…nslation Add the test:summary seam and the runtime stage: optional per-file read-through before translate, independent AI provider, trivial-file skip, degrade-without-fail, and one-pass system prompt injection. Task UI can toggle the stage; non-AI translation keeps the summary for reference only.
Document task-level glossary selection, the translation-page summary
prompt, ${summary} as an optional placeholder, and the generate-summary
flow on the subtitle translation guide.
… size Plain-text summary calls now set structuredOutput=disabled so json_schema providers do not force the src/tr protocol. Trivial-skip and cost logs use the translation provider's capped batch size, not the summary provider's.
Add summaryFollowLabel, document ${summary} in systemPromptTips, and show
task glossary state plus follow-hint on the snapshot bar. zh/en keys stay
paired; check:i18n passes.
The factory draft no longer asks the summary model to rewrite names into glossary Chinese. Recap stays in the target language; names stay as in the source so later translation batches can align. Glossary appendix is for not inventing extra names. Tests and the enhancement plan follow.
The S01E06 hand-test facts stay. Retract the claim that source names in the summary prove the glossary table was sent. Record whole-episode matching versus per-batch injection, and that keeping source names is now the factory spec (b533bef).
Keep the archived task log with the plan and evidence chain. Drop the step-2 implement handoff; it is process-only and not needed upstream.
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.
摘要
启动台「翻译已有字幕」(及共用配置条的其它翻译路径)增加:
glossaryIds三态:未选 = 全部已启用,[]= 不用,显式 id = 含已停用库)不含
dist/、.next/、app/等编译产物。行为要点
summaryProvider缺省跟随翻译服务(须为已配置 AI)meta写入glossaryIds+episodeSummary,不 bump 版本;独立校对回落全局已启用yarn check:i18n通过内部文档(本 PR 一并带上)
docs/docs/summary_glossary_enhancement/summary_glossary_enhance_plan.mddocs/docs/summary_glossary_enhancement/evidence.mddocs/docs/summary_glossary_enhancement/summary_glossary_test.log(S01E06 手测归档,API Key 已脱敏)用户文档:
docs/docs/advanced/glossary.md、custom-prompts.md、features/subtitle-translation.md测试
yarn test:glossaryyarn test:summary(35)yarn test:proofread-datayarn check:i18nA.French.Village.S01E06.eng.srt(647 条 / 13 批),摘要注入首批 system,sidecar 落盘 676 字手测建议