Repository navigation
refactor(search): one definition of what a search occurrence is - #6905
Merged
Merged
Conversation
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.
Follow-up to #6901. Two places where the workflow search index and the Note card that mirrors it could drift apart. Neither is a live bug — both are the shape that produced one during that PR's review, where the card silently disagreed with the panel about which hit was which.
1. The scan was duplicated
#6901 shared
foldSearchWhitespacebut left the loop around it written out twice — normalize, then non-overlappingindexOfstepping bymax(len, 1)— once infindTextRangesand once in the renderer package.They agree today. They stop agreeing the moment either grows whole-word matching, diacritic folding, or a regex mode, and the failure mode is silent: the panel counts a hit the card marks somewhere else. That is exactly the bug Bugbot caught in #6901, in its whitespace-folding form; sharing only the fold fixed the instance and left the mechanism.
Both now call one
forEachSearchOccurrencein@sim/utils/string. That is the only place they can share it: the card renders from@sim/workflow-renderer, and packages cannot import fromapps/*.2. The markdown declaration was unpinned
The indexer projects markdown escapes only when a field declares
searchTextFormat: 'markdown'. The card projects unconditionally — it has no access to the block registry. Removing that one line from the Note config would leave the two disagreeing about what an occurrence is, with nothing to catch it.A test now pins the declaration and explains the coupling. Verified it fails when the line is removed.
Notes for review
forEachNoteSearchOccurrenceis gone from the renderer package — it was a wrapper around the duplicate. Callers use the shared primitive directly.Testing
@sim/utils160,@sim/workflow-renderer104,apps/simsearch-replace + panel 132 — all pass. Both type-checks,check:api-validation, monorepo boundaries and biome clean.The new parity test was checked for vacuousness: deleting
searchTextFormatfromblocks/blocks/note.tsmakes it fail.🤖 Generated with Claude Code