An agent working in a browser it shares with a person navigated a tab. The person was in the middle of a
An agent working in a browser it shares with a person navigated a tab. The person was in the middle of a multi-step form; every field they had filled was gone. The SPA's Back button did not bring it back, because the step they were on had been reached with pushState, not a document load.
The report reads as a story about a careless click. It is not. It is a class of action, and the class is destructive: the thing being destroyed is not in the agent's control surface, cannot be snapshotted from the outside, and usually cannot be undone.
history.back() returns to a URL, and the component re-mounts with empty state. "The user can just press Back" is false in exactly the applications where this hurts most.beforeunload protects the user, not you. Browsers only raise that dialog for user-initiated unloads, and automation can dismiss or bypass it. Do not treat its presence as permission.Four rules, in order of how much they save you:
document.activeElement, dirty form fields, an open modal), and if any of that is true, stop and ask instead of navigating.target=_blank or an explicit new-tab/context step costs nothing and makes the ownership question disappear. The shared tab stays exactly as you found it.When a page genuinely needs to move, move it the way the application expects: click the app's own next/continue/submit control rather than assigning location or calling history.pushState. The app's control knows how to carry state forward; a navigation does not.
Before the navigation, this has to be true — and it is checkable, not a vibe:
tab opened by this task -> yes (otherwise: ask, do not navigate)
document.activeElement is not a form field -> true
no unsaved-input indicator on the page -> true
a snapshot of any state you need exists -> yes, outside the pageAfter the run, the person's form should be untouched: same step, same values, no reload. If that is not something you can assert, you have not finished the check — and the failure mode is somebody else's lost work, so "probably fine" is not a passing grade.
Do not reload again, do not click Back, and do not "help" by filling the form in. Read the current DOM and report exactly what is still there, including anything the app persisted to localStorage or a server-side draft — some frameworks keep per-step drafts even when the component state is gone. Then hand the decision to the person: they may know a resume path you cannot see.
beforeunload, and do not disable it to make automation simpler.State which tab you are acting on and why it is yours before you navigate, the way you would state which file you are about to delete. If you cannot answer that in one sentence, the answer is "open a new tab".