Desktop entry exec line breaking after installation

For some reason, when I install my Flatpak for stoat.chat, it breaks my desktop entry.

Desktop entry before installation:

[Desktop Entry]
Name=Stoat
Exec=/usr/bin/flatpak run --arch=x86_64 --command=stoat-desktop chat.stoat.StoatDesktop
Type=Application
Icon=chat.stoat.StoatDesktop
Categories=Internet;

Installed entry:

[Desktop Entry]
Name=Stoat
Exec=/usr/bin/flatpak run --branch=master --arch=x86_64 --command=/usr/bin/flatpak chat.stoat.StoatDesktop run --arch=x86_64 --command=stoat-desktop chat.stoat.StoatDesktop
Type=Application
Icon=chat.stoat.StoatDesktop
Categories=Internet;
X-Flatpak=chat.stoat.StoatDesktop

Any idea what I’m doing wrong?

All files here: GitHub - Legomountain14/chat.stoat.StoatDesktop

When Flatpak builds an application, it creates an “export” version of your desktop. This exported version is placed in an special folder during Installation and is the one the desktop displays.

During this export, Flatpak adds the necessary commands to launch the right Flatpak app to the Exec-line of the export desktop file.

Now, this means that since Flatpak does these additions itself, you as the developer shouldn’t add them.

Instead, the desktop file you add during the build should be from the view of inside the sandbox.
So, in short, remove anything Flatpak related from the Exec line. Just stoat-desktop should be there.

why is there flatpak in your desktop file Exec line ? Nowhere in the document it say to do that.