Skip to content

feat: normalize search text#14449

Merged
darkskygit merged 2 commits intocanaryfrom
darksky/normalize-search-text
Feb 16, 2026
Merged

feat: normalize search text#14449
darkskygit merged 2 commits intocanaryfrom
darksky/normalize-search-text

Conversation

@darkskygit
Copy link
Member

@darkskygit darkskygit commented Feb 15, 2026

PR Dependency Tree

This tree was auto-generated by Charcoal

Summary by CodeRabbit

  • Improvements

    • Search text normalization now applied consistently across doc titles, search results, and highlights for uniform display formatting.
  • Tests

    • Added comprehensive test coverage for search text normalization utility.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

A refactoring that consolidates text normalization logic across three service modules by introducing a reusable normalizeSearchText utility function. The utility replaces scattered normalization implementations and private methods, standardizing search text processing for doc display, search results, and search menu functionality.

Changes

Cohort / File(s) Summary
Text Normalization Utility
packages/frontend/core/src/utils/normalize-search-text.ts, packages/frontend/core/src/utils/__tests__/normalize-search-text.spec.ts, packages/frontend/core/src/utils/index.ts
Introduces new normalizeSearchText utility with recursive logic to handle serialized text, arrays, and fallback values. Comprehensive test coverage validates plain text pass-through, array deserialization, HTML tag preservation, and multiple input scenarios. Function exported from utils index for reuse.
Service Integrations
packages/frontend/core/src/modules/doc-display-meta/services/doc-display-meta.ts, packages/frontend/core/src/modules/docs-search/services/docs-search.ts, packages/frontend/core/src/modules/search-menu/services/index.ts
Replaces direct title/content handling with normalizeSearchText calls. Removes private normalizeHighlight method from docs-search service. Normalizes doc titles in display metadata and standardizes highlight normalization in search menu result mapping.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 The texts once scattered, now align—
A rabbit refactored normalization's line.
From serial chaos to utility clean,
Search strings now dance in standardized sheen.
One function to bind them, one truth to unearth,
Celebrating the clarity brought to the search.

🚥 Pre-merge checks | ✅ 2 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (6 files):

⚔️ packages/backend/server/src/core/doc-renderer/__tests__/controller.spec.ts (content)
⚔️ packages/backend/server/src/core/doc-renderer/controller.ts (content)
⚔️ packages/frontend/core/src/modules/doc-display-meta/services/doc-display-meta.ts (content)
⚔️ packages/frontend/core/src/modules/docs-search/services/docs-search.ts (content)
⚔️ packages/frontend/core/src/modules/search-menu/services/index.ts (content)
⚔️ packages/frontend/core/src/utils/index.ts (content)

These conflicts must be resolved before merging into canary.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: normalize search text' directly and clearly describes the main change: introducing a normalizeSearchText utility and applying it across multiple modules for consistent search text handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch darksky/normalize-search-text
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch darksky/normalize-search-text
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/frontend/core/src/modules/docs-search/services/docs-search.ts (1)

142-149: ⚠️ Potential issue | 🟡 Minor

Block-match branch does not normalize title — potential inconsistency with the title-match branch.

In the title-match branch (Line 135), the title is normalized via normalizeSearchText. However, in this block-match branch, doc.title$.value is used directly without normalization. If doc.title$ can return serialized JSON strings (which is the reason normalizeSearchText was introduced), this title could remain un-normalized in search results.

Suggested fix
             const title =
-                this.docsService.list.doc$(bucket.key).value?.title$.value ??
-                '';
+                normalizeSearchText(
+                  this.docsService.list.doc$(bucket.key).value?.title$.value
+                );
🧹 Nitpick comments (2)
packages/frontend/core/src/utils/__tests__/normalize-search-text.spec.ts (1)

1-33: Consider adding tests for null/undefined inputs and the options parameter.

The current suite covers the main parsing paths well, but doesn't exercise:

  • null/undefined → fallback behavior
  • Custom fallback and arrayJoiner options
  • Non-string primitive input (e.g., numbers)
  • Empty string / empty array edge cases

These are the remaining branches in normalizeSearchText that lack coverage.

packages/frontend/core/src/utils/normalize-search-text.ts (1)

6-6: Nit: unknown | null is redundant — null is already a subset of unknown.

The return type unknown | null is equivalent to just unknown. Consider simplifying for clarity.

Suggested fix
-function tryParseSerializedText(value: string): unknown | null {
+function tryParseSerializedText(value: string): unknown {

@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

❌ Patch coverage is 60.86957% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.04%. Comparing base (9d7f4ac) to head (b18d8c7).
⚠️ Report is 2 commits behind head on canary.

Files with missing lines Patch % Lines
...s/frontend/core/src/utils/normalize-search-text.ts 60.86% 4 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           canary   #14449      +/-   ##
==========================================
+ Coverage   54.40%   57.04%   +2.64%     
==========================================
  Files        2835     2836       +1     
  Lines      153864   153926      +62     
  Branches    23183    23088      -95     
==========================================
+ Hits        83708    87806    +4098     
+ Misses      66748    63258    -3490     
+ Partials     3408     2862     -546     
Flag Coverage Δ
server-test 75.23% <ø> (-0.94%) ⬇️
unittest 33.76% <60.86%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@darkskygit darkskygit merged commit e3177e6 into canary Feb 16, 2026
58 checks passed
@darkskygit darkskygit deleted the darksky/normalize-search-text branch February 16, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app:core test Related to test cases

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant