Skip to content

feat: report new URL after actions that trigger navigation#1853

Open
rogeroliveira84 wants to merge 1 commit intoChromeDevTools:mainfrom
rogeroliveira84:feat/report-navigation-url
Open

feat: report new URL after actions that trigger navigation#1853
rogeroliveira84 wants to merge 1 commit intoChromeDevTools:mainfrom
rogeroliveira84:feat/report-navigation-url

Conversation

@rogeroliveira84
Copy link
Copy Markdown

Summary

  • Input tools (click, fill, press_key, hover, drag, type_text, fill_form, click_at) and evaluate_script now append a Page navigated to <url>. line to the response when the action triggers a cross-document navigation.
  • WaitForHelper.waitForEventsAfterAction returns {navigated: boolean} instead of void, surfacing the navigation signal that was already being detected internally.
  • No change to navigate_page or new_page since they already report the URL explicitly.

Fixes #243

Why

Today, if a click causes a page navigation, the response says "Successfully clicked on the element" with no indication that the page URL changed. The agent has to make an extra list_pages call to discover where it landed. This saves that round-trip for every navigation-triggering action.

Design

The existing waitForNavigationStarted in WaitForHelper already knows whether a cross-document navigation started. We propagate that signal as {navigated: boolean} through the return value of waitForEventsAfterActionMcpPageContextPage interface, and let each handler append the URL line when navigated is true.

Same-document (history API) navigations remain filtered out by the existing waitForNavigationStarted logic, matching current behavior. Click-opens-new-tab is a separate concern (#367).

Test plan

  • New test: click on a link that causes navigation → response includes Page navigated to <url>.
  • New test: click on a button that doesn't navigate → no navigation line in response
  • Full test suite (563 tests) passes
  • TypeScript typecheck clean
  • ESLint + Prettier clean

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 12, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@rogeroliveira84 rogeroliveira84 force-pushed the feat/report-navigation-url branch from 5a3832c to d281454 Compare April 12, 2026 04:13
Copy link
Copy Markdown
Collaborator

@Lightning00Blade Lightning00Blade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR,
there are some comments that would need to be address before we can merge.

Comment thread src/WaitForHelper.ts Outdated
Comment thread src/WaitForHelper.ts Outdated
Comment thread src/WaitForHelper.ts Outdated
Comment thread src/tools/input.ts Outdated
Comment thread src/tools/script.ts Outdated
Comment thread src/tools/script.ts Outdated
@masamaru0513
Copy link
Copy Markdown
Contributor

masamaru0513 commented Apr 24, 2026

Hi @rogeroliveira84, thanks for the original PR and the groundwork here! I noticed the review feedback from @Lightning00Blade hadn't been addressed yet, so I went ahead and opened #1954 incorporating those suggestions (navigatedToUrl naming, shared helper in WaitForHelper.ts, etc.).

@rogeroliveira84
Copy link
Copy Markdown
Author

Hi @Lightning00Blade I have on going work for that was planing to push later on, but once I do you can also check comment on it and see how it goes... cheers!

Input tools (click, fill, press_key, hover, drag, type_text,
fill_form, click_at) and evaluate_script now append a
"Page navigated to <url>." line to the response when the action
triggers a cross-document navigation.

WaitForHelper.waitForEventsAfterAction returns
{navigatedToUrl?: string} instead of void. The URL is detected by
comparing page.url() before and after the action, which is robust
against timing variations in navigation-start detection.

A shared appendWaitForResult helper is exposed from WaitForHelper
so input.ts and script.ts can both render the navigation line
without duplicating the logic.

Fixes ChromeDevTools#243
@rogeroliveira84 rogeroliveira84 force-pushed the feat/report-navigation-url branch from 3d02f39 to 8c875af Compare May 1, 2026 06:23
@rogeroliveira84
Copy link
Copy Markdown
Author

Hi @Lightning00Blade I pushed changes, could review pls. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Actions that result in a navigation should report the new page URL in the response

3 participants