Skip to content

fix: validate non-blank rows and localize todo_list human-input field (#2079) - #2243

Merged
yannickmonney merged 1 commit into
mainfrom
tale/xs71v73kjs4wd71c07ftgcq2vh89acnm
Jun 29, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
tale/xs71v73kjs4wd71c07ftgcq2vh89acnm

Conversation

@larryro

@larryro larryro commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Closes #2079

Problem

Two defects in the request_human_input todo_list field:

  1. 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.
  2. 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).
  • bunx vitest --run lib/i18n/messages.test.ts (locale parity) — green.
  • bunx vitest --run --project client for the affected components — green.
  • bunx tsc --noEmit and bunx oxlint --type-aware — green.

@larryro

larryro commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Desk Review — PR #2243 (fixes #2079)

Verdict: READY TO MERGE.

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.
  • Tests I ran locally on the branch:
    • bunx vitest --run --project client app/features/chat/components/human-input-fields.test.ts → 5 passed
    • bunx vitest --run --project server lib/i18n/messages.test.ts (locale parity, enforce mode) → 23 passed

Defect 1 — blank-row validation (confirmed fixed)

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 + return before 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)

  1. 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.
  2. 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.
  3. Non-required todo_list fields with minItems > 0 don't enforce minItems at submit (the loop continues on non-required) — out of scope for Bug: request_human_input todo_list field — required validation passes on all-blank rows, and the field UI is hardcoded English #2079 and consistent with how all field types treat required.
  4. No PR-specific manual QA guide for this user-visible change (DoD item), not marked N/A.

None of these affect correctness of the reported fix. Approving.

@yannickmonney
yannickmonney merged commit 369c1b7 into main Jun 29, 2026
84 of 87 checks passed
@yannickmonney
yannickmonney deleted the tale/xs71v73kjs4wd71c07ftgcq2vh89acnm branch June 29, 2026 17:21
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.

Bug: request_human_input todo_list field — required validation passes on all-blank rows, and the field UI is hardcoded English

2 participants