mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Keep history entries untouched by unfinished globe picks and restore each visited entry's layers
A picked engine now lives in the switch until it runs; only then is the address written, so a pick superseded by Back or one that fails rewrites no entry. An engine-changing history visit holds the outgoing share link, which neither restores nor writes the visited entry, and the running engine takes the address back once the switch settles, restoring any entry visited while it was held or not yet listening. Handed-off layers keep running where the incoming address agrees with the outgoing one and follow a visited entry where it differs. A failed recovery keeps the error on the loading screen with an engine picker for a retry, and a failing reveal of the new globe no longer blocks the cover removal or later requests.
This commit is contained in:
1 parent
9cc34e324f
commit
a066a2d1ca
10 files changed
+539
-113
No files matched your search
@@ -45,6 +45,24 @@ function currentLayerOutcome(dataManager, layerId) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a layer handed off by an engine switch runs on the incoming engine.
|
||||
* The handoff records the layer's running state and whether the outgoing
|
||||
* address listed it. Where the incoming address agrees with that, the layer
|
||||
* keeps running as it was, operational intents included (a Contacts session
|
||||
* runs layers its address never lists). Where it differs, the person visited
|
||||
* an entry with another layer set (Back/Forward), and the entry wins, as it
|
||||
* does for a same-engine Back.
|
||||
* @param {{enabled?: boolean, durable?: boolean}|undefined} live
|
||||
* @param {boolean} addressEnabled
|
||||
*/
|
||||
export function handoffTargetEnabled(live, addressEnabled) {
|
||||
if (typeof live?.enabled !== 'boolean') return addressEnabled;
|
||||
if (typeof live.durable === 'boolean' && live.durable !== addressEnabled)
|
||||
return addressEnabled;
|
||||
return live.enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Owns durable user layer preferences independently from transient runtime
|
||||
* choreography, and coordinates passive post-registration restoration.
|
||||
@@ -382,7 +400,10 @@ export class LayerStateCoordinator {
|
||||
LAYER_STATE_REGISTRY.map(async (entry) => {
|
||||
const controller = controllers.get(entry.id);
|
||||
const live = handoffLayers?.get(entry.id);
|
||||
const targetEnabled = live?.enabled ?? enabled.has(entry.id);
|
||||
const targetEnabled = handoffTargetEnabled(
|
||||
live,
|
||||
enabled.has(entry.id),
|
||||
);
|
||||
// A same-document engine choice retains operational layer intents.
|
||||
// The share still owns durable preferences and later history visits.
|
||||
if (live && this.dataManager.layers.get(entry.id) === live.entry &&
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { handoffTargetEnabled } from './layerStateCoordinator.js';
|
||||
|
||||
test('a pick keeps every handed-off layer as it runs', () => {
|
||||
// The incoming address is the outgoing one: it agrees everywhere.
|
||||
assert.equal(
|
||||
handoffTargetEnabled({ enabled: true, durable: true }, true),
|
||||
true,
|
||||
);
|
||||
// A Contacts session runs layers its address never lists.
|
||||
assert.equal(
|
||||
handoffTargetEnabled({ enabled: true, durable: false }, false),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
handoffTargetEnabled({ enabled: false, durable: true }, true),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('a visited entry with another layer set wins where it differs', () => {
|
||||
assert.equal(
|
||||
handoffTargetEnabled({ enabled: false, durable: false }, true),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
handoffTargetEnabled({ enabled: true, durable: true }, false),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('without a handoff record the address decides', () => {
|
||||
assert.equal(handoffTargetEnabled(undefined, true), true);
|
||||
assert.equal(handoffTargetEnabled({ entry: null }, false), false);
|
||||
// A record without the outgoing address keeps the running state.
|
||||
assert.equal(handoffTargetEnabled({ enabled: true }, false), true);
|
||||
});
|
||||
Reference in new issue
Block a user