Building client-side reflection mechanisms into modern AI chat interfaces requires balancing zero-friction user experience with robust intent classification. MindShield v1.2.0 introduces a fundamental rework of our local inference runtime, intent triage architecture, cross-platform DOM interception, and Firefox Manifest V3 compliance.
Previous iterations relied on binary pass/flag logic that proved overly restrictive on non-surrender queries. Blueprint v2.0 establishes a nuanced 3-tier triage hierarchy executed locally:
Bypasses all delays for factual lookups, concept breakdowns, comparative analysis, collaborative reviews, and context dumps exceeding 400 characters.
Renders a glassmorphic amber toast without blocking execution. Targeted at cognitive offloading like basic math (15 * 42), social drafting, and action requests.
Enforces a 5-second reflection timer specifically for direct problem-solving surrender, homework evasion, and puzzle shortcuts.
^ start-of-prompt regex anchors, allowing the model to catch offloading intent embedded midway through multi-sentence prompts (e.g., "Database crashed. Tell me exactly what to do.").Running zero-shot classification via @xenova/transformers locally inside the browser presents strict memory and latency boundaries.
[Native Chat Input] ──> [Capture Event] ──> [Warm Offscreen / Service Worker RAM]
│
(DistilBERT-MNLI / ONNX WASM)
│
┌──────────────────┴──────────────────┐
▼ ▼
< 50ms Triage > 400 Chars Auto-Pass
Chrome's background service worker previously terminated the offscreen document post-eval, triggering full 28MB model re-downloads and re-compilations on subsequent queries (~10s latency). Implementing chrome.offscreen.hasDocument() checks keeps the offscreen document permanently warm in memory, bringing inference evaluation down to <50ms.
Candidate labels and hypothesis templates for distilbert-base-uncased-mnli were recalibrated for high-contrast output:
Handling Single Page Application (SPA) state transitions across ChatGPT, Claude, Gemini, and X.com (Grok) required refactoring event capture strategies:
div[role="button"] structures and [data-testid="grok-send-button"], attaching listeners to pointerdown, mousedown, and click phases.popstate and navigation events. Changing conversation threads immediately dismisses lingering toasts, clears active timers, and flushes state flags.Firefox MV3 does not support Chrome's offscreen API. To achieve full cross-browser feature parity, the Firefox build was re-engineered for direct in-process WebAssembly execution within the background module.
host_permissions for HuggingFace and jsDelivr CDN endpoints to eliminate network aborts. Set env.allowLocalModels = false; and constrained WASM threads (env.backends.onnx.wasm.numThreads = 1) to bypass SharedArrayBuffer cross-origin isolation requirements.innerHTML assignments in showToast() with strict document.createElement() and textContent DOM nodes. Manifest configurations updated with "data_collection_permissions": { "required": ["none"] } and a strict_min_version of 112.0.