This commit is contained in:
firestar5683
2026-09-05 11:36:18 -05:00
parent cecc9bc8b6
commit 54a03a91b0
4 changed files with 26 additions and 7 deletions
@@ -21,7 +21,7 @@ import { Sidebar } from "/assets/components/sidebar.js?v=controllers-nav-1"
import { SentryMode } from "/assets/components/tools/sentry.js"
import { SpeedLimits } from "/assets/components/tools/speed_limits.js"
import { ModelManager } from "/assets/components/tools/model_manager.js?v=20260825a"
import { ModelLaboratory } from "/assets/components/tools/model_laboratory.js?v=model-lab-4"
import { ModelLaboratory } from "/assets/components/tools/model_laboratory.js?v=model-lab-5"
import { LivePlots } from "/assets/components/tools/plots.js"
import { ThemeMaker } from "/assets/components/tools/theme_maker.js"
import { TestingGround } from "/assets/components/tools/testing_ground.js"
@@ -17,6 +17,7 @@ const state = reactive({
let initialized = false
let pollHandle = null
let selectionDirty = false
function modelById(modelId) {
return state.models.find(model => model.value === modelId)
@@ -55,12 +56,20 @@ function selectionError() {
}
function applyPayload(payload) {
const draftSelection = {
lateralModel: state.configuration.lateralModel,
longitudinalModel: state.configuration.longitudinalModel,
}
state.chestnutReady = Boolean(payload?.chestnutReady)
state.isOnroad = Boolean(payload?.isOnroad)
state.configuration = {
enabled: Boolean(payload?.configuration?.enabled),
lateralModel: String(payload?.configuration?.lateralModel || ""),
longitudinalModel: String(payload?.configuration?.longitudinalModel || ""),
lateralModel: selectionDirty
? draftSelection.lateralModel
: String(payload?.configuration?.lateralModel || ""),
longitudinalModel: selectionDirty
? draftSelection.longitudinalModel
: String(payload?.configuration?.longitudinalModel || ""),
}
state.runtime = payload?.runtime && typeof payload.runtime === "object" ? payload.runtime : {}
state.download = payload?.download && typeof payload.download === "object" ? payload.download : {}
@@ -127,6 +136,7 @@ async function save(enabled) {
longitudinalModel: state.configuration.longitudinalModel,
}),
})
selectionDirty = false
applyPayload(payload)
state.message = String(payload.message || "Model Laboratory configuration saved.")
} catch (error) {
@@ -173,6 +183,7 @@ function bindControls() {
if (lateral.dataset.bound !== "1") {
lateral.dataset.bound = "1"
lateral.addEventListener("change", event => {
selectionDirty = true
state.configuration.lateralModel = event.target.value
const long = modelById(state.configuration.longitudinalModel)
const lat = modelById(event.target.value)
@@ -187,7 +198,10 @@ function bindControls() {
longitudinal.value = state.configuration.longitudinalModel
if (longitudinal.dataset.bound !== "1") {
longitudinal.dataset.bound = "1"
longitudinal.addEventListener("change", event => { state.configuration.longitudinalModel = event.target.value })
longitudinal.addEventListener("change", event => {
selectionDirty = true
state.configuration.longitudinalModel = event.target.value
})
}
}
if (enable && enable.dataset.bound !== "1") {
@@ -51,7 +51,7 @@
<link rel="stylesheet" href="/assets/components/tools/tsk_manager.css">
<script type="module">
import("/assets/components/router.js?v=router-cycle-fix-6").catch((err) => {
import("/assets/components/router.js?v=router-cycle-fix-7").catch((err) => {
console.error("[the_galaxy] bootstrap failed", err);
const target = document.getElementById("app") || document.body;
const pre = document.createElement("pre");
@@ -23,7 +23,7 @@ def test_router_and_settings_cache_bust_is_consistent():
index = INDEX_PATH.read_text(encoding="utf-8")
assert "/assets/components/settings.js?v=router-cycle-fix-5" in router
assert "/assets/components/router.js?v=router-cycle-fix-6" in index
assert "/assets/components/router.js?v=router-cycle-fix-7" in index
def test_bluetooth_actions_use_reactive_disabled_bindings():
@@ -130,5 +130,10 @@ def test_model_laboratory_frontend_exposes_guards_and_role_copy():
assert "Chestnut experiment" not in source
assert "Manifest shortcomings" not in source
assert "Opportunities" not in source
assert 'model_laboratory.js?v=model-lab-4' in ROUTER_PATH.read_text(encoding="utf-8")
assert "let selectionDirty = false" in source
assert "lateralModel: selectionDirty" in source
assert "longitudinalModel: selectionDirty" in source
assert source.count("selectionDirty = true") == 2
assert "selectionDirty = false\n applyPayload(payload)" in source
assert 'model_laboratory.js?v=model-lab-5' in ROUTER_PATH.read_text(encoding="utf-8")
assert 'model_laboratory.css?v=model-lab-4' in INDEX_PATH.read_text(encoding="utf-8")