# extendify/3.2.1/src/Agent/lib/reload.js

Extendify, version 3.2.1. 21 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.2.1/code/src/Agent/lib/reload.js
- Raw: https://pluginprobe.com/plugins/extendify/3.2.1/raw/src/Agent/lib/reload.js
- Modified: 2026-08-20T19:51:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.2.1/code/src/Agent/lib/reload.js#L10-L20`.

```javascript
import { flushChatStorage } from '@agent/state/chat';
import { useStatusStore } from '@agent/state/status';

const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

// Components navigate through this so the pending chat save always lands first.
export const doReload = async (url) => {
	const flush = flushChatStorage();
	// Quick saves skip the overlay; once shown it holds 1s so it never flashes.
	const saveIsSlow = await Promise.race([
		flush.then(() => false),
		wait(2000).then(() => true),
	]);
	if (saveIsSlow) {
		useStatusStore.getState().setLeavingPage(true);
		await Promise.all([flush, wait(1000)]);
	}
	if (url) return window.location.assign(url);
	window.location.reload();
};

```
