I’d recommend waiting for a couple of seconds before reloading/closing the page to make sure the image is ‘converted/saved’ on the chat. I tried clicking the keep then immediately reloading the page (even closing the page as soon as I clicked ‘keep’), but it managed to keep the image. Not sure what other factors might affect it saving.
If you could provide a video demo of the problem with the console open, it would be helpful to see if there are problems with the code.
You could use ShareX screen record then upload to Streamable. Can you also provide the thread/chat export that is faulty so I can try to replicate the problem on my end?