Skip to Content
ftui-runtimeProgramConfig

ProgramConfig

ProgramConfig is the runtime’s single configuration struct. You build one with ProgramConfig::default() (or a convenience constructor like fullscreen() / inline(u16)), chain with_* methods, and hand it to Program::with_config.

File: crates/ftui-runtime/src/program.rs:2360.

The struct (abbreviated)

crates/ftui-runtime/src/program.rs
pub struct ProgramConfig { pub screen_mode: ScreenMode, pub ui_anchor: UiAnchor, pub budget: FrameBudgetConfig, pub diff_config: RuntimeDiffConfig, pub evidence_sink: EvidenceSinkConfig, pub render_trace: RenderTraceConfig, pub frame_timing: Option<FrameTimingConfig>, pub conformal_config: Option<ConformalConfig>, pub locale_context: LocaleContext, pub poll_timeout: Duration, pub immediate_drain: ImmediateDrainConfig, pub resize_coalescer: CoalescerConfig, pub resize_behavior: ResizeBehavior, pub forced_size: Option<(u16, u16)>, pub mouse_capture_policy: MouseCapturePolicy, pub bracketed_paste: bool, pub focus_reporting: bool, pub kitty_keyboard: bool, pub persistence: PersistenceConfig, pub inline_auto_remeasure: Option<InlineAutoRemeasureConfig>, pub widget_refresh: WidgetRefreshConfig, pub effect_queue: EffectQueueConfig, pub guardrails: GuardrailsConfig, pub intercept_signals: bool, pub tick_strategy: Option<TickStrategyKind>, pub runtime_lane: RuntimeLane, pub rollout_policy: RolloutPolicy, }

All fields are pub — you can poke them directly — but the idiomatic path is the builder. Each with_* below returns Self, so the chain reads left to right.

Constructors

ConstructorShapeNotes
ProgramConfig::default()Inline mode, 4 UI rows, bottom anchor, mouse-auto, bracketed paste on.Safe default.
ProgramConfig::fullscreen()Alt-screen, all else default.For traditional TUI apps.
ProgramConfig::inline(h)Inline mode with fixed UI height h.Shell-embedded mode.
ProgramConfig::inline_auto(min, max)Inline with auto-remeasure between min..=max.Height responds to content.

Builder reference

Method names and signatures come straight from program.rs. Types elided are from the runtime’s public re-exports.

MethodSetsTypical value
with_mouse()MouseCapturePolicy::OnForce mouse on.
with_mouse_enabled(bool)On or OffExplicit toggle.
with_mouse_capture_policy(policy)MouseCapturePolicyAuto / On / Off.
with_budget(cfg)FrameBudgetConfigPer-frame p99 cap.
with_diff_config(cfg)RuntimeDiffConfigDiff strategy config.
with_evidence_sink(cfg)EvidenceSinkConfigJSONL diagnostics.
with_render_trace(cfg)RenderTraceConfigPer-frame trace recorder.
with_frame_timing(cfg)Option<FrameTimingConfig>Attach a timing sink.
with_conformal_config(cfg)ConformalConfigFrame-time risk gating.
without_conformal()NoneDisable risk gating.
with_locale_context(ctx)LocaleContextExplicit locale bundle.
with_locale(locale)Wraps a Locale into context.Convenience.
with_widget_refresh(cfg)WidgetRefreshConfigBudgeted widget selection.
with_effect_queue(cfg)EffectQueueConfigTask backend + queue depth.
with_resize_coalescer(cfg)CoalescerConfigBOCPD-backed resize policy.
with_resize_behavior(behavior)ResizeBehaviorThrottled (default) or Immediate.
with_forced_size(w, h)Option<(u16, u16)>Ignore real resize events.
without_forced_size()Clear override.
with_legacy_resize(bool)Sets Immediate when true.Migration toggle.
with_persistence(cfg)PersistenceConfigState registry + auto-save.
with_registry(arc)Arc<StateRegistry>Shortcut for an existing registry.
with_inline_auto_remeasure(cfg)InlineAutoRemeasureConfigVoI-driven height updates.
without_inline_auto_remeasure()Clear.
with_signal_interception(bool)intercept_signalsSIGINT/SIGTERM/SIGHUP handling.
with_guardrails(cfg)GuardrailsConfigMemory + queue safety limits.
with_immediate_drain(cfg)ImmediateDrainConfigEvent-burst drain policy.
with_tick_strategy(kind)TickStrategyKindUniform, Predictive, Custom
with_lane(lane)RuntimeLaneSee lanes.
with_rollout_policy(policy)RolloutPolicyOff / Shadow / Enabled.
with_env_overrides()Reads FTUI_RUNTIME_LANE and FTUI_ROLLOUT_POLICY.Apply last in a chain.

with_env_overrides (at program.rs:2728) calls RuntimeLane::from_env and RolloutPolicy::from_env; unrecognized values emit a tracing::warn! and leave the current value alone.

Typical setups

main.rs
use ftui::prelude::*; let config = ProgramConfig::default() .with_mouse_capture_policy(MouseCapturePolicy::Auto) .with_tick_strategy( ftui_runtime::tick_strategy::TickStrategyKind::Uniform { divisor: 5 } ); Program::with_config(model, config)?.run()

Environment variables

Several fields are overridable from the environment so operators can change behaviour without a rebuild. Apply them by ending your chain with .with_env_overrides().

VariableField overridden
FTUI_RUNTIME_LANEruntime_lane (legacy/structured/asupersync) — read by RuntimeLane::from_env.
FTUI_ROLLOUT_POLICYrollout_policy (off/shadow/enabled) — read by RolloutPolicy::from_env.
OTEL_* / FTUI_OTEL_HTTP_ENDPOINTOTLP export — see telemetry.

Defaults table

Defaults live at program.rs:2433 and are worth remembering when you are reading a config diff:

FieldDefault
screen_modeInline { ui_height: 4 }
ui_anchorUiAnchor::Bottom
poll_timeout100 ms
resize_behaviorThrottled
mouse_capture_policyAuto (off inline, on alt-screen)
bracketed_pastetrue
focus_reportingfalse
kitty_keyboardfalse
intercept_signalstrue
runtime_laneStructured
rollout_policyOff

Pitfalls

Call with_env_overrides() last. It mutates already-built state. If you call it early and then set .with_lane(...) afterwards, your programmatic value wins — exactly the opposite of what operators usually expect.

forced_size ignores real resizes. Useful in tests and headless demos; disastrous in a real terminal, because the UI will not reflow when the window is resized. Do not set it in production paths.

Cross-references