Skip to content

feat: group identical consecutive console messages in list_console_messages#1938

Closed
masamaru0513 wants to merge 2 commits intoChromeDevTools:mainfrom
masamaru0513:feat/group-identical-console-messages
Closed

feat: group identical consecutive console messages in list_console_messages#1938
masamaru0513 wants to merge 2 commits intoChromeDevTools:mainfrom
masamaru0513:feat/group-identical-console-messages

Conversation

@masamaru0513
Copy link
Copy Markdown
Contributor

Summary

Group consecutive identical console messages in list_console_messages, similar to Chrome DevTools' console grouping behavior.

Fixes #904

Changes

  • Add ConsoleFormatter.groupConsecutive() static method that groups consecutive messages with the same type, text, and argument count
  • Add toStringGrouped() / toJSONGrouped() for count-aware formatting
  • Add lastId to grouped output so consumers can access the last message in a group via get_console_message
  • 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

Output example

msgid=1 [log] hello world (1 args) [5 times, last msgid=5]

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)

…ssages

Group consecutive messages with the same type and text, displaying a
count suffix (e.g. [20 times]) similar to Chrome DevTools' console
grouping behavior. Grouping is applied before pagination so the
grouped count accurately reflects the total items.

- Add groupConsecutive() static method to ConsoleFormatter
- Add toStringGrouped()/toJSONGrouped() for count-aware formatting
- Add optional count field to ConsoleMessageConcise interface
- Apply grouping in McpResponse before pagination

Fixes ChromeDevTools#904
@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 22, 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.

Extend console message grouping to include lastId so that consumers
can access the last message in a group via get_console_message.
Also require argCount to match for grouping, preventing false
grouping of messages with different argument counts.

- Add lastId field to grouped output (string and JSON)
- Add argCount equality check in groupConsecutive()
- Add unit tests for grouping, toStringGrouped, toJSONGrouped

Fixes ChromeDevTools#904
@masamaru0513 masamaru0513 force-pushed the feat/group-identical-console-messages branch from 907f3ed to aad515d Compare April 22, 2026 13:32
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.

Identical console messages should be grouped together in the list_console_messages tool

1 participant