mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-07 18:15:49 +08:00
feat: wire Python backend session to PTT, add pm.vue debug logger
- Pass as top-level field in PTT requests so Whisper STT results are linked to the correct Python backend session - Add namespaced helper in pm.vue (info/warn/error/debug/group) controlled by localStorage PM_DEBUG flag; logs transmit/response cycles, TTS calls, flag/variable syncs, and fallback warnings - Log backend session creation context (flow, start state, vars, flags) in startMonitoring - Fix typo in text input hint: STT fails not PTT fails and fix: sync backend variables to frontend after each transmission The ATC say template was rendered using the frontend engine's local variable defaults (squawk '1234', hardcoded SID, etc.) instead of the authoritative values from the Python backend session. This caused the spoken clearance and the readback prompt to show different squawk codes. - After each backend transmission response, sync all response.variables into vars.value (same pattern already used for flags) - Prefer controller_say_rendered (pre-rendered by backend) over the raw template for TTS scheduling, eliminating any remaining dependency on local variable state for the ATC speech text
This commit is contained in:
@@ -295,8 +295,24 @@ export default function useCommunicationsEngine() {
|
||||
}
|
||||
|
||||
function createSnapshotFromTree(treeData: RuntimeDecisionTree): FlowSnapshot {
|
||||
const variables = { ...treeData.variables }
|
||||
const baseFlags = (treeData.flags && typeof treeData.flags === 'object') ? { ...treeData.flags } : {}
|
||||
// The Python backend serializes variables/flags as VariableDefinition/FlagDefinition objects
|
||||
// ({ name, type, initial, mutable_by }) rather than raw values. Unwrap them here so
|
||||
// template rendering gets the primitive value instead of [object Object].
|
||||
const rawVars = treeData.variables ?? {}
|
||||
const variables = Object.fromEntries(
|
||||
Object.entries(rawVars).map(([k, v]) => [
|
||||
k,
|
||||
v !== null && typeof v === 'object' && 'initial' in v ? (v as any).initial : v,
|
||||
])
|
||||
)
|
||||
const rawFlags = treeData.flags ?? {}
|
||||
const unwrappedFlags = Object.fromEntries(
|
||||
Object.entries(rawFlags).map(([k, v]) => [
|
||||
k,
|
||||
v !== null && typeof v === 'object' && 'initial' in v ? (v as any).initial : v,
|
||||
])
|
||||
)
|
||||
const baseFlags = typeof unwrappedFlags === 'object' ? unwrappedFlags : {}
|
||||
const stack = Array.isArray((baseFlags as any).stack) ? [...(baseFlags as any).stack] : []
|
||||
const flags: EngineFlags = {
|
||||
in_air: Boolean((baseFlags as any).in_air),
|
||||
|
||||
Reference in New Issue
Block a user