Duplicate icons in ~/.local/share/plasma_icons and amarok icon broken

Operating System: Arch Linux
KDE Plasma Version: 6.5.5
KDE Frameworks Version: 6.22.0
Qt Version: 6.10.1
Kernel Version: 6.18.6-zen1-1-zen (64-bit)
Graphics Platform: Wayland

There is a huge mess in ~/.local/share/plasma_icons: I see some icons being duplicated (with (1) added before the .desktop, but no difference in content.

Removing those items while being logged out from the GUI session still makes them reappear.

Then, adding amarok from the menu as item, I get the icon showing up, but when clicking on it: Invalid service name: org.kde.amarok (1)

Interestingly, the problem with duplicate items only happens to some icons I have … it seems those that are either flatpak installs (com.theappgineer.community_remote) or binary programs (microsoft-edge, pycharm, media_center_35), but also items I thought are “native” like signal-desktop.

Any idea what is going on here?

~/.local/share/plasma_icons has a frustrating habit of duplicating .desktop files. For example I have firefox.desktop, firefox (1).desktop, firefox (2).desktop. They all have the same contents. They get created when I try to add an icon to the panel. It wants to create a pin. Adding my own icons to the panel has in general seemed broken to me lately. There isn’t a right click option to add to panel from the menu anymore. I can “add to desktop“, and then drag and drop the icon from the desktop to the panel. At that point “firefox (1).desktop“ will be created in ~/.local/share/plasma_icons/ from the original firefox.desktop. Then I can delete the icon from the desktop. If I delete the “firefox (1).desktop“ in ~/.local/share/plasma_icons/, the panel icon will not work (execute the program). This flow for creating my own panel menus has become frustrating.

I managed to solve the issue by editing the file \~/.config/plasma-org.kde.plasma.desktop-appletsrc and changing the line :
localPath=/home/sam/.local/share/plasma_icons/org.kde.amarok (1).desktop
to
localPath=/home/sam/.local/share/plasma_icons/org.kde.amarok.desktop