Conversation
新建会话发送路径持有 createSession 返回的裸 id,而 UI/SSE/loadSession 一律用 serverId::sessionId 复合键:setStreaming 与 1500ms 兜底拉取全部 落到 UI 永远不读的裸键上。初始消息快照一旦读于发送提交之前 (prompt_async 立即返回、用户消息异步落库),setMessages 会把 SSE 刚推来的用户消息整表擦掉,兜底又写错键,只能靠刷新恢复。 - sendMessageNow 创建会话后立即以 paneServerId 合成复合键, 兜底的 handleMessageUpdated/handlePartUpdated 写入同样带 scope - mergeWithLocalStreamingMessages 在初始加载在途(loading)时也保留 本地独有消息,且仅限不早于快照最新的消息(窗口外旧历史照常丢弃), 不再依赖 prompt_async 响应先于快照响应到达的时序假设
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.
Problem
In a newly created session, the first user message can disappear from the chat until the page is refreshed.
The race is between
prompt_asyncand the initialgetSessionMessagessnapshot: the snapshot can be read before the user message is committed. The live message then gets overwritten by that stale snapshot.The multi-server session-key migration also exposed a second issue:
createSession()returns a raw session ID, while the message store and SSE pipeline useserverId::sessionId. The new-session send path used the raw ID forsetStreamingand its fallback pull, so those writes went to a key the UI never reads.Fix
makeSessionKey(paneServerId, newSession.id).Verification
npx vitest run— 670 tests passednpx tsc --noEmit— passed