Repository navigation
fix(mobile): keep older history reachable after a byte-trimmed refresh - #799
Merged
Merged
Conversation
Sending a message in a long session refreshed the timeline through the desktop bridge, whose 512KiB backward-page budget sheds whole oldest exchanges and advances the cursor past them. The mobile gap-fill integrity check (start + entries.length === before) rejected that shape, failing the whole refresh — the visible conversation collapsed to the tail, and the stale paging cursor could never rejoin it, so older questions vanished and could not be scrolled back. - bridge: a chunked reader may now pass untrimmed to opt out of the backward-page byte budget explicitly (it reassembles the reply from chunks anyway). - mobile: on the trimmed shape (flush failure with hasMore), re-read the same range untrimmed and bridge the gap from it in the same pass instead of throwing. - mobile: keep the retained paging cursor only while the fresh window actually joined the retained prefix (exact join or bridged gap); a wholesale-replaced or grown-past window hands paging to its own cursor.
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.
问题
在一个本来正常的长会话里追加提问后,移动端只剩最新的提问和回答,前面的内容全部消失,上滑也无法找回。
根因
追加提问触发 timeline 刷新(resend/restart),走 desktop bridge 的
get_session_entries回拉页。bridge 对超过 512KiB 的回拉页做字节预算截断(prepare_backward_entries_page_with_cap):整段砍掉最旧的对话、把nextOffset前移、并始终hasMore=true。移动端的 gap-fill 完整性校验(
start + entries.length === nextBefore)把这种形状当作游标非法,整个 refresh 抛错失败。失败后 SyncEngine 保留最后一次 commit 的快照——而那个快照只剩 bridge 截断后的 tail(最新一问)。同时分页游标被 abort 污染,loadOlderTimeline也无法再把旧内容拉回来。服务端/agent 数据其实一直在(本会话 236 条 display 记录、2 条用户消息都完整),纯是客户端配合 bug。
修复
desktop/src-tauri):chunked 客户端可显式传untrimmed: true跳过回拉页的字节预算截断(chunked 读取本来就分块重组回复,不受单条 512KiB 限制)。useTimelineController.loadHistory):遇到"flush 校验失败但 hasMore"的 trim 形状时,用 untrimmed 重读同一区间,就地桥接 gap,而不是整个 refresh 失败。测试
a byte-trimmed gap page re-bridges in place without losing history:模拟 open → loadOlder → 追加提问触发 refresh → 命中截断页,断言旧历史 + 新内容全部保留、游标可继续回拉。cargo clippy --all-targets -- -D warnings干净,cargo test --lib remote248 通过。