feat: add regex search mode to the search bar - #34
Merged
Conversation
Add a `.*` toggle to the tree search bar that switches matching to a case-insensitive regular expression. The regex flag is threaded through the whole search path: protocol message, content UI, worker loop, the scoring matcher, and the worker-client sync fallback. Invalid patterns are caught and surfaced as an inline "Invalid regex" status without crashing or sending the bad query to the worker. Regex matches are tested against searchKey, searchPath, and searchValue. Known limitation: the search index lowercases values and truncates them at 200 chars, so a regex only ever sees that truncated, lowercased text.
pedrosousa13
force-pushed
the
feat/regex-search
branch
from
June 24, 2026 12:56
a5ac4b5 to
c0985e5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a regex toggle (
.*) to the tree search bar. When enabled, the typed query is compiled to a case-insensitiveRegExpand a node matches when the pattern tests true against itssearchKey,searchPath, orsearchValue. Theregex: booleanflag is plumbed through the entire search path:tree-worker-protocol.ts—regexadded to the search request shapecontent.ts— toggle UI, sends the flag, validates the pattern, shows an inline errortree-worker.ts— matching loop passes the flag through and skips normalization for regextree-search.ts— newcompileSearchRegexhelper + regex match branch alongside the existing substring scoringtree-worker-client.ts— sync fallback honors the flag tooWhy
Substring search can't express alternation, anchors, or character classes. Regex mode gives power users precise matching across keys, paths, and values without leaving the search bar.
Behavior notes
iflag, so matching is case-insensitive. The query is passed verbatim in regex mode (not trimmed/lowercased) since metacharacters and escapes are case-sensitive.Invalid regexstatus, and never sent to the worker — no crash, no worker spam. Fixing the pattern clears the error.Known limitation
The search index lowercases values and truncates them at 200 chars (existing
SEARCH_VALUE_PREVIEW_LIMITbehavior). A regex therefore only ever sees that truncated, lowercased text. Documented in a code comment oncompileSearchRegex.Test evidence
npm run typecheck— clean.npm test— 12 files, 121 tests passing. New coverage:src/tree-search.test.ts— regex matches across key/path/value, case-insensitivity, alternation, invalid regex handled gracefully (no throw → empty result), and substring mode unchanged (metacharacters treated literally when off).src/tree-worker-client.test.ts— worker request carries theregexflag (defaults tofalse); sync fallback honors it.npm run build— succeeds (dist/content.js,dist/tree-worker.js,dist/content.css).npm run test:e2e— 20 tests passing including the newe2e/regex-search.spec.ts: toggling regex on, matching via alternation, stepping through hits, and the invalid-regex inline error path. No regressions in existing specs.Try it
⌘F/Ctrl+F), enable the.*toggle, try@\w+\.bizor^lau→ highlighted matches + counter, step withEnter/Shift+Enter.[) → inline "Invalid regex" error, no crash.