Skip to content

fix(renderer): cancel copied prompt reset on unmount - #20906

Merged
OrcaWin merged 3 commits into
mainfrom
np-oom-scan-prompt-reset
Sep 18, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
np-oom-scan-prompt-reset

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one reuse suggestion inline.

Reviewed changes

  • Copy-prompt reset timer (src/renderer/src/components/settings/EphemeralVmsPane.tsx) — the delayed promptCopied reset 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment on lines +139 to +145
if (promptResetTimerRef.current !== null) {
window.clearTimeout(promptResetTimerRef.current)
}
promptResetTimerRef.current = window.setTimeout(() => {
promptResetTimerRef.current = null
setPromptCopied(false)
}, 1500)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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'`.

@OrcaWin
OrcaWin force-pushed the np-oom-scan-prompt-reset branch from dff94c2 to a5d9082 Compare September 16, 2026 03:28
@OrcaWin
OrcaWin changed the base branch from np-oom-scan to main September 16, 2026 03:28
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview 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: 812075c4-13a6-401d-bd26-a89239f388eb

📥 Commits

Reviewing files that changed from the base of the PR and between 15cac68 and ea8f016.

📒 Files selected for processing (2)
  • src/renderer/src/components/settings/EphemeralVmsPane.test.tsx
  • src/renderer/src/components/settings/EphemeralVmsPane.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

EphemeralVmsPane now tracks the prompt feedback reset timer. It clears existing timers before scheduling a new reset and clears the timer on unmount. Clipboard completion after unmount exits before updating feedback. Tests cover delayed completion after unmount and cleanup of the mounted copy feedback timer.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to ea8f0

The clipboard feedback lifecycle change has no identified merge-blocking issue.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning 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 Disc… 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 appli…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the main change: canceling the copied prompt reset when the renderer component unmounts.
Full details: Description check

Explanation

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.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ 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 — after writeClipboardText resolves, the handler returns early if the pane has unmounted, so no post-unmount setPromptCopied(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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit d7d3bcf into main Sep 18, 2026
28 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
* 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>
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