Skip to content

Task Issue 1376 ReqEdit ExpectedCoverage Config Gate

opencode-agent edited this page Sep 16, 2026 · 1 revision

Task — Issue #1376: reqEdit expected-coverage configuration gates + free numeric input

Issue: #1376 Status: IMPLEMENTED (2026-09-16) — branch task/issue-1376

The gap

The modern Requirement Editor (gui/templates/requirements/reqEdit.html, BFF api/reqedit) dropped three legacy expected-coverage behaviours:

  1. The legacy screen is gated by the global config req_cfg->expected_coverage_management (config.inc.php:1666, default ENABLED). When disabled, the whole Expected Coverage field is not rendered (reqEdit.tpl:345).
  2. The field is additionally gated per requirement type by req_cfg->type_expected_coverage (reqCommands.class.php:33-41; default in cfg/const.inc.php:759: type_expected_coverage = [TL_REQ_TYPE_INFO => false], i.e. type Informational/"1" disabled out of the box). Disabled type → stored value 0 (reqEdit.tpl:69-91).
  3. The legacy field is a free numeric input accepting any positive integer (7, 12, …) persisted as-is (reqEdit.tpl:353-355). The modern screen had a fixed dropdown [1,2,3,5,10] and save() forced max(1, intval(...)).

The type-change toggle (configure_attr, reqEdit.tpl:188-213) was also missing.

Modern implementation

BFF api/reqedit/index.php

  • reqOptions() exposes expectedCoverageManagement (tolerant boolishConfig(), default false when absent, matching api/requirements + legacy-if-absent) and expectedCoverageByType (type → 1|0, absent type = enabled).
  • effectiveExpectedCoverage($type, $posted): management disabled → 0; type disabled → 0; else posted positive int as-is.
  • create/update call-sites unchanged (still receive an int).

Frontend reqEdit.html

  • Fixed <select> replaced by free numeric text <input id="reqExpectedCoverage" maxlength="6">.
  • #expectedCoverageCol hide/show via coverageManagementEnabled() / coverageEnabledForType() / currentCoverageEnabled() / refreshCoverageField(), run on load and on #reqType change (legacy configure_attr parity).
  • save() validates number > 0 when visible (reqe.warningExpectedCoverage(_range)), sends 0 when hidden (legacy force-0, not max(1,...)).
  • read-only mode still disables the input via setEditable().

i18n — reqe.warningExpectedCoverage + reqe.warningExpectedCoverageRange in all 10 bundles (en/ro/de/es/fr/it/ja/pt/ru/zh).

Screenshots

Edit mode — free numeric coverage input

Per-type gate — field hidden for Informational/type-1

Validation warning — non-numeric value

Verification

Case Result
Options: expectedCoverageManagement:true, map {1:0,2:1,...,7:1} PASS
Edit: free input carries value 7 PASS
Arbitrary edit value 12 → DB 12 PASS
Create ?spec_id=2: coverage 15 → new req stored 15 PASS
Type-Info requirement loads with field hidden PASS
Type switch toggles visibility (configure_attr) PASS
Hidden-type save persists 0 PASS
Validation abc/0 → localized warnings, no save PASS
Management DISABLED (temp) → hidden + save=0; default restored & re-verified PASS
Regression: general save, version-copy (v2 12), Event Viewer clean PASS

Follow-up

reqSpecMgmt modal still uses a fixed min=1 coverage input ignoring both gates — filed as #1516 (task).

Clone this wiki locally