Skip to content

[codex] Extract local AI provider controls#454

Merged
elkimek merged 3 commits into
mainfrom
codex/extract-local-ai-controls
May 30, 2026
Merged

[codex] Extract local AI provider controls#454
elkimek merged 3 commits into
mainfrom
codex/extract-local-ai-controls

Conversation

@elkimek
Copy link
Copy Markdown
Owner

@elkimek elkimek commented May 30, 2026

Summary

  • Move Local AI/Ollama connection checks, PII Local AI probing, model advisor rendering, and hardware override handlers into provider-local-ai-controls.js.
  • Keep provider-panels.js as the settings bridge for existing exports and window-facing handlers.
  • Add the new module to the service worker app shell and bump APP_VERSION to 1.8.280.

Validation

  • node tests/test-hardware.js
  • node tests/test-audit.js
  • node tests/test-pii.js
  • node tests/test-openrouter.js
  • node tests/test-custom-api.js
  • node tests/test-cashu-wallet.js
  • ./run-tests.sh

@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
get-based Ready Ready Preview, Comment May 30, 2026 1:52pm

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 30, 2026

Greptile Summary

This PR extracts the Local AI/Ollama connection checks, PII probing, model advisor rendering, and hardware-override handlers from provider-panels.js into a new provider-local-ai-controls.js module, keeping provider-panels.js as a thin settings bridge that re-exports everything. The new module is registered in the service worker app shell and covered by extended URL-validation and CORS-probe tests.

  • New provider-local-ai-controls.js: adds normalizeLocalAiBaseUrl (protocol/format validation before any network call) and a two-step no-cors reachability probe (isLikelyCorsBlocked) that replaces the old inline isCORSError preflight guard with a more accurate detection strategy.
  • provider-panels.js: removes ~188 lines of local-AI code; re-exports the extracted symbols and injects _returnToChatIfOnboarding via a top-level configureLocalAiControls() call.
  • Tests: test-hardware.js gains a new section (9. Local AI URL Validation) with DOM-mock integration tests for malformed URLs, unreachable servers, and CORS classification.

Confidence Score: 5/5

Safe to merge — this is a pure code extraction with no logic changes to any non-local-AI path, and backward compatibility is maintained via re-exports in provider-panels.js.

The extraction is mechanically faithful: every exported symbol is re-exposed, the dependency-injection pattern for returnToChatIfOnboarding is correct, and the new URL-validation and no-cors CORS probe are improvements over the old code. The only behavioral delta (loss of CORS guidance in the outer catch block) is a narrow edge case and does not affect data integrity or security.

js/provider-local-ai-controls.js — both connection-test catch blocks lost the CORS-specific error message that was present in the old code.

Important Files Changed

Filename Overview
js/provider-local-ai-controls.js New module extracting Ollama connection checks, PII probing, model advisor rendering, and hardware-override handlers; introduces URL normalization and a two-step no-cors CORS probe, but the main catch block no longer shows platform-specific CORS guidance.
js/provider-panels.js Settings bridge: removed ~188 lines of local-AI code, replaced with import/re-export from the new module and a top-level configureLocalAiControls() injection; existing exports and window bindings preserved cleanly.
service-worker.js Adds provider-local-ai-controls.js to the APP_SHELL cache list in the correct position (before provider-panels.js which imports it).
tests/test-audit.js Adds one assertion verifying the new module is present in the service worker app shell; straightforward test extension.
tests/test-hardware.js Adds a new section (9. Local AI URL Validation) with DOM-mock integration tests covering malformed URLs, unreachable servers, and CORS detection; import source assertions updated to reference the new module.
version.js Version bumped from 1.8.279 to 1.8.282; PR description states 1.8.280, so there is a three-patch discrepancy between the description and the committed value.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[testOllamaConnection / testPIIOllamaConnection] --> B[normalizeLocalAiBaseUrl]
    B -->|error| C[Show validation error, return]
    B -->|ok url| D{isHttpsToNonLocalhost?}
    D -->|yes| E[Show HTTPS/localhost error, return]
    D -->|no| F[HEAD preflight fetch]
    F -->|success| G[checkOpenAICompatible + checkOllama]
    F -->|transport error| H[isFetchTransportError?]
    H -->|yes| I[isLikelyCorsBlocked no-cors probe]
    H -->|no| G
    I -->|reachable| J[Show CORS help text, return]
    I -->|unreachable| G
    G -->|result.available + models| K[Update UI, saveOllamaConfig, renderModelAdvisor]
    G -->|not available| L[throw Not reachable]
    G -->|exception| M[Show NOT_CONNECTED_TEXT]
    K --> N[updatePrivacyStatusCard / returnToChatIfOnboarding]
Loading

Reviews (3): Last reviewed commit: "Refine local AI CORS detection" | Re-trigger Greptile

@elkimek elkimek merged commit 499a857 into main May 30, 2026
5 checks passed
@elkimek elkimek deleted the codex/extract-local-ai-controls branch May 30, 2026 13:56
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.

1 participant