Guide-Adding-New-Field-Types

Guide: Adding a New Field Type to the TUI

When extending the configuration schema, touch these layers in order so the new field stays coherent across pour-design-spec and the running app:

  1. Config Layer (src/config.rs): Add the new variant to the FieldType enum. Update validate() if the field requires specific properties, like static_select requiring options.
  2. State Layer (src/app.rs): Update App::init_form() to handle any default state population for the new field, and App::validate_form() if it requires custom validation logic before submission.
  3. Presentation Layer (src/tui/form.rs): Add the render logic to render(). Determine if it renders inline like text or requires a popup overlay like selects.
  4. Input Handling (src/tui/form.rs): Update the KeyEvent matcher to handle how the user interacts with this specific field when it is active.
  5. Output Layer (src/output/mod.rs): Ensure the field's data structure is properly routed to either frontmatter or body targets during submission.

For the current TUI shape and event routing, see System-Architecture-Overview and sprint-5-tui-report.