Repository navigation
fix: 修复固定标签触发 LRU 淘汰或分屏初始化后消息区空白问题 - #1830
Merged
Merged
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Author
Type
Summary
问题
view-registry.ts中存放会话视图的views使用了原生非响应式Map。当某个已打开的聊天标签隐藏在后台由<KeepAlive>保活,用户在其他标签连续浏览超过 12 个会话(CHAT_SESSION_VIEW_CACHE_LIMIT = 12)触发 LRU 淘汰时,旧ChatViewEntry被清空并从Map删除;再次切回原标签时,由于botId/sessionId/viewId均未变化,ChatPane的paneView计算属性不会重新求值,持续引用已被清空的旧对象,而新拉取的历史消息写入了新建的ChatViewEntry,导致消息区一片空白(关闭标签页销毁组件重开后才恢复)。initialize()时,stopStreams()会中止所有已恢复分屏面板在途的初始历史加载,但initialize()结束时只为当前焦点所在的单个sessionId调用startSessionRuntime,导致其余可见分屏会话停留在未初始化的空白态。修复
view-registry.ts中的views改为shallowReactive(new Map<string, ChatViewEntry>()),按单个会话 key 建立浅层响应式依赖:被淘汰并重建的会话在标签重新激活时会自动重绑到新的ChatViewEntry,同时既不递归代理条目内部属性,也不会触发其他未变动面板的多余重算。view-registry.ts提供visibleSessionIds(botId),并在bootstrap.ts的initialize()完成 WebSocket 启动后,为当前 Bot 下所有处于可见状态的会话视图恢复startSessionRuntime。Related Issues
Validation
自动化检查
pnpm vitest run apps/web/src/store/chat/view-registry.test.ts apps/web/src/store/chat/bootstrap.test.ts apps/web/src/store/chat/cache-revisit.test.ts apps/web/src/store/chat-list.test.ts:167/167 全部通过(含新增的隐藏标签淘汰重建重绑与单 key 隔离测试、分屏可见会话初始化恢复测试)。node scripts/check-ui-contract.mjs:通过。eslint):通过。mise run lint与后端测试未在本地全量运行(本次仅改动apps/web),由 CI 覆盖。Agent 本地运行与真实界面验证(非真人 QA)
memoh-dev后端(127.0.0.1:18080)+ 修复前前端(localhost:18082)与本分支前端(http://127.0.0.1:8084)。[data-message-id]数量从2变为0。[data-message-id]数量保持为2。Screenshots / Recordings
修复前(触发 12 会话 LRU 淘汰后切回固定标签,消息区空白)
修复后(相同操作路径切回固定标签,正常重绑并渲染对话)
Human QA