diff --git a/ci-results/flm-offroad.json b/ci-results/flm-offroad.json new file mode 100644 index 0000000000..0fead9e706 --- /dev/null +++ b/ci-results/flm-offroad.json @@ -0,0 +1 @@ +{"flmUxBrowser":{"checks":[],"failure":"Error: FLM browser check deadline exceeded\nError: spawn chromedriver ENOENT\n at ChildProcess._handle.onexit (node:internal/child_process:285:19)\n at onErrorNT (node:internal/child_process:483:16)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)\n at until (file:///home/prabh/Projects/openpilot/openpilot/starpilot/galaxy/tests/test_flm_ux_browser.mjs:177:9)\n at async file:///home/prabh/Projects/openpilot/openpilot/starpilot/galaxy/tests/test_flm_ux_browser.mjs:254:3","screenshots":[],"cleanup":{"driver_exit_code":-2,"driver_signal":null,"driver_reaped":true,"server_closed":true}}} \ No newline at end of file diff --git a/openpilot/starpilot/galaxy/tests/browser/compact-actions.cjs b/openpilot/starpilot/galaxy/tests/browser/compact-actions.cjs index 3cdd8efa28..650afbcc45 100644 --- a/openpilot/starpilot/galaxy/tests/browser/compact-actions.cjs +++ b/openpilot/starpilot/galaxy/tests/browser/compact-actions.cjs @@ -51,7 +51,7 @@ const assert = require('node:assert/strict') for (const width of [320, 360, 390, 600, 1280]) { await page.setViewportSize({ width, height: 900 }) await mount('starport') - await checkActions('.gx-starport-step-card__body, .gx-starport-sheet__toolbar') + await checkActions('.gx-step-card__body, .gx-starport-sheet__toolbar') await page.getByRole('button', { name: 'Turn On and Install', exact: true }).click() assert.equal(await page.evaluate(() => window.uploadClicks), 1) await page.evaluate(() => { window.fixtureVM.setup.enabled = true }) @@ -61,7 +61,7 @@ const assert = require('node:assert/strict') await page.evaluate(() => { window.fixtureVM.busy = true; window.fixtureVM.uploadProgress = { loaded: 1, total: 2 } }) assert.equal(await page.getByRole('progressbar', { name: 'Sending to your comma' }).isVisible(), true) assert.equal(await page.getByLabel('Android Auto APK, XAPK, APKM, or ZIP', { exact: true }).isDisabled(), true) - await checkActions('.gx-starport-step-card__body, .gx-starport-sheet__toolbar') + await checkActions('.gx-step-card__body, .gx-starport-sheet__toolbar') await mount('recording') await checkActions('.gx-route-workspace__toolbar, .gx-route-workspace__download-actions') diff --git a/openpilot/starpilot/galaxy/tests/browser/design-system.cjs b/openpilot/starpilot/galaxy/tests/browser/design-system.cjs index 814d985e15..b6a2a6b5dc 100644 --- a/openpilot/starpilot/galaxy/tests/browser/design-system.cjs +++ b/openpilot/starpilot/galaxy/tests/browser/design-system.cjs @@ -28,7 +28,7 @@ const assert = require('node:assert/strict') window.fixture = createApp({ components: { software, GxState, GxNotice, GxDialog, GxSummary }, data: () => ({ dialog: false }), template: `
Card
Card
-

Time on the Road

Saved history

Android Auto

Connect your car

Reading your device…Nothing here yet. +

Time on the Road

Saved history

Android Auto

Connect your car

Reading your device…Nothing here yet. Preferences saved.An error occurred.
@@ -58,7 +58,7 @@ const assert = require('node:assert/strict') const summary = await page.locator('.gx-summary > div').evaluateAll(elements => elements.map(element => element.getBoundingClientRect().top)) assert.ok(summary.every(top => Math.abs(top - summary[0]) < 1), 'summary counts share one row') assert.ok(Math.abs(geometry.notice - geometry.container) < 1 && geometry.aligned, 'progress fills the padded panel with the track below its label') - for (const selector of ['.gx-panel', '.gx-message', '.gx-home__totals > section', '.gx-starport-step']) { + for (const selector of ['.gx-panel', '.gx-message', '.gx-home__totals > section', '.gx-step']) { const padding = await page.locator(selector).first().evaluate(element => { const style = getComputedStyle(element); return [parseFloat(style.paddingLeft), parseFloat(style.paddingRight), parseFloat(style.paddingTop), parseFloat(style.paddingBottom)] }) assert.ok(padding[0] >= 16 && padding[1] >= 16, `${selector}: horizontal padding survives all themes and widths`) assert.ok(padding[2] >= 16 && padding[3] >= 16, `${selector}: vertical padding`) diff --git a/openpilot/starpilot/galaxy/tests/browser/disclosure-motion.cjs b/openpilot/starpilot/galaxy/tests/browser/disclosure-motion.cjs new file mode 100644 index 0000000000..b19428f9de --- /dev/null +++ b/openpilot/starpilot/galaxy/tests/browser/disclosure-motion.cjs @@ -0,0 +1,107 @@ +const { chromium } = require(process.env.PLAYWRIGHT_MODULE || 'playwright') +const { readFileSync } = require('node:fs') +const path = require('node:path') +const assert = require('node:assert/strict') +const web = path.resolve(__dirname, '../../web') +const reviewMarkup = readFileSync(path.join(web, 'js/flm.js'), 'utf8').match(/
/)[0] +const reviewIcons = [...reviewMarkup.matchAll(/'(bi-[\w-]+)'/g)].map(match => match[1]) +const iconCss = readFileSync(path.join(web, 'vendor/bootstrap-icons/bootstrap-icons.min.css'), 'utf8') +for (const icon of reviewIcons) assert.ok(iconCss.includes('.' + icon + '::before'), `${icon} must exist in the bundled font`) + +;(async () => { + const browser = await chromium.launch({ headless: true, + ...(process.env.PLAYWRIGHT_EXECUTABLE_PATH ? { executablePath: process.env.PLAYWRIGHT_EXECUTABLE_PATH } : {}) }) + try { + const page = await browser.newPage({ viewport: { width: 390, height: 844 } }) + const errors = [] + page.on('pageerror', error => errors.push(error.message)) + await page.route('http://motion.test/**', route => { + const pathname = new URL(route.request().url()).pathname + if (pathname === '/') return route.fulfill({ contentType: 'text/html', body: ` + + +
` }) + const file = path.join(web, pathname) + const ext = path.extname(file) + return route.fulfill({ body: readFileSync(file), contentType: ({ '.js': 'text/javascript', '.css': 'text/css', '.woff2': 'font/woff2' })[ext] || 'application/octet-stream' }) + }) + await page.goto('http://motion.test/') + await page.locator('details#example > summary').waitFor() + assert.notEqual(await page.locator('#review-icon').evaluate(node => getComputedStyle(node, '::before').content), 'none') + // All native disclosures use the same CSS, including late-rendered content. + const details = page.locator('#example') + const closedHeight = await details.evaluate(node => node.getBoundingClientRect().height) + await details.locator(':scope > summary').click() + await page.waitForTimeout(30) + assert.ok(await details.evaluate(node => node.getAnimations().length > 0), 'Outer card animates open') + const openingHeight = await details.evaluate(node => node.getBoundingClientRect().height) + await page.waitForTimeout(280) + const openHeight = await details.evaluate(node => node.getBoundingClientRect().height) + assert.ok(openHeight > closedHeight + 100) + assert.ok(openingHeight > closedHeight && openingHeight < openHeight, 'Border height expands gradually') + await details.locator(':scope > summary').click() + await page.waitForTimeout(30) + assert.ok(await details.evaluate(node => node.getAnimations().length > 0), 'Outer card animates closed') + const closingHeight = await details.evaluate(node => node.getBoundingClientRect().height) + assert.ok(closingHeight > closedHeight && closingHeight < openHeight, 'Border height collapses gradually') + await page.waitForTimeout(280) + assert.ok(Math.abs(await details.evaluate(node => node.getBoundingClientRect().height) - closedHeight) < 1) + // Real shared select keeps keyboard selection and focus restoration. + const button = page.locator('button[aria-haspopup="listbox"]') + await button.click() + const menu = page.locator('.gx-select-menu') + assert.ok(await menu.evaluate(node => node.getAnimations().length > 0), 'Menu animates open') + await page.waitForTimeout(280) + await page.getByRole('option', { name: 'Two' }).click() + assert.ok(await menu.evaluate(node => node.getAnimations().length > 0), 'Menu animates closed') + await page.waitForTimeout(280) + assert.equal(await button.getAttribute('aria-expanded'), 'false') + assert.equal(await button.evaluate(node => node === document.activeElement), true) + assert.match(await button.textContent(), /Two/) + // Reversing an in-flight transition must settle in the final native state. + await details.locator(':scope > summary').click() + await details.locator(':scope > summary').click() + await page.waitForTimeout(280) + assert.equal(await details.getAttribute('open'), null) + await page.locator('#panel-toggle').click() + assert.ok(await page.locator('#panel').evaluate(node => node.getAnimations().length > 0), 'Vue panels share the height animation') + await page.waitForTimeout(280) + await page.locator('#panel-toggle').click() + assert.ok(await page.locator('#panel').evaluate(node => node.getAnimations().length > 0), 'Vue panels animate closed') + await page.waitForTimeout(280) + assert.equal(await page.locator('#panel').evaluate(node => getComputedStyle(node).display), 'none') + // No per-page registration is needed for disclosures rendered after startup. + await page.evaluate(() => { + const dynamic = document.createElement('details') + dynamic.id = 'dynamic' + dynamic.innerHTML = 'Later disclosure

Dynamic content

' + document.querySelector('main').append(dynamic) + }) + await page.locator('#dynamic > summary').click() + assert.ok(await page.locator('#dynamic').evaluate(node => node.getAnimations().length > 0)) + await page.waitForTimeout(280) + const danger = page.getByRole('button', { name: 'Delete all driving routes' }) + assert.equal(await danger.evaluate(node => getComputedStyle(node).backgroundColor), await danger.evaluate(node => { + const probe = document.createElement('span'); probe.style.color = 'var(--error)'; node.append(probe) + const color = getComputedStyle(probe).color; probe.remove(); return color + })) + await page.emulateMedia({ reducedMotion: 'reduce' }) + await details.locator(':scope > summary').click() + assert.equal(await details.evaluate(node => node.getAnimations().length), 0) + await button.click() + assert.equal(await menu.evaluate(node => node.getAnimations().length), 0) + await page.keyboard.press('Escape') + assert.equal(await button.evaluate(node => node === document.activeElement), true) + assert.deepEqual(errors, []) + console.log('Shared disclosure/menu motion, reversal, reduced motion, keyboard focus and danger contrast passed') + } finally { await browser.close() } +})().catch(error => { console.error(error); process.exitCode = 1 }) diff --git a/openpilot/starpilot/galaxy/tests/test_app_reminder.mjs b/openpilot/starpilot/galaxy/tests/test_app_reminder.mjs index 18722cef91..de1ec48932 100644 --- a/openpilot/starpilot/galaxy/tests/test_app_reminder.mjs +++ b/openpilot/starpilot/galaxy/tests/test_app_reminder.mjs @@ -14,8 +14,8 @@ for (const userAgent of ['Macintosh Safari', 'Windows Chrome', 'Linux x86_64 Fir assert.equal(appDownloadPlatform({ ...android, StarPilotApp: {} }), null) assert.equal(appDownloadPlatform({ ...iphone, webkit: { messageHandlers: { galaxyDiagnostics: {} } } }), null) assert.equal(appDownloadPlatform({ ...iphone, webkit: {} }), 'ios', 'Safari itself must not be mistaken for the native app') -assert.equal(APP_DOWNLOADS.ios.href, 'https://firestar.link/iOS') -assert.equal(APP_DOWNLOADS.android.href, 'https://firestar.link/android') +assert.equal(APP_DOWNLOADS.ios.href, 'https://apps.apple.com/ca/app/starpilot-bt/id6821039119') +assert.equal(APP_DOWNLOADS.android.href, 'https://play.google.com/store/apps/details?id=com.starpilot.galaxy') const values = new Map() const target = { localStorage: { getItem: k => values.get(k), setItem: (k, v) => values.set(k, v) }, sessionStorage: { getItem: k => values.get(k), setItem: (k, v) => values.set(k, v) } } diff --git a/openpilot/starpilot/galaxy/tests/test_bluetooth_notices.mjs b/openpilot/starpilot/galaxy/tests/test_bluetooth_notices.mjs index 56605d9ed0..b954e23528 100644 --- a/openpilot/starpilot/galaxy/tests/test_bluetooth_notices.mjs +++ b/openpilot/starpilot/galaxy/tests/test_bluetooth_notices.mjs @@ -8,7 +8,6 @@ import { VasmPage } from '../web/js/vasm.js' import { NavigationPage } from '../web/js/navigation.js' import { OfflineRoadMapsPanel } from '../web/js/offline-road-maps.js' import { StarPortPage } from '../web/js/starport.js' -import { GalaxyCompanion } from '../web/js/companion.js' globalThis.window = {} assert.equal(bluetoothConnection(), false) @@ -105,7 +104,6 @@ aa.uploadReason = StarPortPage.computed.uploadReason.call(aa) assert.match(aa.uploadReason, /not available over Bluetooth/) await StarPortPage.methods.upload.call(aa) assert.equal(uploaded, 0) -await GalaxyCompanion.methods.toggle.call({ bluetooth: true }) assert.equal(requests, 0) window.StarPilotApp.bluetooth = () => false diff --git a/openpilot/starpilot/galaxy/tests/test_companion.mjs b/openpilot/starpilot/galaxy/tests/test_companion.mjs index 5348b8d223..7b3937c4b6 100644 --- a/openpilot/starpilot/galaxy/tests/test_companion.mjs +++ b/openpilot/starpilot/galaxy/tests/test_companion.mjs @@ -1,14 +1,14 @@ import assert from 'node:assert/strict' import { compile } from '../web/vendor/vue/vue.esm-browser.js' -import { GalaxyCompanion, validCompanion } from '../web/js/companion.js' +import { CompanionUpdates, validCompanion } from '../web/js/companion-updates.js' globalThis.window = {} const value = { protocol: 1, enabled: false, connected: false, active: false, appAvailable: true, updateAvailable: false, bytes: 0, shippedVersion: '1.0.0', state: 'disabled' } assert.equal(validCompanion(value), true) assert.equal(validCompanion({ ...value, bytes: -1 }), false) -compile(GalaxyCompanion.template, { decodeEntities: v => v }) -const vm = { ...GalaxyCompanion.data(), mode: 'sample', unauthorized() {}, $emit() {} } -for (const [key, fn] of Object.entries(GalaxyCompanion.methods)) vm[key] = fn.bind(vm) +compile(CompanionUpdates.template, { decodeEntities: v => v }) +const vm = { ...CompanionUpdates.data(), mode: 'sample', eligible: true, unauthorized() {}, $emit() {} } +for (const [key, fn] of Object.entries(CompanionUpdates.methods)) vm[key] = fn.bind(vm) let requests = 0, resolve globalThis.fetch = () => { requests++; return new Promise(done => { resolve = done }) } vm.start() diff --git a/openpilot/starpilot/galaxy/tests/test_companion_update.mjs b/openpilot/starpilot/galaxy/tests/test_companion_update.mjs index 8bbdf33062..cbc90a45d3 100644 --- a/openpilot/starpilot/galaxy/tests/test_companion_update.mjs +++ b/openpilot/starpilot/galaxy/tests/test_companion_update.mjs @@ -1,24 +1,21 @@ import assert from 'node:assert/strict' import { createRenderer, nextTick } from '../web/vendor/vue/vue.esm-browser.js' -import { GalaxyPage } from '../web/js/galaxy.js' -import { newerCompanionVersion } from '../web/js/companion.js' +import { CompanionUpdates, newerCompanionVersion } from '../web/js/companion-updates.js' -assert.equal(newerCompanionVersion('1.1.5', '1.1.4'), true) assert.equal(newerCompanionVersion('1.1.10', '1.1.9'), true) assert.equal(newerCompanionVersion('1.2', '1.1.99'), true) -for (const [available, installed] of [['1.1.5', '1.1.5'], ['1.1.4', '1.1.5'], ['1.1', '1.1.0'], - ['', '1.1.4'], ['1.1.5', ''], ['unknown', '1.1.4'], ['1.1.5', null]]) { +for (const [available, installed] of [['1.1.5', '1.1.5'], ['1.1.4', '1.1.5'], ['1.1', '1.1.0'], ['', '1.1.4'], ['1.1.5', ''], ['unknown', '1.1.4']]) { assert.equal(newerCompanionVersion(available, installed), false) } - const storage = new Map() globalThis.localStorage = { getItem: key => storage.get(key) ?? null, setItem: (key, value) => storage.set(key, value) } -globalThis.window = { StarPilotApp: { version: () => '1.1.4', uplinkState: () => '{}' } } +globalThis.window = { StarPilotApp: { version: () => '1.1.4' } } globalThis.document = { activeElement: null } +Object.defineProperty(globalThis, 'navigator', { configurable: true, value: { userAgent: 'Android' } }) const status = { protocol: 1, enabled: false, connected: false, active: false, appAvailable: true, updateAvailable: false, bytes: 0, shippedVersion: '1.1.5', version: null, state: 'disabled' } -globalThis.fetch = async url => ({ ok: true, json: async () => url.includes('/api/companion/status') ? status : { paired: false } }) - +let requests = 0, installs = 0 +globalThis.fetch = async () => { requests++; return { ok: true, json: async () => status } } const node = (type, text = '') => ({ type, text, props: {}, children: [], parent: null, addEventListener() {}, removeEventListener() {} }) const renderer = createRenderer({ @@ -40,91 +37,45 @@ const text = item => [item.text, ...item.children.map(text)].join(' ') const banner = host => all(host).find(item => item.type === 'div' && text(item).includes('Android app update available') && item.props.role === 'status') async function mount() { const host = node('host') - const app = renderer.createApp({ ...GalaxyPage, - // The real companion child still polls and emits metadata to the real page. - components: { ...GalaxyPage.components, GalaxyHotspot: { template: '
' }, InstallApp: { props: ['updateAvailable'], template: '
{{ updateAvailable }}
' } }, - }, { mode: 'local', unauthorized() { assert.fail('Unexpected authentication failure') } }) - app.config.compilerOptions.decodeEntities = raw => raw.replaceAll('&', '&') + const app = renderer.createApp(CompanionUpdates, { mode: 'local', unauthorized() { assert.fail('Unexpected authentication failure') } }) + app.config.compilerOptions.decodeEntities = raw => raw const vm = app.mount(host) await new Promise(resolve => setImmediate(resolve)) await nextTick() return { host, app, vm } } - let mounted = await mount() try { - const { host, vm } = mounted - const notice = banner(host) - assert.ok(notice, 'A native app without an internet-sharing lease still gets an update notice') - assert.match(text(notice), /Version 1.1.5 is available.*Installed: 1.1.4/s) - assert.ok(all(notice).some(item => item.type === 'a' && item.props.href === 'https://groups.google.com/g/galaxy-starpilot-android-beta' && text(item).includes('Update app'))) - assert.ok(all(host).some(item => item.type === 'div' && item.props.class === 'install-state' && text(item).includes('true')), - 'The main install action is told to render as an update') - const root = host.children.find(item => item.type === 'div') - assert.ok(root.children.indexOf(notice) < root.children.findIndex(item => item.type === 'ol'), 'Notice precedes the setup steps') - const install = all(host).find(item => item.type === 'li' && text(item).includes('Install Galaxy')) - assert.match(text(install), /Android offline app version:.*1.1.5.*Installed.*1.1.4/s) - const dismiss = all(notice).find(item => item.type === 'button' && item.props['aria-label'] === 'Dismiss app update notice') - dismiss.props.onClick() + assert.ok(banner(mounted.host)) + assert.match(text(mounted.host), /Version 1.1.5 is available.*Installed: 1.1.4/s) + assert.ok(all(mounted.host).some(item => item.type === 'a' && item.props.href === 'https://play.google.com/store/apps/details?id=com.starpilot.galaxy')) + mounted.vm.dismissUpdate() await nextTick() - assert.equal(banner(host), undefined) - vm.companionStatus = { ...status } - await nextTick() - assert.equal(banner(host), undefined, 'Polling does not undo dismissal') + assert.equal(banner(mounted.host), undefined) } finally { mounted.app.unmount() } - -let nativeInstalls = 0 -window.StarPilotApp.installUpdate = () => nativeInstalls++ +window.StarPilotApp.installUpdate = () => installs++ mounted = await mount() try { - assert.equal(banner(mounted.host), undefined, 'Dismissal survives leaving and returning to the page') - mounted.vm.companionStatus = { ...status, shippedVersion: '1.1.6' } + assert.equal(banner(mounted.host), undefined, 'Dismissal persists across remounts') + mounted.vm.status = { ...status, shippedVersion: '1.1.6' } await nextTick() - const nativeNotice = banner(mounted.host) - assert.ok(nativeNotice, 'A later available release gets a new notice') - const nativeUpdate = all(nativeNotice).find(item => item.type === 'button' && text(item).includes('Update app')) - assert.ok(nativeUpdate, 'A current native app uses the in-app installer') - nativeUpdate.props.onClick() - assert.equal(nativeInstalls, 1) - mounted.vm.companionStatus = { ...status, shippedVersion: '1.1.3', updateAvailable: true } - await nextTick() - assert.equal(banner(mounted.host), undefined, 'A server mismatch flag cannot suggest downgrading this phone') - mounted.vm.companionStatus = { ...status, shippedVersion: '1.1.6', appAvailable: false } - await nextTick() - assert.equal(banner(mounted.host), undefined, 'Missing APK never advertises a dead update link') - mounted.vm.companionStatus = { ...status, shippedVersion: '1.1.6' } - localStorage.setItem = () => { throw new Error('Storage unavailable') } - mounted.vm.dismissAppUpdate() - await nextTick() - assert.equal(banner(mounted.host), undefined, 'Dismiss still works when persistent storage is unavailable') + all(banner(mounted.host)).find(item => item.type === 'button' && text(item).includes('Update app')).props.onClick() + assert.equal(installs, 1) + for (const override of [{ shippedVersion: '1.1.3', updateAvailable: true }, { appAvailable: false }]) { + mounted.vm.status = { ...status, ...override } + await nextTick() + assert.equal(banner(mounted.host), undefined, 'Never offer a downgrade or missing artifact') + } } finally { mounted.app.unmount() } - -delete window.StarPilotApp -storage.clear() -mounted = await mount() -try { - assert.equal(banner(mounted.host), undefined, 'A browser cannot infer an installed version without a connected phone') - const install = all(mounted.host).find(item => item.type === 'li' && text(item).includes('Install Galaxy')) - assert.match(text(install), /Android offline app version:.*1.1.5/s) - assert.doesNotMatch(text(install), /Installed:/) -} finally { mounted.app.unmount() } - -// iPhone users never mount or poll the Android companion section. -Object.defineProperty(globalThis, 'navigator', { configurable: true, value: { userAgent: 'iPhone' } }) -let companionMounts = 0 -const iosHost = node('host') -const iosApp = renderer.createApp({ ...GalaxyPage, components: { ...GalaxyPage.components, - GalaxyHotspot: { template: '
' }, InstallApp: { template: '
Install as web app
' }, - GalaxyCompanion: { mounted() { companionMounts++ }, template: '
Android companion
' }, -} }, { mode: 'local', unauthorized() { assert.fail('Unexpected authentication failure') } }) -iosApp.config.compilerOptions.decodeEntities = raw => raw.replaceAll('&', '&') -const iosVm = iosApp.mount(iosHost) -await new Promise(resolve => setImmediate(resolve)) -await nextTick() -assert.equal(iosVm.ios, true) -assert.equal(companionMounts, 0) -assert.doesNotMatch(text(iosHost), /Android companion/) -assert.match(text(iosHost), /Install as web app/) -iosApp.unmount() - -console.log('Companion install version, in-app update, browser fallback, version ordering and persistent dismissal passed') +for (const [agent, bridge] of [['Chrome', undefined], ['iPhone', { version: () => '1.1.4' }], ['Android', { version: () => '1.1.4', distribution: () => 'play' }]]) { + navigator.userAgent = agent + window.StarPilotApp = bridge + const before = requests + mounted = await mount() + try { + assert.equal(requests, before, 'Browsers, iOS and Play apps do not poll the legacy APK endpoint') + assert.equal(banner(mounted.host), undefined) + assert.doesNotMatch(text(mounted.host), /MB today|disabled|Connections/) + } finally { mounted.app.unmount() } +} +console.log('Companion updates: version ordering, native install, persistent dismissal, platform and distribution isolation passed') diff --git a/openpilot/starpilot/galaxy/tests/test_galaxy_access.mjs b/openpilot/starpilot/galaxy/tests/test_galaxy_access.mjs new file mode 100644 index 0000000000..eda3c72bf1 --- /dev/null +++ b/openpilot/starpilot/galaxy/tests/test_galaxy_access.mjs @@ -0,0 +1,89 @@ +import assert from 'node:assert/strict' +import { createRenderer, nextTick } from '../web/vendor/vue/vue.esm-browser.js' +import { GalaxyPage } from '../web/js/galaxy.js' +import { RemoteAccess } from '../web/js/remote-access.js' +import { APP_DOWNLOADS } from '../web/js/app-downloads.js' + +Object.defineProperty(globalThis, 'navigator', { configurable: true, value: { userAgent: 'Android', clipboard: { writeText: async () => {} } } }) +globalThis.window = { confirm: () => true } +globalThis.document = { activeElement: null } +let paired = true, requests = [], unauthorized = 0 +const link = 'https://galaxy.firestar.link/device' +globalThis.fetch = async (url, options) => { + requests.push([url, options]) + if (url.endsWith('/pair')) paired = true + if (url.endsWith('/unpair')) paired = false + return { ok: true, json: async () => url.endsWith('/session') ? { paired, sessionToken: 'test%20key' } : + { paired, url: paired ? link : '', tunnelClientAvailable: true } } +} +const node = (type, text = '') => ({ type, text, props: {}, children: [], parent: null, + addEventListener() {}, removeEventListener() {} }) +const renderer = createRenderer({ + createElement: type => node(type), createText: text => node('text', text), createComment: text => node('comment', text), + setText: (item, text) => { item.text = text }, setElementText: (item, text) => { item.text = text; item.children = [] }, + patchProp: (item, key, before, after) => { item.props[key] = after }, + insert: (item, parent, anchor = null) => { + if (item.parent) item.parent.children.splice(item.parent.children.indexOf(item), 1) + item.parent = parent + const index = parent.children.indexOf(anchor) + parent.children.splice(index < 0 ? parent.children.length : index, 0, item) + }, + remove: item => { const index = item.parent?.children.indexOf(item); if (index >= 0) item.parent.children.splice(index, 1) }, + parentNode: item => item.parent, + nextSibling: item => item.parent?.children[item.parent.children.indexOf(item) + 1] ?? null, +}) +const all = item => [item, ...item.children.flatMap(all)] +const text = item => [item.text, ...item.children.map(text)].join(' ') +const flush = async () => { await new Promise(resolve => setImmediate(resolve)); await nextTick() } +const host = node('host') +const app = renderer.createApp({ ...GalaxyPage, components: { ...GalaxyPage.components, + GalaxyHotspot: { template: '
Hotspot settings
' }, + InstallApp: { props: ['url'], template: '' }, +} }, { mode: 'local', unauthorized() { unauthorized++ } }) +app.config.compilerOptions.decodeEntities = value => value.replaceAll('&', '&') +const vm = app.mount(host) +await flush() +try { + const nodes = all(host), links = nodes.filter(item => item.type === 'a') + for (const download of Object.values(APP_DOWNLOADS)) { + assert.equal(links.filter(item => item.props.href === download.href).length, 1, 'Each store link appears exactly once') + } + assert.match(text(host), /Set up remote access.*Get the app/s) + assert.doesNotMatch(text(host), /Local access/) + const stepList = nodes.find(item => item.type === 'ol' && item.props.class === 'gx-steps') + assert.equal(stepList.children.filter(item => item.type === 'li' && item.props.class?.includes('gx-step')).length, 2) + assert.equal(nodes.filter(item => item.props.class === 'gx-step__head').length, 2) + assert.doesNotMatch(text(host), /MB today|Status:|Connections|offline app version/) + assert.equal(requests.length, 1, 'A browser reads remote pairing status without polling Android internet-sharing status') + assert.equal(requests[0][0], './api/galaxy/status') + assert.equal(vm.url, link, 'Remote link reaches the web installer') + const steps = vm.$.subTree.children.find(child => child.props?.class === 'gx-steps') + const remote = steps.children.find(child => child.type === RemoteAccess).component.proxy + await remote.showAppKey() + await nextTick() + assert.match(text(host), /test key/) + await remote.unpair() + await nextTick() + assert.equal(vm.url, '') + assert.equal(remote.appKey, '') + assert.equal(remote.keyVisible, false) + remote.password = 'new-password' + await remote.pair() + await nextTick() + assert.equal(vm.url, link) + assert.equal(remote.password, '') + assert.equal(unauthorized, 0) +} finally { app.unmount() } + +// A secret response arriving after unmount must never restore the key. +let resolve +const state = { ...RemoteAccess.data(), mode: 'local', paired: true, url: link, unauthorized() {}, $emit() {} } +for (const [key, method] of Object.entries(RemoteAccess.methods)) state[key] = method.bind(state) +globalThis.fetch = () => new Promise(done => { resolve = done }) +const pending = state.showAppKey() +RemoteAccess.beforeUnmount.call(state) +resolve({ ok: true, json: async () => ({ paired: true, sessionToken: 'stale-secret' }) }) +await pending +assert.equal(state.appKey, '') +assert.equal(state.keyVisible, false) +console.log('Galaxy access: unique store links, browser isolation, remote pairing/link propagation and secret cleanup passed') diff --git a/openpilot/starpilot/galaxy/tests/test_home_polish.mjs b/openpilot/starpilot/galaxy/tests/test_home_polish.mjs index b6e406a58a..3a1ef5a524 100644 --- a/openpilot/starpilot/galaxy/tests/test_home_polish.mjs +++ b/openpilot/starpilot/galaxy/tests/test_home_polish.mjs @@ -12,16 +12,12 @@ assert.ok(Home.template.includes('recordArt(record.id)')) assert.ok(Home.template.includes('aria-hidden="true">Galaxy Access & Install')) assert.ok(!GalaxyPage.template.includes('Galaxy & App Install')) -assert.ok(GalaxyPage.template.includes('Your remote link needs Internet and an active tunnel.')) -assert.ok(GalaxyPage.template.includes('join the Android beta on Google Groups')) -assert.ok(GalaxyPage.template.includes('Android offline app version:')) -assert.ok(GalaxyPage.template.includes('Remote pairing') < GalaxyPage.template.indexOf('')) +assert.ok(!GalaxyPage.template.includes('Android users:')) +assert.ok(!GalaxyPage.template.includes('Phone companion · Connections')) +assert.ok(GalaxyPage.template.indexOf('Get the app')) +assert.ok(GalaxyPage.template.includes('')) assert.ok(!GalaxyPage.template.includes('PWA')) assert.ok(DriveStatePanel.template.includes('gx-card gx-force-drive')) const css = readFileSync(new URL('../web/css/galaxy.css', import.meta.url), 'utf8') diff --git a/openpilot/starpilot/galaxy/tests/test_install_app.mjs b/openpilot/starpilot/galaxy/tests/test_install_app.mjs index ee97e07012..622bed9c63 100644 --- a/openpilot/starpilot/galaxy/tests/test_install_app.mjs +++ b/openpilot/starpilot/galaxy/tests/test_install_app.mjs @@ -1,9 +1,10 @@ +import { APP_DOWNLOADS, AppStoreLinks } from '../web/js/app-downloads.js' import assert from 'node:assert/strict' -import { ANDROID_BETA_URL, installHelp, InstallApp, rememberInstallPrompt, isIosDevice, isAndroidDevice } from '../web/js/install-app.js' +import { installHelp, InstallApp, rememberInstallPrompt, isIosDevice, isAndroidDevice } from '../web/js/install-app.js' assert.match(installHelp({ secure: true, agent: 'iPhone' }), /Share.*Add to Home Screen/) assert.match(installHelp({ secure: false, agent: 'Android' }), /web app.*https:\/\/galaxy\.firestar\.link/) assert.match(installHelp({ secure: true, agent: 'Android' }), /Install app/) -assert.equal(ANDROID_BETA_URL, 'https://groups.google.com/g/galaxy-starpilot-android-beta') +assert.equal(APP_DOWNLOADS.android.href, 'https://play.google.com/store/apps/details?id=com.starpilot.galaxy') assert.match(installHelp({ secure: true, agent: 'Chrome' }), /Install app/) const events = new Map() let modeListener @@ -44,26 +45,11 @@ await InstallApp.methods.installWeb.call(late) assert.equal(prompted, 2) InstallApp.beforeUnmount.call(late) -// Android sends users to the Google Groups beta instead of a direct APK download. -navigator.userAgent = 'Android' -let apk -globalThis.location = { protocol: 'http:', assign: value => { apk = value } } -let nativeUpdates = 0 -window.StarPilotApp = { installUpdate: () => nativeUpdates++ } -const nativeUpdate = { ...InstallApp.data(), updateAvailable: true } -InstallApp.methods.installAndroid.call(nativeUpdate) -assert.equal(nativeUpdates, 1) -assert.equal(apk, undefined, 'Native updates never hand the APK to a browser') -delete window.StarPilotApp +// Store metadata lives outside the web installer. +assert.equal(APP_DOWNLOADS.ios.href, 'https://apps.apple.com/ca/app/starpilot-bt/id6821039119') +assert.match(AppStoreLinks.template, /app.href/) +assert.doesNotMatch(InstallApp.template, /Google Play|App Store|offline app|app\.apk/) const android = { ...InstallApp.data() } -InstallApp.methods.installAndroid.call(android) -assert.equal(apk, ANDROID_BETA_URL) -assert.match(InstallApp.template, /Install web app/) -assert.match(InstallApp.template, /Join the Android beta/) -assert.doesNotMatch(InstallApp.template, /app\.apk|Download Android APK/) -assert.match(InstallApp.template, /Update offline app \(Android\)/) -assert.match(InstallApp.template, /android && !ios/) - // Choosing the web app on Android always keeps web-install guidance. const webHelp = InstallApp.methods.installHelp.call(android) assert.match(webHelp, /Install app/) @@ -77,8 +63,4 @@ assert.equal(isAndroidDevice('Android'), true) assert.equal(isAndroidDevice('iPhone'), false) navigator.userAgent = 'iPhone' const ios = { ...InstallApp.data() } -assert.equal(ios.android, false) -assert.equal(ios.ios, true) -assert.match(InstallApp.template, /]+href="https:\/\/apps\.apple\.com\/ca\/app\/starpilot-bt\/id6821039119"/) assert.match(InstallApp.methods.installHelp.call(ios), /Share.*Add to Home Screen/) -assert.match(InstallApp.template, /v-if="android && !ios/) diff --git a/openpilot/starpilot/galaxy/tests/test_local_access.mjs b/openpilot/starpilot/galaxy/tests/test_local_access.mjs index 258a825278..dacc6ae7d8 100644 --- a/openpilot/starpilot/galaxy/tests/test_local_access.mjs +++ b/openpilot/starpilot/galaxy/tests/test_local_access.mjs @@ -59,13 +59,11 @@ setup.feed.stop() assert.equal(Home.components.LocalAccess, LocalAccess) assert.ok(Home.template.includes(':on-unauthorized="unauthorized"')) assert.ok(LocalAccess.template.includes('Connect your phone to the Galaxy hotspot')) -assert.ok(LocalAccess.template.includes('full http:// address into a new browser tab')) -assert.ok(LocalAccess.template.includes('public Galaxy link uses the Internet tunnel')) +assert.ok(LocalAccess.template.includes('full http:// address')) +assert.ok(LocalAccess.template.includes('Your Firestar Link uses Internet instead.')) console.log('Local access: actual Vue component/setup, bounded automatically synchronized read, sample exclusion, authentication, safe links and unmount race passed') -assert.equal(GalaxyPage.components.LocalAccess, LocalAccess) -const installStep = GalaxyPage.template.slice(GalaxyPage.template.indexOf('

Install Galaxy

'), GalaxyPage.template.indexOf('', GalaxyPage.template.indexOf('

Install Galaxy

'))) -assert.ok(installStep.includes('')) -assert.ok(installStep.indexOf('Android users:') < installStep.indexOf(' value.replaceAll('&', '&') }) -console.log('Galaxy APK installation exposes authenticated local links with current mode and session handling') +console.log('Galaxy local access remains independent of app installation') diff --git a/openpilot/starpilot/galaxy/tests/test_starport_guided.mjs b/openpilot/starpilot/galaxy/tests/test_starport_guided.mjs index 4889d49e54..e850a6277c 100644 --- a/openpilot/starpilot/galaxy/tests/test_starport_guided.mjs +++ b/openpilot/starpilot/galaxy/tests/test_starport_guided.mjs @@ -270,7 +270,7 @@ console.log("StarPort guided setup: Bluetooth-first hint passed") assert.match(guidedBlock, /beginPairing/) // Find car / Find adapter assert.match(guidedBlock, /@click="connect"/) // the Connect button assert.match(guidedBlock, /Stuck pairing\?/) // the pairing help stays - assert.match(template, /
    \s* div { display: flex; flex-direction: column; min-width: 0; text-align: center; } .gx-summary dt { color: var(--text-muted); font-size: var(--fs-xs); line-height: 1.35; overflow-wrap: anywhere; } .gx-summary dd { order: -1; margin: 0 0 var(--sp-1); font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--primary); overflow-wrap: anywhere; } -/* Android Auto setup layout; controls reuse shared Galaxy styles. */ -.gx-starport__steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-4); } -.gx-starport__steps > .gx-card { margin-bottom: 0; } -.gx-starport-step { padding: var(--panel-padding); display: grid; gap: var(--sp-4); min-width: 0; } -.gx-starport-step__head { display: flex; align-items: flex-start; gap: var(--sp-4); min-width: 0; } -.gx-starport-step__head h3 { margin: 2px 0 var(--sp-1); font-size: var(--fs-lg); } -.gx-starport-step__head p { margin: 0; color: var(--text-muted); line-height: 1.45; } -.gx-starport-step__head > .gx-btn { margin-left: auto; flex: none; } -.gx-starport-step__num { flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-full); +/* Shared setup steps: Galaxy access, navigation, music and StarPort. */ +.gx-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-4); } +.gx-steps > .gx-card { margin-bottom: 0; } +.gx-step { padding: var(--panel-padding); display: grid; gap: var(--sp-4); min-width: 0; } +.gx-step__head { display: flex; align-items: flex-start; gap: var(--sp-4); min-width: 0; } +.gx-step__head h3 { margin: 2px 0 var(--sp-1); font-size: var(--fs-lg); } +.gx-step__head p { margin: 0; color: var(--text-muted); line-height: 1.45; } +.gx-step__head > .gx-btn { margin-left: auto; flex: none; } +.gx-step__num { flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-full); background: var(--primary-container); color: var(--on-primary-container); font-weight: var(--fw-bold); } -.gx-starport-step--done .gx-starport-step__num { background: var(--success); color: var(--background); } +.gx-step--done .gx-step__num { background: var(--success); color: var(--background); } +.gx-step__body { display: grid; gap: var(--sp-3); min-width: 0; padding-left: calc(36px + var(--sp-4)); } +.gx-step__body > p { margin: 0; line-height: 1.45; } +.gx-step__body > p:has(> .gx-spinner) { display: flex; align-items: center; gap: var(--sp-2); } +.gx-step__body > .gx-driving__actions { margin-block: 0; } +.gx-steps--compact { gap: var(--sp-3); } +.gx-step-card { +display: grid; +gap: var(--sp-3); +padding: var(--sp-3) var(--sp-4); +border-radius: var(--radius-md); +background: var(--surface-container); +border: 1px solid var(--outline); +transition: border-color var(--motion-fast); +} +.gx-step-card:focus-within { +border-color: var(--primary); +} +.gx-step-card__head { +display: flex; +align-items: center; +gap: var(--sp-3); +} +.gx-step-card__num { +width: 28px; +height: 28px; +font-size: var(--fs-sm); +} +.gx-step-card__title { +display: grid; +gap: 1px; +} +.gx-step-card__title strong { +font-size: var(--fs-sm); +font-weight: var(--fw-bold); +color: var(--on-surface); +} +.gx-step-card__title small { +font-size: var(--fs-xs); +color: var(--on-surface-variant); +} +.gx-step-card__body { +display: grid; +gap: var(--sp-2); +padding-left: 40px; +} +@media (max-width: 500px) { +.gx-step-card__body { padding-left: 0; } +.gx-step-card { padding: var(--sp-3); } +} +@media (max-width: 600px) { +.gx-step { padding: var(--sp-4); } +.gx-step__body { padding-left: 0; } +} + +/* StarPort-specific status and setup controls. */ .gx-starport-home { margin-bottom: 0; } -.gx-starport-step__num.gx-starport-home__icon--live { background: var(--success); color: var(--background); } -.gx-starport-step__body { display: grid; gap: var(--sp-3); min-width: 0; padding-left: calc(36px + var(--sp-4)); } -.gx-starport-step__body > p { margin: 0; line-height: 1.45; } -.gx-starport-step__body > p:has(> .gx-spinner) { display: flex; align-items: center; gap: var(--sp-2); } -.gx-starport-step__body > .gx-driving__actions { margin-block: 0; } +.gx-step__num.gx-starport-home__icon--live { background: var(--success); color: var(--background); } .gx-starport-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); } .gx-starport-status__actions { margin-left: auto; } .gx-starport-pill { display: inline-flex; align-items: center; gap: var(--sp-2); width: fit-content; max-width: 100%; margin: 0; padding: 6px 14px; @@ -1471,57 +1522,6 @@ letter-spacing: -0.01em; .gx-starport-sheet__dialog .gx-note { line-height: 1.45; } -.gx-starport-sheet__steps { -list-style: none; -margin: 0; -padding: 0; -display: grid; -gap: var(--sp-3); -} -.gx-starport-step-card { -display: grid; -gap: var(--sp-3); -padding: var(--sp-3) var(--sp-4); -border-radius: var(--radius-md); -background: var(--surface-container); -border: 1px solid var(--outline); -transition: border-color var(--motion-fast); -} -.gx-starport-step-card:focus-within { -border-color: var(--primary); -} -.gx-starport-step-card__head { -display: flex; -align-items: center; -gap: var(--sp-3); -} -.gx-starport-step-card__num { -width: 28px; -height: 28px; -font-size: var(--fs-sm); -} -.gx-starport-step-card__title { -display: grid; -gap: 1px; -} -.gx-starport-step-card__title strong { -font-size: var(--fs-sm); -font-weight: var(--fw-bold); -color: var(--on-surface); -} -.gx-starport-step-card__title small { -font-size: var(--fs-xs); -color: var(--on-surface-variant); -} -.gx-starport-step-card__body { -display: grid; -gap: var(--sp-2); -padding-left: 40px; -} -@media (max-width: 500px) { -.gx-starport-step-card__body { padding-left: 0; } -.gx-starport-step-card { padding: var(--sp-3); } -} .gx-starport-sheet__step--muted { opacity: .7; } .gx-starport-file { position: relative; } .gx-starport-file input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; } @@ -1568,8 +1568,6 @@ border-top: 1px solid var(--outline-variant); .gx-starport-trademark { display: block; font-size: var(--fs-xs); opacity: .75; line-height: 1.35; } @media (prefers-reduced-motion: reduce) { .gx-spinner, .gx-starport-checks .gx-starport-check--active::before { animation: none; } } @media (max-width: 600px) { -.gx-starport-step { padding: var(--sp-4); } -.gx-starport-step__body { padding-left: 0; } .gx-starport-status__actions { margin-left: 0; width: 100%; } .gx-starport-status__actions .gx-btn { flex: 1 1 auto; } .gx-starport-row { flex-wrap: wrap; } @@ -1607,7 +1605,7 @@ border-top: 1px solid var(--outline-variant); .gx-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .gx-device-picker__row { display: flex; align-items: center; gap: var(--sp-1); } .gx-device-picker__form { padding: var(--sp-2); display: grid; gap: var(--sp-2); } -.gx-tunnel__qr { display: block; width: min(250px, 100%); background: white; padding: var(--sp-2); border-radius: var(--radius-sm); } +.gx-tunnel__qr { display: block; margin-inline: auto; width: min(250px, 100%); background: white; padding: var(--sp-2); border-radius: var(--radius-sm); } .gx-plots__hint { min-height: 2.8em; } .gx-tabs > button { min-height: var(--touch-target); padding: var(--sp-2) var(--sp-4); } .gx-tabs > button[aria-pressed="true"], .gx-tabs > button[aria-selected="true"], .gx-chip--selected { background: var(--primary); color: var(--on-primary); } @@ -1684,7 +1682,7 @@ progress { max-width: 100%; accent-color: var(--primary); } .gx-replay__player:fullscreen .gx-replay__video { min-height: 0; flex: 1; } } .gx-spotify-now { display: grid; gap: var(--sp-3); } -.gx-spotify > .gx-starport-step > h3 { margin: 0; font-size: var(--fs-lg); } +.gx-spotify > .gx-step > h3 { margin: 0; font-size: var(--fs-lg); } .gx-spotify-now__main { display: flex; gap: var(--sp-3); align-items: center; justify-content: center; min-width: 0; } .gx-spotify-now__text { min-width: 0; } .gx-spotify-now__text h3, .gx-spotify-now__text p { margin: 0; } @@ -1883,3 +1881,18 @@ progress { max-width: 100%; accent-color: var(--primary); } .gx-app-download__get { width: 100%; min-height: 48px; } .gx-app-download > .gx-app-download__platform { margin-top: -8px; font-size: .75rem; } .gx-app-download > .gx-btn--text { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-muted); min-height: 44px; } + +/* Shared disclosure motion. Native focus, keyboard and open state stay intact. */ +.gx-select-menu { + opacity: 0; + transform: translateY(-4px); + transition: opacity var(--motion-base), transform var(--motion-base), display var(--motion-base) allow-discrete, overlay var(--motion-base) allow-discrete; +} +.gx-select-menu[open] { opacity: 1; transform: translateY(0); } +.gx-select-menu:not([open]) { pointer-events: none; } +@starting-style { + .gx-select-menu[open] { opacity: 0; transform: translateY(-4px); } +} +@media (prefers-reduced-motion: reduce) { + .gx-select-menu { transition: none; } +} diff --git a/openpilot/starpilot/galaxy/web/css/navigation.css b/openpilot/starpilot/galaxy/web/css/navigation.css index 9e50eb8fb8..8b9000b8e9 100644 --- a/openpilot/starpilot/galaxy/web/css/navigation.css +++ b/openpilot/starpilot/galaxy/web/css/navigation.css @@ -183,8 +183,8 @@ .gx-navigation__sources { display: flex; flex-wrap: wrap; gap: var(--sp-2); list-style: none; margin: 0; padding: 0; } .gx-navigation__sources .gx-navigation__chip { text-decoration: none; border: 1px solid var(--outline); } .gx-navigation__power .gx-row__info { display: grid; gap: 2px; } -.gx-navigation .gx-starport-step__body { padding-left: 0; } -@media (min-width: 640px) { .gx-navigation .gx-starport-step__body { padding-left: calc(36px + var(--sp-4)); } } +.gx-navigation .gx-step__body { padding-left: 0; } +@media (min-width: 640px) { .gx-navigation .gx-step__body { padding-left: calc(36px + var(--sp-4)); } } @media (max-width: 540px) { .gx-compare__row { grid-template-columns: 1fr; gap: 2px; } .gx-compare__row--head { display: none; } .gx-compare__row > :nth-child(2)::before { content: "Mapbox: "; } .gx-compare__row > :nth-child(3)::before { content: "Google: "; } } .gx-navigation__guide { border: 1px solid var(--outline); border-radius: var(--radius-sm); padding: var(--sp-3); } diff --git a/openpilot/starpilot/galaxy/web/js/app-downloads.js b/openpilot/starpilot/galaxy/web/js/app-downloads.js new file mode 100644 index 0000000000..6f595f0d11 --- /dev/null +++ b/openpilot/starpilot/galaxy/web/js/app-downloads.js @@ -0,0 +1,13 @@ +// Canonical store metadata shared by download links and reminders. +export const APP_DOWNLOADS = Object.freeze({ + ios: Object.freeze({ href: 'https://apps.apple.com/ca/app/starpilot-bt/id6821039119', label: 'App Store', icon: 'bi-apple', name: 'StarPilot BT for iPhone' }), + android: Object.freeze({ href: 'https://play.google.com/store/apps/details?id=com.starpilot.galaxy', label: 'Google Play', icon: 'bi-google-play', name: 'Galaxy for Android' }), +}) + +export const AppStoreLinks = { + data: () => ({ downloads: APP_DOWNLOADS }), + template: ``, +} diff --git a/openpilot/starpilot/galaxy/web/js/app-reminder.js b/openpilot/starpilot/galaxy/web/js/app-reminder.js index dbc57d6bfb..60ce062d71 100644 --- a/openpilot/starpilot/galaxy/web/js/app-reminder.js +++ b/openpilot/starpilot/galaxy/web/js/app-reminder.js @@ -1,12 +1,11 @@ +import { APP_DOWNLOADS } from "./app-downloads.js" +export { APP_DOWNLOADS } from "./app-downloads.js" import { reactive } from "../vendor/vue/vue.esm-browser.js" import { GxDialog } from "./dialog.js" export const HIDE_APP_REMINDER = "galaxy-hide-app-download-reminder" export const DISMISSED_APP_REMINDER = "galaxy-app-download-reminder-dismissed" -export const APP_DOWNLOADS = { - ios: { href: "https://firestar.link/iOS", label: "Download for iOS", icon: "bi-apple", name: "StarPilot BT for iPhone" }, - android: { href: "https://firestar.link/android", label: "Get the Android app", icon: "bi-google-play", name: "Galaxy for Android" }, -} + export function appDownloadPlatform(target = globalThis) { // Native bridges exist before page scripts run on both companion apps. @@ -69,5 +68,5 @@ export const AppReminderSettings = {
    Hide app download reminderSaved for this browser.
    - `, + `, } diff --git a/openpilot/starpilot/galaxy/web/js/app.js b/openpilot/starpilot/galaxy/web/js/app.js index 3de850986c..7daf91e795 100644 --- a/openpilot/starpilot/galaxy/web/js/app.js +++ b/openpilot/starpilot/galaxy/web/js/app.js @@ -1,3 +1,4 @@ +import { installDisclosureMotion } from './disclosure.js' import { startLocalization } from "./localization.js" import { rememberInstallPrompt } from "./install-app.js" import { toggleHaptic } from "./haptics.js" @@ -13,6 +14,8 @@ import { route, navigate, navigateBack, ensureBackEntry, setRouteLeaveGuard, sta import { loadCatalog } from "./startup.js" import { Tools } from "./tools.js" window.addEventListener("beforeinstallprompt", rememberInstallPrompt) +installDisclosureMotion() + const Logs = page(() => import("./logs.js").then((module) => module.Logs)) const SoftwarePage = page(() => import("./software-status.js").then((module) => module.SoftwarePage)) const NavigationPage = page(() => import("./navigation.js").then((module) => module.NavigationPage)) diff --git a/openpilot/starpilot/galaxy/web/js/companion-updates.js b/openpilot/starpilot/galaxy/web/js/companion-updates.js new file mode 100644 index 0000000000..c7420a9890 --- /dev/null +++ b/openpilot/starpilot/galaxy/web/js/companion-updates.js @@ -0,0 +1,85 @@ +import { requestJson } from './startup.js' +import { GxNotice } from './notice.js' +import { BluetoothNotice, bluetoothConnection } from './bluetooth-notice.js' +import { APP_DOWNLOADS } from './app-downloads.js' +import { isIosDevice } from './install-app.js' + +const DISMISSED_UPDATE = 'galaxy.companion.dismissedUpdateVersion' + +export function newerCompanionVersion(available, installed) { + const parts = version => typeof version === 'string' && /^\d+(?:\.\d+){1,3}$/.test(version) ? version.split('.').map(Number) : [] + const next = parts(available), current = parts(installed) + if (!next.length || !current.length || ![...next, ...current].every(Number.isSafeInteger)) return false + for (let index = 0; index < Math.max(next.length, current.length); index++) { + const difference = (next[index] || 0) - (current[index] || 0) + if (difference) return difference > 0 + } + return false +} + +export function validCompanion(value) { + return value?.protocol === 1 && ['enabled', 'connected', 'active', 'appAvailable', 'updateAvailable'].every(key => typeof value[key] === 'boolean') && + Number.isSafeInteger(value.bytes) && value.bytes >= 0 && typeof value.shippedVersion === 'string' && + ['active', 'waiting', 'disabled', 'error'].includes(value.state) +} + +export const CompanionUpdates = { + components: { GxNotice, BluetoothNotice }, + props: { mode: String, unauthorized: Function }, + data: () => ({ status: null, error: '', androidApp: APP_DOWNLOADS.android, nativeVersion: window.StarPilotApp?.version?.() || '', + eligible: !isIosDevice() && !!window.StarPilotApp?.version && window.StarPilotApp?.distribution?.() !== 'play', + playDistribution: window.StarPilotApp?.distribution?.() === 'play', + bluetooth: bluetoothConnection(), generation: 0, alive: false, dismissedUpdateVersion: (() => { + try { return localStorage.getItem(DISMISSED_UPDATE) || '' } catch { return '' } + })() }), + computed: { + availableVersion() { return this.status?.appAvailable ? this.status.shippedVersion : '' }, + showUpdate() { return this.eligible && this.mode === 'local' && this.availableVersion !== this.dismissedUpdateVersion && newerCompanionVersion(this.availableVersion, this.nativeVersion) }, + nativeInstallerAvailable() { return typeof window.StarPilotApp?.installUpdate === 'function' }, + }, + mounted() { this.start() }, + beforeUnmount() { this.stop() }, + watch: { mode() { this.stop(); this.start() } }, + methods: { + installUpdate() { window.StarPilotApp?.installUpdate?.() }, + dismissUpdate() { + this.dismissedUpdateVersion = this.availableVersion + try { localStorage.setItem(DISMISSED_UPDATE, this.dismissedUpdateVersion) } catch {} + }, + start() { if (this.mode === 'local' && this.eligible) { this.alive = true; this.refresh() } }, + stop() { this.alive = false; this.generation++; clearTimeout(this.timer); this.controller?.abort(); this.status = null }, + adopt(status) { + if (!validCompanion(status)) throw new Error('Invalid companion status') + this.status = status + }, + async refresh() { + if (!this.alive) return + clearTimeout(this.timer) + const generation = ++this.generation + this.controller = new AbortController() + try { + const status = await requestJson('./api/companion/status', { request: { signal: this.controller.signal } }) + if (!this.alive || generation !== this.generation) return + this.adopt(status); this.error = '' + } catch (e) { + if (!this.alive || generation !== this.generation) return + this.error = e.message + if (e.status === 401) { this.stop(); this.unauthorized() } + } finally { if (this.alive && generation === this.generation) this.timer = setTimeout(() => this.refresh(), 5000) } + }, + }, + template: `

    Updates come from Google Play.

    + + Installed: {{ nativeVersion }}. Connect over Wi-Fi to update. + + + + Version {{ availableVersion }} is available. Installed: {{ nativeVersion }}. + + + {{ error }}`, +} diff --git a/openpilot/starpilot/galaxy/web/js/companion.js b/openpilot/starpilot/galaxy/web/js/companion.js deleted file mode 100644 index 1b33ded54c..0000000000 --- a/openpilot/starpilot/galaxy/web/js/companion.js +++ /dev/null @@ -1,96 +0,0 @@ -import { requestJson } from './startup.js' -import { GxNotice } from './notice.js' -import { BluetoothNotice, bluetoothConnection } from './bluetooth-notice.js' -import { ANDROID_BETA_URL } from './install-app.js' - -export function newerCompanionVersion(available, installed) { - const parts = version => typeof version === 'string' && /^\d+(?:\.\d+){1,3}$/.test(version) ? version.split('.').map(Number) : [] - const next = parts(available), current = parts(installed) - if (!next.length || !current.length || ![...next, ...current].every(Number.isSafeInteger)) return false - for (let index = 0; index < Math.max(next.length, current.length); index++) { - const difference = (next[index] || 0) - (current[index] || 0) - if (difference) return difference > 0 - } - return false -} - -export function validCompanion(value) { - return value?.protocol === 1 && ['enabled', 'connected', 'active', 'appAvailable', 'updateAvailable'].every(key => typeof value[key] === 'boolean') && - Number.isSafeInteger(value.bytes) && value.bytes >= 0 && typeof value.shippedVersion === 'string' && - ['active', 'waiting', 'disabled', 'error'].includes(value.state) -} - -export const GalaxyCompanion = { - components: { GxNotice, BluetoothNotice }, - emits: ['status'], - props: { mode: String, unauthorized: Function }, - data: () => ({ status: null, error: '', betaUrl: ANDROID_BETA_URL, native: !!window.StarPilotApp?.uplinkState, sharing: false, autoStart: false, - bluetooth: bluetoothConnection(), nativeBytes: 0, busy: false, generation: 0, alive: false }), - computed: { windowAutoStart() { return !!window.StarPilotApp?.setAutoStart } }, - mounted() { this.start() }, - beforeUnmount() { this.stop() }, - watch: { mode() { this.stop(); this.start() } }, - methods: { - connectionOptions() { window.StarPilotApp?.connectionOptions?.() }, - setAutoStart() { window.StarPilotApp.setAutoStart(this.autoStart) }, - start() { if (this.mode === 'local') { this.alive = true; this.refresh() } }, - stop() { this.alive = false; this.generation++; clearTimeout(this.timer); this.controller?.abort(); this.status = null; this.$emit('status', null) }, - adopt(status) { - if (!validCompanion(status)) throw new Error('Invalid companion status') - this.status = status - this.$emit('status', status) - if (this.native) { - const state = JSON.parse(window.StarPilotApp.uplinkState()) - this.sharing = state.enabled === true; this.autoStart = state.autoStart === true - this.nativeBytes = Number.isSafeInteger(state.bytes) && state.bytes >= 0 ? state.bytes : status.bytes - } - }, - async refresh() { - if (!this.alive || this.busy) return - clearTimeout(this.timer) - const generation = ++this.generation - this.controller = new AbortController() - try { - const status = await requestJson('./api/companion/status', { request: { signal: this.controller.signal } }) - if (!this.alive || generation !== this.generation) return - this.adopt(status); this.error = '' - } catch (e) { - if (!this.alive || generation !== this.generation) return - this.error = e.message - if (e.status === 401) { this.stop(); this.unauthorized() } - } finally { if (this.alive && generation === this.generation) this.timer = setTimeout(() => this.refresh(), 5000) } - }, - async toggle() { - if (this.bluetooth || !this.alive || this.busy || !this.status || this.mode !== 'local') return - clearTimeout(this.timer); this.controller?.abort() - const generation = ++this.generation - this.busy = true - try { - const enabled = this.native ? !this.sharing : !this.status.enabled - if (this.native && window.StarPilotApp.setUplinkEnabled(enabled) === false) { this.sharing = false; return } - const status = await requestJson('./api/companion/settings', { request: { method: 'POST', - headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ enabled }) } }) - if (!this.alive || generation !== this.generation) return - this.adopt(status) - if (this.native) this.sharing = enabled - this.error = '' - } catch (e) { - if (!this.alive || generation !== this.generation) return - this.error = e.message - if (e.status === 401) { this.stop(); this.unauthorized() } - } finally { - this.busy = false - if (this.alive && generation === this.generation) this.timer = setTimeout(() => this.refresh(), 1000) - } - }, - }, - template: `

    Android companion · Connections

    -

    - Phone internet requires the Galaxy hotspot. Settings and small requests remain available. - - {{ error }} -
    `, -} diff --git a/openpilot/starpilot/galaxy/web/js/disclosure.js b/openpilot/starpilot/galaxy/web/js/disclosure.js new file mode 100644 index 0000000000..d3f91fd5d2 --- /dev/null +++ b/openpilot/starpilot/galaxy/web/js/disclosure.js @@ -0,0 +1,78 @@ +const motions = new WeakMap() +const interrupted = new WeakMap() + +function reducedMotion() { return globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true } + +function cancel(element) { + const motion = motions.get(element) + if (!motion) return + interrupted.set(element, element.getBoundingClientRect().height) + motion.animation.cancel() + element.style.overflow = motion.overflow + motions.delete(element) +} + +// Animate the outer box, including bordered cards, using Galaxy's shared timing. +function resize(element, from, to, done, expanded) { + cancel(element) + interrupted.delete(element) + if (reducedMotion() || !element.animate || from === to) { done(); return } + const token = getComputedStyle(element).getPropertyValue('--motion-base').trim() + const [time, ...curve] = token.split(/\s+/) + const duration = Number.parseFloat(time) * (time?.endsWith('ms') ? 1 : 1000) || 240 + const overflow = element.style.overflow + element.style.overflow = 'hidden' + const animation = element.animate([{ height: `${from}px` }, { height: `${to}px` }], { + duration, easing: curve.join(' ') || 'ease-out', + }) + motions.set(element, { animation, overflow, expanded }) + animation.onfinish = () => { + if (motions.get(element)?.animation !== animation) return + motions.delete(element) + element.style.overflow = overflow + done() + } +} + +// One delegated handler covers every native disclosure, including dynamic/nested ones. +export function installDisclosureMotion(root = document) { + const click = event => { + if (event.defaultPrevented || event.button !== 0 || reducedMotion()) return + const summary = event.target.closest?.('summary') + const details = summary?.parentElement + if (details?.tagName !== 'DETAILS' || details.querySelector('summary') !== summary || !details.animate) return + if (event.target.closest('a, button, input, select, textarea')) return + event.preventDefault() + const expanded = !(motions.get(details)?.expanded ?? details.open) + const from = details.getBoundingClientRect().height + cancel(details) + details.open = expanded + const to = details.getBoundingClientRect().height + // Keep content rendered during closing; update native state when it finishes. + details.open = true + resize(details, from, to, () => { details.open = expanded }, expanded) + } + root.addEventListener('click', click) + return () => root.removeEventListener('click', click) +} + +// The same resize implementation for Vue-controlled panels; no extra wrapper DOM. +export const GxCollapse = { + name: 'GxCollapse', + methods: { + enter(element, done) { + if (!element.animate || reducedMotion()) { cancel(element); interrupted.delete(element); done(); return } + const from = interrupted.get(element) ?? 0 + cancel(element) + const to = element.getBoundingClientRect().height + resize(element, from, to, done, true) + }, + leave(element, done) { + if (!element.animate || reducedMotion()) { cancel(element); interrupted.delete(element); done(); return } + const from = interrupted.get(element) ?? element.getBoundingClientRect().height + resize(element, from, 0, done, false) + }, + cancel, + }, + template: ``, +} diff --git a/openpilot/starpilot/galaxy/web/js/flm.js b/openpilot/starpilot/galaxy/web/js/flm.js index 2ee40551df..c05a0ede3c 100644 --- a/openpilot/starpilot/galaxy/web/js/flm.js +++ b/openpilot/starpilot/galaxy/web/js/flm.js @@ -322,7 +322,7 @@ export const FlmPage = {
    - +

    COMPLETED DRIVE REVIEW

    {{ review.title }}

    {{ review.description }}

    These suggestions come from an earlier drive. Newer driving is reviewed separately.

    diff --git a/openpilot/starpilot/galaxy/web/js/galaxy.js b/openpilot/starpilot/galaxy/web/js/galaxy.js index b9f8cff7b1..3ee89d900d 100644 --- a/openpilot/starpilot/galaxy/web/js/galaxy.js +++ b/openpilot/starpilot/galaxy/web/js/galaxy.js @@ -1,155 +1,29 @@ -import { GxState } from "./state.js" -import { GxNotice } from "./notice.js" -import { requestJson } from "./startup.js" -import { ANDROID_BETA_URL, InstallApp, isIosDevice } from "./install-app.js" -import { GalaxyCompanion, newerCompanionVersion } from "./companion.js" -import { GalaxyHotspot } from "./hotspot.js" -import { LocalAccess } from "./local-access.js" -import { BluetoothNotice, bluetoothConnection } from "./bluetooth-notice.js" - -const DISMISSED_UPDATE = 'galaxy.companion.dismissedUpdateVersion' -const dismissedUpdate = () => { try { return localStorage.getItem(DISMISSED_UPDATE) || '' } catch { return '' } } +import { AppStoreLinks } from './app-downloads.js' +import { InstallApp } from './install-app.js' +import { RemoteAccess } from './remote-access.js' +import { CompanionUpdates } from './companion-updates.js' +import { GalaxyHotspot } from './hotspot.js' export const GalaxyPage = { - name: "GalaxyPage", - components: { GxState, GxNotice, BluetoothNotice, InstallApp, GalaxyHotspot, GalaxyCompanion, LocalAccess }, + name: 'GalaxyPage', + components: { AppStoreLinks, InstallApp, RemoteAccess, CompanionUpdates, GalaxyHotspot }, props: { mode: { type: String, required: true }, unauthorized: { type: Function, required: true } }, - data: () => ({ loading: true, paired: false, url: "", tunnelClientAvailable: false, legacyPassword: false, - appKey: '', keyVisible: false, betaUrl: ANDROID_BETA_URL, legacyPairingAvailable: false, password: "", busy: false, error: "", companionStatus: null, - bluetooth: bluetoothConnection(), nativeVersion: window.StarPilotApp?.version?.() || '', dismissedUpdateVersion: dismissedUpdate(), - ios: isIosDevice() }), - computed: { - availableAppVersion() { return this.companionStatus?.appAvailable ? this.companionStatus.shippedVersion : '' }, - installedAppVersion() { return this.nativeVersion || this.companionStatus?.version || '' }, - playDistribution() { return window.StarPilotApp?.distribution?.() === 'play' }, - appUpdateAvailable() { - return !this.playDistribution && this.mode === 'local' && newerCompanionVersion(this.availableAppVersion, this.installedAppVersion) - }, - nativeInstallerAvailable() { return typeof window.StarPilotApp?.installUpdate === 'function' }, - showAppUpdate() { - return this.appUpdateAvailable && this.availableAppVersion !== this.dismissedUpdateVersion - }, - }, - mounted() { this.load() }, - methods: { - async showAppKey() { - const url = this.url - try { const data = await this.request('./api/galaxy/session'); if (this.url !== url || !this.paired) return; this.appKey = data.paired ? decodeURIComponent(data.sessionToken) : ''; this.keyVisible = !!this.appKey } - catch (error) { this.error = error.message } - }, - async copyAppKey() { - try { await navigator.clipboard.writeText(this.appKey) } catch { this.error = 'Select and copy the displayed key.' } - }, - installAppUpdate() { window.StarPilotApp?.installUpdate?.() }, - dismissAppUpdate() { - this.dismissedUpdateVersion = this.availableAppVersion - try { localStorage.setItem(DISMISSED_UPDATE, this.dismissedUpdateVersion) } catch {} - }, - async request(path, body) { - try { - return await requestJson(path, { request: body === undefined ? {} : { - method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), - } }) - } catch (error) { - if (error.status === 401) this.unauthorized() - throw error - } - }, - async load() { - if (this.mode !== "local") { this.loading = false; return } - try { - const data = await this.request("./api/galaxy/status") - this.paired = data.paired - this.url = data.url - this.tunnelClientAvailable = data.tunnelClientAvailable === true - this.legacyPassword = data.legacyPassword === true - this.legacyPairingAvailable = data.legacyPairingAvailable === true - } catch (error) { this.error = error.message } - finally { this.loading = false } - }, - async pair() { - this.busy = true - this.error = "" - try { - const data = await this.request("./api/galaxy/pair", { password: this.password }) - this.paired = data.paired - this.url = data.url - this.appKey = '' - this.keyVisible = false - this.password = "" - } catch (error) { this.error = error.message } - finally { this.busy = false } - }, - async unpair() { - if (!window.confirm("Unpair from Galaxy? Remote access will stop until you pair again.")) return - this.busy = true - this.error = "" - try { - await this.request("./api/galaxy/unpair", {}) - this.paired = false - this.url = "" - this.appKey = '' - this.keyVisible = false - } catch (error) { this.error = error.message } - finally { this.busy = false } - }, - }, - template: ` -

    Galaxy Access & Install

    -

    Pair your comma, then install Galaxy from your remote link.

    -

    Updates come from Google Play.

    - - Installed: {{ installedAppVersion }}. - - - - Version {{ availableAppVersion }} is available. Installed: {{ installedAppVersion }}. - - - Connect to your comma to set up remote access. - Checking pairing status… -
      -
    1. -
      -

      Remote pairing

      Pair your comma to get a secure Galaxy link.

      -
      - - - {{ error }} -
      -
    2. -
    3. -
      -

      Install Galaxy

      Launch Galaxy from your home screen or desktop.

      -
      -

      Android offline app version: {{ availableAppVersion }} · {{ nativeVersion ? 'Installed' : 'Connected phone' }}: {{ installedAppVersion }}

      -

      Android users: join the Android beta on Google Groups to get the app for use over Galaxy Wi-Fi or your local network without Internet.

      - -

      Your remote link needs Internet and an active tunnel. For offline local access, bookmark your hotspot or local address.

      -
      -
    4. -
    - - -
    - `, + data: () => ({ url: '' }), + template: `
    +

    Galaxy Access & Install

    +

    Set up your link, then choose how to open Galaxy.

    +
      + +
    1. +
      +

      Get the app

      Choose the phone app or install Galaxy in your browser.

      +
      + +

      Connect through your Firestar Link, nearby Wi-Fi, or Bluetooth.

      + +
      +
    2. +
    + +
    `, } diff --git a/openpilot/starpilot/galaxy/web/js/install-app.js b/openpilot/starpilot/galaxy/web/js/install-app.js index 79ea94d0da..57038cb8e4 100644 --- a/openpilot/starpilot/galaxy/web/js/install-app.js +++ b/openpilot/starpilot/galaxy/web/js/install-app.js @@ -18,14 +18,11 @@ export function installHelp({ secure = window.isSecureContext, agent = navigator return 'This browser cannot install Galaxy automatically. Open the browser menu and choose Install app or Add to Home Screen. On a Mac in Safari, choose File → Add to Dock.' } -export const ANDROID_BETA_URL = 'https://groups.google.com/g/galaxy-starpilot-android-beta' - export const InstallApp = { name: 'InstallApp', - props: { url: { type: String, default: '' }, updateAvailable: { type: Boolean, default: false } }, - data: () => ({ prompt: null, installed: false, message: '', betaUrl: ANDROID_BETA_URL, - android: isAndroidDevice(), ios: isIosDevice() }), - computed: { playDistribution() { return window.StarPilotApp?.distribution?.() === 'play' }, onPublicGalaxy() { return window.location?.hostname === 'galaxy.firestar.link' } }, + props: { url: { type: String, default: '' } }, + data: () => ({ prompt: null, installed: false, message: '' }), + computed: { onPublicGalaxy() { return window.location?.hostname === 'galaxy.firestar.link' } }, mounted() { this.prompt = deferredPrompt this.displayMode = window.matchMedia('(display-mode: standalone)') @@ -54,13 +51,6 @@ export const InstallApp = { await prompt.userChoice } catch { this.message = installHelp() } }, - installAndroid() { - if (this.updateAvailable && typeof window.StarPilotApp?.installUpdate === 'function') { - window.StarPilotApp.installUpdate() - return - } - location.assign(ANDROID_BETA_URL) - }, }, template: `

    Galaxy is installed.

    @@ -70,10 +60,6 @@ export const InstallApp = {

    {{ message }}

    Install web app -

    Pair in step 1 to get your install link.

    - Download StarPilot BT on the App Store - - Join the Android beta -

    Updates come from Google Play.

    +

    Set up remote access to get your web app link.

    `, } diff --git a/openpilot/starpilot/galaxy/web/js/local-access.js b/openpilot/starpilot/galaxy/web/js/local-access.js index fa3fd83487..e54a9b48ac 100644 --- a/openpilot/starpilot/galaxy/web/js/local-access.js +++ b/openpilot/starpilot/galaxy/web/js/local-access.js @@ -64,9 +64,9 @@ export const LocalAccess = {
    Local access
    {{ state.error }}

    {{ state.data.reason || 'The comma has no local network address available.' }}

    `, diff --git a/openpilot/starpilot/galaxy/web/js/navigation.js b/openpilot/starpilot/galaxy/web/js/navigation.js index c129cb986f..949a54bff7 100644 --- a/openpilot/starpilot/galaxy/web/js/navigation.js +++ b/openpilot/starpilot/galaxy/web/js/navigation.js @@ -1,3 +1,4 @@ +import { GxCollapse } from './disclosure.js' import { isMapLink } from "./share-destination.js" import { GxNotice } from "./notice.js" import { BluetoothNotice, bluetoothConnection } from "./bluetooth-notice.js" @@ -308,7 +309,7 @@ export const FavoriteChoices = { export const NavigationPage = { name: "NavigationPage", - components: { GxNotice, BluetoothNotice, MapOperationsPanel, NavigationMap, OfflineRoadMapsPanel, FavoriteChoices, GalaxySelect, ChoiceGroup, SourceCompare }, + components: { GxCollapse, GxNotice, BluetoothNotice, MapOperationsPanel, NavigationMap, OfflineRoadMapsPanel, FavoriteChoices, GalaxySelect, ChoiceGroup, SourceCompare }, props: { mode: { type: String, required: true }, unauthorized: { type: Function, required: true }, go: { type: Function, default: null }, initialTab: { type: String, default: "route" }, tabs: { type: Array, required: true } }, data() { return { bluetooth: bluetoothConnection(), data: null, results: [], busy: false, error: "", stale: false, tab: this.initialTab, gpsGuide: "android", query: "", token: "", googleKey: "", googleTest: null, mapboxOpen: false, googleOpen: false, searched: false, @@ -573,16 +574,16 @@ export const NavigationPage = {
-
-
- +
+
+

Mapbox key

{{ !data ? 'Loading…' : data.hasKey ? 'Key saved' : 'Needs a key' }}

Required, with or without Google. Finds places, saves offline roads, plans routes and backs up Google.

-
-
-
- +
+
+

Google key

{{ data?.hasGoogleKey ? (googleWorking ? 'Key saved · ' + googleWorking : 'Key saved') : 'Optional' }}

Added on top of the Mapbox key. Unlocks Google's street & traffic map, live-traffic routes and place search.

@@ -614,7 +615,7 @@ export const NavigationPage = {
Google isn't used until the Mapbox key above is added too. -
-
-
- +
+
+

Choose your sources

Google choices need both keys. Each one falls back to Mapbox if it can't work.

-
+
-
-
- +
+
+

Ways to send a destination

Start a trip from Galaxy or share a place straight from your phone.

-
+
  • {{ way.title }}{{ way.detail }}
  • diff --git a/openpilot/starpilot/galaxy/web/js/offline-road-maps.js b/openpilot/starpilot/galaxy/web/js/offline-road-maps.js index c87fd89fbf..efbe6b060b 100644 --- a/openpilot/starpilot/galaxy/web/js/offline-road-maps.js +++ b/openpilot/starpilot/galaxy/web/js/offline-road-maps.js @@ -235,7 +235,7 @@ export const OfflineRoadMapsPanel = { template: `
    - +

    Offline Map Management

    diff --git a/openpilot/starpilot/galaxy/web/js/onroad-layout-template.js b/openpilot/starpilot/galaxy/web/js/onroad-layout-template.js index 180de97770..8c6d9e4e48 100644 --- a/openpilot/starpilot/galaxy/web/js/onroad-layout-template.js +++ b/openpilot/starpilot/galaxy/web/js/onroad-layout-template.js @@ -14,10 +14,10 @@ export const ONROAD_LAYOUT_TEMPLATE = ` :aria-pressed="state.profile === tab.id" :disabled="!!state.drag" @click="selectProfile(tab.id)">{{ tab.label }} (active UI)
    -
    +

    Choose a widget to move it or change its colors. Edit the layout available on this comma.

    Move widgets for the last connected StarPort screen. The comma layout stays separate. Colors follow the comma theme. Changes apply on the next connection.

    Last usable screen: {{ state.data.screen.width - state.data.screen.margin_width }} × {{ state.data.screen.height - state.data.screen.margin_height }} pixels.

    -
    +

    {{ state.data.reason }}

    Connect to local Galaxy to edit this device’s colors and layouts. -
    +

    Music Source