Repository navigation
fix: group a turn whose anchor falls outside the first history page - #941
Merged
Merged
Conversation
The session detail route serves the most recent 50 entries by default, so a turn longer than that page is delivered without its leading user message. The render loop treats every message before the first anchor as standalone and pushes it directly, which skips the process-details grouping for that turn: the whole turn renders flat, with no collapsible group, even though it has a final answer. Group the anchorless leading segment as well. findFinalAssistantIndex already scans back to userIdx + 1, so passing -1 covers index 0, and groupStartIdx keeps the render range and the group key pointing at the first loaded message.
Owner
|
Reviewed. The bug is real: The fix is right as written:
Merged locally with current Generated by Claude Code |
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
…#907 agegr#941 agegr#946 agegr#961 agegr#968 agegr#969 agegr#1007 agegr#1008 agegr#1009 agegr#1010) 上游已把我们提前摘取的 agegr#884 / agegr#871 / agegr#996 / agegr#961 原样合并(agegr#961 逐字节相同), agegr#967 与 agegr#963 由上游的 agegr#1009 / agegr#1008 接管。 冲突解决: - demo/ 对齐上游 fe288c0,撤销 agegr#963 对 demo 的两处改动(`@/lib/chat-phase-label` 在 demo/lib 下不存在,会打断 Pages 构建)。 - AGENTS.md:保留我们的 default-project 条目,open-folder 换成上游的 open-in-explorer。 - MessageView.tsx / SessionSidebar.tsx / FileExplorer.tsx:以上游为准, DismissButton 采用上游的独立文件,保留我们的思考卡片与文件管理改动。 - SessionSidebar 移除引用已删函数的旧 agegr#951 工作区按钮(agegr#951 的其他入口另行收尾)。
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…gegr#941) The session detail route serves the most recent 50 entries by default, so a turn longer than that page is delivered without its leading user message. The render loop treats every message before the first anchor as standalone and pushes it directly, which skips the process-details grouping for that turn: the whole turn renders flat, with no collapsible group, even though it has a final answer. Group the anchorless leading segment as well. findFinalAssistantIndex already scans back to userIdx + 1, so passing -1 covers index 0, and groupStartIdx keeps the render range and the group key pointing at the first loaded message. Co-authored-by: wayne.luo <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…gegr#941) The session detail route serves the most recent 50 entries by default, so a turn longer than that page is delivered without its leading user message. The render loop treats every message before the first anchor as standalone and pushes it directly, which skips the process-details grouping for that turn: the whole turn renders flat, with no collapsible group, even though it has a final answer. Group the anchorless leading segment as well. findFinalAssistantIndex already scans back to userIdx + 1, so passing -1 covers index 0, and groupStartIdx keeps the render range and the group key pointing at the first loaded message. Co-authored-by: wayne.luo <[email protected]>
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
A turn longer than the first history page renders completely flat: every thinking block and tool call is laid out inline, with no "Process details" group to collapse, even though the turn ended with a normal final answer.
app/api/sessions/[id]serves the most recent 50 visible entries by default, andloadSession()does not overridetail. When a single turn contains more than 50 entries, the first page starts in the middle of it and the leading user message is simply not inmessages.The render loop then hits this branch for every message in that page:
With no anchor anywhere in the page, the turn never reaches the grouping path, so
ProcessDetailsGroupis never constructed.Reproduction
On a real 5818-entry session here, the latest user message sits 100 entries from the end, and the first page contains 24 assistant + 24 toolResult + 2 custom messages and zero anchors.
Before (current
main, a 60-tool-call turn — the page keeps scrolling like this all the way up):After (this branch, same session):
Fix
Treat the anchorless leading segment as its own group instead of flattening it.
findFinalAssistantIndexalready scans back touserIdx + 1, so passing-1covers index 0 without touching that helper.groupStartIdxkeeps the flat-render fallbacks and the group key pointing at the first loaded message, and the user bubble is only pushed when the anchor is actually present.Loading is untouched — still 50 entries — so there is no extra transfer or parse cost. The grouped page renders fewer DOM nodes than before, because the process messages now sit inside a collapsed group.
I considered widening the initial window server-side instead, but measured it as clearly worse: extending
tailto cover a full turn grew the first-page payload 2.8x–7.5x across local sessions (183 KiB to 556 KiB, 253 KiB to 711 KiB, 113 KiB to 842 KiB), while the client-side fix costs nothing.Verification
components/ChatWindow.process-details.test.mjs— new case for the paginated leading segment.npm test,tsc --noEmit,npm run lint— clean on this branch merged onto currentmain(v0.9.3).mainand this branch.