Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: resume deferred travel projection updates without polling (#8536)

[._.]/ Adam Eivy9bf157f34715
diff --git a/client/src/components/eidoverse/EidoverseTravel.jsx b/client/src/components/eidoverse/EidoverseTravel.jsx
index ff88e123f8..252b07a998 100644
--- a/client/src/components/eidoverse/EidoverseTravel.jsx
+++ b/client/src/components/eidoverse/EidoverseTravel.jsx
@@ -13,8 +13,6 @@ export default function EidoverseTravel({ travelRef, enabled, objects = [], onDe
const [pending, setPending] = useState(null);
const [error, setError] = useState('');
const generation = useRef(0);
- const destinationsChanged = useRef(onDestinationsChange);
- destinationsChanged.current = onDestinationsChange;
const lastDestinations = useRef(null);
const busy = useRef(false);
const mounted = useMounted();
@@ -27,9 +25,18 @@ export default function EidoverseTravel({ travelRef, enabled, objects = [], onDe
if (!Array.isArray(result?.destinations)) return;
setDestinations(result.destinations);
const fingerprint = JSON.stringify(result.destinations.map((entry) => entry.peerId).sort());
- if (lastDestinations.current === null || fingerprint === lastDestinations.current
- || destinationsChanged.current?.() !== false) lastDestinations.current = fingerprint;
+ if (lastDestinations.current === null) lastDestinations.current = fingerprint;
}, []);
+ useEffect(() => {
+ if (!watching || lastDestinations.current === null) return;
+ const fingerprint = JSON.stringify(destinations.map((entry) => entry.peerId).sort());
+ // The parent can defer while projecting or editing. Retry when its
+ // callback changes after that gate clears, without waiting for a poll
+ // or another (possibly unchanged) server snapshot.
+ if (fingerprint !== lastDestinations.current && onDestinationsChange?.() !== false) {
+ lastDestinations.current = fingerprint;
+ }
+ }, [destinations, onDestinationsChange, watching]);
const refresh = useCallback(async () => {
const current = generation.current;
const sequence = ++fetchSequence.current;
diff --git a/client/src/components/eidoverse/EidoverseTravel.test.jsx b/client/src/components/eidoverse/EidoverseTravel.test.jsx
index d22fed3a8e..4d68d9d3b0 100644
--- a/client/src/components/eidoverse/EidoverseTravel.test.jsx
+++ b/client/src/components/eidoverse/EidoverseTravel.test.jsx
@@ -123,3 +123,18 @@ it('keeps a pushed destination snapshot when an older read finishes later', asyn
await act(async () => finish({ destinations: [] }));
expect(screen.getByRole('button', { name: 'Current world' })).toBeInTheDocument();
});
+
+it('retries a deferred world update when the parent becomes ready without another destination event', async () => {
+ const travelRef = createRef();
+ const deferred = vi.fn(() => false);
+ const ready = vi.fn(() => true);
+ const view = render(<EidoverseTravel enabled travelRef={travelRef} onDestinationsChange={deferred} />);
+ await screen.findByRole('button', { name: 'Example world' });
+ await act(async () => socket.receive('eidoverse-travel:destinations', {
+ destinations: [{ peerId: 'next-peer', label: 'Next world' }],
+ }));
+ expect(deferred).toHaveBeenCalledTimes(1);
+ view.rerender(<EidoverseTravel enabled travelRef={travelRef} onDestinationsChange={ready} />);
+ expect(ready).toHaveBeenCalledTimes(1);
+ expect(getEidoverseDestinations).toHaveBeenCalledTimes(1);
+});