• Will Chen's avatar
    Fix preserved URL not cleared when navigating to root or restarting (#2422) · 92b90720
    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: 's avatarClaude Opus 4.5 <noreply@anthropic.com>
    92b90720
名称
最后提交
最后更新
.claude 正在载入提交数据...
.cursor/rules 正在载入提交数据...
.devcontainer 正在载入提交数据...
.github 正在载入提交数据...
.husky 正在载入提交数据...
assets 正在载入提交数据...
docs 正在载入提交数据...
drizzle 正在载入提交数据...
e2e-tests 正在载入提交数据...
makers 正在载入提交数据...
packages/@dyad-sh 正在载入提交数据...
scaffold 正在载入提交数据...
scripts 正在载入提交数据...
shared 正在载入提交数据...
src 正在载入提交数据...
testing 正在载入提交数据...
tools 正在载入提交数据...
worker 正在载入提交数据...
workers/tsc 正在载入提交数据...
.cursorignore 正在载入提交数据...
.env.example 正在载入提交数据...
.eslintrc.json 正在载入提交数据...
.gitattributes 正在载入提交数据...
.gitignore 正在载入提交数据...
.oxfmtrc.json 正在载入提交数据...
.oxlintrc.json 正在载入提交数据...
.prettierignore 正在载入提交数据...
.prettierrc 正在载入提交数据...
AGENTS.md 正在载入提交数据...
CLA.md 正在载入提交数据...
CLAUDE.md 正在载入提交数据...
CONTRIBUTING.md 正在载入提交数据...
LICENSE 正在载入提交数据...
README.md 正在载入提交数据...
SECURITY.md 正在载入提交数据...
biome.json 正在载入提交数据...
components.json 正在载入提交数据...
drizzle.config.ts 正在载入提交数据...
forge.config.ts 正在载入提交数据...
forge.env.d.ts 正在载入提交数据...
index.html 正在载入提交数据...
lint-staged.config.js 正在载入提交数据...
merge.config.ts 正在载入提交数据...
package-lock.json 正在载入提交数据...
package.json 正在载入提交数据...
playwright.config.ts 正在载入提交数据...
tsconfig.app.json 正在载入提交数据...
tsconfig.json 正在载入提交数据...
tsconfig.node.json 正在载入提交数据...
vite.main.config.mts 正在载入提交数据...
vite.preload.config.mts 正在载入提交数据...
vite.renderer.config.mts 正在载入提交数据...
vite.worker.config.mts 正在载入提交数据...
vitest.config.ts 正在载入提交数据...