Repository navigation
Add end-to-end latency benchmarking and optimize axe scanning - #156
Conversation
Every optimization here removes work that was never needed, so the tool surface and its output are unchanged. Scan path (scan_page, scan_page_matrix, audit_site) - Run axe-core directly instead of through @axe-core/playwright. Its default path opens a blank helper page per scan, injects axe into it, and ships the whole partial-result set through it for `axe.finishRun`. Injecting into the frames that already exist and running `axe.run` in the main one produces identical results, cross-origin iframes included (verified against the wrapper on a page with same- and cross-origin frames). - Reduce the result inside the page. Only violations, incomplete and the rule counts of passes/inapplicable are ever reported; a content-heavy page was serializing ~1.9MB per scan to throw ~85% of it away. - Skip re-injecting axe into a frame that already holds this exact build. - Validate include and exclude selectors in one round trip instead of two. - Removes the @axe-core/playwright dependency, and with it the blank helper page that made scan_page fail on Electron CDP targets. Interaction path (click, type, hover, press_key, fill_form, audit_keyboard) - Skip the fixed settle delay when the action issued no request and navigated nowhere: nothing was started, so there is nothing to settle. Worth ~500ms per action, and ~25s on a default 50-step keyboard audit. - Resolve element refs against the snapshot already returned to the caller - which is where those refs came from - instead of capturing a fresh one per call. A ref the cached snapshot does not hold still costs one capture. Elsewhere - Snapshot the current tab and refresh the other tabs' titles concurrently. - Cache the tool list's JSON-schema conversion; look tools up by name. - truncateDataUrls: scan case-insensitively instead of lower-casing a copy of the whole text, and return the input untouched when it holds no data URL. This also fixes offsets after characters whose lower-case form is longer. - audit_site reads each page's title and links in one evaluate; scan_page_matrix applies viewport, media and zoom together. Measured with the new benchmark (`npm run bench`), median of 5 iterations, headless Chromium, against the previous commit: tools/list 5.6ms -> 1.8ms 3.10x browser_click 657.4ms -> 107.1ms 6.14x browser_type 602.1ms -> 60.9ms 9.88x browser_hover 660.0ms -> 124.5ms 5.30x browser_press_key 556.1ms -> 51.4ms 10.81x scan_page 4125.6ms -> 1271.8ms 3.24x audit_keyboard (12 tabs) 6177.6ms -> 100.0ms 61.76x scan_page_matrix (3 variants)13463.4ms -> 4053.5ms 3.32x audit_site (6 pages) 3235.0ms -> 2028.9ms 1.59x TOTAL 29722.7ms -> 8037.1ms 3.70x (-73.0%) bench/mcp-bench.mjs serves a fixed synthetic site, speaks MCP to the built server over stdio, and times real tools/call round trips; `--server`/`--lib` point it at another build so two revisions can be compared, and `npm run bench:compare` prints the table above. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
|
Warning Review limit reached
Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR adds an MCP latency benchmark and updates Axe scanning, frame reporting, accessibility snapshot reuse, conditional settling, data-URL processing, tests, and documentation. ChangesRuntime and benchmarking changes
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Benchmark
participant FixtureServer
participant MCPClient
participant BuiltCLI
Benchmark->>FixtureServer: Serve synthetic pages
Benchmark->>MCPClient: Connect to built CLI
MCPClient->>BuiltCLI: List and call tools
BuiltCLI->>FixtureServer: Load benchmark pages
MCPClient-->>Benchmark: Return results and timings
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (5)
bench/mcp-bench.mjs (2)
40-40: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse
os.tmpdir()for the benchmark output directory.
process.env.TMPDIRis unset on Windows, so the fallback/tmpis used there andmkdtempSyncfails.os.tmpdir()readsTMPDIR,TMP, andTEMPand returns a valid platform default.♻️ Proposed fix
import http from 'node:http'; +import os from 'node:os'; import path from 'node:path';-const outputDir = fs.mkdtempSync(path.join(process.env.TMPDIR ?? '/tmp', 'mcp-bench-')); +const outputDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mcp-bench-'));🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bench/mcp-bench.mjs` at line 40, Update the benchmark output directory initialization to use os.tmpdir() as the base path instead of manually reading process.env.TMPDIR with a /tmp fallback, and ensure the os module is imported or otherwise available in bench/mcp-bench.mjs.
145-166: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winWrap the measurement phase in
try/finallyso a failed scenario still releases resources.Cleanup at lines 164-166 runs only when every scenario and micro-benchmark succeeds. If a scenario throws, for example when
refForfinds no matching ref or a tool call returnsisError, the client is not closed, the fixture server is not closed, and the tempoutputDiris left behind. Repeated failed runs then accumulate temp directories and can leave the spawned browser process alive.♻️ Proposed restructure
-const results = []; -for (const scenario of scenarios) { - const samples = []; - let state; - for (let index = 0; index < warmups + iterations; index++) { - state = scenario.setup ? await scenario.setup() : undefined; - const startedAt = performance.now(); - await scenario.run(state); - const elapsed = performance.now() - startedAt; - if (index >= warmups) - samples.push(elapsed); - } - const stats = summarize(samples); - results.push({ name: scenario.name, ...stats }); - process.stderr.write(`${scenario.name.padEnd(34)} median ${stats.median.toFixed(1).padStart(9)} ms mean ${stats.mean.toFixed(1).padStart(9)} ms\n`); -} - -results.push(...await runMicroBenchmarks()); - -await client.close().catch(() => {}); -await new Promise(resolve => server.close(resolve)); -fs.rmSync(outputDir, { recursive: true, force: true }); +const results = []; +try { + for (const scenario of scenarios) { + const samples = []; + let state; + for (let index = 0; index < warmups + iterations; index++) { + state = scenario.setup ? await scenario.setup() : undefined; + const startedAt = performance.now(); + await scenario.run(state); + const elapsed = performance.now() - startedAt; + if (index >= warmups) + samples.push(elapsed); + } + const stats = summarize(samples); + results.push({ name: scenario.name, ...stats }); + process.stderr.write(`${scenario.name.padEnd(34)} median ${stats.median.toFixed(1).padStart(9)} ms mean ${stats.mean.toFixed(1).padStart(9)} ms\n`); + } + + results.push(...await runMicroBenchmarks()); +} finally { + await client.close().catch(() => {}); + await new Promise(resolve => server.close(resolve)); + fs.rmSync(outputDir, { recursive: true, force: true }); +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@bench/mcp-bench.mjs` around lines 145 - 166, Wrap the scenario and micro-benchmark execution, including the results processing, in a try/finally block, and move the existing client close, server close, and outputDir removal into the finally block. Use the existing client, server, and outputDir cleanup operations unchanged so resources are released when any benchmark fails.src/tools/axe.ts (2)
185-204: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffConsider recording which child frames went unscanned.
A child frame that rejects injection, or that exceeds
childFrameInjectionTimeoutMs, is skipped with no record. The scan then reports a clean result for a page whose iframe content was never examined. axe'sframe-testedrule would flag this, but it carries thebest-practicetag anddefaultAxeTagsselects onlywcag*andsection508, so it does not run by default.Returning the skipped frame URLs from
injectAxeIntoFramesand adding them toAxeScanResultwould letaudit_siteandscan_page_matrixstate the coverage limit in their reports. This mirrors how the crawl already reports session losses instead of silently auditing signed-out pages.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tools/axe.ts` around lines 185 - 204, Update injectAxeIntoFrames to collect and return the URLs of child frames whose injection rejects or exceeds childFrameInjectionTimeoutMs, while preserving successful injection behavior. Add this skipped-frame information to AxeScanResult and propagate it through audit_site and scan_page_matrix so their reports explicitly state when iframe coverage is incomplete.
269-295: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueWidening the trimmed type removes the compile-time trimming guarantee.
trimAxeResultsnow returnsAxeViolation[]instead of a distinct trimmed type.PageReport.violationsinsrc/tools/auditSite.tsandVariantResult.violationsinsrc/tools/scanPageMatrix.tsare alsoAxeViolation[]. AssigningaxeResult.violationsstraight into either field now compiles, which would bypassmaxNodesPerViolationand write an unbounded node list into the JSON report.Both call sites are correct today. A branded return type would keep the compiler enforcing that only trimmed violations reach a report field.
♻️ Optional: brand the trimmed result
+declare const trimmed: unique symbol; +export type TrimmedAxeViolation = AxeViolation & { readonly [trimmed]?: true }; + export function trimAxeResults( violations: AxeViolation[], options: { maxNodesPerViolation: number; dedupe?: boolean } -): AxeViolation[] { +): TrimmedAxeViolation[] {
PageReport.violationsandVariantResult.violationsthen declareTrimmedAxeViolation[].🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tools/axe.ts` around lines 269 - 295, Restore a distinct branded trimmed-violation type for trimAxeResults and use it for the report-facing violations fields in PageReport and VariantResult. Update prepareAxeResults so its trimmed result preserves this type, while deduped results remain untrimmed; ensure direct assignment of untrimmed AxeViolation[] to report violations is rejected at compile time.tests/tools-axe.test.ts (1)
17-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winThe harness cannot exercise injection reuse or the child-frame timeout.
The fake frame returns
undefinedfor the version probe, soinjected === axe.versioninsrc/tools/axe.tsis never true and the skip-redundant-injection path never runs.frames()returns only the object thatmainFrame()also returns, soframe === mainFramealways holds and the child-framePromise.raceagainstchildFrameInjectionTimeoutMsnever runs.Both paths are new in this PR. The injection skip is a stated performance goal, and the race carries the unhandled-rejection concern that the source comment at lines 195-196 calls out. Adding a second frame to the harness and letting the probe report a configurable version would cover both.
♻️ Sketch: make the probe and the frame list configurable
-function pageWithSelectorCounts(countBySelector: Record<string, number> = {}) { - const frame = { +function pageWithSelectorCounts( + countBySelector: Record<string, number> = {}, + frameOptions: { injectedVersion?: string; childFrames?: { evaluate: (...args: any[]) => any }[] } = {} +) { + const frame = { evaluate: async (script: unknown, arg?: unknown) => { - // Injection: the version probe, then the axe source as a string. - if (typeof script === 'string' || arg === undefined) - return undefined; + if (typeof script === 'string') + return undefined; + // The version probe: answering with the injected build exercises the skip path. + if (arg === undefined) + return frameOptions.injectedVersion; if (Array.isArray(arg)) return arg.map(selector => countBySelector[selector as string] ?? 0); lastScan = arg as ScanCall; if (scanResult instanceof Error) throw scanResult; return scanResult; }, }; return { ...frame, - frames: () => [frame], + frames: () => [frame, ...(frameOptions.childFrames ?? [])], mainFrame: () => frame, } as any; }A child frame whose
evaluatenever settles then covers the timeout branch, and one that rejects covers the swallowed-failure branch.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/tools-axe.test.ts` around lines 17 - 36, Update pageWithSelectorCounts to accept configurable injected-version and child-frame behavior: have the version probe return the configured version so axe injection reuse is exercised, and make frames() include a distinct child frame while mainFrame() continues returning the main frame. Allow the child frame’s evaluate to remain pending or reject so tests cover the timeout and swallowed-failure branches around child-frame injection.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@bench/mcp-bench.mjs`:
- Around line 313-316: Validate the values parsed for the --iterations and
--warmups flags before storing them in parsed, rejecting missing, non-numeric,
or otherwise invalid values with a clear command-line error. Update the
argument-parsing logic around these flag branches so execution stops with the
validation message instead of allowing NaN to reach the sampling loop and
summarize.
In `@src/tab.ts`:
- Around line 358-377: Invalidate collected artifacts before navigating back so
refLocators cannot reuse a snapshot from the page being left. Update goBack() to
call _clearCollectedArtifacts() before page.goBack(), and add a regression test
covering snapshot capture, goBack(), and a subsequent ref lookup that triggers a
fresh capture.
In `@src/tools/auditSite.ts`:
- Around line 578-587: Update the nav branch that assigns linkSelector so it
also requires item.depth < params.maxDepth, matching the links strategy and
preventing depth-1 URLs when maxDepth is 0. Keep the existing item.depth === 0
requirement for nav crawling.
In `@tests/tools-auditSite.test.ts`:
- Around line 714-716: Strengthen the assertion around the readPage evaluation
in the audit-site test so it verifies evaluate was called at least once, while
retaining the check that every call uses no selector argument. Update the
assertion associated with crawlTab.page.evaluate to cover both page-title
reading and disabled link discovery.
---
Nitpick comments:
In `@bench/mcp-bench.mjs`:
- Line 40: Update the benchmark output directory initialization to use
os.tmpdir() as the base path instead of manually reading process.env.TMPDIR with
a /tmp fallback, and ensure the os module is imported or otherwise available in
bench/mcp-bench.mjs.
- Around line 145-166: Wrap the scenario and micro-benchmark execution,
including the results processing, in a try/finally block, and move the existing
client close, server close, and outputDir removal into the finally block. Use
the existing client, server, and outputDir cleanup operations unchanged so
resources are released when any benchmark fails.
In `@src/tools/axe.ts`:
- Around line 185-204: Update injectAxeIntoFrames to collect and return the URLs
of child frames whose injection rejects or exceeds childFrameInjectionTimeoutMs,
while preserving successful injection behavior. Add this skipped-frame
information to AxeScanResult and propagate it through audit_site and
scan_page_matrix so their reports explicitly state when iframe coverage is
incomplete.
- Around line 269-295: Restore a distinct branded trimmed-violation type for
trimAxeResults and use it for the report-facing violations fields in PageReport
and VariantResult. Update prepareAxeResults so its trimmed result preserves this
type, while deduped results remain untrimmed; ensure direct assignment of
untrimmed AxeViolation[] to report violations is rejected at compile time.
In `@tests/tools-axe.test.ts`:
- Around line 17-36: Update pageWithSelectorCounts to accept configurable
injected-version and child-frame behavior: have the version probe return the
configured version so axe injection reuse is exercised, and make frames()
include a distinct child frame while mainFrame() continues returning the main
frame. Allow the child frame’s evaluate to remain pending or reject so tests
cover the timeout and swallowed-failure branches around child-frame injection.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8ee38020-a1f6-4364-9e07-94185f13c51f
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (22)
.oxlintrc.jsonAGENTS.mdREADME.mdSKILL.mdbench/fixture.mjsbench/mcp-bench.mjspackage.jsonsrc/browserServerBackend.tssrc/response.tssrc/tab.tssrc/tools/auditSite.tssrc/tools/axe.tssrc/tools/scanPageMatrix.tssrc/tools/tool.tssrc/tools/utils.tssrc/utils/dataUrl.tstests/tab.test.tstests/tools-auditSite.integration.test.tstests/tools-auditSite.test.tstests/tools-axe.test.tstests/tools-utils.test.tstests/utils.test.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8802371a82
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex and CodeRabbit findings on #156. - waitForCompletion: an action that finished quietly is now watched for up to 100ms (or the settle delay, whichever is shorter) for the first request or navigation before the settle is skipped. Work a handler schedules on a timer rather than starting outright is caught, and then settles in full. The previous unconditional 500ms sleep never actually waited for such work either - it resolved its barrier first and covered the case by luck. - Tab: clear the cached aria snapshot on any main-frame navigation instead of only in Tab.navigate(). goBack(), the page.reload() behind reloadBetweenVariants, a meta refresh and a page-driven location change all swap the document without going through it, and a ref resolved against the page the caller left would target the wrong document. Sub-frame navigations leave the cache alone. - axe: always inject and configure axe-core rather than reusing a matching `window.axe`. That global belongs to the page, which may have installed its own copy or reconfigured ours; a scan must run this build with this configuration. The reuse was worth ~4%. - bench: reject non-integer or out-of-range --iterations/--warmups before the fixture server and browser start, where NaN used to surface as a crash while formatting undefined statistics. - bench: browser_type without `slowly` or `submit` takes no snapshot, so the scenario is named for the fill it actually measures. - bench fixture: the intentionally unnamed buttons carried visible text, which supplied an accessible name, so button-name never fired. They now hold only an aria-hidden glyph. - Test that asserted no link discovery passed vacuously on an empty call list; it now also asserts the page was read. Four new tests: the quiet window catching scheduled work, and snapshot-cache invalidation on main-frame versus sub-frame navigation. Headline latency figures are being re-measured against the corrected fixture and will follow on the PR; the quiet window and per-scan injection give back some of the original margin by design. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
Re-measured after the review fixesThe fixture changed (the intentionally unnamed buttons now really are unnamed, so
What the two P1 fixes costBoth were priced in deliberately, and the totals below are what the branch now claims:
Together they take the headline from -73.0% to -68.1%. Reading the two apparent regressions
Generated by Claude Code |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/tab.ts (1)
57-59: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftInvalidate cached AI refs when the page DOM changes.
refLocators()trusts_lastAriaSnapshotwhen the requested refs are present, so same-document mutations such as clicks, timers, form fills, or response handlers can leave stale refs in the snapshot. Invalidate the cache at mutation boundaries, or capture a fresh snapshot before resolving those refs. Add a regression test for a DOM-only mutation betweencaptureSnapshot()andrefLocators().🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tab.ts` around lines 57 - 59, Ensure cached AI refs in _lastAriaSnapshot are invalidated whenever the page DOM changes, including mutations caused by clicks, timers, form fills, and response handlers, before refLocators() resolves requested refs. Preserve the existing snapshot flow for unchanged pages, and add a regression test covering a DOM-only mutation between captureSnapshot() and refLocators().
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/tab.ts`:
- Around line 57-59: Ensure cached AI refs in _lastAriaSnapshot are invalidated
whenever the page DOM changes, including mutations caused by clicks, timers,
form fills, and response handlers, before refLocators() resolves requested refs.
Preserve the existing snapshot flow for unchanged pages, and add a regression
test covering a DOM-only mutation between captureSnapshot() and refLocators().
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 102f9163-ffe9-4c02-9824-ed732230fbca
📒 Files selected for processing (9)
README.mdbench/fixture.mjsbench/mcp-bench.mjssrc/tab.tssrc/tools/axe.tssrc/tools/utils.tstests/tab.test.tstests/tools-auditSite.test.tstests/tools-utils.test.ts
🚧 Files skipped from review as they are similar to previous changes (6)
- tests/tab.test.ts
- bench/fixture.mjs
- tests/tools-auditSite.test.ts
- tests/tools-utils.test.ts
- bench/mcp-bench.mjs
- src/tools/axe.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9de01135e9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…olve Second review round on #156. Codex P1 - a child frame whose Axe injection failed or timed out was skipped silently, so its violations vanished from a report that still looked clean. runAxeScan now returns the URLs of those frames, and scan_page, audit_site and scan_page_matrix all say so: a WARNING block naming the frames, plus `unscannedFrames` per page and per variant in the JSON reports and in structuredContent. Failing the whole scan instead would let one flaky embed break every audit; what was missing is the report, not the tolerance. Frames without an http(s) URL stay unreported - about:blank holds nothing to miss. CodeRabbit - refLocators() trusting the cached snapshot for a page whose DOM has since changed. Measured against a real page first: Playwright keeps a ref bound to the element it was issued for, so a DOM change never moves a ref onto a different element, and both the cached and the fresh-snapshot paths resolve the same one. The case that does differ is an element that has since been removed or replaced - the ref is still in the cached text but matches nothing, which used to surface as our clear "capture a new snapshot" error and would now have been an action timeout. So the cache hit is confirmed with a resolve check: 1.5ms against the ~37ms snapshot it still avoids, and a stale ref fails fast with the same message as before. Tests: a cached ref that no longer resolves re-captures; a failed child-frame injection is reported; about:blank frames are not; a healthy frame reports nothing. README documents the new warning and the JSON fields. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3935b8aef
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…n up bench Third review round on #156. Codex P1 - the `^https?:` filter on unscanned frames suppressed exactly the failures worth reporting. A srcdoc or scripted about:blank frame reports "about:blank" while holding a complete document, and injection into a genuinely empty frame succeeds, so a frame that reached that filter had already failed for a reason. Every failed frame is now reported, identified by URL plus the frame's name when it has one, since "about:blank" alone would not say which frame went unscanned. Codex P2 - scan_page_matrix carried unscannedFrames into its JSON report and markdown warning but not into structuredContent, so a client reading only structured output could read a partly-scanned variant as clean - which is what the README promises it can tell apart. Added per variant. Codex P2 - the benchmark cleaned up its client, fixture server and temp output directory only on the success path, so a throwing scenario left the server process, its browser and the directory behind. Wrapped in try/finally. Verified: invalid --iterations/--warmups still fail before anything is started (exit 1, named flag and value), a full benchmark run leaves no stray browser behind, and all 30 tools pass the direct MCP harness. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tools/auditSite.ts`:
- Around line 735-738: Add non-empty partial-scan coverage in
src/tools/auditSite.ts lines 735-738 by extending the nearby audit_site Vitest
test to assert pagesWithUnscannedFrames and its text warning; also update the
nearby scan_page test in src/tools/snapshot.ts line 105 to assert the formatted
frame warning. Preserve existing empty-array cases and test the public reporting
for pages containing unscanned frames.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a98bd3e6-16d7-4219-b1b1-a1f0d6521143
📒 Files selected for processing (13)
README.mdbench/mcp-bench.mjssrc/tab.tssrc/tools/auditSite.tssrc/tools/axe.tssrc/tools/scanPageMatrix.tssrc/tools/snapshot.tstests/tab.test.tstests/tools-auditSite.integration.test.tstests/tools-auditSite.test.tstests/tools-axe.test.tstests/tools-scanPageMatrix.test.tstests/tools-snapshot.test.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- tests/tools-auditSite.integration.test.ts
- tests/tools-auditSite.test.ts
- src/tab.ts
- bench/mcp-bench.mjs
- tests/tab.test.ts
- src/tools/scanPageMatrix.ts
- README.md
- src/tools/axe.ts
Fourth review round on #156. CodeRabbit - the unscanned-frame reporting added last round was only tested where the list is empty. runAxeScan populating it was covered, but nothing asserted that the tools actually say so, which is the part that stops a partly-scanned page reading as clean. Four tests: scan_page naming every frame it could not reach and staying silent when it reached them all, and audit_site doing the same across a crawl - warning text, per-page unscannedFrames in the JSON report, and pagesWithUnscannedFrames in structuredContent, since a client reading only structured output has to be able to tell the difference too. Checked they are not vacuous: stubbing out unscannedFrameLines() and the audit_site page filter makes both warning tests fail, and restoring them passes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be17d680db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…bench args Fifth review round on #156. Codex P1 - frame coverage was decided from what injection returned, so a frame that navigated while a slower sibling was still injecting kept its "injected" verdict while its new document had no Axe. The run then skipped it and the report looked complete. Coverage is now decided by probing the frames as they are, immediately before the run, against a freshly read frame list - which also catches a frame that appeared after injection started. The remaining window (a navigation between that probe and the run) is microseconds instead of the length of the slowest injection, and is documented as the ceiling. Codex P2 - a failed data: frame put its entire encoded document into unscannedFrames, and from there into tool text, structured content and JSON reports. Routed through the repo's existing truncateDataUrl helper. Codex P2 - the Set collapsed frames that describe identically, so two unnamed about:blank frames were reported as one. Duplicates are kept: two failures are two unscanned documents. Codex P2 - scan_page_matrix applied viewport, media and zoom in parallel. A page that writes document.documentElement.style.zoom from a resize or media handler could overwrite the variant's zoom, and the report would then claim a zoom that was never active. Back to the original strict ordering on both the apply and restore paths; the parallelism was worth ~60ms of a ~4250ms scan. Codex P2 - the benchmark created its temp output directory before connecting, so a missing or unbuilt --server left the directory behind. Connection moved inside the cleanup scope. String flags now reject a missing value during parsing rather than running the whole suite and silently skipping the report. Verified: `--out` with no value and a missing --server both exit 1 leaving no temp directory, and all 30 tools pass the direct MCP harness. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
Re-measured at
|
| Scenario | before (ms) | after (ms) | Change |
|---|---|---|---|
| tools/list | 3.6 | 2.1 | -43.0% |
| browser_click (ref + snapshot) | 644.9 | 223.2 | -65.4% |
| browser_type (ref, fill only) | 618.2 | 176.7 | -71.4% |
| browser_hover (ref + snapshot) | 664.0 | 251.3 | -62.2% |
| browser_press_key | 554.6 | 159.2 | -71.3% |
| scan_page (axe) | 4728.3 | 1615.1 | -65.8% |
| audit_keyboard (12 tabs) | 6218.8 | 1362.2 | -78.1% |
| scan_page_matrix (3 variants) | 14066.9 | 4402.7 | -68.7% |
| audit_site (6 pages) | 3391.6 | 2020.9 | -40.4% |
| micro: truncateDataUrls (data url heavy) | 73.9 | 2.9 | -96.0% |
| TOTAL | 31144.1 | 10472.8 | -66.4% |
Down from -68.1% at 0e54e82. The correctness rounds cost about 1.7 points in total, which is the right trade: the settle observation window, per-scan Axe injection, the ref resolve check and now sequential emulation each bought back a way for a result to be wrong or a coverage gap to go unreported.
On reading these per-scenario
This runner drifts. The baseline measured 4125, 4412 and 4728 ms for scan_page across three separate runs of unmodified main — a 15% spread on the same code. So treat individual rows as ±15% and the total as the reliable figure; scan_page reading 1615 here against 1324 at 0e54e82 is within that band, and nothing in this round's diff touches the no-iframe path that scenario exercises.
Generated by Claude Code
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f86824650f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sixth review round on #156, all four on code added in the previous two rounds. Codex P1 - the post-injection coverage probe called frame.evaluate with no timeout, so an unresponsive child renderer hung the scan indefinitely instead of producing the partial-coverage warning the probe exists to produce. Every read from a child frame now shares one bound (withFrameTimeout), and a probe that times out counts as unscanned. The injection race collapses into the same helper. Codex P2 - the probe compared window.axe.version, which a frame carrying the page's own axe of the same version would satisfy while lacking the allowedOrigins configuration the top-level run needs; it would then answer no ping, contribute nothing, and still read as covered. The configure step now sets a marker and the probe checks that instead. Any in-page marker can be forged by the page, which is documented as the ceiling. Codex P2 - frame.name() went into reports raw while only the URL was truncated. It is author-controlled and unbounded, and can carry a data URL of its own, so it is now whitespace-normalized, truncated and capped at 80 characters. Codex P2 - Tab._refsResolve used locator.count(), which takes Playwright's no-timeout query path, so an unresponsive renderer hung a ref-based interaction on what is meant to be a ~1.5ms check. Wrapped in the same page-state timeout the rest of the class uses; a check that cannot answer falls through to a fresh capture. Three tests: a frame with a page-owned axe is reported unscanned, an author-controlled name is capped and truncated, and the existing coverage cases still hold. All 30 tools pass the direct MCP harness. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c296ec9000
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…of the scan Seventh review round on #156. Codex P2 - waitForCompletion removed requests on `requestfinished` only. A request that fails - offline, CORS-blocked, aborted - emits `requestfailed` instead and stayed in the pending set until the 10s hard timeout, stalling the tool call. The bug predates this branch, but the quiet window made it reachable where it was not before: a delayed fetch that fails now gets detected and waited on, where it used to fall through the 500ms settle. Both events share one removal path. Codex P2 - a frame scoped out of the scan was still reported as a coverage gap. `excludeSelectors: ["iframe.chat-widget"]` is the documented way to drop a flaky third-party widget, and that widget failing injection produced a warning about content the caller deliberately removed. Scope is now checked from the iframe element in its parent document, and only for frames that actually failed - which is normally none, so a healthy scoped scan pays nothing. The check is fail-open: an unreachable frame element, an unresolvable selector or a nested frame whose exclusion lives in a grandparent document all fall through to reporting, so no genuine gap is suppressed by a check that could not answer. Not changed, with reasons in the PR threads: verifying that `axe.source` really replaced a booby-trapped `window.axe` (any in-page postcondition is forgeable by the same page, and this is the documented ceiling), and regenerating OpenWiki (generated by external tooling with no in-repo entry point, and 89 commits stale independently of this branch). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/tools/scanPageMatrix.ts (2)
222-232: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCapture and restore the page’s original media emulation before cleanup.
The cleanup block currently passes
nullfor every media option, which disables emulation rather than restoring any existing non-default values set beforescan_page_matrixruns. Save the original emulation state and restore it in thefinallyblock forcolorScheme,forcedColors,contrast,reducedMotion, andmedia.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tools/scanPageMatrix.ts` around lines 222 - 232, Update the scan_page_matrix setup and cleanup flow around the visible viewport/zoom restoration and tab.page.emulateMedia calls: capture the page’s original media emulation values before applying scan settings, then restore those captured values in the finally block for colorScheme, forcedColors, contrast, reducedMotion, and media instead of passing nulls. Preserve the existing viewport and zoom restoration behavior.
165-173: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winReload before applying variant state.
page.reload()refreshes the page afterdocument.documentElement.style.zoomis set. Whenparams.reloadBetweenVariantsis true, the scan can run with the original zoom whileapplied.zoomPercentstill reports the requested zoom. Move the reload beforesetViewportSize/emulateMedia/zoom, or reapply those states after the reload. Add a regression test for zoom variants withreloadBetweenVariants.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tools/scanPageMatrix.ts` around lines 165 - 173, Move the reload in the variant-processing flow before applying state through setViewportSize, emulateMedia, and the zoom evaluate call, ensuring reloadBetweenVariants leaves the requested zoom active for scanning and reporting. Add a regression test covering zoom variants when params.reloadBetweenVariants is enabled.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/tools/scanPageMatrix.ts`:
- Around line 222-232: Update the scan_page_matrix setup and cleanup flow around
the visible viewport/zoom restoration and tab.page.emulateMedia calls: capture
the page’s original media emulation values before applying scan settings, then
restore those captured values in the finally block for colorScheme,
forcedColors, contrast, reducedMotion, and media instead of passing nulls.
Preserve the existing viewport and zoom restoration behavior.
- Around line 165-173: Move the reload in the variant-processing flow before
applying state through setViewportSize, emulateMedia, and the zoom evaluate
call, ensuring reloadBetweenVariants leaves the requested zoom active for
scanning and reporting. Add a regression test covering zoom variants when
params.reloadBetweenVariants is enabled.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4ec33c7b-ee11-4102-bc93-2e5a7b74fed3
📒 Files selected for processing (8)
bench/mcp-bench.mjssrc/tab.tssrc/tools/axe.tssrc/tools/scanPageMatrix.tssrc/tools/utils.tstests/tools-auditSite.test.tstests/tools-axe.test.tstests/tools-snapshot.test.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- tests/tools-snapshot.test.ts
- src/tab.ts
- src/tools/utils.ts
- tests/tools-auditSite.test.ts
- bench/mcp-bench.mjs
- tests/tools-axe.test.ts
- src/tools/axe.ts
There was a problem hiding this comment.
💡 Codex Review
mcp-accessibility-scanner/src/tools/auditSite.ts
Lines 145 to 147 in 246c124
When distinct Axe nodes have normalized HTML values that collide under this 32-bit FNV-1a hash—a realistic birthday-bound risk across large 200-page audits and something page markup can deliberately induce—the second node is treated as an existing occurrence, so uniqueOccurrences is undercounted and sampleNodes may omit it. Retain the fixed-size storage benefit with a collision-resistant digest rather than replacing the previous SHA-256 fingerprint with 32 bits.
AGENTS.md reference: AGENTS.md:L27-L27
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…d frame scope scan_page_matrix reset media emulation to the browser default instead of the state the page arrived in. A context created with colorScheme "dark" was therefore scanned light - including the baseline every other variant is diffed against - and left light after the tool returned. The effective state is now measured from the page up front (matchMedia, folded into the existing zoom read so it costs no extra round trip) and used both as the per-variant fallback and to restore the page, the same way viewport and zoom already were. With reloadBetweenVariants the zoom was applied before the reload. Viewport and media emulation survive a reload but zoom is an inline style on documentElement and the new document does not carry it, so the variant was scanned unzoomed while applied.zoomPercent still claimed the requested zoom. Frame scope was resolved only against the immediate parent document, but closest() stops at a frame boundary while an Axe context does not: an iframe nested inside an iframe inside #main was treated as scoped out of an includeSelectors: ["#main"] scan and dropped from unscannedFrames, letting a partial scan look clean. The whole ancestor chain is walked now, which also makes an exclude on an outer frame correctly cover the frames beneath it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
Round 8 — replies to the findings posted outside the diffThree findings landed in review bodies rather than as inline threads, so there is nowhere to reply in place. Answering them here. ✅
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57dbf462e6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…me coverage An interaction that navigates only a child frame skipped the settle delay entirely. Swapping an iframe's srcdoc or pointing it at a data: URL replaces a document without touching the network, so neither the request path nor the main-frame path marked it as page work and the response was captured while the replacement document was still initializing. It now signals like any other page work, tracked separately so it does not gate the barrier on a top-level load state a sub-frame navigation never produces. Frame scope was resolved with closest(), which stops at a shadow boundary as well as a frame one. An iframe inside a shadow root therefore did not match an includeSelectors entry naming an ancestor of its host, and was dropped from unscannedFrames - a partial scan looking clean. The walk now steps onto the host via getRootNode() and continues, which also makes excluding a shadow host cover the frames inside it. Coverage was decided per frame, so a nested frame that took its own injection counted as covered even when an ancestor had none. Axe reaches a nested document only by relaying through the frames above it, and a frame without Axe relays nothing, so both documents go unscanned. Coverage failure now propagates down the frame tree and every affected document is listed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 581ddb9921
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…bench output isFrameInScope looked up frameElement() unbounded. That call takes no timeout of its own, so an unresponsive parent renderer would hang the scan on the very check that exists to report unresponsive frames. It now shares the same 1s bound as every other child-frame read, fails open to reporting the frame, and disposes a handle that arrives after the bound rather than leaking it. scan_page_matrix computed baseline deltas unconditionally. When a frame goes unscanned on one side, a rule absent from that run may simply live in the document nobody looked at, and the report called it resolved - or its reappearance new. The warning said coverage was incomplete while the numbers next to it stated an accessibility outcome the run could not support. Deltas are now null whenever either side has unscanned frames: null rather than an empty list in structuredContent, and "n/a (partial scan)" in the table, because an empty list reads as "compared, nothing changed". A page where neither prefers-color-scheme query matches was recorded as light, which pins a preference it never had and leaves it pinned afterwards. It is now left un-emulated, matching how the unrepresentable contrast values are handled. Compare mode called process.exit() straight after writing the table. stdout is only synchronous on a TTY, so piped into a consumer that applies backpressure the tail was discarded: measured 608 of 4003 lines surviving, cut at the 64 KB pipe buffer. It now waits for the writes to drain. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
|
@coderabbitai review Triggering explicitly: the last three commits ( Generated by Claude Code |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/tab.ts (1)
389-420: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winReject cached refs when the page changes during validation.
_refsMatchSnapshot()validates a cached snapshot across asynchronouslocator.ariaSnapshot()calls. A main-frame navigation during those calls clears_lastAriaSnapshot, but the localcachedvalue remains usable. If each locator call resolves with the old document state,refLocators()can return locators from the new document using refs from the old snapshot.Record
_pageGenerationbefore validation. Returnfalseif it changes before validation completes. Add a regression test that navigates during ref validation and verifies thatrefLocators()captures a fresh snapshot.Proposed fix
private async _refsMatchSnapshot(params: { ref: string }[], snapshot: string): Promise<boolean> { + const pageGeneration = this._pageGeneration; const lines = snapshot.split('\n'); const timeout = Math.min(this._pageStateTimeoutMs(), 1000); const matches = await Promise.all(params.map(async param => { // ... })); - return matches.every(Boolean); + return pageGeneration === this._pageGeneration && matches.every(Boolean); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tab.ts` around lines 389 - 420, Update _refsMatchSnapshot to record _pageGeneration before starting asynchronous ref validation and return false if the generation changes before all checks complete, preventing stale cached refs from being reused after navigation. Add a regression test covering navigation during ref validation and verify refLocators captures and uses a fresh snapshot.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 224-230: Update the README descriptions for timeouts.settle and
--timeout-settle/PLAYWRIGHT_MCP_TIMEOUT_SETTLE to reflect conditional settling:
quiet actions return after the observation window, while the configured settle
delay applies when an action starts or schedules navigation or network activity.
Remove wording that says the delay applies after every action.
In `@tests/tools-axe.test.ts`:
- Around line 389-403: Update the injected evaluation counter in the stale
readiness-marker test so the hanging promise occurs on evaluation four, not
evaluation two. Keep the existing two runAxeScan calls and expectations
unchanged, ensuring the first scan completes and leaves its marker while the
second scan is blocked to verify stale-marker rejection.
---
Outside diff comments:
In `@src/tab.ts`:
- Around line 389-420: Update _refsMatchSnapshot to record _pageGeneration
before starting asynchronous ref validation and return false if the generation
changes before all checks complete, preventing stale cached refs from being
reused after navigation. Add a regression test covering navigation during ref
validation and verify refLocators captures and uses a fresh snapshot.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: a0165405-61ee-49a4-9c43-8eb7a7b782c2
📒 Files selected for processing (11)
README.mdbench/mcp-bench.mjssrc/tab.tssrc/tools/axe.tssrc/tools/scanPageMatrix.tssrc/tools/utils.tstests/bench.test.tstests/tab.test.tstests/tools-axe.test.tstests/tools-scanPageMatrix.test.tstests/tools-utils.test.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- bench/mcp-bench.mjs
- tests/tab.test.ts
- tests/tools-scanPageMatrix.test.ts
- src/tools/scanPageMatrix.ts
- src/tools/axe.ts
|
CodeRabbit outside-diff finding from review 4838573171 is fixed in d720e14. _refsMatchSnapshot now records the page generation before asynchronous locator validation and rejects the cached snapshot if navigation changes it before completion. The regression navigates while validation is pending and proves refLocators performs a fresh full snapshot instead of accepting the old ref. Validation: focused tab suite 58 passed, lint and build passed. |
|
@codex review |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d720e14264
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 247f136097
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/tools-axe.test.ts (1)
717-740: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winSet an explicit timeout for the real-browser test.
This test launches Chromium, loads content, and waits for a frame navigation. The default Vitest test timeout is 5000 ms. A cold browser launch in CI can exceed that limit and produce a flaky failure. Add a per-test timeout.
♻️ Proposed change
- expect((await runAxeScan(page)).unscannedFrames).toEqual(['about:srcdoc']); - } finally { - await browser.close(); - } - }); + expect((await runAxeScan(page)).unscannedFrames).toEqual(['about:srcdoc']); + } finally { + await browser.close(); + } + }, 30_000);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/tools-axe.test.ts` around lines 717 - 740, Set an explicit, sufficiently generous per-test timeout on the real-browser test in the “axe frame coverage in a real browser” describe block, covering Chromium launch and frame navigation without changing the test logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/tools-axe.test.ts`:
- Around line 717-740: Set an explicit, sufficiently generous per-test timeout
on the real-browser test in the “axe frame coverage in a real browser” describe
block, covering Chromium launch and frame navigation without changing the test
logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 1a3a5892-2a34-4c21-b333-c14d84f04a65
📒 Files selected for processing (4)
src/tab.tssrc/tools/axe.tstests/tab.test.tstests/tools-axe.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- tests/tab.test.ts
- src/tab.ts
- src/tools/axe.ts
|
CodeRabbit exact-head nitpick from review 4839311458 is already covered: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 750f6c25d5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 343d05de5c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
✅ Action performedReview finished.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c73fef18cd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
✅ Action performedReview finished.
|
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Cuts end-to-end MCP tool latency by 66% (31.1s → 10.5s across the benchmark suite) and adds the benchmark that measures it. Every optimization removes work that was never needed, so the tool surface and its output are unchanged — except where this PR now reports coverage, or applies state, that it previously left implicit or got wrong.
Measured result
npm run bench, median of 5 iterations after 1 warmup, headless Chromium, againstmain:Read the total, not the rows. This runner drifts: the baseline measured 4125, 4412 and 4728 ms for
scan_pageacross three separate runs of unmodifiedmain— a 15% spread on identical code. Treat individual rows as ±15%.browser_navigateandbrowser_snapshotshow single-digit percentage moves in both directions across runs — neither touches a changed code path; that is run-to-run variance on 40-130 ms scenarios.The figure started at -73% and settled at -66.4%. Eight rounds of review fixes cost those points, and each one bought back a way for a result to be wrong or a coverage gap to go unreported. That is the right trade in an accessibility tool: the settle observation window, per-scan Axe injection, the ref resolve check and strict sequential emulation are all latency given back deliberately.
Scan path —
scan_page,scan_page_matrix,audit_site@axe-core/playwright. Its default path opens a blank helper page per scan, injects axe into it, and ships the whole partial-result set through it foraxe.finishRun. Injecting into the frames that already exist and runningaxe.runin the main one produces identical results, cross-origin iframes included — verified against the wrapper on a page with same- and cross-origin frames before switching.includeSelectorsandexcludeSelectorsin one round trip instead of two.@axe-core/playwrightdependency, and with it the blank helper page that madescan_pagefail on Electron CDP targets (Target.createTarget: Not supported).Axe is injected fresh for every scan rather than reused when
window.axealready looks right: that global belongs to the page, which may have installed its own axe or reconfigured ours.Interaction path — click, type, hover, press_key, fill_form, audit_keyboard
count()resolve check (~1.5 ms against the ~37 ms snapshot it avoids, and bounded by the same page-state timeout as every other read inTab) so a ref whose element has gone still fails fast with "capture a new snapshot" rather than as an action timeout. The cache is invalidated on any main-frame navigation, which coversgoBack(),page.reload(), meta refresh and page-drivenlocationchanges alike.Coverage reporting (new behaviour)
A child frame Axe cannot be installed into contributes no violations, and previously said nothing about it — so a partly-scanned page read as clean.
runAxeScannow returns an identifier for every such frame (URL plus frame name, since asrcdocframe reportsabout:blank; both truncated, as either can carry a data URL), and all three scan tools surface them: aWARNINGblock, plusunscannedFramesper page and per variant in the JSON reports and instructuredContent. Reporting rather than failing, so one flaky third-party embed cannot break an entire audit.Coverage is judged by probing each frame for this server's own configured injection after injection completes — not by what injection returned — so a frame that navigated mid-scan, or appeared late, or carries only the page's own axe, is counted as unscanned. Frames the caller scoped out with
includeSelectors/excludeSelectorsare not reported, since their contents were never going to be. Scope is resolved through the whole ancestor frame chain, so an include naming an ancestor still covers frames nested below it. Anything the check cannot resolve is reported rather than hidden.Correctness fixes in
scan_page_matrixBoth found in review, both changing what a report claims:
null, which resets a feature to the browser default rather than to the session's configured state — so a context createdcolorScheme: 'dark'was scanned light, including the baseline every other variant is diffed against, and was left light afterwards. The effective state is now measured from the page and used as both the per-variant fallback and the restore.applied.mediaconsequently reports the effective value rather thannull.documentElementand does not, soreloadBetweenVariantsscanned unzoomed whileapplied.zoomPercentclaimed otherwise.Elsewhere
truncateDataUrls: scan case-insensitively instead of lower-casing a copy of the whole text, and return the input untouched when it holds no data URL. This also fixes offsets after characters whose lower-case form is longer (e.g.İ).audit_sitereads each page's title and links in one evaluate.Benchmark
bench/mcp-bench.mjsserves a fixed synthetic site, speaks MCP to the built server over stdio, and times realtools/callround trips.--server/--libpoint it at another build so two revisions can be compared, andnpm run bench:compareprints the table above. Documented in the README.Verification
npm run lintandnpm run typecheckclean; 707 tests pass. All 30 tools pass the direct MCP harness (npm run test:mcp) against a real browser.23 failures in
tests/tools-auditScreenReader.test.tsare container-only — they need achromium.launch()this environment cannot provide — and reproduce unchanged on the base commit.Note: the repo's CI workflow only triggers on PRs targeting
feat/branches, so no check runs appear on this PR.https://claude.ai/code/session_0169kf5JnRWzLgwDDcBSmsnn
Summary by CodeRabbit
New Features
Bug Fixes
Documentation