Repository navigation
feat: group identical consecutive console messages in list_console_messages - #1939
Merged
OrKoN merged 1 commit intoApr 23, 2026
Conversation
masamaru0513
force-pushed
the
feat/group-identical-console-messages
branch
2 times, most recently
from
April 22, 2026 13:40
46d187b to
65c63d8
Compare
OrKoN
reviewed
Apr 22, 2026
masamaru0513
force-pushed
the
feat/group-identical-console-messages
branch
from
April 22, 2026 14:00
65c63d8 to
6e3d0de
Compare
Contributor
Author
|
@OrKoN
Ready for another look when you get a chance. Thanks! |
Collaborator
|
Please update the PR description accordingly. |
OrKoN
self-requested a review
April 22, 2026 14:07
Contributor
Author
|
@OrKoN |
…ssages Group consecutive console messages with the same type, text, and argument count into a single entry with a count indicator (e.g. [5 times]). Introduces GroupedConsoleFormatter subclass that extends ConsoleFormatter to handle grouped message display.
OrKoN
force-pushed
the
feat/group-identical-console-messages
branch
from
April 23, 2026 09:42
6e3d0de to
4c95f28
Compare
pull Bot
pushed a commit
to Mu-L/chrome-devtools-mcp
that referenced
this pull request
May 4, 2026
🤖 I have created a release *beep* *boop* --- ## [0.24.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v0.23.0...chrome-devtools-mcp-v0.24.0) (2026-05-02) ### 🎉 Features * agentic browsing in lighthouse ([ChromeDevTools#1931](ChromeDevTools#1931)) ([5fa2750](ChromeDevTools@5fa2750)) * **cli:** generate commands for conditional tools ([ChromeDevTools#1962](ChromeDevTools#1962)) ([b2b3e99](ChromeDevTools@b2b3e99)) * group identical consecutive console messages in list_console_messages ([ChromeDevTools#1939](ChromeDevTools#1939)) ([dbddb2e](ChromeDevTools@dbddb2e)) * support MCP client roots feature ([ChromeDevTools#1945](ChromeDevTools#1945)) ([def53dd](ChromeDevTools@def53dd)) ### 🛠️ Fixes * add proactive tool rejection when dialog is open ([ChromeDevTools#1978](ChromeDevTools#1978)) ([6ce254e](ChromeDevTools@6ce254e)) * always allow tmpdir access with client roots ([ChromeDevTools#1984](ChromeDevTools#1984)) ([a90378a](ChromeDevTools@a90378a)) * **cli:** re-generate cli correctly ([ChromeDevTools#1969](ChromeDevTools#1969)) ([8cbdb8d](ChromeDevTools@8cbdb8d)) * handle errors due to open dialogs during tool calls ([ChromeDevTools#1953](ChromeDevTools#1953)) ([06b331f](ChromeDevTools@06b331f)) * note about missing elements should not show in verbose mode ([ChromeDevTools#1950](ChromeDevTools#1950)) ([80bee1e](ChromeDevTools@80bee1e)) * **telemetry:** bucketize string length ([ChromeDevTools#1972](ChromeDevTools#1972)) ([bf3cb58](ChromeDevTools@bf3cb58)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
zjdCander
pushed a commit
to zjdCander/chrome-devtools-mcp
that referenced
this pull request
Nov 26, 2026
…jects (ChromeDevTools#3642) ## Summary `list_console_messages` merges consecutive messages that log different objects into one line. `groupConsecutive()` compares type, text and argument count, and the text comes from Puppeteer's `msg.text()`, which renders every object argument as a fixed placeholder like `[object Object]`. So a loop such as `items.forEach(i => console.log(i))` shows up as a single entry, and only the first message ID is listed. The other objects can only be reached by guessing their IDs for `get_console_message`. ChromeDevTools#1939 kept only the first ID on the assumption that grouped messages are identical. That doesn't hold for object arguments. A number and a string with the same text (`console.log(1)` then `console.log('1')`) were also merged. ## Reproduction A page that runs: ```js for (const user of [{id: 1}, {id: 2}, {id: 3}]) console.log(user); console.log(1); console.log('1'); for (const id of [10, 20]) console.error({failedId: id}); ``` `list_console_messages` on main: ``` msgid=1 [log] [object Object] (1 args) [3 times] msgid=4 [log] 1 (1 args) [2 times] msgid=6 [error] [object Object] (1 args) [2 times] ``` `get_console_message msgid=2` returns the second object, but msgid=2 never appears in the list. With this change all 7 messages are listed separately. ## Fix `groupConsecutive()` now also compares the arguments' remote objects (type, subtype, value, unserializableValue, description), the same fields DevTools compares in `ConsoleMessage.isEqual`. As in DevTools, an argument that is an object other than an error never compares equal. Null is treated as a plain value and still groups. Uncaught errors have no arguments, so they still group by their text as before. ## User-visible changes Both places that use `groupConsecutive()` change the same way: `list_console_messages` and the "Console errors during this call" section that `navigate_page`, `evaluate_script` and other tools append. - Consecutive messages that log a non-error object (plain objects, arrays, DOM nodes, Map/Set) are listed one per message instead of as `[N times]`. A loop that logs objects now produces N lines, so output grows in that case. Because there are fewer groups, the 10-entry cap on "Console errors during this call" can fill sooner. - Primitives with the same text but a different type are no longer grouped. - Messages that log errors with the same message but a different stack are no longer grouped. - Repeated identical strings, numbers, null, identical errors, and repeated uncaught errors or promise rejections still group as before. ## Tests Seven new cases in `tests/formatters/ConsoleFormatterGrouping.test.ts`. Three fail on main (different objects, number vs string, errors with different stacks) and pass with the fix. The others check that same strings, null, same errors and repeated uncaught errors still group. `npm run check-format` and `npm run build` are clean. `npm run test` passes locally (macOS arm64, Node 24, Chrome for Testing 157). I also ran the built server against the page above and against pages logging repeated strings, repeated uncaught errors from `setInterval`, and repeated identical promise rejections: those still group. Same call site is still not part of the comparison (DevTools also compares url, line and stack), so identical text logged from different lines still groups, same as main. That seemed like a separate change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Group consecutive identical console messages in
list_console_messages, similar to Chrome DevTools' console grouping behavior.Fixes #904
Changes
GroupedConsoleFormattersubclass that extendsConsoleFormatterand overridestoString()/toJSON()for count-aware formattingConsoleFormatter.groupConsecutive()static method that groups consecutive messages with the same type, text, and argument countKey design decisions
GroupedConsoleFormattersubclass: Keeps the existing formatter interface clean — no new methods added toConsoleFormatter.ConsoleFormatterandGroupedConsoleFormatterare interchangeable via the same interface.McpResponsebefore callingpaginate().lastId: Since grouped messages are truly identical, only the first message's ID is needed.argCountmatching: Prevents false grouping of messages with the same text but different argument counts.Output example
Testing
tests/formatters/ConsoleFormatterGrouping.test.ts