You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: validate non-blank rows and localize todo_list human-input field (#2079) - #2243
Two defects in the request_human_inputtodo_list field:
Required validation passes on all-blank rows.TodoListFieldInput always seeds a row and serializes via JSON.stringify, so formValues[label] is a non-empty string (e.g. [{"id":"…","content":""}]) even when every row is blank. The required-field check in handleSubmit fell through to the generic typeof value === 'string' && !value.trim() branch, which sees a non-empty string and wrongly passes.
The field UI is hardcoded English with no i18n (placeholder, item aria-label, remove-item title, and the "Add item" button).
Fix
Validation: added an explicit todo_list case to the required-field loop in handleSubmit. It counts rows with real (non-whitespace) content via a new exported countFilledTodoRows helper and requires at least max(1, minItems) filled rows, surfacing a localized error otherwise.
i18n:TodoListFieldInput now uses useT('humanInputRequest'). The four hardcoded strings became keys with {n}/{label} interpolation (the agent-supplied {label} stays verbatim), plus two new validation-error keys. Translated across en / de / fr (de-CH is a sparse regional override that falls back to de).
Tests
New human-input-fields.test.ts covers parseTodoList and countFilledTodoRows (all-blank → 0, whitespace → 0, mixed content counted, invalid → 0).
Reviewed the whole implementation (not just the diff) over two rounds of fan-out review with independent confirmation of every load-bearing claim.
CI & tests
CI: all green — every required check passes (Type check, Lint, Format, Unit, UI, Browser, Storybook, Opengrep, Build platform, all 16 Playwright (platform) shards, etc.). The only non-pass jobs are skipping (fork-PR / conditional: Trivy, Smoke test (fork PR), Web/Docs container test) — not failures.
New todo_list branch in handleSubmit (human-input-request-card.tsx:350-369) counts non-whitespace rows via the new exported countFilledTodoRows and requires max(1, minItems). Traced end-to-end: an untouched required field serializes to [{"id":"…","content":""}] → countFilledTodoRows = 0 → 0 < 1 → setError + returnbefore the submit mutation. The branch intercepts todo_list before the generic else that previously let the non-empty string pass. Rows with real content (≥1) proceed normally — no false-positive blocking. countFilledTodoRows/parseTodoList are robust to '', malformed JSON, empty array, and non-string content (no throw path).
Defect 2 — hardcoded English (confirmed fixed)
TodoListFieldInput now uses useT('humanInputRequest'); all four named strings (placeholder, item aria-label, remove-item title, "Add item") are localized with {n}/{label} interpolation. Keys added to en/de/fr under the correct humanInputRequest namespace; ICU placeholder tokens are identical across locales. de-CH is a sparse regional override that falls back to de (parity test treats - locales as exempt). The agent-supplied field label is intentionally passed through verbatim.
Non-blocking notes (optional, do not block merge)
errorTodoListMinItems ("Please add at least {count} items") is a flat string rather than the repo's usual ICU plural. Currently harmless — it only renders when threshold > 1 (integer minItems), so count is always ≥ 2 and never yields "1 items". Consider ICU plural for future-proofing.
No test covers the minItems threshold / errorTodoListMinItems-vs-errorTodoListRequired selection branch (that logic lives only in handleSubmit, not in the tested helper). The sibling validation branches (errorSelectRequired, errorFillRequiredFields) are also untested, so this is consistent with the component's existing bar.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2079
Problem
Two defects in the
request_human_inputtodo_listfield:TodoListFieldInputalways seeds a row and serializes viaJSON.stringify, soformValues[label]is a non-empty string (e.g.[{"id":"…","content":""}]) even when every row is blank. The required-field check inhandleSubmitfell through to the generictypeof value === 'string' && !value.trim()branch, which sees a non-empty string and wrongly passes.aria-label, remove-itemtitle, and the "Add item" button).Fix
todo_listcase to the required-field loop inhandleSubmit. It counts rows with real (non-whitespace) content via a new exportedcountFilledTodoRowshelper and requires at leastmax(1, minItems)filled rows, surfacing a localized error otherwise.TodoListFieldInputnow usesuseT('humanInputRequest'). The four hardcoded strings became keys with{n}/{label}interpolation (the agent-supplied{label}stays verbatim), plus two new validation-error keys. Translated acrossen/de/fr(de-CHis a sparse regional override that falls back tode).Tests
human-input-fields.test.tscoversparseTodoListandcountFilledTodoRows(all-blank → 0, whitespace → 0, mixed content counted, invalid → 0).bunx vitest --run lib/i18n/messages.test.ts(locale parity) — green.bunx vitest --run --project clientfor the affected components — green.bunx tsc --noEmitandbunx oxlint --type-aware— green.