This is a UX bug.
Kagi Translate does not make proper (or any?) use of the browser's history API. This means that when I e.g. click the "switch languages" button reversing the source and target language, I cannot get my original source text back: Clicking the back button leaves the Translate page. So my text is lost, and I have to remember to back it up before typing it into Kagi Translate. Clicking anything in the Kagi Translate is irreversible and potentially leads to data loss.
There is a design space and several considerations here. For example, typing anything into the source text area changes the URL, and should not update the history on every single keypress, since that will render the back button equally useless (clicking back shouldn't delete a single character). So while a perfect solution might also create history checkpoints when typing, this is also somewhat handled by the browser's typing undo functionality.
Other and more important events that might trigger first:
- Flipping source and target language
- Switching between "standard" and "best"
- Changing source language in the dropdown
- Changing target language in the dropdown
- Changing translation style (several options)
- ...
Because the list is open-ended, it also leaves a hole for forgetting to add history checkpoints to future UI components. (This is something a pattern match on a sum type in a strictly typed language would solve.)
It might get a little tricky to determine what "back" is when the source text is part of the URL; so clicking back would indirectly revert the text. This is okay, and results in a not useless level of granularity for undo'ing the text itself, even without explicitly checkpointing the text.
Adding history checkpointing to Kagi Translate's UI leaves the possibility of caching the result, since any history navigation is going to trigger a re-render of the exact same text, so there is a high potential of optimizing token use here. The caching isn't required to fulfill the functionality, and can be added after. Surely, caching carries its own complexity since there are multiple UI elements that load asynchronously, so the total cached state has structure.
When switching languages, or changing languages, or changing the translation style or quality, clicking the browser's back button should backtrack on those choices and revert the text in larger chunks if necessary.