feat(console): group consecutive identical console messagesfeat(console): group consecutive identical console messages#963
Closed
SucRunBug wants to merge 1 commit intoChromeDevTools:mainfrom
Conversation
|
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. |
OrKoN
requested changes
Feb 16, 2026
Collaborator
OrKoN
left a comment
There was a problem hiding this comment.
Thanks for the PR! we should be grouping data when we receive not when we format the response for pagination to work correctly. If you update the PR, please sign the CLA as well.
Collaborator
|
Closing as stale. |
This was referenced Apr 22, 2026
pull Bot
pushed a commit
to oogalieboogalie/chrome-devtools-mcp
that referenced
this pull request
Apr 23, 2026
…ssages (ChromeDevTools#1939) ## Summary Group consecutive identical console messages in `list_console_messages`, similar to Chrome DevTools' console grouping behavior. Fixes ChromeDevTools#904 ## Changes - Introduce `GroupedConsoleFormatter` subclass that extends `ConsoleFormatter` and overrides `toString()` / `toJSON()` for count-aware formatting - Add `ConsoleFormatter.groupConsecutive()` static method that groups consecutive messages with the same type, text, and argument count - Apply grouping **before pagination** so grouped counts are accurate and page sizes reflect the collapsed view - Add unit tests for grouping logic, string formatting, and JSON output ## Key design decisions - **`GroupedConsoleFormatter` subclass**: Keeps the existing formatter interface clean — no new methods added to `ConsoleFormatter`. `ConsoleFormatter` and `GroupedConsoleFormatter` are interchangeable via the same interface. - **Grouping before pagination** (not at format time): This was the feedback on ChromeDevTools#963 and ChromeDevTools#1025 — grouping at format time breaks pagination counts. This implementation groups in `McpResponse` before calling `paginate()`. - **No `lastId`**: Since grouped messages are truly identical, only the first message's ID is needed. - **`argCount` matching**: Prevents false grouping of messages with the same text but different argument counts. ## Output example ``` msgid=1 [log] hello world (1 args) [5 times] ``` ## Testing - Unit tests in `tests/formatters/ConsoleFormatterGrouping.test.ts` - Manual verification: identical messages (×5), mixed pattern (A,A,B,A,A → A×2, B×1, A×2)
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
list_console_messages.[N times]suffix in text output for collapsed duplicates.occurrencesto structured console message output when duplicates are collapsed.Closes #904.
Changes
/Users/yanmai/Downloads/MCP 测试/chrome-devtools-mcp/src/McpResponse.ts/Users/yanmai/Downloads/MCP 测试/chrome-devtools-mcp/tests/tools/console.test.tsgroups consecutive identical messagestest.Validation
npm run typechecknpx eslint src/McpResponse.ts tests/tools/console.test.tsPUPPETEER_EXECUTABLE_PATH='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' npm run test:no-build -- --test-name-pattern='groups consecutive identical messages' tests/tools/console.test.tsPUPPETEER_EXECUTABLE_PATH='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' npm run test:no-build -- --test-name-pattern='adds console messages when the setting is true' tests/McpResponse.test.ts