Prebuilt flag bug fix

This commit is contained in:
whoisdomi
2026-04-30 05:42:43 -05:00
parent a919998872
commit b9c5a78d16
3 changed files with 27 additions and 2 deletions
+4 -1
View File
@@ -22,7 +22,10 @@ class Params(_Params):
def get_bool(self, key, block=False, default=False):
try:
return super().get_bool(key, block=block)
result = super().get(key, block=block, return_default=True)
if result is None:
return bool(default)
return bool(result)
except UnknownKeyName:
return bool(default)
+6 -1
View File
@@ -14,7 +14,7 @@ DEFAULT_STEER_KP = 0.6
LEGACY_STEER_KP = 0.7
QT_STEER_KP_PLACEHOLDER = 1.0
LAUNCH_PARAM_MIGRATION_MARKER = ".starpilot_launch_param_migrations_v1"
LAUNCH_PARAM_MIGRATION_MARKER = ".starpilot_launch_param_migrations_v2"
class ParamsLike(Protocol):
@@ -53,6 +53,11 @@ def apply_launch_param_migrations(params: ParamsLike, marker_path: Path | None =
_approx_equal(steer_kp_stock, QT_STEER_KP_PLACEHOLDER)):
params.put_float(STEER_KP_STOCK_KEY, DEFAULT_STEER_KP)
# Initialize UsePrebuilt to True if never explicitly set, so the UI default
# matches the shell script's default of USE_PREBUILT=1.
if not Path(params.get_param_path("UsePrebuilt")).exists():
params.put_bool("UsePrebuilt", True)
marker.touch()
@@ -53,6 +53,23 @@ def test_apply_launch_param_migrations_sets_branch_defaults_once(tmp_path):
assert (tmp_path / "params" / LAUNCH_PARAM_MIGRATION_MARKER).is_file()
def test_apply_launch_param_migrations_initializes_use_prebuilt(tmp_path):
params = FileBackedFakeParams(tmp_path / "params")
apply_launch_param_migrations(params)
assert params.get_bool("UsePrebuilt")
def test_apply_launch_param_migrations_does_not_overwrite_use_prebuilt(tmp_path):
params = FileBackedFakeParams(tmp_path / "params")
params.put_bool("UsePrebuilt", False)
apply_launch_param_migrations(params)
assert not params.get_bool("UsePrebuilt")
def test_apply_launch_param_migrations_does_not_reapply_after_marker(tmp_path):
params = FileBackedFakeParams(tmp_path / "params")
marker = tmp_path / "params" / LAUNCH_PARAM_MIGRATION_MARKER