mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 18:47:42 +01:00
Found by a code-health audit; these are the two findings that were verifiably
BREAKING something rather than merely untidy.
── The widget dropped reports ────────────────────────────────────────────────
/api/feedback validates with zod and, on ANY failure, returns the single string
"Invalid submission" naming no field. The widget renders that and the visitor's
report is gone.
Of the five string fields it sends, three were clamped to exactly the route's
`.max()` and two were not:
url .slice(0, 1000) matches max(1000) ✅
pageTitle .slice(0, 300) matches max(300) ✅
suggestion textarea maxLength = MAX_LEN 2000 ✅
contact (unclamped) server max(200) ✗
page (unclamped) server max(300) ✗
The contact <input> had no `maxLength` either, so a visitor pasting a signature
into "Name / email" — or anyone on a page with a very long pathname — lost
everything they had typed, with no field named and nothing logged. This is the
only surface strangers on other people's sites touch.
The author plainly knew the rule: MAX_SHOT_CHARS carries the comment "ingest
caps the data URL at 600k chars". It was applied 3 times of 5, which is what a
hand-mirrored constant does.
scripts/test/widget-server-caps-mirror.ts now reads the caps out of the zod
schema and asserts the widget clamps to the same numbers, so the two cannot
drift again. Mutation-proven: drop the contact clamp -> 8 passed, 1 failed.
── A tap target 16px under the floor ─────────────────────────────────────────
ProjectProvision's chip carried `ui-btn-chip gap-1.5 px-3 py-1.5 text-xs`.
`ui-btn-chip` is NOT in the coarse-pointer floor list in globals.css — it
reaches 44px through its own `py-3`. Overriding that to `py-1.5 text-xs`
without adding `ui-tap` produced roughly 28px on a phone, visibly shorter than
the seven identical sibling chips (ProjectBriefFill ×4, BusinessPlanSection,
ProjectDocSync) which all carry `ui-tap`.
audit:responsive reports zero undersized targets and is right to: this button
lives on /projects/[id], and the audit's page list has /projects but no detail
page. The gate is not wrong, its coverage is — worth knowing before trusting a
green run on a page it never opens.
pnpm run verify green.
Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>