fix(chat): 删除靠前 message 后保持滚动锚点稳定 (#2289) - #2437
Conversation
|
| Filename | Overview |
|---|---|
| apps/desktop/src/renderer/components/chat/MessageStream.tsx | 集中实现删除锚点采集、相邻内容选择、render window 重建,以及 focus/chip/跳底滚动的 generation 与补偿生命周期。 |
| apps/desktop/src/renderer/components/chat/AgentActionRow.tsx | 为展开工具行增加 message clientId DOM 锚点,使视口量测和删除恢复能够定位到具体工具行。 |
| apps/desktop/src/renderer/components/chat/useNavigationKeyListener.ts | 扩展滚动导航键的共享判定,使空格键接管程序化滚动,同时排除可编辑输入目标。 |
| apps/desktop/src/renderer/tests/focusScrollLifecycle.test.ts | 覆盖滚动 generation、用户接管、延期删除重放、目标重新解析和子锚点量测的回归场景。 |
| apps/desktop/src/renderer/tests/buildRenderItemsKeyStability.test.ts | 覆盖删除后相邻锚点选择、完整 clientId 顺序及滚动接管按键判定。 |
| apps/desktop/src/renderer/tests/agentActionRowRendering.test.ts | 验证工具行会暴露可供视口恢复使用的精确 clientId DOM 锚点。 |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[记录删除前视口锚点] --> B{消息是否在程序化滚动期间删除}
B -- 否 --> C[按旧序列选择存活锚点]
B -- 是 --> D[登记延期删除补偿]
D --> E{滚动如何结束}
E -- 正常落定 --> F[校正导航目标]
E -- 用户接管 --> G[取消当前 generation]
F --> H[刷新视口锚点]
G --> I[重放延期删除补偿]
I --> C
C --> J{目标是否在当前 render window}
J -- 是 --> K[恢复 message 或 render-item 偏移]
J -- 否 --> L[重建窗口并在 DOM 就绪后复位]
Reviews (33): Last reviewed commit: "fix(chat): 删除靠前 message 后保持滚动锚点稳定 (#2289..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 82e4467491
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
82e4467 to
6ee319a
Compare
|
已采纳 @greptile-apps 的发现并修复。 原问题:删除补偿 effect 之前读 修复:改用本 effect 每帧量测并缓存的「上一帧视口顶端」ref( 已 force push( |
|
The fix is well-reasoned and the implementation looks correct. A few observations on the approach: The ordering is the key insight. Capturing One edge case worth noting: The fallback for idx = Math.min(prevIdx, curKeys.length - 1);This correctly handles the case where the deleted item was the viewport top — it pins to whatever is now at that index position (the next surviving item). One subtlety: if The attribution comment is a nice touch. The approach is sound — using the layout effect's own per-frame measurement as the pre-deletion snapshot is strictly more accurate than relying on Tip: You can customize Greptile's behavior for this repo with |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ee319a9b2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@gardenZzz 👋 这个 PR 还有 6 条 review conversation 没 resolve(apps/desktop/src/renderer/components/chat/MessageStream.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bed39e9ef6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
bed39e9 to
8d27939
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8d27939f8c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
8d27939 to
a03e953
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a03e953f30
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
a03e953 to
57c4b01
Compare
57c4b01 to
56e762b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56e762b651
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
56e762b to
678c29f
Compare
678c29f to
66d7002
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 66d7002e0b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
此 PR 触发了维护者确认门(product:命中 UI 路径 MessageStream.tsx)。已创建讨论 issue,等待维护者确认后放行。 讨论 issue:#2456 |
66d7002 to
b3aa8b5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea96eb5ad3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
93d888d to
49038af
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93d888dfd7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49038af44c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
bef6541 to
6b31112
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b31112634
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
6b31112 to
57f007b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57f007b174
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@gardenZzz 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/components/chat/MessageStream.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
57f007b to
ad73002
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad73002b71
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ad73002 to
816b0e4
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 816b0e48dc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@gardenZzz 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/components/chat/MessageStream.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
816b0e4 to
e96fcce
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e96fcce7ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
e96fcce to
5296d91
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5296d91d95
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
5296d91 to
6da1192
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6da1192e5e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
删除后用删除前视口快照选择相邻存活内容;展开工作组内的子消息删除按完整 clientId 序列选邻居,不再跳过中间的工具行。视口子锚点同时识别 data-message-client-id 与工具块的 data-message-client-ids;chip/轨道跳转 把空格和滚动条拖拽视为用户接管,输入框内的空格除外。跳底 smooth 的 generation 在 scrollend、接管或安全超时后收尾,避免删除补偿被卡住。 用户接管时先解除乐观贴底并停止原生平滑滚动,避免延期删除重放被贴底 保护吞掉;会话还原落定后补量子锚点。 验证:ESLint 与 focusScrollLifecycle / buildRenderItemsKeyStability / scrollAnchoringDetect / agentActionRowRendering 共 123 个定向测试通过; 全量 test:unit 与 typecheck 交 client-ci。 Closes makecindy#2289 Signed-off-by: GardenX <20606485+gardenZzz@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
6da1192 to
36522dd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 36522ddab7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| itemElement.querySelectorAll<HTMLElement>( | ||
| '[data-message-client-id], [data-message-client-ids]', | ||
| ), |
There was a problem hiding this comment.
当视口顶边穿过已展开工作组里的 thinking 行时,这个查询无法记录该 child:ExpandedThinkingRow(WorkGroupBlock.tsx:203-287)没有 data-message-client-id,redacted 分支也同样没有。若该 thinking 消息随后被删除而同一工作组仍有其他子项,外层 render-item key 和可见条目数都不变,snapshotMessageGone 也不会成立,删除补偿会直接跳过并留下 Chromium 造成的视口跳变;应像工具行和普通消息一样给 thinking 行暴露其 clientId。 docs/dev-rules/engineering-conventions.mdL243-L248
Useful? React with 👍 / 👎.
|
@gardenZzz 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/components/chat/MessageStream.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
这次改了什么
摘要
删除会话中靠前的 message 后,聊天视口可能跳到错误位置。删除路径只更新 store,原有补偿在数组收缩时不会介入;Chromium 的
overflow-anchor又会在锚点元素本身被删时失效。本 PR 将删除、分组和程序化滚动的锚点处理收敛到
MessageStream:data-message-client-ids。data-message-client-id与折叠工具块的data-message-client-ids,避免外层 work-group key 仍在时跳过删除补偿。变更类型
fix缺陷修复范围
MessageStream.tsx、AgentActionRow.tsx、useNavigationKeyListener.ts与对应 key / anchor / focus 生命周期回归测试。UI 变化
不涉及视觉、文案、颜色或布局规范变更;仅修正既有聊天列表的滚动位置与导航接管语义。
docs/design-rules/DESIGN.md§14 Interaction Conventions;保持用户直接控制,用户滚轮、触摸、空格、滚动条或键盘接管后不再被旧程序化滚动拉回。怎么验证的
本地定向验证
CI 验证
36522ddab:push 后由 fork / 主仓 client-ci 执行,终态以该 SHA 的 run 为准。Signed-off-by。未在本地执行
pnpm test:unit全量:按维护者指示考虑本地机器负载,不在本机运行;交client-ci完整执行。client-ci的verify-checks。风险
提交前检查
Signed-off-by