mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 10:13:44 +08:00
Keep FLM vehicle status stable and explain parked analysis waits
This commit is contained in:
@@ -102,6 +102,28 @@ function instance() {
|
||||
for (const [name, method] of Object.entries(FlmPage.computed)) Object.defineProperty(vm, name, { get: () => method.call(vm) })
|
||||
return vm
|
||||
}
|
||||
const drivingStatus = instance()
|
||||
drivingStatus.receivedAt = 10000
|
||||
drivingStatus.report = { ...report(), preference: { ...choice, parked: false } }
|
||||
for (const age of [.2, 2.1, .1, 3, .5]) {
|
||||
drivingStatus.now = 10000
|
||||
drivingStatus.report.current.ageSeconds = age
|
||||
assert.equal(drivingStatus.connectionState, 'Driving', 'A late learner report cannot erase fresh vehicle status')
|
||||
assert.equal(drivingStatus.currentApplied, false, 'Driving status does not claim a saved tune or current application')
|
||||
}
|
||||
drivingStatus.report = { ...value, preference: { ...choice, parked: false } }
|
||||
assert.equal(drivingStatus.connectionState, 'Learned tune in use')
|
||||
drivingStatus.report.current.ageSeconds = 3
|
||||
assert.equal(drivingStatus.connectionState, 'Driving', 'Stale application evidence cannot keep an in-use claim')
|
||||
drivingStatus.report.current.ageSeconds = .1
|
||||
drivingStatus.report.preference.parked = true
|
||||
assert.equal(drivingStatus.connectionState, 'Parked')
|
||||
drivingStatus.now = 12100
|
||||
assert.equal(drivingStatus.connectionState, 'Waiting for vehicle status', 'Stale vehicle status is never kept as current')
|
||||
drivingStatus.now = 10000; drivingStatus.error = 'offline'
|
||||
assert.equal(drivingStatus.connectionState, 'Waiting for vehicle status')
|
||||
assert.match(FlmPage.template, /connectionState/)
|
||||
assert.doesNotMatch(FlmPage.template, /Driving · use not confirmed|State not confirmed/)
|
||||
const originalFetch = globalThis.fetch, originalDocument = globalThis.document
|
||||
try {
|
||||
globalThis.document = { getElementById: () => null, hidden: false, addEventListener() {}, removeEventListener() {} }
|
||||
|
||||
@@ -73,6 +73,24 @@ assert.equal(offroadView(completed).evidenceDrives, null, 'Older reports must no
|
||||
assert.equal(tunerStatus(completed, true, true).title, 'Completed drive analyzed', 'Parked status must not mask completed analysis')
|
||||
assert.match(tunerStatus(completed, true, true).description, /left your tune unchanged/)
|
||||
assert.equal(completed.current.application.applied, false)
|
||||
const ignitionWait = { ...report(), preference: { version: 1, valid: true, enabled: true, parked: true,
|
||||
vehicle: 'TOYOTA_RAV4_PRIME', controller: 'torque' } }
|
||||
ignitionWait.current.reason = 'waiting_for_ignition_off'
|
||||
const waitingStatus = tunerStatus(ignitionWait, false, true, '', true)
|
||||
assert.equal(waitingStatus.title, 'Waiting to analyze your drive')
|
||||
assert.match(waitingStatus.description, /ignition on.*ignition turns off/)
|
||||
assert.equal(ignitionWait.current.application.applied, false)
|
||||
assert.notEqual(tunerStatus(ignitionWait, false, true, '', false).key, 'waiting-parked', 'An old blocker is not current permission evidence')
|
||||
for (const reason of ['waiting_for_valid_deviceState', 'waiting_for_fresh_pandaStates', 'waiting_for_vehicle_offroad',
|
||||
'waiting_for_vehicle_to_switch_off', 'waiting_for_connected_panda_status', 'waiting_for_panda_controls_to_disarm',
|
||||
'waiting_for_panda_fault_to_clear', 'waiting_for_shutdown_to_finish', 'waiting_for_parked_permission']) {
|
||||
ignitionWait.current.reason = reason
|
||||
assert.equal(tunerStatus(ignitionWait, false, true, '', true).key, 'waiting-parked', reason)
|
||||
}
|
||||
ignitionWait.preference.parked = false
|
||||
assert.notEqual(tunerStatus(ignitionWait, true, true, '', true).key, 'waiting-parked')
|
||||
ignitionWait.preference.parked = true; ignitionWait.preference.enabled = false
|
||||
assert.equal(tunerStatus(ignitionWait, false, true, '', true).key, 'off')
|
||||
const earlierDrive = structuredClone(completed)
|
||||
Object.assign(earlierDrive.current.details, {
|
||||
'Latest completed recording reviewed': 'declared-newer-manual-drive',
|
||||
|
||||
@@ -258,6 +258,17 @@ const REASONS = {
|
||||
accepted_target_currently_acknowledged: "The controller acknowledged the accepted correction.",
|
||||
}
|
||||
export function learningReason(reason) {
|
||||
if (reason === 'waiting_for_ignition_off' || reason === 'waiting_for_vehicle_to_switch_off')
|
||||
return 'The vehicle interface still reports ignition on. Drive analysis starts after the ignition turns off.'
|
||||
if (/^waiting_for_(valid|fresh)_(deviceState|pandaStates|peripheralState)$/.test(reason))
|
||||
return 'Waiting for current vehicle status before analyzing the recorded drive.'
|
||||
if (reason === 'waiting_for_controls_to_disengage' || reason === 'waiting_for_panda_controls_to_disarm')
|
||||
return 'Drive analysis is waiting for steering controls to disengage.'
|
||||
if (reason === 'waiting_for_panda_fault_to_clear') return 'Drive analysis is paused while the vehicle interface reports a fault.'
|
||||
if (reason === 'waiting_for_connected_panda_status') return 'Waiting for the vehicle interface before analyzing the recorded drive.'
|
||||
if (reason === 'waiting_for_shutdown_to_finish') return 'Drive analysis is waiting for shutdown to finish.'
|
||||
if (reason === 'waiting_for_vehicle_offroad' || reason === 'waiting_for_parked_permission')
|
||||
return 'Drive analysis is waiting for the vehicle to be offroad.'
|
||||
if (reason === 'vehicle_identity_unavailable') return 'This drive was reviewed on its own. Automatic saving is waiting for the car to identify itself.'
|
||||
if (reason === "Assessment cache full") return "FLM ran out of space in its review history. The latest analysis could not be saved; this does not mean your saved tune was erased."
|
||||
if (Object.hasOwn(REASONS, reason)) return REASONS[reason]
|
||||
@@ -415,6 +426,8 @@ export function tunerStatus(report, live = false, choiceLive = false, error = ""
|
||||
return { key: "off", tone: "muted", title: "Auto Learn is off", description: "No driving samples are being collected by the learner. Turn it on in steering settings to begin." }
|
||||
if (reportFresh && current?.status === 'fitting' && ['analyzing_last_completed_drive', 'checking_recorded_steering_recommendations'].includes(current.reason))
|
||||
return { key: 'fitting', tone: 'active', title: 'Analyzing your drive', description: learningReason(current.reason) + (offroadView(report)?.retained ? ' Earlier drive findings remain below while this analysis runs.' : '') }
|
||||
if (reportFresh && preference?.valid && preference.enabled && preference.parked && current?.reason?.startsWith('waiting_for_'))
|
||||
return { key: 'waiting-parked', tone: 'muted', title: 'Waiting to analyze your drive', description: learningReason(current.reason) }
|
||||
const route = reportFresh && (!preference || preference.parked) ? offroadView(report) : null
|
||||
if (route) {
|
||||
if (route.partial)
|
||||
|
||||
@@ -117,6 +117,11 @@ export const FlmPage = {
|
||||
},
|
||||
|
||||
connectionTone() { return this.error || !this.choiceLive ? 'muted' : this.preference?.enabled ? 'ready' : 'muted' },
|
||||
connectionState() {
|
||||
if (!this.choiceLive) return 'Waiting for vehicle status'
|
||||
if (this.preference.parked) return 'Parked'
|
||||
return this.currentApplied ? 'Learned tune in use' : 'Driving'
|
||||
},
|
||||
current() { return this.report?.current },
|
||||
preference() { return validLearningPreference(this.report?.preference) ? this.report.preference : null },
|
||||
choiceLive() { return !this.error && !!this.preference && Math.max(0, this.now - this.receivedAt) <= 2000 },
|
||||
@@ -392,7 +397,7 @@ export const FlmPage = {
|
||||
<p>{{ parameterLabel(findingDraft.parameter) }}: {{ dialPercent(findingDraft.target) }}</p><p>Use this value for your next drive. Auto Learn can keep improving this setting.</p>
|
||||
<div class="gx-dialog__actions"><button type="button" class="gx-btn gx-btn--tonal" :disabled="findingBusy" @click="findingDraft = null">Cancel</button>
|
||||
<button type="button" class="gx-btn" :disabled="findingBusy || !canReviewFindings" @click="acceptFinding">{{ findingPhase === 'checking' ? 'Checking…' : findingBusy ? 'Saving…' : 'Accept finding' }}</button></div></GxDialog>
|
||||
<div v-if="view !== 'plots'" class="gx-tuner__connection" role="status"><span class="gx-tuner__status-dot" :data-tone="connectionTone" aria-hidden="true"></span><span>{{ connectionLabel }}</span><span class="gx-tuner__connection-state">{{ currentApplied ? 'Learned tune in use' : preference?.parked ? 'Parked' : live ? 'Driving · use not confirmed' : 'State not confirmed' }}</span></div>
|
||||
<div v-if="view !== 'plots'" class="gx-tuner__connection" role="status"><span class="gx-tuner__status-dot" :data-tone="connectionTone" aria-hidden="true"></span><span>{{ connectionLabel }}</span><span class="gx-tuner__connection-state">{{ connectionState }}</span></div>
|
||||
<GxDialog v-if="manualResetRequested && manualState.pending" labelledby="manual-tune-confirm-title" @close="cancelManualReset"><h3 id="manual-tune-confirm-title">Reset manual tune?</h3><p>{{ manualState.pending.question }}</p><div class="gx-dialog__actions"><button type="button" class="gx-btn gx-btn--tonal" @click="cancelManualReset">Cancel</button><button type="button" class="gx-btn" @click="confirmManualReset">Reset</button></div></GxDialog>
|
||||
<nav class="gx-tuner__tabs" role="tablist" aria-label="Tuner views">
|
||||
<button v-for="tab in ['overview', 'tune', 'activity', 'plots']" :key="tab" type="button" role="tab" :id="'tuner-tab-' + tab" :aria-controls="'tuner-panel-' + tab" :aria-selected="view === tab" :tabindex="view === tab ? 0 : -1" @click="selectView(tab)" @keydown="tabKey">{{ tab === 'overview' ? 'Overview' : tab === 'tune' ? 'Your tune' : tab === 'activity' ? 'Activity' : 'Live plots' }}</button>
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "cbec5dade56a5ebe2eef2776858cbe0fd67a67ae2541268ae24580a7d3156482", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "78d3dd7d3c367905a043ae893bffccaf5c4a667a57eef39e0304216a914b73d6", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user