From 76cf9331ef17b3edda6d03d3b9a575a979150b0b Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Tue, 17 Nov 2026 21:52:05 -0600 Subject: [PATCH] Show effective profiles in Galaxy acceleration and deceleration selectors --- openpilot/starpilot/galaxy/settings.py | 3 +- .../starpilot/galaxy/tests/test_settings.py | 33 +++++++++++++++++++ .../galaxy/tests/test_settings_controls.mjs | 27 +++++++++++++++ .../galaxy/web/js/galaxy-setting-row.js | 10 ++++-- prebuilt.json | 2 +- 5 files changed, 71 insertions(+), 4 deletions(-) diff --git a/openpilot/starpilot/galaxy/settings.py b/openpilot/starpilot/galaxy/settings.py index 3085d430f1..e1020235d8 100644 --- a/openpilot/starpilot/galaxy/settings.py +++ b/openpilot/starpilot/galaxy/settings.py @@ -415,7 +415,8 @@ def _projection(row: FeatureRow) -> dict: "confirm": bool(row.key in CONFIRM_ACTIONS or is_long_confirm_action(row.key) or row.key in (PIP_RESET, PIP_EDITOR, VASM_RESET, VASM_ANNOTATION) or row.key.startswith(PIP_FORMAT_PREFIX)), "repairValue": row.repair_value, "defaultValue": row.default_value, "resetAvailable": row_default(row) is not None, - "displayScale": "lane-strength" if row.key == "LaneCenteringStrength" else None, + "displayScale": ("lane-strength" if row.key == "LaneCenteringStrength" else + "selected-profile" if row.key in ("profile:global_acceleration", "profile:global_braking") else None), **({"coordinate": row.key.removeprefix("torque:surface:")} if row.key.startswith("torque:surface:") and row.key != "torque:surface:reset" else {}), **({"acceptedFindingValue": row.accepted_finding_value} if row.accepted_finding_value is not None else {}), "heading": is_heading(row.key), "collapsed": bool(row.collapsed), diff --git a/openpilot/starpilot/galaxy/tests/test_settings.py b/openpilot/starpilot/galaxy/tests/test_settings.py index b7aba371b5..c34de41326 100644 --- a/openpilot/starpilot/galaxy/tests/test_settings.py +++ b/openpilot/starpilot/galaxy/tests/test_settings.py @@ -909,6 +909,39 @@ class SettingsGatewayTest(unittest.TestCase): self.assertTrue(self.gateway.confirm(intent["intent"], self.session, self.generation)) self.assertEqual(json.loads(required_raw(self.params, "LongitudinalPersonalityProfiles", 65536))["selectedAccelerationProfile"], "standard") + def test_global_profile_display_keeps_fresh_legacy_and_saved_values(self): + from openpilot.starpilot.longitudinal.profile_document import default_personality_profiles, profile_document + + fresh = self.page("profiles") + rows = {row["label"]: row for row in fresh["rows"]} + self.assertEqual(rows["Selected Acceleration Profile"]["value"], "StarPilot Default") + self.assertEqual(rows["Selected Deceleration Profile"]["value"], "Comfort") + for name in ("Selected Acceleration Profile", "Selected Deceleration Profile"): + self.assertEqual(rows[name]["displayScale"], "selected-profile") + self.assertIsNone(self.params.get("LongitudinalPersonalityProfiles")) + for acceleration, braking in (("dom_default", "dom_default"), ("standard", "eco"), ("sport_plus", "sport")): + with self.subTest(acceleration=acceleration, braking=braking): + document = profile_document(default_personality_profiles(False), enabled=False, + selected_acceleration_profile=acceleration, selected_deceleration_profile=braking) + self.params.put("LongitudinalPersonalityProfiles", document, block=True) + path = Path(self.params.get_param_path("LongitudinalPersonalityProfiles")) + before = path.read_bytes() + page = self.page("profiles") + self.assertEqual(path.read_bytes(), before) + for label, field in (("Selected Acceleration Profile", "selectedAccelerationProfile"), + ("Selected Deceleration Profile", "selectedDecelerationProfile")): + index = next(i for i, row in enumerate(page["rows"]) if row["label"] == label) + intent = self.gateway.preview(page["view"], index, 0, self.session, self.generation, value="Sport") + self.assertTrue(self.gateway.confirm(intent["intent"], self.session, self.generation)) + saved = json.loads(path.read_bytes()) + self.assertEqual(saved[field], "sport") + other = "selectedDecelerationProfile" if field == "selectedAccelerationProfile" else "selectedAccelerationProfile" + self.assertEqual(saved[other], document[other]) + reopened = self.page("profiles") + self.assertEqual(reopened["rows"][index]["value"], "Sport") + document = saved + page = reopened + def test_traffic_saved_controls_and_explicit_follow_repair_use_shared_gateway(self): from openpilot.starpilot.longitudinal.profile_runtime import read_traffic_settings diff --git a/openpilot/starpilot/galaxy/tests/test_settings_controls.mjs b/openpilot/starpilot/galaxy/tests/test_settings_controls.mjs index a10eac3d84..e152813072 100644 --- a/openpilot/starpilot/galaxy/tests/test_settings_controls.mjs +++ b/openpilot/starpilot/galaxy/tests/test_settings_controls.mjs @@ -39,6 +39,33 @@ function control(row = numeric) { return { vm, commits, event } } +for (const [label, choices, fresh, initial] of [ + ['Selected Acceleration Profile', ['StarPilot Default', 'Normal', 'Comfort', 'Sport', 'Sport+'], 'StarPilot Default', 'StarPilot Default'], + ['Selected Deceleration Profile', ['StarPilot Default', 'Normal', 'Comfort', 'Sport'], 'Comfort', 'Comfort'], +]) { + for (const saved of new Set([fresh, ...choices])) { + const row = { label, choices, value: saved, defaultValue: initial, displayScale: 'selected-profile', available: true, action: true } + const { vm, commits } = control(row) + const expected = saved === 'StarPilot Default' ? 'Normal' : saved + assert.equal(vm.control, 'select') + assert.equal(vm.currentValue, expected) + assert.deepEqual(vm.presentedRow.choices, choices.slice(1)) + assert.equal(new Set(vm.presentedRow.choices).size, vm.presentedRow.choices.length) + assert.equal(vm.showDefault, saved !== initial, 'reset retains the actual saved/default distinction') + await vm.commit(expected) + assert.deepEqual(commits, [], 'viewing/reselecting a legacy default never writes a profile') + assert.equal(row.value, saved) + await vm.commit('Sport') + assert.deepEqual(commits, expected === 'Sport' ? [] : [[7, 'Sport']]) + vm.row = { ...row, value: 'Sport' } + assert.equal(vm.currentValue, 'Sport', 'saved readback stays selected') + assert.equal(control(vm.row).vm.currentValue, 'Sport', 'reopening retains the saved choice') + } +} +assert.ok(GalaxySettingRow.template.includes('choice in presentedRow.choices')) +assert.deepEqual(control({ choices: ['StarPilot Default', 'Custom'], value: 'StarPilot Default' }).vm.presentedRow.choices, + ['StarPilot Default', 'Custom'], 'personality presets and unrelated selectors are unchanged') + // Drag previews remain local. Fine mode uses the held value and one fifth of normal travel. const fine = control() fine.vm.onSliderPointerDown(fine.event()) diff --git a/openpilot/starpilot/galaxy/web/js/galaxy-setting-row.js b/openpilot/starpilot/galaxy/web/js/galaxy-setting-row.js index b012165c69..01d0c46567 100644 --- a/openpilot/starpilot/galaxy/web/js/galaxy-setting-row.js +++ b/openpilot/starpilot/galaxy/web/js/galaxy-setting-row.js @@ -50,6 +50,11 @@ export function laneStrengthSaved(value, row) { } export function presentedSetting(row) { + if (row.displayScale === "selected-profile") { + const display = value => value === "StarPilot Default" ? "Normal" : value + return { ...row, value: display(row.value), defaultValue: display(row.defaultValue), + choices: row.choices.filter(choice => choice !== "StarPilot Default") } + } if (row.displayScale !== "lane-strength") return row return { ...row, value: laneStrengthDisplay(row.value, row), defaultValue: row.defaultValue == null ? row.defaultValue : laneStrengthDisplay(row.defaultValue, row), @@ -76,7 +81,8 @@ export const GalaxySettingRow = { presentedRow() { return presentedSetting(this.row) }, control() { return settingControl(this.row) }, showDefault() { - const value = this.presentedRow.value, initial = this.presentedRow.defaultValue + const source = this.row.displayScale === "selected-profile" ? this.row : this.presentedRow + const value = source.value, initial = source.defaultValue if (initial === null || initial === undefined || this.row.page) return false return Number.isFinite(Number(value)) && Number.isFinite(Number(initial)) ? Number(value) !== Number(initial) : String(value) !== String(initial) }, @@ -263,7 +269,7 @@ export const GalaxySettingRow = {
{{ Number(bounds.min.toPrecision(7)) }} to {{ Number((bounds.numericMax ?? bounds.max).toPrecision(7)) }} {{ presentedRow.unit }}Step: {{ Number(bounds.step.toPrecision(7)) }} {{ presentedRow.unit }}
- + diff --git a/prebuilt.json b/prebuilt.json index 0fa852de02..617893e571 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "cf4736b61ca2dd1fa3159ff30e781693b7465535c513b9a8f9b7e0d02ad559c6", "schema_version": 1} +{"protected_inventory_sha256": "ead10ba5040358813dcc552e37ca7d0cb6373245bad9a7f6ac80794a44d44c1a", "schema_version": 1}