I don't think it glitches for you, I think you are misinterpreting how the interface is working. When you play Sentry, the game will show you two cards (red bordered) and ask to confirm the trashing.
That doesn't mean it will trash the cards, it asks you to click on any number (0-2) of the 2 cards to select for trashing! In this case, I want to trash the Copper but keep the Sentry, so I click the Copper, which gets marked with a red cross to indicate it will be trashed:
After clicking on "Confirm Trashing", the Copper gets trashed and the UI changes a bit, only showing me the remaining Sentry (orange bordered) and asking me to select which card to discard:
Again, it doesn't mean the Sentry will be discarded, that only happens when you click on it. But I don't want to discard the Sentry, it's a good, useful card, so I simply click on "Conform Discarding" in the previous picture, and the Sentry is not discarded, but topdecked:
The only other thing that may happen is if you neither trash nor discard either card (because they are booth good, playable cards), then you need to specify the order they are topdecked in:
Here you need to use drag and drop to rearrange the cards, if neccessary.
I hope this helped, and if anything is unclear, feel free to ask for clarification!