Skip to content

feat(editor): clear stale feedback on edit + debounced live validation (#102, #100) - #108

Merged
falbany merged 2 commits into
feat/yaml-config-editorfrom
fix/editor-clear-and-live-validation
Nov 4, 2026
Merged

falbany merged 2 commits into
feat/yaml-config-editorfrom
fix/editor-clear-and-live-validation

Conversation

@falbany

@falbany falbany commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Closes #102, closes #100 (sub-issues of the config editor #95). Grouped per the review plan: the clear-on-edit fix is the first lines of the same document-change handler the debounce extends.

Issue #102 — editing clears stale feedback

The CodeMirror update listener now drops the status banner and issue list on every doc change — feedback can never outlive the content it described.

Issue #100 — debounced live validation

  • One deferred validation cycle 800 ms after the last change (debounce-on-edit, deliberately not a fixed 2 s poll: no idle traffic, no lag behind the last keystroke).
  • Rapid typing coalesces (pending timer canceled + rescheduled).
  • No-op elision: text identical to the last validation request is skipped; nothing runs while the compliance gate or Save As dialog is parked (no modal churn).
  • In-flight coexistence: a validation still flying at fire time makes the schedule reschedule — the latest text is always validated exactly once after landing.
  • Explicit Test button: cancels the pending timer, validates immediately.
  • Hygiene: pending timers are canceled on view destroy/unmount (found via the TDD round — a leaked timer polluted a pre-existing test's mock counts: the classic "5 instead of 2" smoke).
  • No backend change.

Verification

  • TDD RED: 5/6 new tests failed for the right reasons; the cancel-guard test passed vacuously pre-implementation and is kept/labelled as a regression pin.
  • GREEN: ConfigEditorModal.test.tsx 29/29 · full web suite 223/223 (14 files) · tsc -b clean · pre-commit hooks green.
  • Python untouched; dist/ intentionally not rebuilt here to avoid conflicts with open PR style(editor): solid VSCode-style CodeMirror theme + bordered editor card (#98, #99) #107 (also touches dist/) — the branch that merges LAST onto feat/yaml-config-editor should re-run the vite build per repo convention.

Live behavior test (manual)

Edit → stop typing → ~800 ms later the banner updates from "validation failed…" to a fresh "Configuration is valid." without touching Test.

f.albany and others added 2 commits November 4, 2026 14:09
#102 #100)

One PR per the review plan: the clearing fix (#102) is the first three
lines of the same update that then prolongs into live validation
(#100) — splitting them would publish a misleading intermediate state.

## Issue #102 — editing clears stale feedback

The document-change listener now also drops `status` and `issues` the
moment the doc changes: a Test/Save banner or issue list can never
outlive the content it described.

## Issue #100 — debounced live validation

`VALIDATION_DEBOUNCE_MS = 800` (deliberately not a fixed 2s poll):

- Every doc change schedules one deferred `Test` cycle 800ms after the
  last change; rapid typing coalesces (pending timer is canceled and
  re-scheduled).
- No-ops elided: text identical to the last validation request
  (`lastValidatedTextRef`) is not re-validated; nothing runs while the
  compliance gate or the Save As dialog is parked (`parkedRef`).
- In-flight coexistence: if a validation round trip is still flying at
  fire time, the schedule RESCHEDULES instead of disappearing — the
  latest text is validated once it lands.
- The explicit Test button cancels the pending timer and validates
  immediately (records its text in the dedupe ref like every cycle).
- Hygiene: pending timers are canceled on view destroy/unmount — a
  pre-existing failing test (`test_save_invalid_shows_gate_with_force_option`,
  watch-listed incl. 5 spurious validate calls from just such leaked
  timers) proved the regression risk; the TDD round surfaced and fixed it.
- No backend change: `POST /api/config/validate` is stateless.

## TDD evidence

- RED: 5 of 6 new tests failed for the right reasons (no clearing, no
  debounce timing, no gate skip, no in-flight re-check). The sixth
  (`test_explicit_test_cancels_pending_debounce`) passed vacuously and
  only becomes a true guard post-implementation — kept as a regression
  pin, noted honestly.
- Two test-side bugs fixed during the cycle themselves: clawed the
  coalesce-timing arithmetic, scoped the exact Save button name.
- GREEN: ConfigEditorModal.test.tsx 29/29, full web suite 223/223
  (14 files), `tsc -b` clean, pre-commit hooks green.
- `dist/` intentionally NOT rebuilt: open PR #107 rebuilds it too;
  the last branch merged onto feat/yaml-config-editor should re-run
  vite build (CI does per repo packaging hook).

Closes #102, closes #100
@falbany
falbany merged commit 507d056 into feat/yaml-config-editor Nov 4, 2026
1 check passed
falbany pushed a commit that referenced this pull request Nov 4, 2026
… dist

The manual merge of PRs #107 + #108 dropped the closing chunk of the
live-validation describe block in ConfigEditorModal.test.tsx: the final
test never closed (`});` for itself and for its describe) and the
"editor chrome" comment block lost its `/**` opening, leaving an
orphaned ` * ...` surface that stopped the whole file from parsing.

Consequences: `npm run build` (tsc) failed with TS1005/TS1434 syntax
errors from line 910 on (found by running src/profiles/web/build.py
--force as instructed), so no dist refresh could ship.

Repairs:
- Restored the missing `});`/`});` closing the
  test_live_validation_skipped_while_gate_parked test and the
  "live validation (issues #102/#100)" describe, and re-opened the
  `/**` block comment of the chrome describe.
- Rebuilt dist from the merged tree (the abort of the local conflicted
  dist merge left this branch needing a regeneration anyway).

Verification: build.py --force SUCCESS; vitest 226/226 (14 files).

No merge body changes otherwise.
@falbany
falbany deleted the fix/editor-clear-and-live-validation branch November 4, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant