Skip to content

Bug: SnapshotFormatter shows misleading hint when verbose mode is already enabled #1947

@achideal

Description

@achideal

Description of the bug

In src/formatters/SnapshotFormatter.ts, the toString() method has an inverted condition that produces a misleading hint message.

Current code (line 22-29):

if (
  this.#snapshot.verbose &&
  this.#snapshot.hasSelectedElement &&
  !this.#snapshot.selectedElementUid
) {
  chunks.push(`Note: there is a selected element in the DevTools Elements panel...`);
}

The condition checks this.#snapshot.verbose (verbose mode is already enabled), but the hint says "Get a verbose snapshot to include all elements" -- which is contradictory.

When verbose = true, the snapshot uses interestingOnly: false, meaning all elements are already included. The hint should only appear in non-verbose mode (!this.#snapshot.verbose), where interestingOnly: true may filter out the selected element.

Fix: Change this.#snapshot.verbose to !this.#snapshot.verbose on line 23.

Reproduction

  1. Select an element in the DevTools Elements panel that is not part of the default (non-verbose) a11y tree
  2. Call take_snapshot with verbose: true
  3. If the selected element still cannot be resolved to a uid (e.g., due to iframe boundaries), the misleading note appears even though verbose mode is already active

Expectation

The hint "Get a verbose snapshot to include all elements" should only appear when not in verbose mode. When already in verbose mode, either no hint should be shown, or a different message should explain why the selected element is missing from the tree.

MCP configuration

No response

Chrome DevTools MCP version

latest (main branch)

Chrome version

No response

Coding agent version

No response

Model version

No response

Chat log

No response

Node version

No response

Operating system

None

Extra checklist

  • I want to provide a PR to fix this bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions