fix(video-calls): clamp list limit#327
Conversation
Greptile SummaryThis PR replaces the
Confidence Score: 5/5Safe to merge — the change is a small, self-contained input-normalisation fix with correct clamping logic and full regression test coverage for every boundary case. The old parseInt/Math.min one-liner could silently forward NaN or negative integers to Supabase's .limit() call; the new parseLimit helper closes all those paths and is straightforward to audit. All four boundary cases (negative, non-numeric, missing, oversized) are now exercised by the new tests, and the Supabase mock faithfully mirrors the actual query chain. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["parseLimit(value)"] --> B{"value is null\nor empty/whitespace?"}
B -- "yes" --> C["parsed = Number(20) = 20"]
B -- "no" --> D["parsed = Number(value)"]
D --> E{"Number.isFinite(parsed)?"}
E -- "no (NaN / Infinity)" --> F["finiteValue = 20"]
E -- "yes" --> G["finiteValue = parsed"]
C --> G
F --> H["Math.trunc(finiteValue)"]
G --> H
H --> I["Math.max(truncated, 1)"]
I --> J["Math.min(clamped, 50)"]
J --> K["return limit in [1, 50]"]
Reviews (2): Last reviewed commit: "test(video-calls): cover limit boundarie..." | Re-trigger Greptile |
Summary
Fixes #326.
Testing