Drop LAST from the speed limit sign; the source label already says where it came from

This commit is contained in:
firestarsdog
2026-11-15 21:12:47 -05:00
parent ded8410a88
commit b2cca153d9
13 changed files with 56 additions and 104 deletions
+4 -5
View File
@@ -64,11 +64,10 @@ driver override wins over the limit. Pressing the accelerator adds no status.
Both sign styles identify the displayed source: DASH for Dashboard, OSM for offline
Maps, and VISION for the vision model. Explicit Mapbox readings in historical
replay use NAV; unidentified live sources show SPEED. A retained road reading
shows LAST alongside its source when known. For the same source and speed, the
label clears after 150 ms of live updates. Vision keeps a confirmed sign current
after it leaves view while the camera pipeline stays healthy. DASH follows the
current OEM reading, and Maps keeps the current road limit separate from its
upcoming preview.
keeps its source label. Vision keeps a confirmed sign current after it leaves
view while the camera pipeline stays healthy. DASH follows the current OEM
reading, and Maps keeps the current road limit separate from its upcoming
preview.
During a new-limit confirmation an active OVERRIDE stays below SET;
if SET is hidden, it appears in the confirmation header with a `Now:` label.
The expanded Accept button contains the proposed limit including its offset
-1
View File
@@ -106,7 +106,6 @@ class SpeedLimitObservation:
last_received_speed_limit_mps: float | None = None
last_received_source: str = 'none'
last_received_adjusted_limit_mps: float | None = None
sign_recovering: bool = False
def __post_init__(self) -> None:
for value in (self.speed_limit_mps, self.offset_mps, self.pending_speed_limit_mps,
+1 -25
View File
@@ -46,7 +46,7 @@ from openpilot.starpilot.ui.onroad_state import conditional_lead_from_message
from openpilot.starpilot.ui.onroad_state import (AlertSize, BorderSignals, ObservationKind, OnroadAlert,
OnroadState, SpeedLimitObservation, is_personality_notice, speed_limit_from_message)
from openpilot.starpilot.ui.unified_speed_presentation import (displayed_adjusted_limit_mps, displayed_limit_mps,
displayed_limit_source, positive, retaining_limit)
positive, retaining_limit)
from openpilot.starpilot.ui.onroad_stopped_timer import StoppedTimer
from openpilot.starpilot.speed_limits.vision.stop_observation import StopConfirmation
from openpilot.starpilot.ui.onroad_lane_alerts import lateral_lane_alert
@@ -344,8 +344,6 @@ class RuntimeSnapshotAdapter:
self._reverse_driver_camera = ReverseDriverCamera()
self._vision_stop = StopConfirmation(display_only=True)
self._slc_sign_cache: tuple[int, tuple[int, int], str, SpeedLimitObservation] | None = None
self._slc_last_sign: tuple[tuple[int, int], str, str, float] | None = None
self._slc_sign_recovery_ns: int | None = None
self._mono_clock, self._boot_clock = mono_clock, boot_clock
self._device_after_mono_ns = mono_clock()
self._device_offset_ns: int | None = None
@@ -399,25 +397,6 @@ class RuntimeSnapshotAdapter:
"""Fresh effective offroad admission for connectivity setup, regardless of ignition."""
return self.confirmed_offroad()
def _stabilize_slc_label(self, observation: SpeedLimitObservation, drive_key: tuple[int, int] | None,
session: str, stamp: int) -> SpeedLimitObservation:
limit = displayed_limit_mps(observation)
if drive_key is not None and session and limit is not None:
sign = (drive_key, session, displayed_limit_source(observation), limit)
if observation.kind != ObservationKind.VALID or observation.status == 'display_hold':
self._slc_last_sign = sign
self._slc_sign_recovery_ns = None
return observation
if sign == self._slc_last_sign:
# Redrawing a single live packet must never clear LAST.
if self._slc_sign_recovery_ns is None or stamp < self._slc_sign_recovery_ns:
self._slc_sign_recovery_ns = stamp
if stamp - self._slc_sign_recovery_ns < SLC_SIGN_HOLD_NS:
return replace(observation, sign_recovering=True)
self._slc_last_sign = None
self._slc_sign_recovery_ns = None
return observation
def build(self, mode: ShellMode, selected: Destination = Destination.STAR, *, compact_y: float = 0,
compact_scroll_x: float = 0, sidebar_expanded: bool = True, now_ns: int | None = None,
menu_only: bool = False, stopped_timer_enabled: bool | None = None,
@@ -668,9 +647,6 @@ class RuntimeSnapshotAdapter:
# instead of letting it come and go with the source.
observation = SpeedLimitObservation(kind=ObservationKind.STALE, source=observation.source, status=observation.status,
source_readings=observation.source_readings)
observation = self._stabilize_slc_label(observation, drive_key if mode == ShellMode.ONROAD else None,
str(getattr(slc, 'sessionId', '')) if show_slc else '',
int(sm.logMonoTime['slcState']) if show_slc else 0)
# Temporary old StarPilot route replay shim. Retire by deleting this call
# and its import; remaining cleanup is documented in
# openpilot/starpilot/ui/old_starpilot_route_shim.py.
+1 -2
View File
@@ -38,8 +38,7 @@ class SpeedLimitPulse:
self.last_limit = limit
return
if not pending:
live = (observation.kind == ObservationKind.VALID and observation.status != 'display_hold' and
not observation.sign_recovering)
live = observation.kind == ObservationKind.VALID and observation.status != 'display_hold'
if live and not observation.action_enabled and limit != self.last_limit:
self.start_time = now
self.display_pulsing = True
@@ -254,8 +254,6 @@ class SpeedLimitWidget:
def _sign(self, state: OnroadState, bounds, now: float) -> None:
shown, obs = resolve_unified_speed(state), state.speed_limit
heading = SOURCE_LABELS.get(shown.source, 'SPEED')
if shown.show_last and self.profile == Profile.LARGE:
heading = f'LAST {heading}' if heading != 'SPEED' else 'LAST'
x, top = bounds[0] + 12, bounds[1] + SIGN_PADDING[self.profile][0]
card_top, large = top, self.profile == Profile.LARGE
scale, text_scale = self.scale, self.text_scale
@@ -174,14 +174,11 @@ def test_mutcd_preserves_text_sizes_and_fits_both_sizes_with_real_fonts(profile)
text, role, size, x, y, _ = call.args
left, right = font.horizontal_ink(text, role, size)
top, bottom = font.vertical_ink(text, role, size)
if text.startswith('LAST '):
assert right - left == pytest.approx(108 * widget.scale)
else:
nominal = {FontRole.SEMI_BOLD: 26, FontRole.SET_SPEED: 70, FontRole.MEDIUM: 27}[role] * widget.text_scale
if role == FontRole.SET_SPEED:
assert size == pytest.approx(nominal)
else: # Large labels are larger, shrinking only to fit the sign.
assert nominal - 1e-6 <= size <= nominal * LABEL_SCALE[profile] + 1e-6
nominal = {FontRole.SEMI_BOLD: 26, FontRole.SET_SPEED: 70, FontRole.MEDIUM: 27}[role] * widget.text_scale
if role == FontRole.SET_SPEED:
assert size == pytest.approx(nominal)
else: # Large labels are larger, shrinking only to fit the sign.
assert nominal - 1e-6 <= size <= nominal * LABEL_SCALE[profile] + 1e-6
boxes.append((x + left, y + top, x + right, y + bottom))
assert cx - half_width + 1 <= min(box[0] for box in boxes)
assert max(box[2] for box in boxes) <= cx + half_width - 1
@@ -300,7 +300,7 @@ def test_every_slc_state_draws_the_plain_sign_with_real_fonts():
calls = []
with patch.object(fonts, 'draw', lambda *args, sink=calls: sink.append(args)):
widget.render(current)
# SLC keeps following its accepted VISION limit through a gap, so no LAST.
# SLC keeps following its accepted VISION limit through a gap.
assert [call[0] for call in calls if call[-1].a == 255] == ['VISION', '100'] + (['+10'] if variant == 'offset' else [])
widget.close()
finally:
@@ -612,7 +612,7 @@ def test_both_sign_styles_contain_text_and_arrows_at_each_profile_scale():
patch.object(widget.shapes, 'arrow') as arrow_draw:
widget.render(current)
calls = [call for call in calls if call[-1].a == 255]
assert sum(call[0] == (f'LAST {heading}' if retained and profile == Profile.LARGE else heading) for call in calls) == 1, case
assert sum(call[0] == heading for call in calls) == 1, case
assert all(call[0] != 'LIMIT' for call in calls), case
ink = []
for text, role, size, left, top, color in calls:
@@ -52,7 +52,7 @@ def test_unknown_slc_keeps_only_display_sign_during_brief_gap(source):
@pytest.mark.parametrize('source', ['dashboard', 'map', 'vision'])
@pytest.mark.parametrize('has_last_received', [False, True])
def test_slc_last_label_requires_stable_recovery(source, has_last_received):
def test_slc_sign_retained_only_through_gaps(source, has_last_received):
ui = display_ui()
live = ui.sm.messages['slcState']
live.source = source
@@ -62,30 +62,26 @@ def test_slc_last_label_requires_stable_recovery(source, has_last_received):
'lastReceivedSpeedLimit': live.speedLimit, 'lastReceivedSource': source}))
adapter = RuntimeSnapshotAdapter(ui)
def update(message, elapsed_ms, *, render_ms=None):
def update(message, elapsed_ms):
ui.sm.messages['slcState'] = message
ui.sm.logMonoTime['slcState'] = NOW + elapsed_ms * 1_000_000
now = elapsed_ms if render_ms is None else render_ms
return adapter.build(ShellMode.ONROAD, now_ns=NOW + now * 1_000_000).onroad
return adapter.build(ShellMode.ONROAD, now_ns=NOW + elapsed_ms * 1_000_000).onroad
def last(state):
return resolve_unified_speed(state).posted_retained or state.speed_limit.sign_recovering
def retained(state):
return resolve_unified_speed(state).posted_retained
assert not last(update(live, 0))
assert last(update(gap, 50))
assert last(update(live, 100))
assert last(update(gap, 150))
assert last(update(live, 200))
assert last(update(live, 250))
assert last(update(live, 300))
assert last(update(live, 300, render_ms=350)) # Redrawing the same packet cannot clear LAST.
assert not last(update(live, 350))
assert not retained(update(live, 0))
assert retained(update(gap, 50))
assert not retained(update(live, 100)) # A live reading is current at once.
assert retained(update(gap, 150))
assert not retained(update(live, 200))
assert not retained(update(live, 350))
assert last(update(gap, 400))
assert not last(update(NS(**(vars(live) | {'speedLimit': live.speedLimit + 1})), 450))
assert last(update(unknown_slc(), 500))
assert retained(update(gap, 400))
assert not retained(update(NS(**(vars(live) | {'speedLimit': live.speedLimit + 1})), 450))
assert retained(update(unknown_slc(), 500))
other_source = 'dashboard' if source != 'dashboard' else 'map'
assert not last(update(NS(**(vars(live) | {'source': other_source})), 550))
assert not retained(update(NS(**(vars(live) | {'source': other_source})), 550))
@pytest.mark.parametrize('display_only', [False, True])
@@ -386,7 +386,7 @@ def test_retired_fallback_cannot_reset_session_or_change_set_speed_sign_and_reco
shown = resolve_unified_speed(view)
assert target == pytest.approx(45, abs=1e-4)
assert (shown.max_text, shown.posted_text, shown.source, shown.status) == ('50', '45', 'map', 'Using speed limit')
assert shown.limit_in_use and not shown.show_last
assert shown.limit_in_use
assert not view.speed_limit.driver_override_active
recovered, view, target = drive.step(1100)
assert not view.speed_limit.driver_override_active
@@ -417,7 +417,7 @@ def test_maps_loss_keeps_accepted_target_display_and_control(tmp_path, loss):
assert view.speed_limit.kind != ObservationKind.VALID
shown = resolve_unified_speed(view)
assert (shown.max_text, shown.posted_text, shown.status) == ('70', '45', 'Using speed limit')
assert shown.limit_in_use and not shown.show_last
assert shown.limit_in_use
assert all(slc_controls(profile, view) == () for profile in Profile)
assert not output.message.slcState.hasPending
@@ -444,7 +444,7 @@ def test_long_gap_confirmation_and_recovery_keep_the_accepted_limit(tmp_path, an
assert not output.message.slcState.hasPending
shown = resolve_unified_speed(view)
assert shown.posted_text == str(limit if answer == 'accept' else 45)
assert shown.limit_in_use and not shown.show_last
assert shown.limit_in_use
assert view.speed_limit.last_received_speed_limit_mps == pytest.approx(limit * MPH)
# A dead SLC publisher cannot make the widget claim retained control indefinitely.
drive.ui.sm.alive['slcState'] = False
@@ -503,10 +503,9 @@ def test_retention_respects_lower_max_and_reset(tmp_path, offset):
assert view.speed_limit.kind != ObservationKind.VALID and shown.posted_retained
assert shown.status == 'Using set speed'
# SLC still follows its accepted limit through the gap; SET below it is ordinary cruising.
assert not shown.limit_in_use and not shown.show_last
assert not shown.limit_in_use
assert replace(shown, posted_retained=False) == resolve_unified_speed(before)
_, recovered, target = drive.step(400)
assert recovered.speed_limit.sign_recovering
assert resolve_unified_speed(recovered) == resolve_unified_speed(before)
assert target == pytest.approx(40, rel=0, abs=1e-4)
drive.runtime.reset()
@@ -135,13 +135,12 @@ def test_display_only_hidden_stale_and_reappearance_do_not_invent_new_limit():
assert rgba(pulse.color(rl.WHITE, 12.5)) == rgba(rl.WHITE)
@pytest.mark.parametrize('held_fields', [{'status': 'display_hold'}, {'sign_recovering': True}])
def test_retained_display_finishes_existing_pulse_without_restarting(held_fields):
def test_retained_display_finishes_existing_pulse_without_restarting():
pulse = SpeedLimitPulse()
current = display_state()
pulse.update(current, 10.)
assert rgba(pulse.color(rl.WHITE, 10.5)) != rgba(rl.WHITE)
held = replace(current, speed_limit=replace(current.speed_limit, **held_fields))
held = replace(current, speed_limit=replace(current.speed_limit, status='display_hold'))
pulse.update(held, 10.5)
assert rgba(pulse.color(rl.WHITE, 10.5)) != rgba(rl.WHITE)
for now in (11.5, 12.5):
@@ -173,11 +172,10 @@ def test_automatic_adoption_finishes_existing_highlight():
assert rgba(pulse.color(rl.WHITE, 13.5)) == rgba(rl.WHITE)
@pytest.mark.parametrize('held_fields', [{'status': 'display_hold'}, {'sign_recovering': True}])
def test_new_held_value_does_not_start_or_inherit_a_highlight(held_fields):
def test_new_held_value_does_not_start_or_inherit_a_highlight():
pulse = SpeedLimitPulse()
pulse.update(display_state(), 10.)
held = replace(display_state(25.), speed_limit=replace(display_state(25.).speed_limit, **held_fields))
held = replace(display_state(25.), speed_limit=replace(display_state(25.).speed_limit, status='display_hold'))
pulse.update(held, 10.5)
assert rgba(pulse.color(rl.WHITE, 10.5)) == rgba(rl.WHITE)
@@ -130,10 +130,10 @@ def test_set_and_binding_slc_stay_visible_beside_sign_or_prompt(profile, stage):
if stage == 'prompt':
assert 'NEW LIMIT' in texts
if pending:
assert '25' in texts and not any(text.startswith('LAST') for text in texts)
assert '25' in texts
assert ('OSM' in texts) == (stage != 'expanded')
else:
assert 'DASH' in texts and '30' in texts and not any(text.startswith('LAST') for text in texts)
assert 'DASH' in texts and '30' in texts
@pytest.mark.parametrize('gap', [False, True])
@@ -175,7 +175,7 @@ def test_accepted_sign_keeps_text_geometry_and_styling_through_source_gaps(profi
last_received_source='vision', last_received_speed_limit_mps=99 / 3.6,
last_received_adjusted_limit_mps=109 / 3.6)
rendered = []
for observation in (obs, gap, replace(obs, sign_recovering=True)):
for observation in (obs, gap):
font.draw.reset_mock()
for shape in ('outline', 'thick_outline', 'circle', 'draw_ring'):
drawing[shape].reset_mock()
@@ -184,9 +184,9 @@ def test_accepted_sign_keeps_text_geometry_and_styling_through_source_gaps(profi
shapes = [(shape, *call.args[:2], rgba_tuple(call.args[2]), call.kwargs)
for shape in ('outline', 'thick_outline', 'circle') for call in drawing[shape].call_args_list]
rendered.append((text, shapes))
assert rendered[0] == rendered[1] == rendered[2]
assert rendered[0] == rendered[1]
texts = [row[0] for row in rendered[0][0]]
assert not any(text.startswith('LAST') or text in ('SET IS LOW', 'RAISE SET', 'LIMIT') for text in texts)
assert not any(text in ('SET IS LOW', 'RAISE SET', 'LIMIT') for text in texts)
@pytest.mark.parametrize('profile', list(Profile))
@@ -286,14 +286,13 @@ def test_pending_notice_pulses_without_changing_ink_and_arrow_follows_speed(prof
@pytest.mark.parametrize('profile', list(Profile))
@pytest.mark.parametrize('vienna', [False, True])
@pytest.mark.parametrize('recovering', [False, True])
def test_regular_sign_keeps_the_outlined_arrow(profile, vienna, recovering, drawing):
def test_regular_sign_keeps_the_outlined_arrow(profile, vienna, drawing):
current = state()
current = replace(current, appearance=replace(current.appearance, use_vienna_sign=vienna),
speed_limit=replace(current.speed_limit, decision_id=0, sign_recovering=recovering))
speed_limit=replace(current.speed_limit, decision_id=0))
font = fonts(profile)
SpeedLimitWidget(font, profile).render(current)
assert foreground_calls(font.draw)[0].args[0] == ('LAST OSM' if recovering and profile == Profile.LARGE else 'OSM')
assert foreground_calls(font.draw)[0].args[0] == 'OSM'
assert drawing['arrow'].call_args.args[0] == 'compact'
@@ -374,10 +373,10 @@ def test_override_sign_uses_cluster_target_and_restores_normal_sign(profile, vie
@pytest.mark.parametrize('vienna', [False, True])
@pytest.mark.parametrize('latest_received', [False, True])
@pytest.mark.parametrize('offset', [False, True])
@pytest.mark.parametrize('source,heading', [('map', 'LAST OSM'), ('vision', 'LAST VISION'), ('dashboard', 'LAST DASH'),
('mapbox', 'LAST NAV'), ('online', 'LAST'), ('unknown', 'LAST')])
@pytest.mark.parametrize('source,heading', [('map', 'OSM'), ('vision', 'VISION'), ('dashboard', 'DASH'),
('mapbox', 'NAV'), ('online', 'SPEED'), ('unknown', 'SPEED')])
def test_retained_limits_keep_original_source_and_have_no_actions(profile, vienna, latest_received, offset, source, heading, drawing):
# LAST history is what the sign shows while SLC is not using an accepted limit.
# A retained reading keeps its own source label while SLC is not using an accepted limit.
current = state(show_slc_offset=offset, longitudinal_active=False)
observation = replace(current.speed_limit, kind=ObservationKind.STALE, source='none', speed_limit_mps=None,
pending_speed_limit_mps=None, last_received_speed_limit_mps=50/3.6 if latest_received else None,
@@ -387,10 +386,8 @@ def test_retained_limits_keep_original_source_and_have_no_actions(profile, vienn
font = fonts(profile)
render_sign(SpeedLimitWidget(font, profile), current)
texts = [call.args[0] for call in foreground_calls(font.draw)]
expected_heading = heading if profile == Profile.LARGE else heading.removeprefix('LAST ').replace('LAST', 'SPEED')
assert texts.count(expected_heading) == 1
if profile == Profile.COMPACT:
assert not any(text.startswith('LAST') for text in texts)
assert texts.count(heading) == 1
assert not any(text.startswith('LAST') for text in texts)
assert ('50' if latest_received else '40') in texts
drawing['arrow'].assert_not_called()
assert slc_controls(profile, current) == ()
@@ -404,7 +401,7 @@ def test_retained_sign_has_no_proposal_arrow_when_actions_are_hidden(profile, dr
last_received_speed_limit_mps=50 / 3.6, last_received_source='map')
font = fonts(profile)
render_sign(SpeedLimitWidget(font, profile), replace(current, speed_limit=observation))
assert foreground_calls(font.draw)[0].args[0] == ('LAST OSM' if profile == Profile.LARGE else 'OSM')
assert foreground_calls(font.draw)[0].args[0] == 'OSM'
drawing['arrow'].assert_not_called()
@@ -22,7 +22,7 @@ def test_sign_shows_the_accepted_limit_while_slc_is_on_and_the_latest_reading_ot
shown = resolve_unified_speed(replace(current, longitudinal_active=on))
assert (shown.posted_text, shown.offset_text) == (accepted if on else live)
assert shown.source == ('dashboard' if on else 'vision')
assert not shown.posted_retained and not shown.show_last
assert not shown.posted_retained
pedal = resolve_unified_speed(replace(current, longitudinal_active=False, longitudinal_overridden=True))
assert (pedal.posted_text, pedal.source) == (accepted[0], 'dashboard')
@@ -121,7 +121,7 @@ def test_confirmation_proposal_uses_the_pending_target_and_its_offset(pending, a
assert resolve_unified_speed(replace(current, speed_limit=observation)).proposal_text == expected
@pytest.mark.parametrize('change', ['none', 'retained', 'hold', 'recovering', 'pending', 'source', 'rounded-posted',
@pytest.mark.parametrize('change', ['none', 'retained', 'hold', 'pending', 'source', 'rounded-posted',
'rounded-target', 'pedal', 'override', 'display-only', 'not-limiting', 'disengaged'])
def test_in_use_requires_accepted_target_and_actual_control(change):
current = state()
@@ -129,7 +129,7 @@ def test_in_use_requires_accepted_target_and_actual_control(change):
accepted_source='vision', effective_cluster_target_mps=32., effective_cap_mps=32., limiting_max_set=True)
changes = {
'retained': {'kind': ObservationKind.STALE, 'speed_limit_mps': None, 'last_received_speed_limit_mps': 30.},
'hold': {'status': 'display_hold'}, 'recovering': {'sign_recovering': True},
'hold': {'status': 'display_hold'},
'pending': {'pending_speed_limit_mps': 30.}, 'source': {'accepted_source': 'dashboard'},
'rounded-posted': {'accepted_speed_limit_mps': 30.01},
'rounded-target': {'effective_cluster_target_mps': 32.01},
@@ -139,7 +139,7 @@ def test_in_use_requires_accepted_target_and_actual_control(change):
current = replace(current, speed_limit=replace(obs, **changes.get(change, {})),
longitudinal_overridden=change == 'pedal', longitudinal_active=change != 'disengaged')
# The accepted limit is the one in use, whichever source or reading the latest observation shows.
assert resolve_unified_speed(current).limit_in_use == (change in ('none', 'retained', 'recovering', 'source', 'rounded-posted'))
assert resolve_unified_speed(current).limit_in_use == (change in ('none', 'retained', 'source', 'rounded-posted'))
def test_pedal_basis_cannot_be_presented_as_a_held_override_between_message_updates():
@@ -167,18 +167,15 @@ def test_accepted_target_survives_source_gaps_without_presenting_rejected_histor
last_received_source='vision')
held = resolve_unified_speed(replace(current, speed_limit=gap))
assert held.posted_retained
assert not held.show_last
assert (held.posted_text, held.source, held.offset_text) == ('55', 'dashboard', '+5')
assert (held.limit_in_use, held.active_side, held.status) == (before.limit_in_use, before.active_side, before.status)
recovered = resolve_unified_speed(replace(current, speed_limit=replace(obs, sign_recovering=True)))
assert recovered == before
@pytest.mark.parametrize('change,accepted', [
('none', True), ('no-cap', True), ('different-target', True), ('no-session', True), ('pedal', True), ('override', True),
('no-accepted', False), ('no-adjusted', False), ('no-source', False), ('off', False), ('display-only', False),
('display-hold', False), ('pending', False)])
def test_source_history_stays_last_only_without_an_accepted_limit_in_use(change, accepted):
def test_sign_shows_accepted_limit_in_use_else_last_reading(change, accepted):
current = state(cruise_kph=60., longitudinal_active=change != 'off', longitudinal_overridden=change == 'pedal')
obs = replace(current.speed_limit, kind=ObservationKind.STALE, speed_limit_mps=None, source='none',
last_received_speed_limit_mps=30., last_received_source='vision',
@@ -192,5 +189,4 @@ def test_source_history_stays_last_only_without_an_accepted_limit_in_use(change,
}
shown = resolve_unified_speed(replace(current, speed_limit=replace(obs, **changes.get(change, {}))))
assert shown.posted_retained
assert shown.show_last != accepted
assert (shown.source, shown.posted_text) == (('dashboard', '72') if accepted else ('vision', '108'))
@@ -25,7 +25,6 @@ class UnifiedSpeedPresentation:
override_text: str | None
posted_retained: bool = False
limit_in_use: bool = False
show_last: bool = False
offset_configured: bool = False
@property
@@ -97,7 +96,6 @@ def resolve_unified_speed(state, *, confirmation=False) -> UnifiedSpeedPresentat
else:
posted, target, source = displayed_limit_mps(obs), displayed_adjusted_limit_mps(obs), displayed_limit_source(obs)
posted_retained = positive(posted) and (str(obs.kind) != 'valid' or obs.status == 'display_hold')
show_last = (posted_retained or obs.sign_recovering) and not using_accepted
# SLC can only limit to a limit it has accepted; old replayed routes carry none.
slc_limiting = (slc_engaged and not obs.driver_override_active and obs.limiting_max_set and
positive(obs.accepted_speed_limit_mps))
@@ -151,6 +149,6 @@ def resolve_unified_speed(state, *, confirmation=False) -> UnifiedSpeedPresentat
posted_text=speed(posted), offset_text=offset, unit='km/h' if state.metric else 'mph', source=source,
pending=pending, active_side=('limit' if slc_limiting else 'max') if state.cruise_active else 'none',
status=status, proposal_text=speed(proposal), override_text=override, posted_retained=posted_retained,
limit_in_use=limit_in_use, show_last=show_last,
limit_in_use=limit_in_use,
offset_configured=state.slc_offset_schedule is not None and
offset_for_limit(posted, state.slc_offset_schedule) not in (None, 0.))