feat(live-atc): forward aircraft position, un-throttle bridge polling

- NormalizedTelemetry carries lat/lon (0/0 no-GPS guard, position in the
  change-detection signature) so the backend can derive distance triggers
- bridge polling moves from setInterval to a Worker tick: with the sim in the
  foreground the /live-atc tab is backgrounded and Chrome throttles plain
  intervals to ~1/min — telemetry-driven ATC lagged behind the silence fallback

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
itsrubberduck
2026-07-18 20:48:09 +02:00
parent cadc0aefb6
commit db1155c8c9
4 changed files with 52 additions and 9 deletions

View File

@@ -38,6 +38,26 @@ test('normalizeBridgeTelemetry returns null for non-object input', () => {
assert.equal(normalizeBridgeTelemetry(null), null)
})
test('normalizeBridgeTelemetry forwards the position', () => {
const result = normalizeBridgeTelemetry({
PLANE_ALTITUDE: 3500,
PLANE_LATITUDE: 50.02671,
PLANE_LONGITUDE: 8.55835,
})
assert.equal(result?.lat, 50.02671)
assert.equal(result?.lon, 8.55835)
})
test('normalizeBridgeTelemetry drops the 0/0 no-GPS default position', () => {
const result = normalizeBridgeTelemetry({
PLANE_ALTITUDE: 3500,
PLANE_LATITUDE: 0,
PLANE_LONGITUDE: 0,
})
assert.equal(result?.lat, undefined)
assert.equal(result?.lon, undefined)
})
test('telemetrySignature is stable under sub-threshold jitter', () => {
const a = telemetrySignature({ altitude_ft: 3500, ias_kts: 140, on_ground: false })
const b = telemetrySignature({ altitude_ft: 3540, ias_kts: 141, on_ground: false })
@@ -49,3 +69,9 @@ test('telemetrySignature changes on a meaningful altitude change', () => {
const b = telemetrySignature({ altitude_ft: 4200, on_ground: false })
assert.notEqual(a, b)
})
test('telemetrySignature changes as the aircraft moves (~0.6 nm)', () => {
const a = telemetrySignature({ altitude_ft: 3500, lat: 50.0, lon: 8.0 })
const b = telemetrySignature({ altitude_ft: 3500, lat: 50.02, lon: 8.0 })
assert.notEqual(a, b)
})