Skip to content

draft feat: get_css_style tool - #2612

Draft
samiyac wants to merge 1 commit into
mainfrom
investigating-styles
Draft

draft feat: get_css_style tool#2612
samiyac wants to merge 1 commit into
mainfrom
investigating-styles

Conversation

@samiyac

@samiyac samiyac commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

No description provided.

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

Thanks! Left a few comments on the overall approach.

Comment thread src/tools/css.ts
import {ToolCategory} from './categories.js';
import {definePageTool, type MatchedStyles} from './ToolDefinition.js';

const INHERITED_PROPERTIES = new Set([

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.

I think this should exist in DevTools? we should re-use it, or introduce it there.

Comment thread src/tools/css.ts
);
}

function formatCssStyles(matchedStyles: MatchedStyles, uid: string): string {

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.

can we re-use any formatters on the DevTools side? If not (even by refactoring presenters), we should extract this in a separate formatter in this repo.

Comment thread src/McpPage.ts
}

await domModel.requestDocument();
const nodeMap = await domModel.pushNodesByBackendIdsToFrontend(

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.

we should not need to push nodes to the frontend. Can we just use the CSS logic relying on backend node IDs only?

Comment thread src/McpPage.ts
}

const devtools = await this.ensureDevToolsUniverse();
const domModel = devtools.target.model(DevTools.DOMModel.DOMModel);

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.

uid might belong to iframes for we need to find the right target instance

Comment thread src/McpPage.ts
);
}

const devtools = await this.ensureDevToolsUniverse();

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.

do we need to ensure the universe here? I think it should automatically exist when the page is available. Let's throw an error if it does not exist instead?

Comment thread src/McpPage.ts

let backendNodeId = node.backendNodeId;
if (!backendNodeId) {
using handle = await this.#resolveElementHandle(node, uid);

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.

could we resolve without creating a handle?

@samiyac
samiyac marked this pull request as draft August 25, 2026 11:26
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.

2 participants