[MergeDups] Fix protection-override data-loss warning#3948
[MergeDups] Fix protection-override data-loss warning#3948imnasnainaec merged 11 commits intomasterfrom
Conversation
The warning now only includes: - Sense reasons when deleting, merging, or displacing from sidebar top - Word reasons when moving the last sense of a protected word - Both when deleting or merging the last sense of a protected word Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
imnasnainaec
left a comment
There was a problem hiding this comment.
@imnasnainaec reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @copilot)
src/goals/MergeDuplicates/MergeDupsStep/MergeDragDrop/index.tsx line 112 at r1 (raw file):
// ... unless protection override is active and user confirms. // Include both sense and word reasons since the sense is being deleted. const protectReason = getProtectReason(true, true);
The added comment before each const protectReason = getProtectReason(... is unnecessary.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3948 +/- ##
==========================================
- Coverage 74.26% 74.21% -0.05%
==========================================
Files 291 291
Lines 10783 10790 +7
Branches 1349 1351 +2
==========================================
Hits 8008 8008
- Misses 2389 2396 +7
Partials 386 386
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Removed the unnecessary comments in commit bbc7d12. |
Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Converted to TSDoc format in commit f2cd742. |
imnasnainaec
left a comment
There was a problem hiding this comment.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @copilot)
src/goals/MergeDuplicates/MergeDupsStep/MergeDragDrop/index.tsx line 141 at r3 (raw file):
if (overrideProtection) { // ... unless protection override is active and user confirms. const protectReason = getProtectReason(true, true);
When a protected sense is being deleted (Case 1a) or merged (Case 2b), you have
const protectReason = getProtectReason(true, true);
However, in both cases, it may be more accurate to have
const protectReason = getProtectReason(isProtectedSense, isOnlySenseInProtectedWord);
where isProtectedSense is defined to replace all instances of (src.isSenseProtected && !src.order).
Extract isProtectedSense from repeated expression and use it with isOnlySenseInProtectedWord to determine which protection reasons to include. This ensures sense reasons are only shown when the sense itself is protected, not just when it's in a protected word. Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Implemented in commit 71f7340. Created |
|
@copilot Now two checks are failing. |
Use double negation (!!) to ensure isProtectedSense is always a boolean type rather than boolean | undefined, fixing the TypeScript compilation error when passing it to getProtectReason. Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Fixed in commit ec63abf. The TypeScript compilation error was due to |
imnasnainaec
left a comment
There was a problem hiding this comment.
@imnasnainaec reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @copilot)
src/goals/MergeDuplicates/MergeDupsStep/MergeDragDrop/index.tsx line 207 at r5 (raw file):
if (overrideProtection) { // ... unless protection override is active and user confirms. const protectReason = getProtectReason(fromTop, false);
The comment "being displaced" above corresponds to (fromTop || toTop), so getProtectReason(fromTop, false); needs to be fixed.
Use (fromTop || toTop) instead of just fromTop when calling getProtectReason to correctly show sense protection reasons whenever the top sidebar sense is being displaced, whether moving from top or to top. Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
Fixed in commit 1c880df. Changed |
imnasnainaec
left a comment
There was a problem hiding this comment.
@imnasnainaec reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @copilot)
src/goals/MergeDuplicates/MergeDupsStep/MergeDragDrop/index.tsx line 207 at r5 (raw file):
Previously, imnasnainaec (D. Ror.) wrote…
The comment "being displaced" above corresponds to
(fromTop || toTop), sogetProtectReason(fromTop, false);needs to be fixed.
This line is inside an if ((fromTop || toTop) && sidebarProtected) loop, so is fromTop || toTop necessary in getProtectedReason?
Since we're inside if ((fromTop || toTop) && sidebarProtected), the expression (fromTop || toTop) is always true, so we can simplify getProtectReason(fromTop || toTop, false) to getProtectReason(true, false). Co-authored-by: imnasnainaec <6411521+imnasnainaec@users.noreply.github.com>
You're right. Since we're inside the |
jasonleenaylor
left a comment
There was a problem hiding this comment.
@jasonleenaylor reviewed 1 of 1 files at r7, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @copilot and @imnasnainaec)
imnasnainaec
left a comment
There was a problem hiding this comment.
@imnasnainaec reviewed 1 of 1 files at r7, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @copilot)
Summary
The protection-override data-loss warning is now context-aware and accurate:
The fix uses clear boolean variables (
isProtectedSense,isOnlySenseInProtectedWord) with TSDoc documentation that makes the code self-documenting and ensures warnings are shown only when relevant data will actually be lost. All checks pass including TypeScript compilation.Original prompt
Fixes #3904
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
This change is