Repository navigation
fix(renderer): cancel copied prompt reset on unmount - #20906
Conversation
There was a problem hiding this comment.
ℹ️ No critical issues — one reuse suggestion inline.
Reviewed changes
- Copy-prompt reset timer (
src/renderer/src/components/settings/EphemeralVmsPane.tsx) — the delayedpromptCopiedreset now lives in a ref-held timer, cleared before reschedule (so rapid clicks coalesce onto the latest click) and cleared by a new mount-only effect on unmount.
The logic is correct: clearing before reschedule fixes the rapid-click case, the unmount cleanup prevents the reset firing after the pane is gone, and the shape matches the accepted inline timer pattern in NativeChatCopyButton.tsx and AutoRenameFailedDialog.tsx.
ℹ️ Nitpicks
- No test accompanies the fix. If the inline timer is kept, a small fake-timer regression test (two rapid copies, then unmount) would pin the coalescing behavior that this change introduces.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| if (promptResetTimerRef.current !== null) { | ||
| window.clearTimeout(promptResetTimerRef.current) | ||
| } | ||
| promptResetTimerRef.current = window.setTimeout(() => { | ||
| promptResetTimerRef.current = null | ||
| setPromptCopied(false) | ||
| }, 1500) |
There was a problem hiding this comment.
This reimplements the timer coalescing and unmount-safe reset that useClipboardTextCopyFeedback already provides (and tests). This button is the same inline copy affordance the hook was written for, so reuse would drop promptResetTimerRef, the new effect, and this manual timer.
Technical details
# Reuse `useClipboardTextCopyFeedback` for the copy-prompt button
## Affected sites
- `src/renderer/src/components/settings/EphemeralVmsPane.tsx:48` — new `promptResetTimerRef`
- `src/renderer/src/components/settings/EphemeralVmsPane.tsx:50-56` — new unmount cleanup effect
- `src/renderer/src/components/settings/EphemeralVmsPane.tsx:139-145` — manual clear/reschedule timer
- `src/renderer/src/hooks/use-clipboard-text-copy-feedback.ts` — existing hook; `scheduleReset` coalesces and `isMountedRef` guards setState after unmount (covered by `use-clipboard-text-copy-feedback.test.ts`)
## Required outcome
- One clipboard-feedback implementation for this button, preserving the `recordFeatureInteraction('ephemeral-vm-setup')` call on success and the `toast.error` on failure.
## Suggested approach (optional)
- `const { copyText, status } = useClipboardTextCopyFeedback(AGENT_PROMPT)`; in `copyPrompt`, `if (await copyText()) recordFeatureInteraction(...) else toast.error(...)`; render on `status === 'copied'`.dff94c2 to
a5d9082
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The clipboard feedback lifecycle change has no identified merge-blocking issue. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the behavior change and validation, but it does not follow the repository template. It omits the required ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, AI Disclosure, Review, boundary, Notes, and Checklist sections. Resolution Update the description to include all required template sections. Add the issue reference after "Fixes #". Provide visual proof or write "N/A" with a reason. Document manual and automated testing, platform coverage, AI disclosure when applicable, review considerations, the agent-skill boundary checkbox, notes about compatibility and performance, and the checklist status.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the two added tests pin the timer fix and both fail when the fix is ablated.
Reviewed changes
- Mounted guard in
copyPrompt— afterwriteClipboardTextresolves, the handler returns early if the pane has unmounted, so no post-unmountsetPromptCopied(true)or reset timer is scheduled. - Two clipboard-timer regression tests — one asserts no 1500 ms reset is scheduled when clipboard completion arrives after unmount, the other asserts the pending reset is cleared on unmount. Both were verified to fail against the unguarded / uncancelled variants.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
* fix(renderer): cancel copied prompt reset on unmount * fix: address memory PR review regressions and withdraw false positives --------- Co-authored-by: m4air <m4air@Mac.localdomain> Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local>

Behavior
Keep Copied feedback for the existing 1.5 seconds while the settings pane is mounted. Clear its reset timer on unmount and ignore a clipboard completion that arrives after unmount, so it cannot create another timer or update the retired component.
Validation
Five permanent tests cover normal feedback, unmount cleanup and deferred clipboard completion. Renderer typecheck, lint and anti-slop checks pass.
Merge decision
No feedback duration or stored-data limit changes. Required CI must pass on the corrected head.