Uh oh!
There was an error while loading. Please reload this page.
fix(ui): only show the previous-question button when a previous question exists - #2355
Merged
jackwener merged 1 commit intoAug 7, 2026
Merged
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Astro-Han
left a comment
Contributor
There was a problem hiding this comment.
Thanks — the core condition is right (questionIndex > 0, and the array is dense so it always equals 'a previous question exists'), the request event is atomic so streaming can't half-populate it, and the e2e pins the Q1-hidden/Q2-shown contract including 'not a disabled one'. CI green.
Four optional nits:
- One-frame dirty render on session switch: staying on index>0 then switching sessions renders one frame of the new request's question with the old draft + previous button, before the effect resets. Pure visual (the click gets reset anyway), but a key={requestId} remount or an effect-less derivation would kill it.
- Narrow containers: the footer grid moves 下一题 from col2 to col3 on Q2, so a fast double-click on the first question lands on the newly-appeared 上一题 and pops back — looks broken on ≤460px. Desktop width is fine (col4 is pinned).
- Back-navigation focus is unpinned: only the forward direction has a toBeFocused assertion; the return path drops focus to body (same as before this PR, just untested).
- The reset effect itself has zero coverage: unit tests only render index 0; a future refactor that breaks the sync would pass everything. One component test (advance to index>0, swap props.request, assert reset) would pin it cheaply.
Merging.
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 freeto 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.
Closes#2354
问题
AskUserQuestion 弹窗底部操作区始终渲染"上一题"按钮,只用
isDisabled在questionIndex === 0时禁用:questionIndex恒为 0,按钮永远禁用但一直占据 UI期望:第一题(含单问题场景)不显示"上一题";从第二题开始才显示。
修复
packages/ui/src/user-question-prompt.tsx:将无条件渲染 +isDisabled改为按questionIndex > 0条件渲染,并去掉冗余的questionIndex === 0禁用判断(渲染条件已保证"有题可回")。测试
conversation-localization.test.tsx,+2):单问题不渲染上一题/Previous;多问题首题不渲染ask-user-question.spec.ts,扩展三题流程):首题按钮toHaveCount(0);次题出现"上一题",点击回退后已选答案保留、按钮消失,再前进继续原流程packages/ui444/444 通过;ask-user-question.spec.ts2/2 通过(Playwright + Electron);biome 干净行为对照