Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION <Link onNavigate> prop not implemented This issue was created by an…

  1. User

    ISSUE DESCRIPTION

    <Link onNavigate> prop not implemented

    This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext main vs Next.js v16.2.6, 2026-05-20).

    Problem

    The onNavigate callback prop on <Link> (added in Next.js 15) does not fire. Tests that rely on onNavigate to detect navigations, intercept them, or track click state all fail.

    Specific failures include:

    • onNavigate callback never fires on click
    • Click state tracking broken (link thinks it was never clicked)
    • History state replacement via onNavigate return value not working

    Estimated Impact

    ~8 test failures.

    Affected Test Suites

    • test/e2e/link-on-navigate-prop/index.test.ts (8 failures)

    Recommendation

    1. Reproduce first in vinext's own test suite. Add a test with <Link href="/page" onNavigate={(e) => ...}> and verify the callback fires on click. Confirm it does not.

    2. Study the Next.js implementation. Search .nextjs-ref/packages/next/src/client/link.tsx for onNavigate to understand the API contract: when the callback fires, what arguments it receives, and how the return value affects navigation (e.g., preventing default, replacing history state).

    3. Implement onNavigate in the next/link shim. The Link component needs to call onNavigate before performing the navigation and respect the return value.

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /vinext, current file: none) bash-$

  2. GLM Assistant

    I'll start by exploring the repository structure to understand the codebase.

  3. GLM Assistant

    Let me look at the full file and the failing test suite.

  4. GLM Assistant

    No test file found. Let me search more broadly.

  5. GLM Assistant

    The test file doesn't exist in this repo yet. Let me look at the Next.js reference implementation to understand the onNavigate API contract.

  6. GLM Assistant

    Let me check the Next.js node_modules for the onNavigate implementation.

  7. GLM Assistant

    Let me look at the Next.js type definitions for onNavigate to understand the full contract.

  8. GLM Assistant

    Let me look at the full link.tsx file, particularly the props destructuring part that was truncated.

  9. GLM Assistant

    Let me check the git status to see the current state of changes.

  10. GLM Assistant

    The working tree is clean, meaning the onNavigate code already exists. Let me examine the existing tests that reference onNavigate to understand what's expected.

  11. GLM Assistant

    There's already an onNavigate test. Let me look at the fixture component and the Next.js test suite for link-on-navigate-prop.

  12. GLM Assistant

    Let me look at the Next.js test suite for link-on-navigate-prop. Let me search the whole filesystem for this test.

  13. GLM Assistant

    No such test file exists in the filesystem. The issue references a Next.js test that runs against vinext. Let me look at the pages-router link-advanced test that also references onNavigate.

  14. GLM Assistant

    Let me look at the existing unit tests for the link to understand the test setup.

  15. GLM Assistant

    Let me search for onNavigate in the unit tests and shims test.

  16. GLM Assistant

    Let me run the existing tests to see the current state.

  17. GLM Assistant

    Let me check the dist version of the link shim and compare.

  18. GLM Assistant

    Let me check the git history of the link.tsx file to see when onNavigate was added.

  19. GLM Assistant

    The onNavigate was added in commit cb2d1c9. Let me check how next/link is resolved and whether there's an App Router-specific link that might not have onNavigate.

  20. GLM Assistant

    Let me look at the existing onNavigate test in link-navigation.test.ts and the test harness.

  21. GLM Assistant

    Let me search for all references to the Next.js test path in the repo.

  22. GLM Assistant

    Let me look at the full onNavigate test block and surrounding context.

  23. GLM Assistant

    Let me search the whole filesystem for the Next.js test or any app fixture related to on-navigate.

  24. GLM Assistant

    Let me look at the full handleClick implementation with line numbers to carefully analyze it.

  25. GLM Assistant

    Let me look at the App Router link (app-dir/link.d.ts) — there might be a separate App Router Link implementation.

  26. GLM Assistant

    Let me look at the App Router's link.js to understand its onNavigate behavior.

  27. GLM Assistant

    The contract matches Next.js. Let me verify how next/link resolves to the shim in the build. Let me check the plugin's module resolution.

  28. GLM Assistant

    Let me verify the onNavigate commit is actually in the current HEAD's history.

  29. GLM Assistant

    Let me look at the dist version's onNavigate implementation to confirm the built artifact works.

  30. GLM Assistant

    Both src and dist have the implementation. Let me actually run the existing e2e tests for onNavigate to see if they pass. Let me check the test infrastructure first.

  31. GLM Assistant

    The implementation appears to exist in both src and dist. Let me actually run the existing onNavigate e2e test to see if it passes or fails. Let me build first.

  32. GLM Assistant

    Build succeeded. Now let me run the specific onNavigate e2e test.

  33. GLM Assistant

    Let me install the Playwright browser and also look for any Next.js test references in the repo.

  34. GLM Assistant

    Let me look at how the deploy suite runs Next.js tests against vinext.

  35. GLM Assistant

    Let me check the e2e-deploy script and search for any cached Next.js checkout.

  36. GLM Assistant

    No cached Next.js checkout. Let me look at the e2e-deploy.sh to understand how vinext deploys the Next.js test app. This is important to understand how next/link resolves.

  37. GLM Assistant

    Let me open the actual link.tsx file to carefully verify the current state of the onNavigate implementation.

  38. GLM Assistant

    Let me look at the vinext view-transitions example that uses onNavigate to understand the expected API.

  39. GLM Assistant

    The implementation looks correct. Let me install the Playwright browser and run the actual e2e test to see the real behavior.

  40. GLM Assistant

    The basic onNavigate test passes. The fix (cb2d1c9, Mar 12) predates the CI run (May 20), so there's a REMAINING bug. Let me find the actual Next.js test to understand the failing scenarios. Let me try to fetch it from GitHub.

  41. GLM Assistant

    I can access GitHub. Let me fetch the full test and the test app.

  42. GLM Assistant

    Now I have the actual test. Let me fetch the test app files to understand the structure.

  43. GLM Assistant

    Let me fetch the app-router and pages-router page structures.

  44. GLM Assistant

    I now have the full Next.js test and app. Let me analyze. The key scenarios involve external links with replace, modifier keys, download, target="_blank", and internal navigation with state tracking via a shared layout. Let me set up a temporary reproduction in the app-basic fixture. First, let me understand the app-basic fixture structure.

  45. GLM Assistant

    Let me create a temporary reproduction fixture mirroring the Next.js test app. Let me first check if app-basic has a pages directory and how existing nextjs-compat fixtures are structured.

  46. GLM Assistant

    Now let me create a temporary reproduction fixture mirroring the Next.js test app (App Router version). I'll add it under the app-basic fixture.

  47. GLM Assistant

    Now let me create a temporary spec to reproduce the Next.js test scenarios against the app-basic dev server.

  48. GLM Assistant

    Now let me run the temporary reproduction spec against the app-router dev server.

  49. GLM Assistant

    There's an issue with the helpers.ts import. It seems the spec file is being treated as ESM but helpers.ts uses CommonJS exports. Let me look at how the existing navigation.spec.ts imports the helper and check the helpers.ts file. Actually the existing spec imports from "../../helpers" and works. Let me check what's different. Maybe it's a TypeScript/ESM issue with how I named the file or the import.

    Wait, the error "exports is not defined in ES module scope" at helpers.ts:3. Line 3 is just a comment *. Hmm, that's odd. Actually the error points to helpers.ts line 3 char 23 which is in a comment block. That suggests the helpers.ts file might have exports somewhere and is being loaded as ESM. But the existing navigation.spec.ts imports it fine.

    Actually, maybe the issue is that my spec file location or naming causes it to be picked up by a DIFFERENT project config that compiles differently. Wait, "No tests found" after the error.

    Actually the real issue: the error happened during loading helpers.ts. But the existing navigation.spec.ts uses the same import. Let me check helpers.ts.

  50. GLM Assistant

    Let me rewrite the spec without the helper import (which is causing a load error) and use a simple content-based wait.

  51. GLM Assistant

    Let me use --grep to filter to my repro tests.

  52. GLM Assistant

    All tests fail — even the button click (toggle-lock) doesn't update state. This suggests the page isn't hydrated when I click. I removed the hydration helper. Let me check what waitForAppRouterHydration does.

  53. GLM Assistant

    The helper is at tests/e2e/helpers.ts. Let me fix the import path and use the hydration helper.

  54. GLM Assistant

    Let me view and fix the ready function using the editor.

  55. GLM Assistant

    The substitution mangled the template literal. Let me recreate the file cleanly using the create command.

  56. GLM Assistant

    With proper hydration, 6 of 7 App Router tests pass — only the external-link-with-replace test fails. Now let me check the Pages Router version, which may have more failures. Let me fetch the pages-router test app files.

  57. GLM Assistant

    Let me look at the pages-basic fixture structure to set up the Pages Router reproduction.

  58. GLM Assistant

    6 of 7 App Router tests pass in dev mode — only external+replace fails. But the deploy suite uses a production build. Let me test in production mode to see if more tests fail there. Let me check the app-basic build/start commands.

  59. GLM Assistant

    Let me build app-basic in production mode and test against it. First, let me parametrize the spec's BASE via env.

  60. GLM Assistant

    vinext build --prerender-all is the right command. Let me build app-basic in production mode.

  61. GLM Assistant

    Production server is running on 4184. Let me run the repro spec against it (the app-router project will still start the dev server, but my spec will hit the prod server via ONNAV_BASE).

  62. GLM Assistant

    Only the external-link-with-replace test fails in both dev and production. This is the "history state replacement" failure. Let me look at the full Link component to understand the href variables before fixing.

  63. GLM Assistant

    Only external+replace fails in the App Router (both dev and prod). The issue mentions 8 failures, so the Pages Router may have more. Let me set up a Pages Router reproduction. First, let me check the pages-basic vite config setup.

  64. GLM Assistant

    Let me set up the Pages Router reproduction. I'll create a shared OnNavigate component and conditionally wrap it in _app for the test routes (reversible). First the component and pages.

  65. GLM Assistant

    Now let me modify _app.tsx to conditionally wrap with OnNavigatePages for the test routes. Let me back it up first.

  66. GLM Assistant

    Now let me create the Pages Router repro spec.

  67. GLM Assistant

    Both routers confirm: only the external-link-with-replace test fails. This is the "history state replacement" bug. Now let me implement the fix in the link shim. Let me view the exact code to edit.

  68. GLM Assistant

    Now let me implement the fix — handle replace for truly external links by replacing history state, mirroring Next.js.

  69. GLM Assistant

    Now let me check whether the dev server uses the src or dist version of the shim, so I know what to rebuild.

  70. GLM Assistant

    Both dev and prod use the dist shim, so I must rebuild vinext. Let me rebuild.

  71. GLM Assistant

    The dist has the fix. Now I need to rebuild app-basic (which bundles the shim) and restart servers. Let me kill running servers and rebuild.

  72. GLM Assistant

    Now let me re-run the App Router repro against the rebuilt production server.

  73. GLM Assistant

    All tests now fail at hydration — the production server may not be serving the rebuilt bundle correctly. Let me check the server log and the page.

  74. GLM Assistant

    The server on 4184 is stale (referencing deleted old asset hashes). Let me check what's actually running and restart cleanly.

  75. GLM Assistant

    This is a build artifact caching issue unrelated to my fix. Let me verify via the dev server instead. Let me kill all servers, clear Vite cache, and run the dev repro (which uses the rebuilt dist shim).

  76. GLM Assistant

    All 7 App Router tests pass now (including external+replace). Let me run the Pages Router repro to confirm the fix works there too.

  77. GLM Assistant

    All 7 Pages Router tests pass too. Now let me verify I didn't break existing tests. Let me run the existing onNavigate e2e tests (navigation.spec.ts and link-advanced.spec.ts).

  78. GLM Assistant

    Existing onNavigate tests pass. Let me run the broader link test suites to ensure nothing broke. Let me run the full link-advanced spec (Pages) and the full navigation spec (App).

  79. GLM Assistant

    All link-advanced tests pass. Now let me run the unit tests for onNavigate to ensure they still pass.

  80. GLM Assistant

    The unit tests are slow to start. Let me check the vitest config and try running with the vp runner.

  81. GLM Assistant

    The onNavigate unit tests pass. Let me run the link-navigation unit tests (which include the onNavigate download-link test).

  82. GLM Assistant

    All 25 link-navigation unit tests pass. Let me verify applyLocaleToHref doesn't mangle external URLs (edge case for the location.replace(fullHref) path).

  83. GLM Assistant

    applyLocaleToHref preserves external URLs. Now let me verify the fix works in a production build too (the deploy suite uses production). Let me do a clean rebuild of app-basic.

  84. GLM Assistant

    The browser-specific project doesn't match my spec (it matches .browser.spec.ts). Let me run with the app-router project (which starts dev server at 4174, but my spec hits 4184 prod). The app-router project will start the dev server unnecessarily, but that's fine. Let me run just the "external link with replace" test against prod.

  85. GLM Assistant

    The fix works in production too. Now let me clean up all temporary reproduction files. Let me check git status to see everything I added/modified.

  86. GLM Assistant

    Let me clean up all temporary files and restore _app.tsx.

  87. GLM Assistant

    Only my link.tsx source change remains. Let me verify the dist is tracked/gitignored and check the final diff.

  88. GLM Assistant

    The dist is gitignored, so only the src change is submitted. Now let me make sure I didn't break other Link behaviors. Let me search for existing tests that exercise external links or replace on <Link>.

  89. GLM Assistant

    Let me check routing-misc.spec.ts which references external links, to ensure my change doesn't break external link handling.

  90. GLM Assistant

    That test is server-side, unaffected. Let me run the full app-router nextjs-compat navigation spec to confirm no regressions.

  91. GLM Assistant

    All navigation tests pass. Let me verify how non-http schemes (mailto:, tel:) are handled, to ensure my external-link change doesn't affect them.

  92. GLM Assistant

    mailto:/tel: are treated as external (not dangerous) and only my replace branch is new — non-replace external links are unchanged. Let me run the existing native-URI-scheme click test to be safe.

  93. GLM Assistant

    Let me see the full error for this test.

  94. GLM Assistant

    This is a test-isolation artifact (mock setup order with -t filter), not my change. Let me confirm by re-running the full file.

  95. GLM Assistant

    All 25 pass when running the full file. The -t failure was a test-isolation artifact. Let me do a final check of the repo state and confirm the dist is in sync with my source.

  96. GLM Assistant

    Everything is clean and in sync. Let me do a final review of the complete change in context.

  97. GLM Assistant

    The fix is complete and well-placed. Let me do a final verification of the complete diff to be submitted.

  98. GLM Assistant

    The diff is clean and minimal. Let me kill any lingering servers before submitting.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.