Add Pure Local Sensors experiment + first-load UX improvements and fixes#4
Add Pure Local Sensors experiment + first-load UX improvements and fixes#4shaal wants to merge 1 commit into
Conversation
- Introduce 'Pure Local Sensors' mode (?pure-local=1) that zeros lf/lr track-orientation features so the brain only receives raw rays + speed. - Add toggle in the 🧪 Experiments panel with URL sync and restart helper. - Improve first-load experience: collapse advanced panels, prominent Start button, one-time helpful hint after first start. - Fix visual bug where #ab-hud (A/B HUD) leaked dark horizontal lines on first load and after A/B toggle cycles (now uses robust .ab-hud-visible class + early hide). - Add dedicated ELI15 chapter for the pure-local experiment. - Add planning documents under docs/plans/ for future RL mode and policy capability enhancements. - Various ELI15 accuracy fixes and supporting screenshots for validation.
📝 WalkthroughWalkthroughThis PR expands the car's neural network from 92 to 244 weights (6→8→4 to 10→16→4), introduces a pure local sensors diagnostic experiment that disables track-proximity features, adds first-time UX polish for A/B and experiments panels, and includes strategic planning for future policy enhancements and reinforcement learning modes. ChangesFeature and Architecture Update
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@AI-Car-Racer/uiPanels.js`:
- Around line 1846-1851: The btn.onclick handler only calls
restartBatch/restartBatch on window which restarts the batch but doesn't clear
the worker's init state, so the worker may keep the old "pure-local" sensor
mode; update the handler (btn.onclick) to first invalidate the worker init state
(e.g. clear a workerInitialized flag or call the existing
workerInitReset/initInvalidation function used elsewhere) and/or send a
reset/init-invalid message to the worker before invoking restartBatch or
window.restartBatch so the worker will re-run its init and receive the correct
sensor mode.
- Around line 1814-1820: The calls to updatePureLocalRestartHelper(...) may run
before the function is assigned to window.updatePureLocalRestartHelper, causing
a ReferenceError; change those call sites to safely reference the function via
window (e.g., check typeof window.updatePureLocalRestartHelper === 'function'
before invoking) — specifically update the two call sites that pass (on,
expPureLocalRow) and the initial-state block that checks window.pureLocalSensors
to call window.updatePureLocalRestartHelper only when it exists, leaving the
later assignment window.updatePureLocalRestartHelper = function(...) unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d2a07e6d-5a6a-4131-a8d4-f374af531252
⛔ Files ignored due to path filters (14)
docs/validation/screenshots/ab-hud-toggle-fix.pngis excluded by!**/*.pngdocs/validation/screenshots/first-load-after-fix.pngis excluded by!**/*.pngdocs/validation/screenshots/first-load-fixed-abhud.pngis excluded by!**/*.pngdocs/validation/screenshots/triangle-checkpoints-left-focus-annotated.pngis excluded by!**/*.pngdocs/validation/screenshots/triangle-checkpoints-left-focus.pngis excluded by!**/*.pngdocs/validation/screenshots/triangle-v2-left-focus-annotated.pngis excluded by!**/*.pngdocs/validation/screenshots/triangle-v2-left-focus.pngis excluded by!**/*.pngdocs/validation/screenshots/two-lines.jpgis excluded by!**/*.jpgdocs/validation/screenshots/vv-after-start.pngis excluded by!**/*.pngdocs/validation/screenshots/vv-first-load.pngis excluded by!**/*.pngdocs/validation/screenshots/vv-headed-03-triangle-10cps-annotated.pngis excluded by!**/*.pngdocs/validation/screenshots/vv-headed-03-triangle-10cps.pngis excluded by!**/*.pngdocs/validation/screenshots/vv-improved-first-load.pngis excluded by!**/*.pngtwo-lines.jpgis excluded by!**/*.jpg
📒 Files selected for processing (16)
AI-Car-Racer/buttonResponse.jsAI-Car-Racer/car.jsAI-Car-Racer/eli15/chapters/lineage.jsAI-Car-Racer/eli15/chapters/neural-network.jsAI-Car-Racer/eli15/chapters/pure-local-experiment.jsAI-Car-Racer/eli15/chapters/sensors.jsAI-Car-Racer/eli15/chapters/what-is-this-project.jsAI-Car-Racer/eli15/chapters/why-cars-crash.jsAI-Car-Racer/eli15/index.jsAI-Car-Racer/eli15/tour.jsAI-Car-Racer/main.jsAI-Car-Racer/sim-worker.jsAI-Car-Racer/style.cssAI-Car-Racer/uiPanels.jsdocs/plans/enhancing-policy-capabilities.mddocs/plans/reinforcement-learning-mode.md
| updatePureLocalRestartHelper(on, expPureLocalRow); | ||
| }); | ||
|
|
||
| // Initial state for restart helper | ||
| if (window.pureLocalSensors) { | ||
| updatePureLocalRestartHelper(true, expPureLocalRow); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify call order and identifier usage around helper initialization.
rg -n -C2 'updatePureLocalRestartHelper|window\.updatePureLocalRestartHelper|window\.pureLocalSensors' AI-Car-Racer/uiPanels.jsRepository: shaal/VrumVector
Length of output: 1037
Fix ReferenceError: call window.updatePureLocalRestartHelper (or guard) before use
In AI-Car-Racer/uiPanels.js, the code calls updatePureLocalRestartHelper(...) at lines 1814 and 1819, but the function is only defined later as window.updatePureLocalRestartHelper = function(...) { ... } at line 1832. This mismatch can throw a runtime ReferenceError when those call sites run; replace/guard the calls to reference window.updatePureLocalRestartHelper (e.g., check typeof window.updatePureLocalRestartHelper === 'function') to wire the restart helper safely.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@AI-Car-Racer/uiPanels.js` around lines 1814 - 1820, The calls to
updatePureLocalRestartHelper(...) may run before the function is assigned to
window.updatePureLocalRestartHelper, causing a ReferenceError; change those call
sites to safely reference the function via window (e.g., check typeof
window.updatePureLocalRestartHelper === 'function' before invoking) —
specifically update the two call sites that pass (on, expPureLocalRow) and the
initial-state block that checks window.pureLocalSensors to call
window.updatePureLocalRestartHelper only when it exists, leaving the later
assignment window.updatePureLocalRestartHelper = function(...) unchanged.
| btn.onclick = () => { | ||
| if (typeof restartBatch === 'function') { | ||
| restartBatch(); | ||
| } else if (typeof window.restartBatch === 'function') { | ||
| window.restartBatch(); | ||
| } |
There was a problem hiding this comment.
Restart helper should invalidate worker init before restarting.
The helper currently restarts the batch only, but pure-local is sent to the worker only during init. Without invalidating init state first, the restart can keep the old sensor mode active.
💡 Suggested fix
if (btn) {
btn.onclick = () => {
+ if (typeof invalidateWorkerInit === 'function') {
+ invalidateWorkerInit();
+ } else if (typeof window.invalidateWorkerInit === 'function') {
+ window.invalidateWorkerInit();
+ }
if (typeof restartBatch === 'function') {
restartBatch();
} else if (typeof window.restartBatch === 'function') {
window.restartBatch();
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@AI-Car-Racer/uiPanels.js` around lines 1846 - 1851, The btn.onclick handler
only calls restartBatch/restartBatch on window which restarts the batch but
doesn't clear the worker's init state, so the worker may keep the old
"pure-local" sensor mode; update the handler (btn.onclick) to first invalidate
the worker init state (e.g. clear a workerInitialized flag or call the existing
workerInitReset/initInvalidation function used elsewhere) and/or send a
reset/init-invalid message to the worker before invoking restartBatch or
window.restartBatch so the worker will re-run its init and receive the correct
sensor mode.
This PR introduces a 'Pure Local Sensors' experiment mode along with several first-load UX improvements and bug fixes.
Key changes
?pure-local=1): Forceslfandlrtrack-orientation features to zero so the brain only receives the 7 raw ray readings + speed. Useful for testing embodied/local-only driving.#ab-hud) produced stray dark horizontal lines on first load and after repeated A/B enable/disable cycles. Now uses a robust CSS class (.ab-hud-visible) + early-hide safeguards.docs/plans/for future Reinforcement Learning mode and policy capability enhancements (memory, anticipation, capacity).All changes were validated with headed browser sessions via agent-browser CLI.
The Triangle track preset changes from earlier experiments have been reverted (kept at the original 4 checkpoints).
Summary by CodeRabbit
Release Notes
New Features
Documentation
Styling