Repository navigation
feat(mobile): jump between questions in the chat transcript - #811
Merged
Merged
Conversation
A long answer pushes its question out of reach, so reading back to the start of the turn you are in meant a long scroll. Once the viewport leaves the tail, the chat now shows a stack of two round buttons on the right edge — ↑ to the closest question start above the reading position, ↓ to the closest below. The landed question sits 12px under the list's top edge and is marked for a moment so the eye can find what moved. The shape is option A of the four on the style sheet (44px circles, the platform's minimum touch target, clear of the composer and of the reading column). The two directions are one ladder, so each press moves exactly one question and the landed question is never its own target again. The anchor is derived from what the list reports as viewable (partly and fully visible rows) rather than from row geometry, because a row's `onLayout` `y` is relative to its own virtualized cell. Reading state is the union of the native drag signal owned by `useChatScroll` and the measured offset: a web build never reports a drag, and a native build reports a drag before any offset exists. The jump is exact rather than approximate: `viewPosition: 1` aligns the target's cell, and an inverted cell lays the list's own row gap out above its row, so the delivered inset is that gap plus the passed offset. A row outside the measured window falls back to an average-height estimate and is re-issued once it has been rendered. Harness: `?multiTurn=1` adds a several-turn demo conversation (there was nothing to jump between with one exchange), and three scenarios cover the shape (`qn-nav-variants`, with the two still-open additions as proposal panels), the states after each press (`qn-jump-states`) and the alignment as a numeric assertion (`qn-align-check`: 12px ±2, plus which question the jump must land on).
huichen
enabled auto-merge (squash)
September 24, 2026 02:12
auto-merge was automatically disabled
September 24, 2026 02:14
Pull request was closed
huichen
enabled auto-merge (squash)
September 24, 2026 02:14
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.
问题
长回答会把它的提问顶出屏幕。流式输出结束后想回到"本轮提问的开头",要往上滑很长时间;而聊天的所有滚动手段都是单向的(只能回最新,不能按"提问"跳)。
做法
视口离开最新之后,聊天右缘出现一组圆钮(采纳样式表中的 A 形态):
两枚 44×44(
layout.touchTarget)圆形按钮,间距 8px,右缘距屏幕边 16px(layout.gutter),底边离输入框 16px;不压输入框、不压发送键、不压消息列。没有目标的方向置灰但不消失,所以另一个钮不会因为状态变化在拇指底下移动。定位与对齐
column-reverse),所以viewPosition: 1对齐单元格后viewOffset是"间距 − 目标内缩",不是内缩本身。onLayout的y——那个坐标是相对虚拟化单元格的,拿不到全篇位置。useChatScroll已有)+ 实测滚动偏移。web 侧永远不上报拖拽(react-native-web 没有onScrollBeginDrag的等价物),原生侧拖拽时还没有偏移。改动
产品代码:
questionNav.ts(纯逻辑:提问索引、梯子、落点)、useQuestionNav.ts(锚点/跳转/落点高亮)、QuestionNavControl.tsx(A 形态控件)、ChatScreen.tsx接线、i18n 两个 key、两个测试文件(16 + 7 条)。截图工装:
?multiTurn=1加了一段多轮演示对话(原来只有一轮,没有可跳的东西),两个场景覆盖行为与对齐:qn-jump-states:滚动后 / 按 ↑ 后 / 按 ↓ 后三格,并用aria-disabled读数断言每格的可用性;qn-align-check:把对齐写成可失败的数值断言(落点行距列表顶边 12px ±2,且必须落在预期那个提问上)。验证
npx tsc --noEmit、npx eslint .、移动端 jest 全量:1893 passed / 125 suites(在 merge 了 origin/main 的树上跑的)。qn-align-check实测{"inset":12,"question":"把 Dreher"};该场景的eval断言失败会让截图非零退出(不是"点了没反应"式假通过)。mobile/与scripts/screenshots/,未触碰 Rust/desktop。范围与已知项
onScrollBeginDrag);该路径靠useChatScroll现有行为 + 平移量兜底。