Skip to content

Add schema and validation for config.json #259

Description

@jongio

As a Dispatch user who edits config.json directly for advanced settings like views, schemes, and keybindings, I want first-class validation and editor hints so I can confidently customize the app without discovering mistakes only after the TUI starts.

flowchart TD
    A[Edit config.json] --> B[Run dispatch config validate]
    B --> C{Valid?}
    C -->|yes| D[Launch Dispatch with confidence]
    C -->|no| E[Show field-specific fixes]
Loading

Problem

internal/config/config.go defines many structured settings, while cmd/dispatch/config.go exposes only scalar list/get/set/edit/path operations. Advanced users must hand-edit maps and arrays such as keybindings, views, schemes, aliases, tags, and exclusions without a JSON Schema or a standalone validation command. The README and web/src/pages/config.astro document options, but they can drift from the Go structs and validators.

Proposed solution

Add dispatch config validate [--json] [--path <file>] and dispatch config schema in cmd/dispatch/config.go, backed by reusable metadata from internal/config/config.go. The validator should load the target config, run the existing migration/sanitize/validation paths, report unknown fields and invalid enum/duration/keybinding values with actionable paths, and include tests in cmd/dispatch/config_test.go and internal/config/config_test.go. Publish the generated schema in docs and reference it from README and web/src/pages/config.astro so editors can provide completions.

User impact

Users get fast feedback before restarting Dispatch, contributors have one source of truth for config docs, and support/debugging gets easier because invalid customizations can be reproduced with a single command.

Acceptance criteria

  • dispatch config validate exits 0 for a valid config and non-zero with clear diagnostics for invalid JSON, unknown keys, invalid enums, bad durations, and keybinding conflicts.
  • dispatch config validate --json emits machine-readable diagnostics suitable for scripts and CI.
  • dispatch config schema emits a JSON Schema covering documented config keys, nested views, schemes, and keybindings action names.
  • README and web/src/pages/config.astro link to the schema/validation workflow and mention editor integration.
  • Unit tests cover success, malformed config, invalid enum values, invalid named views, and keybinding collision cases.

Complexity

M

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestideaFeature idea from the idea pipeline

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions