| 272 | monitoring_active = False |
| 273 | |
| 274 | def console_log_handler(msg: ConsoleMessage) -> None: |
| 275 | nonlocal saw_audio_buffered, saw_audio_flushed |
| 276 | nonlocal saw_cpp_received, saw_cpp_consumed |
| 277 | nonlocal saw_drag_drop_load, saw_script_processor |
| 278 | nonlocal vibe_log_count, last_vibe_log_time |
| 279 | nonlocal worker_audio_msg_count, last_worker_audio_time |
| 280 | nonlocal cpp_output_count, last_cpp_output_time |
| 281 | text = msg.text |
| 282 | all_console_logs.append(f"[{msg.type}] {text}") |
| 283 | |
| 284 | # Track worker audio messages |
| 285 | if "audio_samples" in text: |
| 286 | worker_audio_msg_count += 1 |
| 287 | last_worker_audio_time = time.time() |
| 288 | |
| 289 | # Track any C++ output (has timestamps like "1.2s" prefix or known patterns) |
| 290 | if any( |
| 291 | kw in text |
| 292 | for kw in [">>>", "Vibe:", "AnimartrixRing:", "setup complete"] |
| 293 | ): |
| 294 | cpp_output_count += 1 |
| 295 | last_cpp_output_time = time.time() |
| 296 | |
| 297 | # Print DBG/LOOP/AR_/FLL messages from C++ loop |
| 298 | if ( |
| 299 | "DBG" in text |
| 300 | or "LOOP" in text |
| 301 | or "AR_" in text |
| 302 | or "VIBE_CB" in text |
| 303 | or "FC #" in text |
| 304 | or "FLL" in text |
| 305 | or "WASM_FRAME" in text |
| 306 | ): |
| 307 | console.print(f"[bold yellow] >> {text}[/bold yellow]") |
| 308 | |
| 309 | # During monitoring, print frame errors or worker errors |
| 310 | if monitoring_active and "error" in text.lower(): |
| 311 | console.print( |
| 312 | f"[bold red] !! MONITORING ERROR: {text[:200]}[/bold red]" |
| 313 | ) |
| 314 | |
| 315 | if msg.type in ("error", "warn"): |
| 316 | browser_errors.append(f"[{msg.type}] {text}") |
| 317 | |
| 318 | # Worker-side diagnostics (our new buffered audio code) |
| 319 | if "First audio sample buffered" in text: |
| 320 | saw_audio_buffered = True |
| 321 | console.print( |
| 322 | "[green] >> Worker: First audio sample buffered[/green]" |
| 323 | ) |
| 324 | if "First audio sample flushed to WASM" in text: |
| 325 | saw_audio_flushed = True |
| 326 | console.print( |
| 327 | "[green] >> Worker: First audio sample flushed to WASM[/green]" |
| 328 | ) |
| 329 | |
| 330 | # C++ side diagnostics |
| 331 | if "WasmAudioInput: First audio block received from JS" in text: |