Skip to content

fix(reader): 返回原进度后恢复 TTS 跟读跟随 - #47

Merged
zilorn merged 1 commit into
mainfrom
codex/tts-restore-follow
Nov 7, 2026
Merged

zilorn merged 1 commit into
mainfrom
codex/tts-restore-follow

Conversation

@zilorn

@zilorn zilorn commented Nov 7, 2026

Copy link
Copy Markdown
Owner

解决的问题 / Problem

Fixes #45

使用文本 TTS 听书时,通过目录跳到其它章节,再点击「返回原进度」回到原阅读位置后,页面上的朗读句虽然仍在继续播放,但跟读跟随状态丢失(followEnabled 仍为关闭),后续朗读不再自动翻页。

原因是 restoreJumpOrigin 只调用了 cancelFollowIfActive(),没有像手动翻页、进度条跳页、目录跳章那样在落点重新判定「跟读页」;同时 resumeTarget 精确定位尚未落定时页码仍是暂态值,提前判定会误判。

改动后的行为 / Resulting behavior

  • 分页模式下,点击「返回原进度」落回当前朗读句所在屏(双页模式含右页)时,自动恢复跟读跟随。
  • 返回后的落点不是朗读句所在屏,或朗读已推进到其它章节时,保持取消跟读,不把视图强行拉走。
  • 精确定位(resumeTarget)未落定前保持判定挂起,等页码/滚动位置真正落定后再补判,避免按旧页码误恢复。
  • 滚动模式沿用既有策略,不参与「跟读页」自动恢复;本次不改变该行为。
  • 无界面文案变化,无新增截图;补充了对应回归脚本与前端技能约束。

验证 / Validation

  • 类型检查 / Type check: pnpm exec tsc --noEmit 通过。
  • 文案检查 / i18n check: pnpm run i18n:check 通过(中文 1406 条、英文基础 key 1406 条)。
  • 前端构建 / Frontend build: pnpm build 通过。
  • Rust 测试(如适用)/ Rust tests (if applicable): 不适用 / N/A,未修改 Rust。
  • 手动验证 / Manual verification: 未在真实 Android / 桌面设备上做 TTS 播放交互实测。已运行抽取 Reader 实际逻辑的回归脚本:
    • node scripts/tts-follow-recovery-test.mjs 通过,新增单/双页返回跟读屏、落点非朗读屏、暂态页码不提前恢复、跨章返回、章首返回等用例;并已做变异验证:移除修复后该脚本在「返回原进度落回跟读屏后恢复跟随」处失败。
    • reader-page-turn-test、reader-position-transition-test、reader-auto-page-test、tts-segment-test、tts-timer-test 均通过。
    • tts-replacements-test 在与构建并行首跑时出现一次请求顺序断言失败,单独重跑 3 次均通过;该脚本不涉及本次改动,判断为既有并发时序波动。

数据与兼容性 / Data and compatibility

不涉及 / N/A。未修改持久化格式、迁移或书源引擎;仅调整阅读页 TTS 跟读恢复判定。

提交前检查 / Checklist

  • 已阅读 CONTRIBUTING.md 与 AGENTS.md / I read CONTRIBUTING.md and AGENTS.md.
  • 仅包含本次任务相关文件 / Changes are limited to this task.
  • 已更新相关文档与中英文文案(如适用)/ Relevant docs and both locales are updated where applicable.
  • 已完成适用检查,并说明未验证的部分 / Applicable checks are complete and unverified parts are explained.

@zilorn
zilorn merged commit 902e6b4 into main Nov 7, 2026
3 checks passed
@zilorn
zilorn deleted the codex/tts-restore-follow branch November 7, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

用目录跳转章节后,点击返回原进度,会失去tts跟读

1 participant