Visitar URL original
chore: make get_devtools_comments wait for new comments by OrKoN · Pull Request #3158 · ChromeDevTools/chrome-devtools-mcp · GitHub
Skip to content

chore: make get_devtools_comments wait for new comments - #3158

Merged
OrKoN merged 2 commits into
mainfrom
orkon/blocking-devtools-comments-main
Oct 19, 2026
Merged

OrKoN merged 2 commits into
mainfrom
orkon/blocking-devtools-comments-main

Conversation

@OrKoN

@OrKoN OrKoN commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

get_devtools_comments now waits for the next CommentThreadsChanged event when no comment is pending. This replaces the sleep 10 polling loop in the agent with one tool call per wait.

  • New timeout parameter: 0–30000 ms, default 10000. timeout: 0 returns immediately (previous behavior).
  • The handler fetches first. If no thread is pending, it waits for the event and fetches again, until a thread arrives or the deadline passes.
  • On timeout the response contains No open DevTools comments found. and a note with the elapsed wait time.

Lock handling

ToolHandler holds a server-wide mutex per tool call. A blocking wait under that lock would stall every other tool call.

This PR adds an optional yieldsToolLock flag on tool definitions. For such tools, ToolHandler releases the mutex after page lookup and before the handler runs, then re-acquires it before the response is built. Page lookup, init(), dialog checks, and response formatting stay under the lock. Only get_devtools_comments sets the flag. The handler re-fetches after each wake-up because the DevTools bridge hands out each thread only once.

Tests

  • ToolHandler: another tool runs while a yielding tool waits; non-yielding tools still hold the lock; the yielding tool's response is built only after a queued tool releases the lock (FIFO); the lock is re-acquired when a yielding handler throws.
  • DevToolsCommentBridge.waitForCommentEvent: resolves on event, timeout, and dispose; concurrent waiters; no stale events.
  • get_devtools_comments: sets yieldsToolLock; no wait when threads exist; wait then re-fetch; keep waiting after an empty event; timeout result; elapsed time when the wait ends early; timeout: 0.

Follow-up

The debug-in-devtools skill (separate branch) still describes sleep 10 polling. It will be updated after this lands.

@OrKoN OrKoN changed the title feat: make get_devtools_comments wait for new comments chore: make get_devtools_comments wait for new comments Oct 15, 2026
OrKoN

This comment was marked as resolved.

@OrKoN
OrKoN force-pushed the orkon/blocking-devtools-comments-main branch 2 times, most recently from 4350221 to 81b3d5d Compare October 15, 2026 14:18
@OrKoN

OrKoN commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

@yulunz @Lightning00Blade PTAL. WDYT?

Comment thread src/tools/comments.ts Resolved

@Lightning00Blade Lightning00Blade left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@yulunz yulunz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm but this feels like another method for me (i.e. poll_devtools_comments()), and the original get_devtools_comments is supposed to return fast and still blocking.

Comment thread src/tools/comments.ts Resolved
@OrKoN

OrKoN commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

lgtm but this feels like another method for me (i.e. poll_devtools_comments()), and the original get_devtools_comments is supposed to return fast and still blocking.

but we do not need the original method? timeout: 0 achieves the original behavior without the waiting.

@yulunz

yulunz commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

lgtm but this feels like another method for me (i.e. poll_devtools_comments()), and the original get_devtools_comments is supposed to return fast and still blocking.

but we do not need the original method? timeout: 0 achieves the original behavior without the waiting.

both are fine with me.

OrKoN added 2 commits October 19, 2026 08:26
The tool now waits for the next CommentThreadsChanged event when no
comment is pending. The default wait is 10 s and the maximum is 30 s.
Set timeout to 0 to return immediately.

Tools can set yieldsToolLock. ToolHandler then releases the server tool
lock before the handler runs and re-acquires it before the response is
built, so other tool calls proceed during the wait. The handler
re-fetches comments after each wake-up because the DevTools bridge
hands out each thread only once.
@OrKoN
OrKoN force-pushed the orkon/blocking-devtools-comments-main branch from 81b3d5d to 9f40249 Compare October 19, 2026 07:09
@OrKoN
OrKoN enabled auto-merge October 19, 2026 07:10
@OrKoN
OrKoN added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit 5f185f9 Oct 19, 2026
17 checks passed
@OrKoN
OrKoN deleted the orkon/blocking-devtools-comments-main branch October 19, 2026 07:16
zjdCander pushed a commit to zjdCander/chrome-devtools-mcp that referenced this pull request Oct 19, 2026
…DevTools#3162)

Stacked on ChromeDevTools#3158.

## Summary

The comment bridge sent a `notifications/message` (logging) notification
on each comment change. MCP clients do not forward these notifications
to the model, so the notification had no effect on agent behavior. After
ChromeDevTools#3158, `get_devtools_comments` waits for comment events directly.

This PR removes the `onNotification` plumbing from `McpServer`,
`McpContext`, `McpPage`, and `DevToolsCommentBridge`. The `logging`
capability itself stays; it predates the comments feature.

## Tests

The two bridge tests that asserted on `onNotification` now assert
through `waitForCommentEvent`: the debounce still coalesces rapid
events, and `dispose()` still cancels a pending event.
zjdCander pushed a commit to zjdCander/chrome-devtools-mcp that referenced this pull request Oct 19, 2026
## Summary

Add a **Pre-submit checklist** section to `AGENTS.md`. Each item comes
from a recent review finding or a landed bug fix in this repository.

The checklist has five groups:

- **Scope and PR description**: one change per PR, title and commit type
match, description lists every behavior change and matches the diff,
`npm run gen` and `npm run format` ran.
- **Design**: fix in the lowest layer that owns the data, fix upstream
(Puppeteer, devtools-frontend) first, one helper for repeated code,
options objects instead of positional `undefined` arguments, validation
in Zod schemas.
- **Correctness and edge cases**: no stale state after a failed call,
artifacts written before a throw, abandoned async continuations, mutex
guards, file removal races, `dispose()` releases every resource, secrets
never reach logs, path parameters validated even when they parse as
URLs.
- **Tests**: every new function has a test, no vacuous assertions,
`notCalled` targets the first call after validation, exact-argument
assertions, reusable stubs in `tests/mocks.ts`, bounded timeouts, no
second CDP session for event waits.
- **Documentation and output**: tool descriptions state when a parameter
is ignored, skills stay generic, one-sentence inline comments.

Sources: review comments on ChromeDevTools#2679, ChromeDevTools#2797, ChromeDevTools#2859, ChromeDevTools#2881, ChromeDevTools#2901, ChromeDevTools#3048,
ChromeDevTools#3082, ChromeDevTools#3109, ChromeDevTools#3120, ChromeDevTools#3132, ChromeDevTools#3134, ChromeDevTools#3139, ChromeDevTools#3148, ChromeDevTools#3156, ChromeDevTools#3158, ChromeDevTools#3161,
ChromeDevTools#3182, ChromeDevTools#3183, ChromeDevTools#3186, ChromeDevTools#3187, ChromeDevTools#3188, ChromeDevTools#3189, ChromeDevTools#3192, ChromeDevTools#3196, ChromeDevTools#3197, ChromeDevTools#3198,
ChromeDevTools#3203, ChromeDevTools#3204, and fixes ChromeDevTools#3150, ChromeDevTools#3160, ChromeDevTools#3185, ChromeDevTools#3202, ChromeDevTools#3207, ChromeDevTools#3208.

Existing content in `AGENTS.md` is unchanged.

Closes ChromeDevTools#3222
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.

3 participants