abinazebinoy commited on
Commit
f53ed9e
·
1 Parent(s): f9c6e27

fix(BUG-02/10/11/25): health retry with backoff; duplicate id removed; language selectors synced; fixed error message

Browse files
Files changed (1) hide show
  1. frontend/js/app.js +25 -8
frontend/js/app.js CHANGED
@@ -202,8 +202,9 @@ const Views = {
202
  <div style="padding:var(--space-8) 0">
203
  <div class="container">
204
  <div class="search-bar" style="max-width:700px;margin-bottom:var(--space-6)">
205
- <input class="search-bar__input" id="search-input"
206
- placeholder="Search entities..." id="search-input-field"
 
207
  autocomplete="off">
208
  <button class="search-bar__btn" id="search-btn">Search</button>
209
  </div>
@@ -213,7 +214,7 @@ const Views = {
213
  <select id="lang-select" style="font-size:var(--font-size-xs);padding:4px 8px;
214
  background:var(--bg-secondary);color:var(--text-primary);
215
  border:1px solid var(--border-color);border-radius:6px;cursor:pointer"
216
- onchange="State.language=this.value;applyLanguage(this.value)">
217
  <option value="en">🇮🇳 English</option>
218
  <option value="hi">हिन्दी</option>
219
  <option value="ta">தமிழ்</option>
@@ -839,11 +840,27 @@ function initApp() {
839
  Router.register("/live-feed", Views.liveFeed);
840
  Router.register("/about", Views.about);
841
 
842
- Api.health().then(() => {
843
- State.apiConnected = true;
844
- }).catch(() => {
845
- Components.Toast("API not connected. Start: uvicorn api.main:app --reload", "error");
846
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
847
 
848
  Router.init();
849
 
 
202
  <div style="padding:var(--space-8) 0">
203
  <div class="container">
204
  <div class="search-bar" style="max-width:700px;margin-bottom:var(--space-6)">
205
+ <!-- BUG-10 FIX: removed duplicate id attribute -->
206
+ <input class="search-bar__input" id="search-input"
207
+ placeholder="Search entities..."
208
  autocomplete="off">
209
  <button class="search-bar__btn" id="search-btn">Search</button>
210
  </div>
 
214
  <select id="lang-select" style="font-size:var(--font-size-xs);padding:4px 8px;
215
  background:var(--bg-secondary);color:var(--text-primary);
216
  border:1px solid var(--border-color);border-radius:6px;cursor:pointer"
217
+ onchange="State.language=this.value;applyLanguage(this.value);document.getElementById('navbar-lang-select')&&(document.getElementById('navbar-lang-select').value=this.value)">
218
  <option value="en">🇮🇳 English</option>
219
  <option value="hi">हिन्दी</option>
220
  <option value="ta">தமிழ்</option>
 
840
  Router.register("/live-feed", Views.liveFeed);
841
  Router.register("/about", Views.about);
842
 
843
+ // BUG-02 FIX: was single immediate check — failed permanently on HF cold start.
844
+ // BUG-25 FIX: message said "Start: uvicorn" — wrong for HuggingFace users.
845
+ // Fix: retry up to 5 times with exponential backoff (2s, 4s, 8s, 16s, 30s).
846
+ (function checkHealth(attempt) {
847
+ Api.health()
848
+ .then(data => {
849
+ State.apiConnected = true;
850
+ const dot = document.getElementById("api-status-dot");
851
+ const text = document.getElementById("api-status-text");
852
+ if (dot) dot.style.background = data.neo4j_connected ? "var(--color-risk-low)" : "var(--color-saffron)";
853
+ if (text) text.textContent = data.neo4j_connected ? "Connected" : "API Only";
854
+ })
855
+ .catch(() => {
856
+ if (attempt < 5) {
857
+ const delay = Math.min(2000 * Math.pow(2, attempt - 1), 30000);
858
+ setTimeout(() => checkHealth(attempt + 1), delay);
859
+ } else {
860
+ Components.Toast("API unavailable. Please refresh the page in a moment.", "error");
861
+ }
862
+ });
863
+ })(1);
864
 
865
  Router.init();
866