Skip to content

[Improve] Reduce chat memory retained during long sessions - #1466

Draft
ghost wants to merge 2 commits into
mainfrom
feature/webview-memory-optimization-0lkgswz0njjgl
Draft

ghost wants to merge 2 commits into
mainfrom
feature/webview-memory-optimization-0lkgswz0njjgl

Conversation

@ghost

@ghost ghost commented Aug 31, 2026

Copy link
Copy Markdown

​Opened on behalf of @taltas. Follow up by mentioning @roomote, in the web UI, or in Discord.

What changed

  • Intern repeated strings in completed chat messages and task history to reduce duplicate webview allocations during streaming and state broadcasts.
  • Scope message caches to the active task, skip transient partial messages and rejected stale updates, and clear retained message strings on explicit task transitions.
  • Remount the chat tree between tasks and remount message rows when they transition from partial to complete.
  • Add focused coverage for recursive interning, cache lifecycle and stale updates, task-level chat remounts, and virtualized row keys.

Why this change was made

Long-running webview sessions repeatedly deserialize the same message and history strings, while old React closures can retain prior task state. This implements the linked optimization proof of concept with stricter lifecycle handling and regression coverage suitable for production.

Impact

Chat behavior and appearance are unchanged. The webview can release prior-task message data more reliably and avoid retaining duplicate completed-message and history strings, reducing memory pressure during long sessions.

@ghost ghost assigned taltas Aug 31, 2026
@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Review status

Thanks for contributing. This comment tracks the review sequence and the next action.

Current step: Mark the PR ready. Required CI must pass before CodeRabbit starts.

Review-state labels are managed by this workflow; do not edit them manually. community-approved is managed the same way — do not add or remove it manually. It signals a fresh community code approval for the current head as an advisory priority only; maintainer review is still required.

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.37931% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
webview-ui/src/context/ExtensionStateContext.tsx 83.33% 4 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added has-conflicts PR has merge conflicts with the base branch and removed has-conflicts PR has merge conflicts with the base branch labels Sep 1, 2026
@github-actions github-actions Bot added has-conflicts PR has merge conflicts with the base branch and removed has-conflicts PR has merge conflicts with the base branch labels Sep 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR has been awaiting author changes for 14 days and will be automatically closed in 7 days. Please address the review comments or leave a comment if you need more time.

…y-optimization-0lkgswz0njjgl

# Conflicts:
#	webview-ui/src/__tests__/App.spec.tsx
#	webview-ui/src/context/ExtensionStateContext.tsx
#	webview-ui/src/context/__tests__/ExtensionStateContext.spec.tsx

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale-awaiting-author PR is stale while waiting for requested author changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants