Skip to content

No behavioral tests for tps-meter.tsx (319 lines of TUI plugin logic) #39

Description

@devinoldenburg

Location

plugins/tps-meter.tsx — entire file (319 lines)

Problem

The TUI plugin adapter has zero behavioral tests. It contains:

  • 6 event bus subscriptions: message.part.updated, message.part.removed, message.updated, message.removed, session.status, session.idle
  • setInterval-driven resampling at cfg.pollMs
  • Per-message GenerationTimer lifecycle: create, push, setTokens, cleanup
  • chars→tokens calibration via calibrateRatio (EWMA)
  • buildView composition from reactive state
  • onCleanup handlers (interval clearing, event unsubscription)
  • SolidJS reactive memo recomputing on every tick

The only existing verification is tools/verify-plugin.mjs, which confirms the module loads and registers a slot renderer — it does not test any behavior.

Missing Scenarios (minimum)

  1. Timer lifecycle: create on stream start, push tokens through streaming, setTokens on completion, remove on message removal
  2. Ratio calibration convergence across multiple messages
  3. Event handler error resilience (malformed events should not corrupt state)
  4. Cross-session isolation (events from session A must not contaminate session B)
  5. Concurrent streaming messages (two assistant messages streaming simultaneously)
  6. Cleanup verification (onCleanup removes intervals and unsubscribes events)

Impact

The most complex file in the codebase has no regression protection. Any change to event wiring, timer lifecycle, or reactive memo can silently break runtime behavior.

Severity

High — no automated protection for the runtime integration layer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions