From cbe6f39030a026d9febd915ee5854945e2bf0a8f Mon Sep 17 00:00:00 2001 From: Prabhaav Pillai Date: Tue, 15 Sep 2026 00:16:49 -0400 Subject: [PATCH] Refactor navigation components and enhance slider functionality with fine scrubbing feature --- .../the_galaxy/assets/mobile/css/material.css | 97 ++++------------ .../system/the_galaxy/assets/mobile/js/app.js | 2 +- .../mobile/js/components/GalaxyToggleCard.js | 108 ++++++++++++++++-- .../mobile/js/components/LanguageSelector.js | 22 ++-- .../assets/mobile/js/components/MapsPanel.js | 3 +- .../components/NavigationDestinationPanel.js | 8 +- .../assets/mobile/js/composables.js | 3 +- .../assets/mobile/js/views/Navigation.js | 23 ++-- .../the_galaxy/tests/test_ui_vue_frontend.py | 10 +- 9 files changed, 158 insertions(+), 118 deletions(-) diff --git a/starpilot/system/the_galaxy/assets/mobile/css/material.css b/starpilot/system/the_galaxy/assets/mobile/css/material.css index 8a89bb0272..cf9ad1bed1 100644 --- a/starpilot/system/the_galaxy/assets/mobile/css/material.css +++ b/starpilot/system/the_galaxy/assets/mobile/css/material.css @@ -884,8 +884,7 @@ body.is-scrolling .gx-tile { width: 100%; } -.gx-slider-row .gx-row__value { text-align: left; min-width: 0; } -.gx-slider-row .gx-slider-reset { align-self: flex-end; } +.gx-slider-row .gx-row__value { text-align: left; min-width: 0; transition: color var(--motion-fast), text-shadow var(--motion-fast); } .gx-slider-meta { color: var(--text-muted); @@ -903,6 +902,7 @@ input[type="range"].gx-slider { flex: 1; height: 8px; outline: none; + touch-action: pan-y; width: 100%; } @@ -1317,34 +1317,6 @@ button.gx-chip:hover { color: var(--primary); } -.gx-language-card { - margin-bottom: var(--sp-4); -} - -.gx-language-card__row { - align-items: center; - display: flex; - flex-wrap: wrap; - gap: var(--sp-3); -} - -.gx-language-card__label { - align-items: center; - display: flex; - flex: 1 1 360px; - gap: var(--sp-4); - min-width: 220px; -} - -.gx-language-card__select { - margin-left: var(--sp-2); - max-width: 220px; -} - -.gx-language-card__hint { - margin-left: auto; -} - @media (min-width: 768px) { .gx-app.gx-nav-pinned .gx-content { margin-left: 320px; @@ -1357,25 +1329,6 @@ button.gx-chip:hover { } } -@media (max-width: 767px) { - .gx-language-card__label { - flex-basis: 100%; - } - - .gx-language-card__hint { - margin-left: 0; - width: 100%; - } -} - -/* The destination view is a map-first screen. Search and route details float - over the map, matching the classic navigation experience. */ -.gx-navigation-view { - margin: calc(-1 * var(--sp-4)); - min-height: calc(100dvh - var(--appbar-height)); - position: relative; -} - .gx-navigation-stage { background: var(--surface-container-low); min-height: calc(100dvh - var(--appbar-height)); @@ -1423,8 +1376,7 @@ button.gx-chip:hover { .gx-navigation-search, .gx-navigation-summary, -.gx-navigation-recent, -.gx-navigation-error { +.gx-navigation-recent { max-width: min(500px, calc(100vw - 32px)); } @@ -1641,12 +1593,6 @@ button.gx-chip:hover { border-top: 1px solid var(--outline); } -.gx-navigation-error { - color: var(--error); - margin: var(--sp-4) 0 0; - padding: var(--sp-3); -} - .gx-navigation-empty { align-items: center; display: flex; @@ -1664,30 +1610,11 @@ button.gx-chip:hover { margin: 0; } -.gx-navigation-tabs { - pointer-events: auto; - position: absolute; - right: var(--sp-4); - top: var(--sp-4); - z-index: 3; -} - @media (max-width: 767px) { - .gx-navigation-view { - margin: calc(-1 * var(--sp-3)); - } - .gx-navigation-overlay { padding: var(--sp-3); } - .gx-navigation-tabs { - bottom: calc(var(--bottomnav-height) + var(--sp-3)); - left: var(--sp-3); - right: auto; - top: auto; - } - .gx-navigation-summary__rows > div { grid-template-columns: 28px 82px 1fr; } @@ -2446,3 +2373,21 @@ button.gx-chip:hover { .gx-select-menu { background: linear-gradient(var(--surface-container-high), var(--surface-container-high)), #141020; } [data-theme="light"] .gx-select-menu { background: linear-gradient(var(--surface-container-high), var(--surface-container-high)), #fff; } .gx-select-menu:not([open]) { display: none; } + +.gx-slider-row.is-fine-scrubbing input[type="range"].gx-slider { + touch-action: none; + background: rgba(157, 114, 255, 0.28); + box-shadow: 0 0 8px var(--primary-glow); +} + +.gx-slider-row.is-fine-scrubbing input[type="range"].gx-slider::-webkit-slider-thumb { + transform: scale(1.35); + background: var(--secondary); + border-color: #ffffff; + box-shadow: 0 0 10px var(--secondary-glow); +} + +.gx-slider-row.is-fine-scrubbing .gx-row__value { + color: var(--secondary); + text-shadow: 0 0 10px var(--secondary-glow); +} diff --git a/starpilot/system/the_galaxy/assets/mobile/js/app.js b/starpilot/system/the_galaxy/assets/mobile/js/app.js index 3710275dca..b8d5eaad63 100644 --- a/starpilot/system/the_galaxy/assets/mobile/js/app.js +++ b/starpilot/system/the_galaxy/assets/mobile/js/app.js @@ -6,7 +6,7 @@ import { Tools } from "./views/Tools.js" import { Recordings } from "./views/Recordings.js" import { Logs } from "./views/Logs.js" import { Tuning } from "./views/Tuning.js" -import { Navigation } from "./views/Navigation.js?v=nav-destination-3" +import { Navigation } from "./views/Navigation.js?v=nav-destination-4" import { Vehicle } from "./views/Vehicle.js" import { Bluetooth } from "./views/Bluetooth.js" import { SystemTools } from "./views/SystemTools.js" diff --git a/starpilot/system/the_galaxy/assets/mobile/js/components/GalaxyToggleCard.js b/starpilot/system/the_galaxy/assets/mobile/js/components/GalaxyToggleCard.js index 5a36e2ba9c..b7ff563c81 100644 --- a/starpilot/system/the_galaxy/assets/mobile/js/components/GalaxyToggleCard.js +++ b/starpilot/system/the_galaxy/assets/mobile/js/components/GalaxyToggleCard.js @@ -9,6 +9,10 @@ import { t } from "../i18n.js" const PANDA_FIRMWARE_TOGGLE_KEYS = new Set(["IgnoreIgnitionLine", "RemoteStartBootsComma", "HKGRemoteStartBootsComma", "TeslaWakeOnCAN"]) +const FINE_SCRUB_HOLD_MS = 300 +const FINE_SCRUB_FACTOR = 5 +const FINE_SCRUB_JITTER_PX = 4 + export const GalaxyToggleCard = { name: "GalaxyToggleCard", components: { FavoritesEditor }, @@ -30,6 +34,8 @@ export const GalaxyToggleCard = { endpointLoading: false, preview: undefined, interacting: false, + fineScrub: null, + isFineScrubbing: false, } }, computed: { @@ -127,19 +133,95 @@ export const GalaxyToggleCard = { if (Math.abs(next - current) <= this.epsilon) return this.commit(next) }, + snap(raw) { + return snapNumericToBoundsAndStep(raw, this.bounds, this.precision) + }, + clearHoldTimer() { + if (this._holdTimer) { + clearTimeout(this._holdTimer) + this._holdTimer = null + } + }, + startHoldTimer() { + this.clearHoldTimer() + if (!this.fineScrub || this.fineScrub.active) return + this._holdTimer = setTimeout(() => { + this.activateFineScrub() + }, FINE_SCRUB_HOLD_MS) + }, + activateFineScrub() { + if (!this.fineScrub || this.fineScrub.active) return + this.fineScrub.active = true + this.fineScrub.baseValue = this.snap(this.currentValue) ?? Number(this.bounds.min) + this.fineScrub.baseX = this.fineScrub.lastX + this.isFineScrubbing = true + try { navigator.vibrate?.(15) } catch (_) {} + }, onSliderInput(e) { + if (this.fineScrub?.active) { + if (this.$refs.slider) this.$refs.slider.value = this.currentValue + return + } this.beginInteract() this.preview = Number(e.target.value) + this.startHoldTimer() }, onSliderCommit(e) { + if (this.fineScrub?.active) return this.interacting = false this.flushSlider(e.target.value) }, onSliderBlur(e) { - if (this.interacting) this.onSliderCommit(e) + if (this.interacting && !this.fineScrub) this.onSliderCommit(e) }, - snap(raw) { - return snapNumericToBoundsAndStep(raw, this.bounds, this.precision) + onSliderPointerDown(e) { + this.beginInteract() + try { e.target.setPointerCapture?.(e.pointerId) } catch (err) {} + const rect = e.target.getBoundingClientRect() + this.fineScrub = { + active: false, + baseValue: this.snap(this.currentValue) ?? Number(this.bounds.min), + baseX: e.clientX, + lastX: e.clientX, + min: Number(this.bounds.min), + max: Number(this.bounds.max), + track: rect.width || 200, + pointerId: e.pointerId, + } + this.startHoldTimer() + }, + onSliderPointerMove(e) { + const scrub = this.fineScrub + if (!scrub) return + + if (!scrub.active) { + if (Math.abs(e.clientX - scrub.lastX) > FINE_SCRUB_JITTER_PX) { + scrub.lastX = e.clientX + this.startHoldTimer() + } + return + } + + e.preventDefault() + if (!Number.isFinite(scrub.min) || !Number.isFinite(scrub.max) || !Number.isFinite(scrub.track) || scrub.track <= 0) return + const totalSpan = scrub.max - scrub.min + const dx = e.clientX - scrub.baseX + const raw = scrub.baseValue + (dx * totalSpan) / scrub.track / FINE_SCRUB_FACTOR + const next = this.snap(raw) + if (next === null) return + this.preview = next + if (this.$refs.slider) this.$refs.slider.value = next + }, + onSliderPointerEnd(e) { + this.clearHoldTimer() + const wasFine = this.isFineScrubbing + this.fineScrub = null + this.isFineScrubbing = false + try { e.target.releasePointerCapture?.(e.pointerId) } catch (_) {} + this.interacting = false + if (wasFine || this.preview !== undefined) { + this.flushSlider(this.currentValue) + } }, async resetToDefault() { const defaults = await api.getDefaults() @@ -183,6 +265,9 @@ export const GalaxyToggleCard = { mounted() { if (this.param.options_endpoint) this.loadEndpointOptions() }, + unmounted() { + this.clearHoldTimer() + }, template: `
@@ -204,17 +289,26 @@ export const GalaxyToggleCard = {
-
- {{ sliderDisplay }} - +
+
+ {{ sliderDisplay }} + + {{ isFineScrubbing ? tr("Fine scrubbing") : tr("Hold to fine scrub") }} + +
+ +
+
{{ sliderRangeDisplay }} {{ tr("Step:") }} {{ sliderStepDisplay }}
-
- - - - {{ tr("Galaxy uses English when no language is selected.") }} +
+
+ {{ tr("Select language") }} + {{ tr("Galaxy uses English when no language is selected.") }} +
+
-

{{ error }}

+
`, } diff --git a/starpilot/system/the_galaxy/assets/mobile/js/components/MapsPanel.js b/starpilot/system/the_galaxy/assets/mobile/js/components/MapsPanel.js index 96d4cd606d..6427f9c6a1 100644 --- a/starpilot/system/the_galaxy/assets/mobile/js/components/MapsPanel.js +++ b/starpilot/system/the_galaxy/assets/mobile/js/components/MapsPanel.js @@ -309,6 +309,7 @@ export const MapsPanel = { }, template: `
+
@@ -451,8 +452,6 @@ export const MapsPanel = {
- - `, } diff --git a/starpilot/system/the_galaxy/assets/mobile/js/components/NavigationDestinationPanel.js b/starpilot/system/the_galaxy/assets/mobile/js/components/NavigationDestinationPanel.js index b37afc278d..730fb5a406 100644 --- a/starpilot/system/the_galaxy/assets/mobile/js/components/NavigationDestinationPanel.js +++ b/starpilot/system/the_galaxy/assets/mobile/js/components/NavigationDestinationPanel.js @@ -1,4 +1,5 @@ import { api, showSnackbar } from "../api.js" +import { GxNotice } from "./GxNotice.js" import { getMapboxSearchContext, addRouteToMap, @@ -80,6 +81,7 @@ function secondaryLabel(place) { export const NavigationDestinationPanel = { name: "NavigationDestinationPanel", + components: { GxNotice }, data() { return { loading: true, @@ -426,9 +428,9 @@ export const NavigationDestinationPanel = {
-
+ The map and destination search only use your public Mapbox key. Add a secret Mapbox key in App Keys before starting navigation so the comma can calculate the on-device route and provide turn desires. -
+ -

{{ error }}

+
`, diff --git a/starpilot/system/the_galaxy/assets/mobile/js/composables.js b/starpilot/system/the_galaxy/assets/mobile/js/composables.js index 648d51a09b..79d618c4ab 100644 --- a/starpilot/system/the_galaxy/assets/mobile/js/composables.js +++ b/starpilot/system/the_galaxy/assets/mobile/js/composables.js @@ -30,8 +30,9 @@ export function usePolling(fn, { interval = 3000, enabled = () => true } = {}) { let destroyed = false const stop = () => { if (timer) { clearTimeout(timer); timer = null } } + const scrolling = () => typeof document !== "undefined" && !!document.body?.classList?.contains("is-scrolling") const tick = async () => { - if (destroyed || !enabled() || document.visibilityState !== "visible") { + if (destroyed || !enabled() || document.visibilityState !== "visible" || scrolling()) { timer = setTimeout(tick, interval) return } diff --git a/starpilot/system/the_galaxy/assets/mobile/js/views/Navigation.js b/starpilot/system/the_galaxy/assets/mobile/js/views/Navigation.js index 150edf9bed..12c469f903 100644 --- a/starpilot/system/the_galaxy/assets/mobile/js/views/Navigation.js +++ b/starpilot/system/the_galaxy/assets/mobile/js/views/Navigation.js @@ -1,4 +1,4 @@ -import { NavigationDestinationPanel } from "../components/NavigationDestinationPanel.js?v=nav-destination-3" +import { NavigationDestinationPanel } from "../components/NavigationDestinationPanel.js?v=nav-destination-4" import { MapsPanel } from "../components/MapsPanel.js" import { NavigationKeysPanel } from "../components/NavigationKeysPanel.js" import { SpeedLimitsPanel } from "../components/SpeedLimitsPanel.js" @@ -22,18 +22,13 @@ export const Navigation = { }) }, template: ` - -
-

Navigation & Maps

- - - - -
+
+

Navigation & Maps

+ + + + + +
`, } diff --git a/starpilot/system/the_galaxy/tests/test_ui_vue_frontend.py b/starpilot/system/the_galaxy/tests/test_ui_vue_frontend.py index e4ecd1153b..d3a95e95de 100644 --- a/starpilot/system/the_galaxy/tests/test_ui_vue_frontend.py +++ b/starpilot/system/the_galaxy/tests/test_ui_vue_frontend.py @@ -300,9 +300,11 @@ def test_ui_eliminates_slider_toggle_flicker(): assert "interacting" in card assert "onSliderCommit" in card assert "flushSlider" in card - # No mid-drag auto-commit timer: holding still must NOT release/lock. + # No mid-drag auto-commit timer: holding still must NOT release/lock or + # commit. A hold may only switch the slider into fine scrubbing. assert "commitTimer" not in card - assert "setTimeout" not in card + hold = card[card.index("startHoldTimer"):card.index("activateFineScrub")] + assert "flushSlider" not in hold and "commit" not in hold # Release (change) and blur (keyboard) both flush the commit. assert "interacting = false" in card assert "onSliderBlur" in card @@ -497,8 +499,8 @@ def test_ui_all_remaining_classic_tools_native_no_embed(): assert "GalaxyEmbed" not in tuning and "LateralTuningPanel" in tuning assert _read("js/components/MapsPanel.js") and _read("js/components/NavigationKeysPanel.js") destination = _read("js/components/NavigationDestinationPanel.js") - assert '"./views/Navigation.js?v=nav-destination-2"' in _read("js/app.js") - assert '"../components/NavigationDestinationPanel.js?v=nav-destination-2"' in _read("js/views/Navigation.js") + assert '"./views/Navigation.js?v=nav-destination-4"' in _read("js/app.js") + assert '"../components/NavigationDestinationPanel.js?v=nav-destination-4"' in _read("js/views/Navigation.js") assert "mapboxSuggest" in destination and "mapboxRetrieve" in destination assert "mapboxGeocode" in destination and "mapboxDirections" in destination assert "ref=\"map\"" in destination and "setNavigation(this.destination)" in destination