Skip to content

feat(console): group consecutive identical console messagesfeat(console): group consecutive identical console messages#963

Closed
SucRunBug wants to merge 1 commit intoChromeDevTools:mainfrom
SucRunBug:codex/issue-904-group-console-messages
Closed

feat(console): group consecutive identical console messagesfeat(console): group consecutive identical console messages#963
SucRunBug wants to merge 1 commit intoChromeDevTools:mainfrom
SucRunBug:codex/issue-904-group-console-messages

Conversation

@SucRunBug
Copy link
Copy Markdown

Summary

  • Group consecutive identical messages in list_console_messages.
  • Add [N times] suffix in text output for collapsed duplicates.
  • Add occurrences to structured console message output when duplicates are collapsed.
  • Add test coverage for grouped duplicate console messages.

Closes #904.

Changes

  • /Users/yanmai/Downloads/MCP 测试/chrome-devtools-mcp/src/McpResponse.ts
    • Added grouping/formatting logic for consecutive identical console messages.
  • /Users/yanmai/Downloads/MCP 测试/chrome-devtools-mcp/tests/tools/console.test.ts
    • Added groups consecutive identical messages test.

Validation

  • npm run typecheck
  • npx eslint src/McpResponse.ts tests/tools/console.test.ts
  • PUPPETEER_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.ts
  • PUPPETEER_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

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Feb 14, 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.

Copy link
Copy Markdown
Collaborator

@OrKoN OrKoN 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! 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.

@OrKoN
Copy link
Copy Markdown
Collaborator

OrKoN commented Mar 2, 2026

Closing as stale.

@OrKoN OrKoN closed this Mar 2, 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)
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

2 participants