Repository navigation
fix(chat-history): preserve image chronology across collapse - #2158
Merged
Merged
Conversation
Pre-commit hook ran. Total eslint: 0, total circular: 0
Pre-commit hook ran. Total eslint: 0, total circular: 0
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
Loading a Claude Code session can move a browser screenshot below the last assistant reply. The raw JSONL and parser associate the image with its earlier tool result, but the shared chat projection attaches turn images to the final surviving row. Expanded and collapsed histories therefore show the wrong chronology.
Solution
Attach galleries to their producing chat items before turn collapse. Keep gallery-only rows at those positions when tool text is collapsed, preserving image-only turns, compact tool stacks, and user-message attachments. The native regression fixture imports a Claude Code JSONL through the actual app and asserts that the loaded screenshot precedes the final reply. No transcript or persistence format changes.
Potential risks
Collapsed turns with several image-producing items now have several gallery rows; virtualized row counts and search mappings use those rows. Repeated image references from different producing items remain separate occurrences. Desktop scroll anchoring after lazy hydration, reload/restart, and CPU/RSS remain unverified. The pre-existing lazy-replay E2E has a stale pagination expectation and fails before reaching its media assertions; the focused native import scenario passes. The local native run required an uncommitted development-server proxy compatibility shim because the installed webpack-dev-server rejected the repository's object-shaped proxy config; CI does not run that native scenario. Rollback is a code revert; original history is untouched.
Verification
pnpm test src/engines/ChatPanel/ChatHistory src/engines/ChatPanel/rendering— 74 files / 668 tests passedpnpm typecheck:fast, changed-file ESLint with--max-warnings 0,pnpm check:circular,pnpm check:test-placement, andgit diff --check— passedE2E_CHAT_RENDERING_SCENARIOS=claude-imported-image-order pnpm test -- --spec './specs/core/chat-rendering-ui.spec.mjs'— passed locally with the temporary development-server proxy shim (1 scenario); the app discovered on-disk Claude Code JSONL, opened it through the rendered sidebar, and showed the loaded image at flat index 9 before the reply at index 10claude-imported-lazy-replay— failed before image checks because current UI renders all ten fixture rounds and no longer showsturn-pagination-current-round; tracked separately from this ordering fixVisual evidence
The native screenshot shows the isolated Tauri app after Claude Code JSONL ingestion. The component screenshots cover light desktop and narrow dark framing. Fixture media and text contain no private transcript data.
Architecture and lifecycle details:
docs/org2-performance-guard-2026-09-26/HistoryImageOrder.md.