FrankenTerm

Native Event Bridge (push mode)

225 words1 min read4 subsectionsFrom the README at ft 0.15.21

On this page4
What push mode doesWhy this matters at scaleImplementationFallback

The default capture mode is poll: ft watch queries the mux for pane state every poll_interval_ms. A complementary push mode is available when the native event bridge is wired up.

What push mode does

The native event bridge subscribes to OS-level signals from the mux/GUI process: pane lifecycle events (created, exited, focus changed), PTY events (output ready), and visibility events. When a signal arrives, the watcher captures the affected pane immediately rather than waiting for the next poll tick.

Why this matters at scale

  • A 200-pane fleet polling every 200 ms generates 1000 mux queries/sec just for discovery. Push mode collapses that to ~zero for idle panes.
  • Latency from "agent produces output" to "ft has captured it" drops from ~half the poll interval to ~bridge round-trip + extraction time.
  • Capture is more accurate: poll-mode can miss bursts that started and finished within a poll window; push-mode catches them.

Implementation

native_events.rs houses the bridge. It forwards native events to the runtime over an asupersync mpsc channel. The emitter side lives in the GUI / mux process and ships through the codec layer. The receiver side in ft watch subscribes per-pane.

Fallback

When the native event bridge is unavailable (running against an older mux, or against a backend that doesn't expose push signals), the watcher transparently falls back to poll mode. ft doctor --json reports the effective bridge state.