Skip to content

Reduce memory pressure in heavy threads#9

Merged
jacobjmc merged 2 commits intomainfrom
codex/reduce-memory-pressure
Mar 8, 2026
Merged

Reduce memory pressure in heavy threads#9
jacobjmc merged 2 commits intomainfrom
codex/reduce-memory-pressure

Conversation

@jacobjmc
Copy link
Owner

@jacobjmc jacobjmc commented Mar 8, 2026

Summary

  • evict inactive thread item caches so loaded thread state does not grow without bound
  • materialize inline data URL images to temp files before sending them to the frontend
  • virtualize large message lists and add regression coverage for eviction, virtualization, and image conversion

Testing

  • npm run typecheck
  • npm run test -- src/features/messages/components/Messages.test.tsx
  • npm run test -- src/features/threads/hooks/useThreads.integration.test.tsx
  • cargo test frontend_image_value_materializes_data_urls_to_temp_files --lib
  • npm run test -- src/features/threads/hooks/useThreadsReducer.test.ts src/utils/threadItems.test.ts src/features/composer/components/ComposerInput.attachments.test.tsx
  • cd src-tauri && cargo check

Summary by cubic

Reduces memory use in thread-heavy sessions by evicting inactive thread caches, virtualizing long message lists, and materializing inline image data URLs to temp files. Keeps the UI responsive and prevents unbounded growth.

  • New Features
    • Evict cached items for inactive threads beyond 5; active/processing/reviewing/pinned threads are protected. Threads auto-resume when reopened.
    • Virtualize the messages list when it exceeds 30 rows using @tanstack/react-virtual to cut DOM nodes and improve scroll performance.
    • Convert inline data:image/* URLs to temp files in the Rust core, deduplicate by hash, and reuse the path to reduce memory and payload size, with 8 MB pre/post-decode guards for base64 images.
    • Added focused tests for eviction, virtualization, and image materialization.

Written for commit efbbf16. Summary will update on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 7 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src-tauri/src/shared/codex_core.rs">

<violation number="1" location="src-tauri/src/shared/codex_core.rs:1132">
P2: Add a byte-size limit before/after base64 decode for data URL images. Decoding unbounded payloads can cause high memory usage or OOM under large inline images.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

Copilot AI commented Mar 8, 2026

@jacobjmc I've opened a new pull request, #10, to work on those changes. Once the pull request is ready, I'll request review from you.

…ion (#10)

* Initial plan

* Add pre/post-decode size guards for data URL base64 images

Co-authored-by: jacobjmc <111402762+jacobjmc@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jacobjmc <111402762+jacobjmc@users.noreply.github.com>
@jacobjmc jacobjmc merged commit b62b42f into main Mar 8, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants