Skip to content

Integration - merge recent frontend highlighter and scanner change branches - #1066

Merged
pattonwebz merged 25 commits into
developfrom
william/integration/merge-recent-frontend-highlighter-and-scanner-change-branches
Jul 8, 2025
Merged

Integration - merge recent frontend highlighter and scanner change branches#1066
pattonwebz merged 25 commits into
developfrom
william/integration/merge-recent-frontend-highlighter-and-scanner-change-branches

Conversation

@pattonwebz

@pattonwebz pattonwebz commented Jul 8, 2025

Copy link
Copy Markdown
Member

Checklist

  • PR is linked to the main issue in the repo
  • Tests are added that cover changes

Summary by CodeRabbit

  • New Features

    • Added support for capturing and storing additional selector information (selector, ancestry, xpath) for accessibility rule violations.
    • Introduced the ability to trigger an accessibility scan from the frontend, with improved error handling and user feedback.
    • Added a new scanner script bundle for enhanced scanning capabilities.
  • Improvements

    • Enhanced the frontend highlighter to retry scans automatically if needed and provide clearer error messages.
    • Improved scan result processing and error handling, including support for iframe contexts and scan timeouts.
  • Bug Fixes

    • Improved consistency and reliability in saving and displaying scan results.
  • Tests

    • Updated test setup to use the centralized database schema update process for improved reliability.

pattonwebz and others added 25 commits May 21, 2025 16:13
…the old scan runner in iframe checking contexts
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This change allows the frontend highlighter app to access the scanner bundle for enhanced functionality.
Refactor the scanning logic to improve readability and maintainability. Introduce helper methods for kicking off the scan, running the scan, and saving results. Enhance error handling and user feedback during the scanning process.
This update introduces new fields in the database schema to support enhanced accessibility features.

[PRO-191]
This function extracts relevant details from a violation object, including selector, ancestry, xpath, and landmark information.

[PRO-192]
This change introduces additional selectors (selector, ancestry, xpath) to the Insert_Rule_Data method, improving the flexibility and functionality of rule data insertion.

[PRO-193]
Enhanced the insert method to accept additional parameters for selectors and ancestry, improving the flexibility of rule insertion.

[PRO-193]
…n/merge-recent-frontend-highlighter-and-scanner-change-branches
…e' into william/integration/merge-recent-frontend-highlighter-and-scanner-change-branches
@coderabbitai

coderabbitai Bot commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Selector-related fields (selector, ancestry, xpath) are added to rule violation records in both the database schema and data insertion logic. The frontend and REST API are updated to handle these new fields. Frontend scanning logic is modularized, enabling programmatic scans and improved error handling, with support for iframe contexts and scan retries.

Changes

Files/Paths Change Summary
admin/class-insert-rule-data.php Added optional $selectors parameter to insert; stores selector, ancestry, xpath in rule data.
admin/class-update-database.php Database schema updated: adds selector, ancestry, xpath columns to accessibility_checker table.
includes/classes/class-rest-api.php REST API passes selector-related data to Insert_Rule_Data::insert.
includes/classes/class-enqueue-frontend.php Adds scannerBundleUrl to localized frontend script data.
src/frontendHighlighterApp/index.js Adds scan initiation/retry logic, error UI, and methods for programmatic scanning and result saving.
src/pageScanner/index.js Adds global scan API, iframe auto-run, timeout/error handling, and selector field processing.
tests/phpunit/Admin/InsertRuleDataTest.php Test setup uses centralized database update logic for schema creation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FrontendApp
    participant PageScanner
    participant REST_API
    participant InsertRuleData
    participant Database

    User->>FrontendApp: Initiate highlight/scan
    FrontendApp->>PageScanner: runAccessibilityScan()
    PageScanner->>PageScanner: Perform scan, collect violations with selector fields
    PageScanner-->>FrontendApp: Return violations (with selector, ancestry, xpath)
    FrontendApp->>REST_API: POST scan results (includes selector fields)
    REST_API->>InsertRuleData: insert(post, rule, ..., selectors)
    InsertRuleData->>Database: Insert record with selector, ancestry, xpath
    Database-->>InsertRuleData: Confirmation
    InsertRuleData-->>REST_API: Success
    REST_API-->>FrontendApp: Scan results saved
Loading

Possibly related PRs

  • Added Landmark Location #1028: Adds landmark-related fields and logic to the same Insert_Rule_Data class and database schema, similar in structure but focused on different data aspects.

Poem

In the warren where selectors grow,
New fields burrow deep below.
Scans now run with nimble flair,
Ancestry, xpath—handled with care.
Frontend and backend, all in sync,
With every hop, more bugs extinct!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-08T19_51_35_785Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1bb8760 and f364662.

📒 Files selected for processing (7)
  • admin/class-insert-rule-data.php (4 hunks)
  • admin/class-update-database.php (1 hunks)
  • includes/classes/class-enqueue-frontend.php (1 hunks)
  • includes/classes/class-rest-api.php (1 hunks)
  • src/frontendHighlighterApp/index.js (4 hunks)
  • src/pageScanner/index.js (5 hunks)
  • tests/phpunit/Admin/InsertRuleDataTest.php (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary of Changes

Hello @pattonwebz, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates recent work on the frontend accessibility highlighter and the page scanner, enabling on-demand accessibility scans directly from the frontend. It significantly enhances the detail of stored violation data by capturing CSS selectors, element ancestry, and XPath, providing a more robust foundation for identifying and resolving accessibility issues.

Highlights

  • Frontend-Initiated Accessibility Scanning: The frontend highlighter application can now dynamically load the accessibility scanner and initiate a scan of the current page directly from the user interface. This includes logic to retry fetching results after a scan is triggered.
  • Enhanced Violation Data Capture: The system now captures and stores more granular details about accessibility violations, specifically including the CSS selector, element ancestry (a list of parent selectors), and XPath for each identified issue. This provides more precise location information for debugging and fixing.
  • Database and API Integration for New Data: The database schema has been updated to include new columns for selector, ancestry, and xpath. Correspondingly, the REST API endpoint for submitting scan results and the Insert_Rule_Data class have been modified to accept, process, and persist this new detailed violation data.
  • Refactored Scanner Module: The core page scanner module (src/pageScanner/index.js) has been refactored to expose its scanning functionality via window.runAccessibilityScan, allowing it to be called programmatically by the frontend highlighter. It also includes improved timeout handling and helper functions for processing violation data.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request integrates frontend highlighter and scanner changes. It introduces new database fields, enhances the frontend highlighter app, and updates the page scanner. There are some areas for improvement, including typo correction, potential infinite loop prevention, and error message enhancement.

Comment on lines 191 to +199
}
} else if ( ! self._scanAttempted && response.data?.[ 0 ]?.code === -3 ) {
// Only try kickoffScan once per highlightAjax call
self._scanAttempted = true;
self.kickoffScan();
// After kickoffScan, try highlightAjax again, but only once
setTimeout( () => {
self.highlightAjax().then( resolve ).catch( reject );
}, 5000 ); // Wait 5s for scan to complete.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The highlightAjax function retries the scan with a 5-second timeout. If the scan consistently fails or takes longer than 5 seconds, this could lead to an infinite loop and degrade performance. Consider adding a maximum retry count or implementing exponential backoff to prevent this.1

      } else if ( ! self._scanAttempted && response.data?.[ 0 ]?.code === -3 ) {
						// Only try kickoffScan once per highlightAjax call
						self._scanAttempted = true;
						self.kickoffScan();
						// After kickoffScan, try highlightAjax again, but only once
						setTimeout( () => {
							self.highlightAjax().then( resolve ).catch( reject );
						}, 5000 ); // Wait 5s for scan to complete.

Style Guide References

Footnotes

  1. Avoid infinite loops by adding retry limits or exponential backoff. (link)

Comment thread src/pageScanner/index.js
Comment on lines +313 to 314
// eslint-disable-next-line no-unused-vars
const onDone = ( violations = [], errorMsgs = [], error = false ) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The onDone function has an unused parameter error = false. Remove the parameter to avoid confusion and improve code clarity.1

Style Guide References

Suggested change
// eslint-disable-next-line no-unused-vars
const onDone = ( violations = [], errorMsgs = [], error = false ) => {
// eslint-disable-next-line no-unused-vars
const onDone = ( violations = [], errorMsgs = [] ) => {

Footnotes

  1. Remove unused parameters to improve code clarity. (link)

@pattonwebz pattonwebz changed the title William/integration/merge recent frontend highlighter and scanner change branches Integration - merge recent frontend highlighter and scanner change branches Jul 8, 2025
@pattonwebz
pattonwebz marked this pull request as ready for review July 8, 2025 19:50
@pattonwebz
pattonwebz merged commit b83dc20 into develop Jul 8, 2025
17 of 18 checks passed
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.

1 participant