Commit Graph
4 Commits
Author SHA1 Message Date
Metona 1e3f4d4ba5 fix: 彻底修复RAG下消息不显示 - 用模块变量替代CSS选择器
根本原因:所有CSS选择器方案都依赖DOM位置关系,
而 appendSystemMessage 在 placeholder 之后插入 div 会破坏这种关系。

解决方案:用模块变量 currentPlaceholder 直接持有 placeholder DOM 引用,
updateLastAssistantMessage 直接读取该引用,完全不依赖选择器。

- appendAssistantPlaceholder: 设置 currentPlaceholder = div
- updateLastAssistantMessage: 使用 currentPlaceholder,首次调用移除 loading
- clearMessages: 清除 currentPlaceholder
2026-04-05 00:38:35 +08:00
Metona 1de1084173 fix: 第一个chunk后loading class被移除导致后续内容更新全部跳过
updateLastAssistantMessage 的首次调用找到 .message.assistant.loading 后
立即 remove('loading'),导致后续 chunk 调用时选择器找不到元素,直接 return。

修复:
- 首次调用:找到 .loading,移除 loading 指示器,但保留 class 直到流结束
- 后续调用:.loading 选择器失败时回退到 .message.assistant:last-of-type
- loading class 在 sendMessage 的 try/finally 或 catch 中统一移除
2026-04-05 00:34:23 +08:00
Metona 86a2797d44 fix: 用 loading class 精确定位placeholder,修复RAG下loading不消失
上次用 :last-of-type 修复无效(:last-of-type 也是按元素类型div匹配,
系统消息也是div,一样命中不了placeholder)。

改用给 placeholder 加 .loading class 的方案:
- appendAssistantPlaceholder 添加 .loading class
- updateLastAssistantMessage 用 .message.assistant.loading 选择器
- 成功/失败后移除 .loading class

选择器不再依赖 DOM 位置,彻底不受 appendSystemMessage 影响。
2026-04-05 00:29:08 +08:00
Metona f3589ae057 fix: RAG开启时AI回复后loading动画不消失的问题
根因:appendSystemMessage() 在 assistant placeholder 之后插入了一个无 .message class 的 div,
导致 CSS 选择器 .message.assistant:last-child 无法命中 placeholder(它不再是 :last-child)。
updateLastAssistantMessage() 返回 null,loading 动画永远不会被移除。

修复:将 3 处 :last-child 改为 :last-of-type,使选择器基于元素类型(div)而非精确的最后一个子节点匹配。
2026-04-05 00:22:24 +08:00