fix: lazy-init code diff views for restored AI conversations (APP-4200)#10034
Draft
kevinchevalier wants to merge 1 commit intomasterfrom
Draft
fix: lazy-init code diff views for restored AI conversations (APP-4200)#10034kevinchevalier wants to merge 1 commit intomasterfrom
kevinchevalier wants to merge 1 commit intomasterfrom
Conversation
Defers creation of CodeEditorView/InlineDiffView instances for restored AI conversation diffs until the user explicitly expands them. Previously, every restored conversation eagerly materialized full editor views, diff models, syntax models, and file registrations for each file diff, even though restored diffs are always in a terminal state (Accepted/Rejected/ Reverted) and displayed collapsed (header-only). The fix introduces a DeferredDiffState that stores lightweight metadata (file paths, pre-computed line counts) alongside the raw FileDiff data. The collapsed header renders using this metadata instead of querying editor views. When the user clicks to expand, views are materialized on-demand via the existing set_candidate_diffs path. This significantly reduces memory usage during AI conversation restoration, particularly for sessions with many conversations and file edits (the dominant allocation path identified in Sentry heap profiles). Fixes APP-4200 Sentry: https://sentry.io/organizations/warpdotdev/issues/7366781652/ 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 #10072
Description
Fixes excessive memory usage during AI conversation restoration (APP-4200 / Sentry 7366781652).
Root cause: When restoring AI conversations on app startup, every
RequestFileEditsaction eagerly created fullCodeEditorView+InlineDiffViewinstances for each file diff. These include editor buffers, syntax models, diff computation, and file registrations — all heavy allocations that are never used because restored diffs are always in a terminal state (Accepted/Rejected/Reverted) and rendered collapsed (header-only).Fix: Introduces lazy initialization via
DeferredDiffState:set_deferred_candidate_diffs()stores lightweight metadata (file paths, pre-computed line counts fromDiffType) alongside rawFileDiffdata, without creating any editor viewsmaterialize_deferred_diffs()calls the existingset_candidate_diffs()to create the full editor views on demandImpact: For a session with N restored conversations × M file edits each, this avoids creating N×M
CodeEditorView+InlineDiffViewinstances at startup, saving significant memory from editor buffers, diff models, syntax highlighting infrastructure, and file model registrations.Linked Issue
Testing
cargo check -p warp(no errors, no new warnings)cargo fmtto ensure formatting complianceset_candidate_diffscode, so existing editor/diff behavior is preservedAgent Mode
CHANGELOG-BUG-FIX: Fixed excessive memory usage when restoring AI conversations with file edits
Conversation: https://staging.warp.dev/conversation/ae68e989-1130-4586-99ef-f70978a8b94a
Run: https://oz.staging.warp.dev/runs/019df333-b449-7169-9513-b7fb6fd84c9c
This PR was generated with Oz.