Skip to content

Fix duplicate, unclickable row when re-dropping the same track - #3

Open
shyam-habarakada wants to merge 1 commit into
nsaintot:mainfrom
shyam-habarakada:fix/duplicate-recent-drop-row
Open

Fix duplicate, unclickable row when re-dropping the same track#3
shyam-habarakada wants to merge 1 commit into
nsaintot:mainfrom
shyam-habarakada:fix/duplicate-recent-drop-row

Conversation

@shyam-habarakada

Copy link
Copy Markdown

Fixes #2

The bug

If you drop the same track on the window twice (or drop it again after it already finished separating), the "Separated" list ended up with two rows for it instead of one. The newer of the two rows was broken: hovering and clicking did nothing on it. To get any hover/click feedback on that track, you had to move the mouse onto the older duplicate row further down the list instead.

Why it happened

Two separate things combined to cause this:

  1. Nothing de-duplicated the list. Every time a file was dropped, the window just inserted a brand-new row at the top of the "recent drops" list, with no check for whether that same file was already sitting somewhere in the list. So re-running a track always added a second row rather than updating the one already there.

  2. Rows were sharing an identity behind the scenes. Each row's click/hover handling needs a stable ID so the UI toolkit (egui) can tell "this row was pressed" from "that row was pressed." That ID was built from the track's display name (the file's title). But two rows for the same file obviously have the same title, so both rows ended up using the exact same ID. egui only routes input correctly when every interactive element has a unique ID, so with two rows sharing one ID, input got misattributed — the newer row looked normal but silently couldn't be clicked, while the older row (usually hidden further down the list) picked up the intended interaction instead.

The fix

  • When a track is dropped, the window now first removes any existing row for that same source file before adding the new one, then puts the new row at the top. So re-dropping a track now moves it to the top of the list and refreshes its status, instead of piling up a duplicate.
  • Row IDs are now built from the file's full path instead of its display name. This is a more accurate identity anyway (two different files in different folders can share the same name), and it means two rows can never again collide on the same ID, so this class of bug can't resurface even in that edge case.

Tests added

Added a test that simulates dropping the same file twice: it drops file A, then drops an unrelated file B, then drops file A again, and checks that:

  • the list still has exactly two rows (no duplicate was created),
  • the re-dropped file A is now at the top of the list,
  • the unrelated file B's row wasn't disturbed.

All existing tests continue to pass.

🤖 Generated with Claude Code

Dropping a track that was already separated added a second row to the
"Separated" list instead of updating the existing one, and the new row
was stuck: hovering and clicking did nothing until the pointer moved
over the older row instead.

Both symptoms traced back to the same two spots:

- Drops::accept always inserted a new row at the top of the list with
  no check for whether that file was already there, so re-running a
  track duplicated it rather than refreshing it.
- Each row's click/hover handling was keyed off the track's displayed
  title. Two rows for the same file have the same title, so they ended
  up sharing one interaction id, and egui attributed input to only one
  of them.

Fixed both: re-dropping a track now replaces its existing row and
moves it to the top instead of adding a new one, and each row's id is
now derived from the source file path rather than the title, so two
different files that happen to share a name can never collide either.

Added a test (re_dropping_a_track_replaces_its_row_instead_of_duplicating)
that drops the same path twice and checks the list stays deduplicated,
with the re-run at the top and unrelated rows undisturbed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@nsaintot nsaintot left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Overall good QoL PR

Comment on lines 167 to 168
/// different folders are two drops, and dropping one track twice makes two
/// rows that must be dismissable separately.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Comment is stale with the dedup. Trim or update

recent.insert(0, Arc::clone(&dropped));
recent.truncate(REMEMBERED);
}
remember(&mut self.recent.lock(), Arc::clone(&dropped));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

[Nit] Dedup lives only in accept; nothing structural stops a future insert from bypassing remember.

I would tend to favor a method for remember rather than a free function that only has one caller.

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.

When the same track has been separated more than once, the UI behaves erratically

2 participants