fix(ui): repair botched-merge syntax errors that break app boot (#111)#112
Merged
elder-plinius merged 2 commits intoJul 24, 2026
Conversation
…st parse Compiles every classic inline <script> in docs/index.html with node:vm (how a browser parses it). Fails on current main with 'Identifier response has already been declared' — the duplicate declaration in _safeLLMCallOnce that stops the whole SPA from booting.
…r-plinius#111) docs/index.html is a single classic <script>. Eight scars from bad auto-merges (duplicated old/new versions of the same LLM-call sites left side by side) made the script fail to PARSE, so nothing ran: the UI stuck on "Initializing…", every link/handler dead, only the pre-registered selfimprove/ledger poller still firing. A parse error surfaces one at a time (the engine stops at the first), so these were only visible once each prior one was fixed. Repaired: - _safeLLMCallOnce: duplicate `response` decl + a leftover pre-refactor fetch; restored backend-aware endpoint/headers (OpenRouter + Venice, backend.key) and kept the cancellable AbortController. - runLLMJudge: two function bodies concatenated (one nested, never closed). - safeLLMCall: the whole function duplicated (old truncated head + new loop that referenced an undefined `backend`); reunified into one function with backend resolution, agent/server routing, model chain and the fallback loop. - runBenchmarks / autoApplyRecommendations: old "ANY LLM backend" guard left un-closed before the new "reachable (key or local mode)" guard — dropped the dead old guard / restored the missing brace. - generateAnalysis auto-apply button, config-optimizer, self-improve and CTF call sites: duplicated option objects / double catch collapsed to the newer (_noFallback / cancellable) variant. Verified on macOS: new regression test compiles every classic inline <script> with node:vm (the RED baseline failed with "Identifier response has already been declared"); full suite 646 green; headless-Chromium boot now reaches "Connected", navigateTo is defined, zero uncaught errors.
|
It fix the problem for me (on linux) |
Contributor
Author
|
Thanks for testing, @beunwa — much appreciated. I could only verify on macOS, so a Linux confirmation is exactly the cross-platform datapoint this needed. 🙏 |
This was referenced Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
What & why
Fixes #111 — the Web UI is stuck on "Initializing…", all links/buttons dead, only
GET /api/selfimprove/ledgerlooping in the terminal.Root cause:
docs/index.htmlis one big classic<script>. A series of bad auto-merges left duplicated old/new copies of the same LLM-call code side by side, producing JavaScript syntax errors. A syntax error means the browser never executes any of that script — sonavigateToand every handler are undefined, the health poll never runs (status stays "Initializing…"), and only a previously-scheduled poller keeps firing. The server itself is healthy (/api/health→ok:true).Because a JS engine reports only the first syntax error per script, these were layered — each fix revealed the next. There were eight.
The fixes (all in
docs/index.html)_safeLLMCallOnceresponsedecl + leftover pre-refactorfetchbackend.key), cancellableAbortControllerkeptsafeLLMCallbackend)runLLMJudgeqItem/cancellation variantrunBenchmarks,autoApplyRecommendations}catch_noFallback/cancellable variantNet −58 lines (dead duplicated code removed). No behavior removed — the newer, local-mode-aware / cancellable variants are kept; Venice + OpenRouter + agent/server + model-fallback all preserved.
Regression test
src/__tests__/ui-inline-scripts-parse.test.ts(new) compiles every classic inline<script>withnode:vm— exactly how a browser parses it — with zero new dependencies. It fails on currentmainwithIdentifier 'response' has already been declaredand passes after the fix, guarding the whole class of "the app won't boot because the script won't parse" regressions.Verification (macOS)
main, passes after the fix.#connectionTextnow reads "Connected",typeof navigateTo === 'function', client-side navigation works, 0 uncaught JS errors (was: stuck "Initializing…",navigateToundefined).Verified on macOS only. The LLM-call reconstructions are validated for parse + boot and preserve the pre-merge behavior of both merge halves; I couldn't exercise live provider calls without keys, so a maintainer spot-check of a real OpenRouter/Venice/local run is welcome.
Closes #111