Skip to content

Claude/search index utility 5ekh4q - #3356

Merged
amirbiron merged 7 commits into
mainfrom
claude/search-index-utility-5ekh4q
Sep 7, 2026
Merged

amirbiron merged 7 commits into
mainfrom
claude/search-index-utility-5ekh4q

Conversation

@amirbiron

@amirbiron amirbiron commented Sep 7, 2026 •

Copy link
Copy Markdown
Owner

תבנית Pull Request

✨ תיאור קצר

  • מה שיניתם ולמה? (2-3 משפטים)

📦 שינויים עיקריים

  • קוד (Backend)
  • בוט טלגרם
  • מסד נתונים/מיגרציות
  • תיעוד (docs/)
  • DevOps/CI/CD

פירוט נקודות (רשימת תבליטים):

🧪 בדיקות

  • איך בדקתם? מה עבר? מה נשאר?
  • Unit
  • Integration
  • Manual

🧪 בדיקות נדרשות ב‑PR

  • 🔍 Code Quality & Security
  • Unit Tests (3.11)
  • Unit Tests (3.12)

📝 סוג שינוי

  • feat: פיצ'ר חדש
  • fix: תיקון באג
  • docs: שינוי תיעוד בלבד
  • refactor: שינוי קוד ללא שינוי התנהגות
  • perf: שיפור ביצועים
  • chore/ci: תשתית/CI
  • breaking change: שינוי שובר תאימות

דוגמאות Conventional Commits

סוג דוגמה להודעה מתי להשתמש
feat feat: הוספת מסך הגדרות פיצ'ר חדש למשתמש
fix fix: תיקון קריסה בעת התחברות תיקון באג מול משתמשים/פרודקשן
chore chore: שדרוג Gradle ל-8.9 תחזוקה, כלי פיתוח, housekeeping
docs docs: עדכון README עם הוראות התקנה שינויי תיעוד בלבד
refactor refactor: חילוץ Repository ל-UseCases שינוי מבני ללא שינוי התנהגות
test test: הוספת בדיקות ל-LoginViewModel הוספת/עדכון בדיקות
build build: הוספת flavor staging ל-CI שינויים בבילד/תלויות/תצורה

✅ צ'קליסט

  • הקוד עוקב אחרי הסגנון (Black/isort/flake8/mypy)
  • בדיקות רצות ועוברות
  • תיעוד עודכן (README/Docs)
  • אם נוספו ג'ובים חדשים (Background Jobs) – וודא שהם רשומים ב-services/register_jobs.py (כולל Callback/Trigger להפעלה ידנית — למשל callback_name/trigger_func לפי המבנה) כדי שיופיעו בדשבורד
  • אם נוספו/שונו משתני סביבה – עודכן docs/environment-variables.rst וגם services/config_inspector_service.py
  • אם נוספו/השתנו טוקנים – עודכן גם docs/webapp/theming_and_css.rst + FEATURE_SUGGESTIONS/theme_matrix.md
  • אין סודות/מפתחות בקוד
  • אין מחיקות מסוכנות/פעולות על root (ראו .cursorrules)
  • הודעת הקומיט תואמת Conventional Commits (ע"פ הטבלה)
  • CHANGELOG עודכן אם נדרש
  • כל ה‑Required Checks לעיל ירוקים
  • צילום/וידאו UI מצורף אם רלוונטי
  • עיינתי במסמכי אתר התיעוד — נתיב: ______ | המשפט: "______"
  • לא נדרש עיון — התנאי לא התקיים כי: ______

🧩 השפעות/סיכונים

  • השפעה אפשרית על פרודקשן, ביצועים, או אבטחה:

🔗 קישורים

🧯 סיכון / החזרה לאחור (Rollback)

  • תוכנית חזרה לאחור במקרה תקלה:

Review in cubic

Summary by Sourcery

Bug Fixes:

  • Ensure global search autocomplete and language menus render above adjacent search cards.

claude and others added 6 commits September 7, 2026 15:12
‏`AdvancedSearchEngine.search` בנה את `SearchIndex` לפני שבדק איזה סוג חיפוש
התבקש. רק `TEXT` ו-`FUNCTION` קוראים מהאינדקס; `CONTENT`, `REGEX` ו-`FUZZY`
סורקים את ה-DB בעצמם ואינם נוגעים בו. מכיוון ש-`CONTENT` הוא ברירת המחדל של
החיפוש ב-WebApp, המסלול הרגיל שילם על סריקה מלאה של כל קבצי המשתמש (כולל
`code`, במנות של `SEARCH_PAGE_SIZE`, עם קיבוץ גרסאות מלא בכל עמוד) שאיש לא
קרא את תוצאתה — ומיד אחריה סריקה מלאה שנייה לחיפוש עצמו.

מה השתנה:

- ‏`get_index` נקרא רק בענפי `TEXT` ו-`FUNCTION`, דרך `_get_index_for_search`
  ששומרת על מדידת `search_index_get` הקיימת.
- הפרמטר `index` הוסר מ-`_fuzzy_search`; הוא התקבל ומעולם לא נקרא, וזה מה
  שהסתיר את העובדה שהמסלול אינו נשען על האינדקס.
- נוסף `SEARCH_MEMORY_INDEX_ENABLED` (ברירת מחדל `true`) לכיבוי מלא של
  האינדקס בזיכרון. כבוי ⇒ `TEXT` ו-`FUNCTION` מחזירים רשימה ריקה, ו-
  ‏`_safe_search` ב-WebApp נופל לחיפוש `$text` במונגו. מה שנעלם: התאמה
  חלקית (prefix/substring) ו-`function_index`.

התיעוד ב-`docs/workflows/search-flow.rst` עודכן בהתאם, כולל היחס בין האינדקס
בזיכרון לאינדקס `search_text_idx` של מונגו.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RgnHZBJaH4VhdFFgwYZKLr
המשך ל-#3351, אחרי שהתברר שהסרת בניית האינדקס מחיפוש `content` גררה רגרסיה
בהשלמה האוטומטית — ושהתצוגה שלה שבורה ממילא.

מתג `SEARCH_MEMORY_INDEX_EAGER_BUILD` (ברירת מחדל `false`)
----------------------------------------------------------

`suggest_completions` קורא את האינדקס דרך `_get_ready_index`, שבמכוון אינו
בונה אותו — ולכן ההשלמה נהנתה מאינדקס שחיפוש `content` בנה כתופעת לוואי.
הרצת בקרה מול הקוד שלפני #3351, אותו קלט: לפני הצעות `['needle','needlehelper']`,
אחרי `[]`. המתג מאפשר להחזיר את החימום מ-ENV, בלי דיפלוי קוד, כדי לשקול את
העלות מול התועלת על נתונים אמיתיים. הוא כפוף ל-`SEARCH_MEMORY_INDEX_ENABLED`.

תיקון זליגה באינדקס ב-`_text_search`
-------------------------------------

`word_index.get(word, set())` מחזיר את הקבוצה השמורה עצמה, וה-`update` אחריו
הזליג את התאמות ה-prefix לתוכה לצמיתות. מאותו רגע הן נספרו כהתאמות מדויקות
וקיבלו 2.0 במקום 1.0, כלומר הדירוג נשחק בכל חיפוש נוסף על אותו אינדקס.

תצוגת ההשלמה האוטומטית
-----------------------

שלושה שורשים, כולם נמדדו ב-Chromium על ה-CSS של הריפו:

- הוובאפ אינו טוען את ה-CSS של Bootstrap, ולכן `list-group-item` על כל הצעה
  לא עיצב דבר: ההצעות היו `<a>` עם `display:inline` וללא ריפוד, וחמש מהן
  נדחסו לשורה אחת בגובה 20 פיקסל. הוחלף במחלקה של הפרויקט, `search-suggestion`.
- `overflow-x:hidden` על `.filters-row` גרם לדפדפן לחשב `overflow-y: auto`.
  השורה הפכה למיכל גלילה אנכי שחתך את הדרופדאון, ולכן הוא נראה רק בגלילה
  בתוך אזור צר שלא נועד לכך. הוחלף ב-`overflow-x: clip`, עם `hidden` כנפילה-לאחור.
- הדרופדאון היה מעוגן לעמודה כולה ולא לתיבת הקלט. הועבר לתוך
  `.search-box-wrapper`, ועכשיו רוחבו וקצהו זהים לתיבה.

בנוסף: `background:#fff` הקשיח הוחלף בטוקני `--solid-surface-*`. הם נמדדו על
כל שבע ערכות הנושא — ניגודיות 17.7 בכולן, כולל `custom`, שבו `--bg-secondary`
אינו מוגדר כלל והתיבה הייתה יוצאת שקופה.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RgnHZBJaH4VhdFFgwYZKLr
אחרי שההצעות קיבלו גובה אמיתי, התגלה שהרשימה נחתכת מאחורי הכרטיס הבא בעמוד.
נמדד ב-Chromium: מתוך חמש הצעות, שתיים היו מכוסות על ידי תיבת החיפוש שבכרטיס
שאחריו.

השורש: ל-`.glass-card` יש `backdrop-filter: blur(20px)`, וזה יוצר
stacking context. לכן `z-index:1000` של רשימת ההצעות כלוא בגבולות הכרטיס
המארח, והכרטיס עצמו הוא `position:static; z-index:auto` — כלומר הכרטיס הבא
ב-DOM נצבע מעליו, ושום z-index פנימי אינו יכול לגבור על כך.

התיקון מרים את הכרטיס המארח עצמו (`position:relative; z-index:3`), כי זו
הרמה שבה ההכרעה באמת מתקבלת. הערך נמוך בכוונה: מודאלים ותפריטים גלובליים
יושבים ב-1000 ומעלה וממשיכים לגבור.

אימות: 12 הצעות, שתי ערכות נושא, שני רוחבים — אפס פריטים מכוסים בכל השילובים.
שתי מוטציות מוכיחות שהמדידה מסוגלת ליפול: הסרת ה-z-index מהכרטיס מחזירה
כיסוי של עד ארבעה פריטים, והחזרת `overflow-x:hidden` לשורה מחזירה כיסוי של
עד שבעה.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RgnHZBJaH4VhdFFgwYZKLr
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sourcery-ai sourcery-ai 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.

Sorry @amirbiron, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 hours and 33 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: a1f72098-a3ea-4533-b07d-11239e3dad58

📥 Commits

Reviewing files that changed from the base of the PR and between 86ade33 and 22f7838.

📒 Files selected for processing (1)
  • webapp/static/css/global_search.css

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.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

🧯 Dangerous deletes guard report

Policy: see .cursorrules — dangerous deletions are blocked unless wrapped safely.

Summary:

  • Flagged findings (blocking): 0
    0
  • Excluded matches (not blocking): 15
  • Total matches (all files): 129

Flagged findings (file:line:snippet):
(none)

Excluded matches (by path pattern)
./webapp/static/js/md_preview.bundle.js.map:4:  "sourcesContent": ["// Markdown-it plugin to render GitHub-style task lists; see\n//\n// https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments\n// https://github.com/blog/1825-t … [truncated]
./docs/DOCUMENTATION_GUIDE.md:453:rm -rf _build
./docs/Makefile:24:	rm -rf $(BUILDDIR)
./Dockerfile:42:    rm -rf /var/lib/apt/lists/*
./Dockerfile:121:    rm -rf /var/lib/apt/lists/*
./node_modules/katex/package.json:153:    "build": "rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c --failAfterWarnings && webpack && node update-sri.js package dist/README.md",
./node_modules/katex/src/fonts/Makefile:139:	rm -rf pfa ff otf ttf woff woff2
./node_modules/mermaid/dist/mermaid.js.map:4:  "sourcesContent": ["/**\n* Default values for dimensions\n*/\nconst defaultIconDimensions = Object.freeze({\n\tleft: 0,\n\ttop: 0,\n\twidth: 16,\n\theight: 16\n});\n/**\n* Default values for tr … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.esm/chunk-2M32CCKP.mjs.map:4:  "sourcesContent": ["{\n  \"name\": \"mermaid\",\n  \"version\": \"11.12.0\",\n  \"description\": \"Markdown-ish syntax for generating flowcharts, mindmaps, sequence d … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.esm.min/chunk-4HFYJGYH.mjs.map:4:  "sourcesContent": ["{\n  \"name\": \"mermaid\",\n  \"version\": \"11.12.0\",\n  \"description\": \"Markdown-ish syntax for generating flowcharts, mindmaps, sequen … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.esm.min/chunk-4HFYJGYH.mjs:1:var r={name:"mermaid",version:"11.12.0",description:"Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graph … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.core/chunk-KS23V3DP.mjs.map:4:  "sourcesContent": ["{\n  \"name\": \"mermaid\",\n  \"version\": \"11.12.0\",\n  \"description\": \"Markdown-ish syntax for generating flowcharts, mindmaps, sequence  … [truncated]
./node_modules/mermaid/dist/mermaid.min.js:1524:`,"getStyles"),c1e=RQe});var h1e={};dr(h1e,{diagram:()=>NQe});var NQe,f1e=N(()=>{"use strict";$ge();a1e();l1e();u1e();NQe={parser:Fge,db:n1e,renderer:o1e,styles:c1e}});var m1e,g1e=N(()=>{"use  … [truncated]
./node_modules/mermaid/dist/mermaid.min.js.map:4:  "sourcesContent": ["/**\n* Default values for dimensions\n*/\nconst defaultIconDimensions = Object.freeze({\n\tleft: 0,\n\ttop: 0,\n\twidth: 16,\n\theight: 16\n});\n/**\n* Default values fo … [truncated]
./README.md:842:find . -name "__pycache__" -exec rm -rf {} +

@sourcery-ai

sourcery-ai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR optimizes search by avoiding unnecessary in-memory index builds, adds configuration controls and regression coverage for index behavior and mutation, and redesigns WebApp autocomplete suggestions for correct positioning, theming, accessibility, and overflow handling.

Sequence diagram for lazy search index building

sequenceDiagram
    participant Caller
    participant SearchEngine
    participant SearchIndex
    participant MongoDB

    Caller->>SearchEngine: search(user_id, query, search_type)
    alt TEXT or FUNCTION
        SearchEngine->>SearchIndex: _get_index_for_search(user_id)
        alt index enabled
            SearchIndex->>SearchIndex: get_index(user_id)
            SearchIndex->>MongoDB: rebuild_index(user_id) when missing or stale
            SearchIndex-->>SearchEngine: ready index
            SearchEngine->>SearchIndex: _text_search or _function_search
        else index disabled
            SearchIndex-->>SearchEngine: empty SearchIndex
            SearchEngine->>MongoDB: $text fallback for TEXT
        end
    else CONTENT, REGEX, or FUZZY
        SearchEngine->>MongoDB: database search
    end
    SearchEngine-->>Caller: search results
Loading

Flow diagram for conditional search index usage

flowchart TD
    A[SearchIndex.search] --> B{SEARCH_MEMORY_INDEX_EAGER_BUILD}
    B -- enabled --> C[_get_index_for_search]
    B -- disabled --> D{Search type}
    C --> D
    D -- TEXT --> E[_text_search]
    D -- FUNCTION --> F[_function_search]
    D -- CONTENT --> G[_content_search]
    D -- REGEX --> H[_regex_search]
    D -- FUZZY --> I[_fuzzy_search]
    E --> J{SEARCH_MEMORY_INDEX_ENABLED}
    F --> J
    J -- enabled --> K[SearchIndex.get_index]
    J -- disabled --> L[MongoDB $text fallback]
Loading

File-Level Changes

Change Details Files
Make in-memory search-index construction conditional and configurable.
  • Add enable/disable and eager-build settings with configuration inspection and documentation.
  • Build the index only for search types that consume it, while preserving an opt-in warm-index path for completion suggestions.
  • Fall back cleanly when the index is disabled and remove the fuzzy-search dependency on it.
config.py
docs/configuration.rst
docs/environment-variables.rst
docs/workflows/search-flow.rst
search_engine.py
services/config_inspector_service.py
Prevent text searches from mutating index state and lock down search behavior with tests.
  • Copy indexed file sets before applying prefix matches so repeated searches remain correctly scored.
  • Test build/no-build behavior across search types, configuration switches, eager warming, fallback defaults, and observable logging.
  • Test that repeated text searches do not pollute the stored index or alter relevance scores.
tests/test_config.py
tests/test_search_engine_index_built_only_when_used.py
tests/test_search_engine_index_not_mutated_by_search.py
Improve search suggestion presentation, positioning, theming, and accessibility in the WebApp.
  • Move suggestions inside the input wrapper and use the native hidden state for visibility.
  • Replace unavailable Bootstrap classes with project-specific styling, theme tokens, RTL-safe positioning, contained scrolling, and reduced-motion support.
  • Add listbox/option semantics and adjust stacking and overflow behavior so the dropdown remains visible and usable.
webapp/static/css/global_search.css
webapp/static/js/global_search.js
webapp/templates/files.html

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

⏱️ Performance report

(No performance test durations collected. Mark tests with @pytest.mark.performance.)

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

📖 Documentation Preview

The documentation has been built successfully!

To view locally:

  1. Download the artifacts
  2. Extract the zip file
  3. Open index.html in your browser

@sourcery-ai sourcery-ai 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.

Sourcery assessment

Approved.

@amirbiron
amirbiron merged commit 8f6aec2 into main Sep 7, 2026
24 checks passed
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants