Defer CodeDiffView editor creation for restored AI conversations#10032
Draft
kevinchevalier wants to merge 1 commit intomasterfrom
Draft
Defer CodeDiffView editor creation for restored AI conversations#10032kevinchevalier wants to merge 1 commit intomasterfrom
kevinchevalier wants to merge 1 commit intomasterfrom
Conversation
When restoring AI conversations on startup, CodeDiffView eagerly created full CodeEditorView + InlineDiffView + text buffers for every file in every exchange, even for diffs already in a terminal state (Accepted/ Rejected/Reverted) that the user never interacts with. This was the dominant source of memory pressure during conversation restoration. This change introduces deferred loading for restored diffs: - Added set_candidate_diffs_deferred() that stores FileDiff data and caches lightweight metadata (line counts, file paths) without creating editor views. - Modified set_restored_file_edits() in AIBlock to use deferred loading when the diff state is complete (Accepted/Rejected/Reverted). - Editor views are materialized lazily via materialize_deferred_diffs() only when the user expands a collapsed diff header. - The collapsed header continues to display file edit stats (+N/-M) and skill/MCP config buttons using cached data. Co-Authored-By: Oz <[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.
Closes #10073
Description
Defer
CodeDiffVieweditor creation for restored AI conversations to reduce memory pressure on startup.When restoring conversations,
set_candidate_diffseagerly created fullCodeEditorView+InlineDiffView+ text buffers for every file in every exchange, even for diffs in a terminal state (Accepted/Rejected/Reverted) that the user never interacts with. This was the dominant allocation source identified in the heap profile for Sentry #7366781652.Changes
CodeDiffView: Addedset_candidate_diffs_deferred()that caches lightweight metadata (line counts, file paths) without creating editor views. Editors are materialized lazily viamaterialize_deferred_diffs()when the user expands a collapsed diff.AIBlock::set_restored_file_edits: Now uses deferred loading when the restored diff state is complete (Accepted/Rejected/Reverted).CodeDiffState::is_complete(): Made public soblock.rscan check state before choosing deferred vs eager loading.Linked Issue
Testing
cargo check -p warpcargo fmtpassesAgent Mode
Conversation: https://staging.warp.dev/conversation/7e927e84-be80-47eb-8558-627af6a404a0
Run: https://oz.staging.warp.dev/runs/019df326-8692-77e2-8b63-273180dfa90b
Plans:
This PR was generated with Oz.