Skip to content

feat(search): syntax highlight regex literals - #125664

Open
JoshuaKGoldberg wants to merge 10 commits into
masterfrom
joshgoldberg/logs-978-add-syntax-highlighting-to-regex-literals
Open

JoshuaKGoldberg wants to merge 10 commits into
masterfrom
joshgoldberg/logs-978-add-syntax-highlighting-to-regex-literals

Conversation

@JoshuaKGoldberg

@JoshuaKGoldberg JoshuaKGoldberg commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Regex filter patterns are now tokenized with Prism's regex grammar and colored, so structure reads apart from literals. The highlighting appears both in the committed filter and, via an overlay drawn on the value input, while a pattern is being typed.

Measuring the filter's middle-ellipsis previously wrote element.textContent directly, which would destroy React-rendered children. It now swaps in a detached text node instead.

Light Dark
Committed Committed log search filter in light mode reading message matches regex ^(?:GET|POST) /api/v\d+/[a-z-]+\?id=\d{2,4}(&.*)?$ syntax highlighted Committed log search filter in dark mode reading message matches regex ^(?:GET|POST) /api/v\d+/[a-z-]+\?id=\d{2,4}(&.*)?$ syntax highlighted
Editing Editing log search filter in light mode reading message matches regex ^(?:GET|POST) /api/v\d+/[a-z-]+\?id=\d{2,4}(&.*)?$ syntax highlighted Editing log search filter in dark mode reading message matches regex ^(?:GET|POST) /api/v\d+/[a-z-]+\?id=\d{2,4}(&.*)?$ syntax highlighted

Closes LOGS-978.

@linear-code

linear-code Bot commented Sep 25, 2026

Copy link
Copy Markdown

LOGS-978

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 25, 2026
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

📊 Type Coverage Diff

✅ no issues found

@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(search): Syntax highlight regex literals in the search bar feat(search): syntax highlight regex literals in the search bar Sep 28, 2026
@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(search): syntax highlight regex literals in the search bar feat(search): syntax highlight regex literals Sep 28, 2026
@JoshuaKGoldberg

Copy link
Copy Markdown
Member Author

@cursor review

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

Stale Bugbot comment from a previous run.

Comment thread static/app/components/searchQueryBuilder/tokens/combobox.tsx
@JoshuaKGoldberg

Copy link
Copy Markdown
Member Author

@cursor review

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

Stale Bugbot comment from a previous run.

@JoshuaKGoldberg
JoshuaKGoldberg marked this pull request as ready for review September 28, 2026 12:57
@JoshuaKGoldberg
JoshuaKGoldberg requested a review from a team as a code owner September 28, 2026 12:57
@JoshuaKGoldberg
JoshuaKGoldberg added this pull request to stack #125662 September 28, 2026 12:59
Base automatically changed from joshgoldberg/logs-976-validate-regex-patterns-client-side-with-re2js to master September 28, 2026 13:33
@JoshuaKGoldberg
JoshuaKGoldberg requested a review from a team as a code owner September 28, 2026 13:33
Renders regex filter patterns with Prism's regex grammar, in the filter itself and in an overlay over the value input while editing.
Collapses the plain-pattern branch, shares one render function between the two call sites, swaps the measure/restore juggling for replaceChildren, and drops selectors for constructs RE2 rejects.
Flex shrinks the input below its autosized width, so a long pattern scrolls under the caret while the overlay kept showing the start of it.
tokens.syntax.selector sits at 3.88:1 on the tinted background an invalid filter gets, below the 4.5 AA bar for small text. colors.green600 is 4.82:1 there and 5.70:1 on the default background.
@JoshuaKGoldberg
JoshuaKGoldberg force-pushed the joshgoldberg/logs-978-add-syntax-highlighting-to-regex-literals branch from fec3c2c to b2d73f4 Compare September 28, 2026 13:33
.token.char-set,
.token.escape,
.token.special-escape {
color: ${p => p.theme.colors.green600};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TODO: Talked with Martha, we'll go with a darker green in light mode. And I'll also make sure dark mode still looks good.

@k-fish k-fish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oooh was going to ask about this but figured it was out of scope, nice 👍

@k-fish k-fish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

😄

Comment thread static/app/components/searchQueryBuilder/tokens/combobox.tsx Outdated
The highlighted value and the input now share one grid cell at least as wide as
the value's text, so the input never scrolls its own text out from under the
highlighting. The chip row scrolls long regex values instead, and keeps the tail
of an input wider than the row in view.

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 782a59d. Configure here.

Comment thread static/app/components/searchQueryBuilder/tokens/filter/valueCombobox.tsx Outdated
When the regex input is wider than the chip row, only pin the row to the
input's tail while the caret is at the end. Otherwise each keystroke yanked
the row toward the tail, leaving the caret stuck at its left edge.

This branch was successfully deployed

1 active deployment
Preview — ffa680bf Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants