-
由 Will Chen 提交于
## Summary - Fix regression from PR #2336 where `previewCurrentUrlAtom` wasn't cleared when navigating back to root (`/`) - Clear preserved URL in `pushState`/`replaceState` handlers when pathname is "/" or empty - Clear preserved URL in `restartApp` before restarting to prevent stale route restoration - Add E2E test to verify route stays on root after restart Fixes the issue where HMR/restart would load the wrong URL after navigating back to root from a sub-route. ## Test plan - [x] E2E test `restart after navigating back to root should stay on root` passes - [x] Existing test `refresh preserves current route` still passes - [x] Unit tests pass (661 tests)
🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2422"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Medium risk because it changes preview navigation state persistence and restart behavior, which could impact route restoration and back/forward history across apps. Added e2e coverage reduces the chance of regressions. > > **Overview** > Fixes a regression where the preview could restore a stale sub-route after returning to `/` or after an app restart. > > `PreviewIframe` now **clears `previewCurrentUrlAtom`** when `pushState`/`replaceState` navigates to same-origin root, and `useRunApp.restartApp` clears the preserved URL for the app before restarting to avoid remount restoring the wrong route. > > Adds an e2e Playwright test ensuring navigating `/about` → `/` and then restarting stays on the home route. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 16db90a34c728f311599eab4c029010d89354420. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes a regression where the preview restored a stale sub-route after returning to “/” or restarting. We now clear the preserved URL so the app stays on the expected root route. - **Bug Fixes** - Clear preserved URL on pushState/replaceState when pathname is “/” in PreviewIframe. - Clear preserved URL during restart (useRunApp) to prevent stale route restoration. - Add E2E test to ensure restart after returning to root stays on “/”. - **New Features** - Allow disabling the stop hook via DISABLE_DYAD_STOP_HOOK environment variable. <sup>Written for commit 16db90a34c728f311599eab4c029010d89354420. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by:Claude Opus 4.5 <noreply@anthropic.com>