refactor: remove legacy demo code, integrate metrics via pipeline context

- Remove ~700 lines of legacy code from app.py (run_demo_mode, run_pipeline_demo,
  run_preset_mode, font picker, effects picker)
- HUD now reads metrics from pipeline context (first-class citizen) with fallback
  to global monitor for backwards compatibility
- Add validate_signal_flow() for PureData-style type validation in presets
- Update MicSensor documentation (self-contained, doesn't use MicMonitor)
- Delete test_app.py (was testing removed legacy code)
- Update AGENTS.md with pipeline architecture documentation
This commit is contained in:
2026-03-16 15:41:10 -07:00
parent b27ddbccb8
commit f43920e2f0
6 changed files with 165 additions and 1047 deletions

View File

@@ -1,4 +1,3 @@
from engine.effects.performance import get_monitor
from engine.effects.types import EffectConfig, EffectContext, EffectPlugin
@@ -8,15 +7,34 @@ class HudEffect(EffectPlugin):
def process(self, buf: list[str], ctx: EffectContext) -> list[str]:
result = list(buf)
monitor = get_monitor()
# Read metrics from pipeline context (first-class citizen)
# Falls back to global monitor for backwards compatibility
metrics = ctx.get_state("metrics")
if not metrics:
# Fallback to global monitor for backwards compatibility
from engine.effects.performance import get_monitor
monitor = get_monitor()
if monitor:
stats = monitor.get_stats()
if stats and "pipeline" in stats:
metrics = stats
fps = 0.0
frame_time = 0.0
if monitor:
stats = monitor.get_stats()
if stats and "pipeline" in stats:
frame_time = stats["pipeline"].get("avg_ms", 0.0)
frame_count = stats.get("frame_count", 0)
if metrics:
if "error" in metrics:
pass # No metrics available yet
elif "pipeline" in metrics:
frame_time = metrics["pipeline"].get("avg_ms", 0.0)
frame_count = metrics.get("frame_count", 0)
if frame_count > 0 and frame_time > 0:
fps = 1000.0 / frame_time
elif "avg_ms" in metrics:
# Direct metrics format
frame_time = metrics.get("avg_ms", 0.0)
frame_count = metrics.get("frame_count", 0)
if frame_count > 0 and frame_time > 0:
fps = 1000.0 / frame_time
@@ -44,11 +62,17 @@ class HudEffect(EffectPlugin):
f"\033[2;1H\033[38;5;45mEFFECT:\033[0m \033[1;38;5;227m{effect_name:12s}\033[0m \033[38;5;245m|\033[0m {bar} \033[38;5;245m|\033[0m \033[38;5;219m{effect_intensity * 100:.0f}%\033[0m"
)
from engine.effects import get_effect_chain
# Try to get pipeline order from context
pipeline_order = ctx.get_state("pipeline_order")
if pipeline_order:
pipeline_str = ",".join(pipeline_order)
else:
# Fallback to legacy effect chain
from engine.effects import get_effect_chain
chain = get_effect_chain()
order = chain.get_order()
pipeline_str = ",".join(order) if order else "(none)"
chain = get_effect_chain()
order = chain.get_order() if chain else []
pipeline_str = ",".join(order) if order else "(none)"
hud_lines.append(f"\033[3;1H\033[38;5;44mPIPELINE:\033[0m {pipeline_str}")
for i, line in enumerate(hud_lines):