Page MenuHomePhabricator

Bulk Discard for detected duplicates (!29)
Closed, ResolvedPublic

Description

Summary

Duplicate detection (cross-Commons sha1 lookup + within-stash matches) already works and visibly flags affected rows. But today the user has to select each flagged row one-by-one and then click Discard or Hide — tedious when a batch of 20 has 5 duplicates.

Add a one-click bulk action: select all flagged duplicates and apply Discard (or Hide) in a single click.

Behavior

  • When the duplicate-detection effect has flagged ≥ 1 row in the current view, surface a button (likely in the toolbar or in the duplicate-status banner) labelled like:
    • "Discard 5 duplicates" / "Hide 5 duplicates" (number reflects the flagged count; offer both Discard and Hide as separate one-click actions).
  • Clicking selects all flagged rows and applies the chosen action atomically — no per-row confirmation, no intermediate selection step.

Open question (decide during build)

Whether to apply to "all detected duplicates" (across the whole list) or "duplicates in the current filter / view" by default.

Lean toward applying to all duplicates (the user's mental model is "remove the duplicates from this batch"), but surface a clear hint if the action will affect rows outside the current filter — e.g. "Discarding 5 duplicates (2 visible, 3 hidden by current filter)".

Out of scope

  • Auto-hiding duplicates without user action (changes the user's data without consent).
  • Distinguishing between "exact-bytewise duplicate of an existing Commons file" vs "duplicate of another file in this batch" — the bulk action applies to both kinds.

Acceptance

  • When duplicates are detected, a clearly-labeled bulk action ("Discard / Hide N duplicates") is reachable in one click.
  • Clicking it discards (or hides) all flagged duplicate rows in one go.
  • The action is reversible by the existing Discard / Hide undo affordances (where present).

Source

User feedback session, 2026-05-10.

Event Timeline

Daanvr updated the task description. (Show Details)
Daanvr moved this task from To do to Doing on the Tool-upload-workbench board.

At first sight it seems to work, however, when playing with it a bit uh it seems a bit buggy. When I select restore all for the hidden uh files. Uh I see a message again with uh for example twelve um files uh are duplicates and can be hidden or can be uh discarded. Um but when I click this button, um uh because I went back and forth already, so I discarded them first time. uh re restore them from uh from the hidden files and then the second time I do it it only does some of them. Uh it's unclear which one are affected or if even maybe some not um copied one uh ones are affected. I don't know. Um or not dub duplicated ones I do amine. Um please investigate why this happens and please make it more uh robust. Keep it simple but uh make it more foolproof I guess. Uh or at least make sure this bug disappears.

Daanvr renamed this task from duplicat detection to Bulk Discard for detected duplicates (!29).May 11 2026, 2:13 PM

Iterated per feedback. Two changes aimed at making the bulk discard foolproof:

  1. Defensive double-key in discardItems — every target with both a sha1 and a filekey is now hidden by both, not just sha1. Belt-and-braces against any future code path that consults only one set.
  2. Post-action receipt banner — after every bulk discard, a transient banner above the stash table lists the count + first three filenames it just hid (rest in the title attribute), with an Undo button that reverses exactly those rows. Auto-clears after 10s. Removes the prior uncertainty about which rows the action affected — you can read the names + click Undo before they age out. Logged to the console as [discard] for diagnostics.

Also re-snapshot duplicates inside onBulkDiscardDuplicates at click time, so any duplicate that arrived (or had its sha1 backfilled) milliseconds before the click is still hidden.

I couldn't reproduce the "only some hidden" symptom from a code read alone — discardItems collects all sha1s up-front, dedupes via hideSha1s, and triggers a single React state update — so I went for foolproof + observable rather than chasing one specific cause. If it recurs, the new console log will show exactly which sha1s/filekeys/names went into the hide.

Preview updated: https://upload-workbench.toolforge.org/mr-29/

Um there is a dynamic where when you unhide Like click on the five hidden files or the five hidden button. Uh it shows me like a a list above the the the table with the hidden files, but also the hidden files appear in the table uh underneath. in the table itself. Um and that's confusing. So that should not be the case and I guess it comes from this edit. Uh but it might come from somewhere else. But in the current version if I open up the list of hidden files, they both appear in the list of hidden files and as rows in the table. Uh the latter one is not supposed to happen So there should not be the hidden files should never be in the table rows

Iterated per feedback: hidden stash rows no longer appear in the table when the "X hidden" disclosure is open — they used to render in both surfaces simultaneously, which made bulk discard look as if rows were silently coming back. stashItems now strictly excludes hidden regardless of the disclosure toggle (no other consumer relied on the old behaviour). This is also the most plausible cause of the previous "only some hidden" symptom: the user was reading the disclosure-injected rows in the table as evidence the discard had partially failed, when only the visualisation was wrong. Defensive double-key + post-action receipt from the previous round are kept. Preview updated: https://upload-workbench.toolforge.org/mr-29/

Released as v0.16.0 (MR !29 merged into main).