Fix AI search button (broken: depends on non-existent search-plus-boot.js)

#4
938 hidden commits · view all commits

Root Cause

The doAISearch() function in index.html depends on window._vaiSearchContext from search-plus-boot.js?v=27 which DOES NOT EXIST in the repo (returns 404). This causes the AI search button to show "⏳ Đang tải..." forever without any results.

Additionally, ai-search.js (which contains the full AI search implementation including window.aiSearch() and window.renderAISearchResults()) exists in the repo but is NOT loaded in index.html.

Fix Applied

  1. ai-search-fix.js (new) - Contains the fixed doAISearch() function that uses window.aiSearch() from ai-search.js, plus _renderAIResultsToDiv() helper that renders results into the #aiResults div
  2. ai-search.js (already existed) - Contains the full NL search logic, category detection, budget parsing, constraint matching, combo builder, AI fallback

Changes needed in index.html

  1. Add <script src="ai-search.js"></script> and <script src="ai-search-fix.js"></script> after the html2canvas script tag
  2. Replace the broken doAISearch() function body with the working version from ai-search-fix.js
  3. Remove reference to non-existent search-plus-boot.js

Summary of Fix

Root cause: doAISearch() in index.html depends on window._vaiSearchContext from search-plus-boot.js?v=27 which returns 404 (file doesn't exist in repo).

Fix applied:

  1. ✅ ai-search.js (30.5KB) - Already existed in repo, contains window.aiSearch()
  2. ✅ ai-search-fix.js (9.5KB) - NEW file uploaded, overrides broken doAISearch() at runtime

Still needed: Add two script tags to index.html <head> section:

<script src="ai-search.js"></script>
<script src="ai-search-fix.js"></script>

These should be added right after:

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>

Note: I was unable to modify index.html programmatically because:

  • MCP file read truncates at ~2000 lines (file is 206KB)
  • Sandbox is rate-limited (can't run Python download/patch script)
  • HF Jobs need namespace credits (none available)

The maintainer needs to manually add those 2 lines to index.html, or grant credits/run the patch script themselves.

Publish this branch
This branch is in draft mode, publish it to be able to merge.

Sign up or log in to comment