[Bug]: Copy Rewrite buttons do not copy suggestions - #1925
Conversation
📝 WalkthroughWalkthroughRewrite option buttons on the Resume Bullet Enhancer page now copy their associated rewrite text to the clipboard when clicked. ChangesResume rewrite clipboard
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/pages/ResumeBulletEnhancer/ResumeBulletEnhancer.jsx`:
- Around line 274-275: Update the button’s inline copy handler in
ResumeBulletEnhancer to use an async try/catch flow around
navigator.clipboard.writeText(text), handling rejected writes and unavailable
Clipboard API without unhandled errors. Reuse the existing clipboard failure and
user-feedback pattern from QuestionCard.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: cc743de9-e1fc-4e13-8ec3-0a8867206283
📒 Files selected for processing (1)
frontend/src/pages/ResumeBulletEnhancer/ResumeBulletEnhancer.jsx
| <button | ||
| onClick={() => navigator.clipboard.writeText(text)} |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- target file ---'
sed -n '250,290p' frontend/src/pages/ResumeBulletEnhancer/ResumeBulletEnhancer.jsx
printf '%s\n' '--- existing clipboard handling ---'
sed -n '1,70p' frontend/src/components/Cards/QuestionCard.jsx
printf '%s\n' '--- clipboard usage ---'
rg -n -C 3 'navigator\.clipboard|writeText' frontend/srcRepository: Canopus-Labs/PrepPilot
Length of output: 7783
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- ResumeBulletEnhancer imports and handlers ---'
sed -n '1,110p' frontend/src/pages/ResumeBulletEnhancer/ResumeBulletEnhancer.jsx
printf '%s\n' '--- existing copy error handling ---'
sed -n '65,90p' frontend/src/pages/ProblemSolver/ProblemSolver.jsx
sed -n '355,380p' frontend/src/pages/NotesSummarizer/NotesSummarizer.jsx
printf '%s\n' '--- toast setup in the target page ---'
rg -n -C 2 'react-hot-toast|toast\.' frontend/src/pages/ResumeBulletEnhancer/ResumeBulletEnhancer.jsx frontend/srcRepository: Canopus-Labs/PrepPilot
Length of output: 41904
🏁 Script executed:
#!/bin/bash
set -eu
node - <<'JS'
const events = [];
process.on("unhandledRejection", (reason) => events.push(`unhandled:${reason.message}`));
global.navigator = {
clipboard: {
writeText: () => Promise.reject(new Error("permission denied")),
},
};
const handler = () => navigator.clipboard.writeText("text");
const returned = handler();
if (!(returned instanceof Promise)) throw new Error("handler did not return the clipboard Promise");
setImmediate(() => {
if (!events.includes("unhandled:permission denied")) {
throw new Error(`expected an unhandled rejection, got ${JSON.stringify(events)}`);
}
console.log("rejected write is unhandled when the returned Promise is ignored");
});
JSRepository: Canopus-Labs/PrepPilot
Length of output: 844
🏁 Script executed:
#!/bin/bash
set -eu
node - <<'JS'
const events = [];
process.on("unhandledRejection", (reason) => events.push(`unhandled:${reason.message}`));
Object.defineProperty(globalThis, "navigator", {
configurable: true,
value: {
clipboard: {
writeText: () => Promise.reject(new Error("permission denied")),
},
},
});
const handler = () => navigator.clipboard.writeText("text");
const returned = handler();
if (!(returned instanceof Promise)) throw new Error("handler did not return the clipboard Promise");
setImmediate(() => {
if (!events.includes("unhandled:permission denied")) {
throw new Error(`expected an unhandled rejection, got ${JSON.stringify(events)}`);
}
console.log("rejected write is unhandled when the returned Promise is ignored");
});
JSRepository: Canopus-Labs/PrepPilot
Length of output: 225
Handle clipboard failures.
Wrap the copy operation in an async handler with try/catch. A rejected navigator.clipboard.writeText(text) is currently unhandled, and an unavailable Clipboard API causes an error without user feedback. Reuse the existing pattern from frontend/src/components/Cards/QuestionCard.jsx.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@frontend/src/pages/ResumeBulletEnhancer/ResumeBulletEnhancer.jsx` around
lines 274 - 275, Update the button’s inline copy handler in ResumeBulletEnhancer
to use an async try/catch flow around navigator.clipboard.writeText(text),
handling rejected writes and unavailable Clipboard API without unhandled errors.
Reuse the existing clipboard failure and user-feedback pattern from
QuestionCard.
|
@kumud-05 Address the coderabbit suggestion, wrap the copy operation with try catch |
📝 Pull Request Description
Related Issue
Closes #1924
Summary
Implemented clipboard functionality for the "Copy Rewrite" buttons in the Resume Bullet Enhancer.
Each rewrite suggestion can now be copied directly to the clipboard by clicking its corresponding "Copy Rewrite" button.
Type of Change
How Has This Been Tested?
Describe the testing steps performed.
Checklist
Summary
navigator.clipboard.writeText.