| @@ -1,20 +1,13 @@ | ||
| 1 | 1 | import { flushChatStorage } from '@agent/state/chat'; |
| 2 | 2 | import { useStatusStore } from '@agent/state/status'; |
| 3 | 3 | |
| 4 | -const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); | |
| 5 | - | |
| 6 | 4 | // Components navigate through this so the pending chat save always lands first. |
| 7 | 5 | export const doReload = async (url) => { |
| 8 | 6 | const flush = flushChatStorage(); |
| 9 | - // Quick saves skip the overlay; once shown it holds 1s so it never flashes. | |
| 10 | - const saveIsSlow = await Promise.race([ | |
| 11 | - flush.then(() => false), | |
| 12 | - wait(2000).then(() => true), | |
| 13 | - ]); | |
| 14 | - if (saveIsSlow) { | |
| 15 | - useStatusStore.getState().setLeavingPage(true); | |
| 16 | - await Promise.all([flush, wait(1000)]); | |
| 17 | - } | |
| 7 | + // Set before the success message paints; the reloaded page opens on this rail. | |
| 8 | + document.documentElement.classList.add('extendify-agent-reloading'); | |
| 9 | + useStatusStore.getState().setLeavingPage(true); | |
| 10 | + await flush; | |
| 18 | 11 | if (url) return window.location.assign(url); |
| 19 | 12 | window.location.reload(); |
| 20 | 13 | }; |