Prevent Loss of Unsubmitted Text When Switching Chats/Tabs

I recently encountered an issue while using the web interface that I believe could be improved to enhance user experience.

I was in the process of composing a substantial amount of text within the “Food” chat/tab. However, before submitting my message, I navigated to a previous “DYI” tab I had, inadvertently losing all the text I had written in the “Food” chat input box. This resulted in a loss of work and was a rather frustrating experience.

A few ideas:

Prompt Warning: When a user attempts to switch chats/tabs while there is unsubmitted text in the input box, display a warning message. This message should alert the user that switching will result in the loss of unsaved text.

Auto-save Functionality: Implement an auto-save feature that temporarily stores text within the input box. This way, even if the user navigates away accidentally, their text remains available when they return to that chat.

These features could significantly improve user experience and prevent frustration in using ChatGPT and any inadvertent loss of work.

1 Like

I don’t understand what you mean by the “Economics” section and the “Engineering” chat input box. Are you just referring to two of your own different ChatGPT conversations: one about economics and one about engineering?

Anyway, I think I experienced a similar issue while logged in to the ChatGPT desktop web app on Firefox. While writing a prompt, ie, a draft, I accidentally closed the Firefox tab before submitting my draft. I restored the Firefox tab (Command-Shift-T), and the conversation reappeared, but my prompt draft was gone. It’d be great if, similar to what you suggest, the chat interface autosaves the draft. Then, that would make a prompt warning unnecessary.

However, a prompt warning is likely easier to implement than an autosave feature, so a prompt warning could be a quick temporary fix, until the autosave feature is added. Here’s an example of how to implement such a prompt warning. The JavaScript code below checks if the prompt text box is empty, and if not, it prevents you from closing the tab, refreshing the tab, or navigating away from ChatGPT, but it doesn’t prevent you from switching to another conversation or page within ChatGPT, so it’s not complete.

function isPromptTextareaEmpty() {
  const promptDiv = document.getElementById('prompt-textarea')
  const pElement = promptDiv.querySelector('p')
  return pElement?.classList.contains('placeholder') ?? true
}

window.addEventListener('beforeunload', (event) => {
  if (!isPromptTextareaEmpty()) { event.preventDefault() }
})

Related topics

  • #952362: Implement autosave while writing prompts during messaging sessions
1 Like

I’ve edited to be clearer. I meant that when using the web interface, you have different chats/tabs on the left hand side. Switching between them before submitting whatever you were writing in one of them will result in that being lost. At least a few months ago when I posted this. Fully agree with your use case too, it’s the same outcome (losing what you were writing) only a different route to get that outcome.