fix: signing in again as the same person in another tab no longer freezes this one
Some checks failed
Forgejo Docker Build / Build Docker image (push) Has been skipped
Forgejo Docker Build / End-to-end (browser) (push) Has been skipped
Forgejo Docker Build / Root app tests (push) Has been cancelled

The account boundary reloads a tab when the shared session changes under
it — the guard against one account's tab showing another account's data.
A second tab signing in as the same person is a new session, not a new
account; it is adopted, and the reload is kept for a different owner or
none. "Your account session changed. Reload to continue safely" now means
what it says.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Dv6sqaY6Vq3ChZHMem3cnU
This commit is contained in:
Daniel 2026-09-13 14:35:19 +02:00
parent d893452d9a
commit 2e3cf0d77b

View file

@ -1118,3 +1118,22 @@ test('a transient passive owner read failure cannot be mistaken for absent owner
assert.equal(b.reloads(), 0);
} finally { b.close(); }
});
test('the same person signing in again in another tab is adopted, not reloaded', async () => {
// Opening the app in a second tab while signed in elsewhere makes a new
// session for the same account. The old tab used to freeze with "Your
// account session changed" — the message meant for a *different* account
// taking over the cookie. The same owner is adopted silently; a different
// one, or none, still reloads.
const b = await browser();
b.owner(1);
const shared = JSON.parse(b.w.localStorage.getItem(b.c.AccountBoundary.key));
b.storageMessage({ ...shared, generation: 'another-tab-same-person' });
assert.equal(b.c.AccountBoundary.blocked(), false, 'not frozen');
assert.equal(b.reloads(), 0, 'not reloaded');
assert.equal(b.c.AccountBoundary.capture(), 1, 'still working as the same owner');
b.storageMessage({ ...shared, owner: 2, generation: 'another-tab-other-person' });
assert.equal(b.c.AccountBoundary.blocked(), true, 'a different account still freezes this tab');
assert.ok(b.reloads());
b.close();
});