Repository navigation
fix(wework): preserve viewport during virtualized streaming - #2298
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughThe PR keeps active streaming messages mounted outside the visible virtual range, expands the desktop streaming scenario with scripted history turns, and updates scroll, anchoring, task-switching, virtualization, and diagnostic documentation in English and Chinese. ChangesStreaming virtualization and E2E validation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Scenario
participant TauriApp
participant MessageList
participant MockSSE
Scenario->>TauriApp: submit history and streaming prompts
TauriApp->>MockSSE: request scripted response
MockSSE-->>TauriApp: emit assistant completion or append content
TauriApp->>MessageList: update message status and content
MessageList-->>Scenario: preserve virtualized row and scroll state
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
wework/src/components/chat/MessageList.tsx (1)
309-318: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winDedupe
forcedIndexesbefore merging —forceVirtualMessageIdcan collide with the streaming index.
[forcedVirtualMessageIndex, streamingVirtualMessageIndex].filter(index => index >= 0 && !indexes.includes(index))only excludes indexes already present in the baseindexesarray; it does not dedupe the two source values against each other. If a caller setsforceVirtualMessageIdto the id of the currently streaming message (e.g. turn navigation jumping to the actively-streaming turn — exactly the scenario exercised by the newSTREAMING_TURN_INDEXE2E check),forcedVirtualMessageIndex === streamingVirtualMessageIndex, and the same index is pushed twice intoforcedIndexes. The final range then contains that index twice, somessageVirtualizer.getVirtualItems()yields two rows with the identicalkey(fromgetItemKey), producing a React duplicate-key warning and unpredictable duplicate/overlapping DOM for that message.🐛 Proposed fix
- const forcedIndexes = [forcedVirtualMessageIndex, streamingVirtualMessageIndex].filter( - index => index >= 0 && !indexes.includes(index) - ) + const forcedIndexes = Array.from( + new Set([forcedVirtualMessageIndex, streamingVirtualMessageIndex]) + ).filter(index => index >= 0 && !indexes.includes(index))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@wework/src/components/chat/MessageList.tsx` around lines 309 - 318, Update the rangeExtractor callback to deduplicate forcedVirtualMessageIndex and streamingVirtualMessageIndex against both the base indexes and each other before merging. Ensure the returned sorted range contains each virtual message index at most once, including when both forced values are identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@wework/src/components/chat/MessageList.tsx`:
- Around line 309-318: Update the rangeExtractor callback to deduplicate
forcedVirtualMessageIndex and streamingVirtualMessageIndex against both the base
indexes and each other before merging. Ensure the returned sorted range contains
each virtual message index at most once, including when both forced values are
identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 727462c1-e778-4a2f-930a-da8eba769c3c
📒 Files selected for processing (7)
docs/en/wework/developer-guide/wework-e2e-automation.mddocs/en/wework/developer-guide/wework-performance-diagnostics.mddocs/zh/wework/developer-guide/wework-e2e-automation.mddocs/zh/wework/developer-guide/wework-performance-diagnostics.mdwework/e2e/desktop/scenarios/streaming-text.scenario.mjswework/src/components/chat/MessageList.tsxwework/src/components/chat/MessageList.virtualization.test.tsx
f14f943 to
b6dcee3
Compare
问题
长对话启用消息虚拟化后,用户在 AI 流式输出期间向上阅读历史内容,活动中的助手消息会离开虚拟列表渲染范围并被卸载。它在屏幕外继续增长时无法被测量,最终重新挂载时会从估算高度跳到真实高度,导致当前阅读位置和最终
scrollTop漂移。修改
scrollTop在流式完成及重新打开任务后保持稳定。验证
pnpm --filter wework test(233 个测试文件、2319 个测试通过)pnpm --filter wework e2e:desktop:streaming-textWEWORK_PORT=1421 pnpm --filter wework ai:verify startSummary by CodeRabbit
Bug Fixes
Documentation
Tests