Skip to content

Release clipboard previews when the chat composer closes - #26234

Merged
nwparker merged 4 commits into
mainfrom
nwparker/perf-composer-preview-lifetime
Oct 8, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/perf-composer-preview-lifetime

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​267 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​267
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13

ELI5

Pasted chat images release their temporary previews when the composer closes. Saved attachments and pending uploads remain available when you return.

What Changed

The current preview-owner hook revokes its own Blob URLs and clears their retained references on unmount. A preview arriving after that owner closes is released immediately. Shared pending chips, saved paths and connection IDs remain in their existing owners.

Why

Preview ownership has moved out of the attachment hook. Cleanup belongs in the hook that now owns those URLs, which avoids revoking another composer's previews or changing attachment persistence. Retiring late arrivals also prevents an asynchronous save from recreating the leak after unmount.

Linked Issue

N/A — maintainer performance audit.

Visual Proof

Original publication evidence below used the production chat portal, composer and store in a fresh hidden macOS app with controlled save/read calls. It showed restored attachments after switching views. The refreshed ownership implementation was verified with focused lifecycle tests; these screenshots were not re-recorded for this update.

Before:
before.png

After:
after.png

Testing

  • Refreshed composer validation: 71 tests across six suites passed.
  • Controls cover independent composers, pending and saved attachments, local/remote paths, remount, development StrictMode, late replies, data URLs and explicit removal/clear.
  • Combined current-main validation: 654 main/renderer tests, 83 mobile tests and 78 performance contracts passed.
  • Full typechecks, desktop build and changed-code quality gate passed locally on macOS.
  • Retirement regressions fail against the current base implementation without cleanup and pass with the fix.
  • Hosted checks must complete on the refreshed PR head. Remote paths use controlled fixtures; a live SSH host was not repeated for this update.

Review

Only URLs created for this preview owner are revoked. Unmount leaves shared drafts and pending uploads intact, and development effect replay restores the mounted guard. No negative user-facing trade-off was identified.

Agent skill upstream boundary

  • Not applicable; no upstream skill source is copied or translated.

Notes

Uses existing browser URL APIs. No path interpretation, main-process routing, remote wire format or mobile behavior changes.

Checklist

  • Small, focused change; behavior, mechanism and approach explained.
  • Original visual proof retained with its scope stated.
  • Correctness, security, performance and platform boundaries reviewed.
  • Relevant tests, typechecks, build, formatting and changed-code quality checks pass locally; hosted checks remain a merge gate.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 056f768e-68cf-40a6-8735-da9e766f4dc5
📥 Commits

Reviewing files that changed from the base of the PR and between 89fc6fd and 137ab83.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/use-native-chat-composer-attachment-previews.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-composer-attachment-previews.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The attachment preview hook now tracks mounted state, revokes tracked blob preview URLs on unmount, and revokes URLs passed to setPreview after unmount. New tests cover preview cleanup, composer ownership, data URLs, and attachment cache behavior.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 137ab

No actionable preview-lifecycle issue is established; this change is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: releasing clipboard preview Blob URLs when the chat composer closes.
Description check ✅ Passed The description is complete and focused. It covers the user impact, implementation, rationale, testing, visual proof, review considerations, scope boundaries, and checklist items. The maintainer-speci…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 665fbc4 into main Oct 8, 2026
3 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.

1 participant