Repository navigation
fix(ui): keep the active prompt tick visible after resize - #2572
Conversation
Astro-Han
left a comment
There was a problem hiding this comment.
Approved — I found no reproducible P0–P3 issues at dc74d257.
This fixes the actual ownership gap cleanly. The active prompt was already correct; what became stale was the rail’s independent viewport geometry. Observing the rail itself therefore follows the real source of change without copying window or composer dimensions into another state path.
The implementation also preserves the existing rail-only scrollTop correction instead of switching to scrollIntoView, so it cannot accidentally move the transcript ancestor. The focused test covers both overflow directions, the initially visible case, the observed target, and cleanup. I do not see low-value coverage or production code that should be removed.
I also checked the three-way combination with current main after #2680. It merges without conflict and retains both the required scrollBehavior contract and this resize correction.
中文对照
批准——在当前 head dc74d257 上没有发现可复现的 P0–P3 问题。
这个改动准确修复了真实的职责缺口。active prompt 本身一直是正确的;失效的是独立变化的 rail viewport 几何。因此直接观察 rail 是符合真实变化来源的方案,不需要把 window 或 composer 尺寸复制到另一条状态路径中。
实现还保留了原有只调整 rail 的 scrollTop 逻辑,没有改成 scrollIntoView,因此不会意外滚动 transcript ancestor。聚焦测试覆盖了上下两个溢出方向、初始已可见状态、observer 目标以及 cleanup。我没有看到应当删除的低价值测试或生产代码。
我也核对了它与 #2680 合并后的当前 main 的三方组合:没有冲突,并且会同时保留必填的 scrollBehavior 契约和本 PR 的 resize 修复。
Disclosure: Codex assisted by inspecting the full diff, issue reproduction evidence, observer lifecycle, focused tests, CI, and the three-way combination with current main. Astro-Han reviewed the resulting evidence, determined the finding threshold, and made the final approval decision.
Summary
The prompt rail currently corrects its active tick only when the active turn changes. When the composer or window later reduces the rail viewport, that same tick can become hidden even though the active turn has not changed.
This keeps the existing rail-only scroll arithmetic and rechecks it whenever the rail's own box resizes. The observer is disconnected with the component effect, and focused coverage exercises both lower and upper overflow after a resize.
Fixes #2324
中文对照
Prompt rail 目前只在激活 turn 变化时校正激活刻度。如果 composer 或窗口随后压缩了 rail 的可视区域,激活 turn 虽未变化,对应刻度仍可能被遮住。
本 PR 保留现有只滚动 rail 的位置计算,并在 rail 自身尺寸变化时重新校正。observer 会随组件 effect 断开;聚焦测试覆盖了 resize 后刻度从下方和上方溢出的情况。
Verification
npm --workspace @maka/ui test— 264 tests passednpx biome check packages/ui/src/prompt-anchor-rail.tsx packages/ui/src/__tests__/prompt-anchor-rail.test.tsgit diff --check origin/main...HEADChecklist
Does this PR entail a change in behavior?