Skip to content

feat(editor): debounced live validation while typing #100

Closed

Description

@falbany

Follow-up to the YAML config editor (#95), approved in the brainstorming session (2026-11-04). Builds on the "clear stale feedback on edit" fix; visually lands with the status-bar + Problems panel issue.

Problem

Validation requires an explicit Test click. Users learn too late that their edit broke the config.

Proposed solution

Debounced live validation on edit — deliberately not a fixed 2-second poll (polling wastes requests on an idle editor and lags behind the last change):

  • On docChanged, schedule validation 800 ms after the last change (debounce resets on further typing), and only when the document differs from the last validated text.
  • Reuse the existing dispatch machinery: the debounce timer fires runToolbarAction("test", ...), so the in-flight dedupe (inFlightActionsRef) and the stale-seq guards already prevent duplicate requests and superseded results landing.
  • The explicit Test button cancels any pending timer and validates immediately (current behavior preserved).
  • Transient "validating…" state while a cycle is in flight; never blocks Apply/Save — they still run their own full server-side validation as today.
  • Skip auto-validation while the compliance gate or the Save As dialog is parked behind the editor, to avoid confusing motion behind a modal.
  • No backend change: POST /api/config/validate is stateless and cheap (ConfigReader.from_content).

Acceptance criteria

  • After the user stops typing for ~800 ms, validity feedback updates automatically.
  • Rapid typing coalesces into one validation request.
  • Undo/redo/revert/new template load trigger a revalidation cycle.
  • Test button still forces immediate validation.

Tests

  • ConfigEditorModal.test.tsx with fake timers:
    • debounce fires exactly once 800 ms after the last change;
    • additional typing resets the timer;
    • an in-flight request is not doubled (dedupe guard);
    • a superseded result is dropped (stale-seq, already covered — add the timer path).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementfrontend

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions