Persist screenshot images through history and cache decoded NSImage#1905
Merged
Conversation
1. Thread imageData through history_response: extract base64 image data from persisted contentBlocks in tool_result blocks during history reconstruction, so screenshot previews survive session reload. 2. Cache decoded NSImage on ToolCallData to avoid repeated base64 decoding inside SwiftUI body on every re-render. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 task
Contributor
Author
|
Addressed in #1908 |
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.
Summary
Addresses two pieces of review feedback from PR #1863:
Thread imageData through history hydration: Screenshot image data was only forwarded on the live
tool_resultstream path. After reopening a session,history_responsepayloads didn't include image bytes, so screenshot previews disappeared. NowrenderHistoryContentextracts base64 image data from persistedcontentBlocksontool_resultblocks, carries it throughmergeToolResults, and includes it in thehistory_responsewire format. The Swift client'spopulateFromHistorypassesimageDatatoToolCallData.Cache decoded screenshot image outside SwiftUI body: Previously,
ToolCallChipdecoded base64 intoDataandNSImagedirectly insidebody, causing repeated heavy work on every SwiftUI re-render. NowToolCallDatahas acachedImage: NSImage?property that's decoded once at init time (or whenimageDatais assigned on tool result), and the view reuses the cached image.Files changed
assistant/src/daemon/handlers.ts— Extract imageData from contentBlocks inrenderHistoryContent, carry throughmergeToolResultsassistant/src/daemon/ipc-protocol.ts— AddimageDatatoHistoryResponseToolCallclients/shared/IPC/IPCMessages.swift— AddimageDatatoHistoryToolCallItemclients/macos/.../ChatMessage.swift— AddcachedImagetoToolCallData, decode once at initclients/macos/.../ChatViewModel.swift— PassimageDatainpopulateFromHistory, setcachedImageon live tool_resultclients/macos/.../ToolCallChip.swift— Use cachedNSImageinstead of decoding inbodyTest plan