Skip to content

Add regex support for textfield on lit renderer#605

Open
dmandar wants to merge 9 commits intomainfrom
md-textregex
Open

Add regex support for textfield on lit renderer#605
dmandar wants to merge 9 commits intomainfrom
md-textregex

Conversation

@dmandar
Copy link
Collaborator

@dmandar dmandar commented Feb 6, 2026

Description

Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.

List which issues are fixed by this PR. For larger changes, raising an issue first helps reduce redundant work.

Pre-launch Checklist

If you need help, consider asking for advice on the discussion board.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

This is a substantial pull request that adds regex validation to text fields, enhances the MultipleChoice component with chip and filterable layouts, and introduces a comprehensive component gallery sample. The new features are well-implemented and the gallery is a valuable addition for demonstration and testing. My review includes suggestions to improve code maintainability, robustness, and style consistency in a few areas, such as simplifying redundant logic, refactoring hardcoded values, and making agent-side dispatching more robust.

Comment on lines +283 to 288
if (!this.processor || !this.component) {
return Array.isArray(this.selections) ? this.selections : [];
}
if (Array.isArray(this.selections)) {
return this.selections;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logic here can be simplified to be less redundant. The Array.isArray(this.selections) check is effectively performed twice. You can check for the array case first, which covers all scenarios where selections is a literal array, and then handle the data-bound path.

Suggested change
if (!this.processor || !this.component) {
return Array.isArray(this.selections) ? this.selections : [];
}
if (Array.isArray(this.selections)) {
return this.selections;
}
if (Array.isArray(this.selections)) {
return this.selections;
}
if (!this.processor || !this.component) {
return [];
}

Comment on lines +42 to +43
import datetime
import asyncio
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

According to PEP 8, imports should be at the top of the file. Moving import datetime and import asyncio to the top level improves readability and follows standard Python conventions.

References
  1. PEP 8 recommends that imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants. (link)

}

.chip.selected:hover {
background: var(--md-sys-color-secondary-container-high, #e8def8);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

It's generally better to define CSS variables in a central theme file rather than providing a hardcoded fallback color like #e8def8 directly in the component's CSS. This ensures theming consistency and makes future updates easier. Please define --md-sys-color-secondary-container-high in the appropriate theme file.

Suggested change
background: var(--md-sys-color-secondary-container-high, #e8def8);
background: var(--md-sys-color-secondary-container-high);

Comment on lines +29 to +39
if "WHO_ARE_YOU" in query or "START" in query: # Simple trigger for initial load
gallery_json = get_gallery_json()
response = f"Here is the component gallery.\n---a2ui_JSON---\n{gallery_json}"
yield {
"is_task_complete": True,
"content": response
}
return

# Handle Actions
if query.startswith("ACTION:"):
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The agent's dispatch logic relies on simple string matching (in and startswith), which can be brittle. For instance, an action's context could unintentionally contain the string "ACTION:", leading to incorrect parsing. It would be more robust to parse the incoming request into a structured object first and then dispatch based on its properties. The agent_executor.py already does some of this parsing, and leveraging that more directly would improve robustness.

Comment on lines +262 to +271
const pathMap: Record<string, string> = {
"demo-text": "galleryData/textField",
"demo-text-regex": "galleryData/textFieldRegex",
"demo-checkbox": "galleryData/checkbox",
"demo-slider": "galleryData/slider",
"demo-date": "galleryData/date",
"demo-multichoice": "galleryData/favorites",
"demo-multichoice-chips": "galleryData/favoritesChips",
"demo-multichoice-filter": "galleryData/favoritesFilter"
};
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The hardcoded pathMap creates a tight coupling between the client-side component gallery and the agent's data model structure. While this might be acceptable for a self-contained demo, in a real-world scenario this makes the client less reusable and harder to maintain. Consider having the agent provide this mapping or designing the components to receive the full data path as a property, which would make the client more generic.

Copy link
Collaborator

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

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

This is a rubber stamp: I'm not reviewing the web code, since that's not my specialty.

id="data"
.value=${value}
.placeholder=${"Please enter a value"}
pattern=${this.validationRegexp || nothing}
Copy link
Collaborator

Choose a reason for hiding this comment

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

LGTM on this, but can you separate this change from your other changes? I assume this only needs like a 5 line change in this file?

@jacobsimionato jacobsimionato requested a review from ditman February 6, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants