Allow whitespace stop sequences from the chips editor (PR #5711)

Round 11 P2 finding: the stop-sequence chips input rejected any draft
that strip to empty, which silently dropped pasted whitespace stops
like `"\n\n"` for blank-line halts. Local llama-server and OpenAI-
compat backends accept those; the Anthropic helper independently
filters whitespace entries before they hit the wire, so allowing them
in the UI cannot turn into a 400.

Drop the .trim() gate; reject only the truly empty draft. Single-line
Input behaviour is unchanged for the common typed-letters path.
This commit is contained in:
Daniel Han 2026-05-24 17:19:50 +00:00
commit 737c5ad0e0

View file

@ -38,10 +38,13 @@ export function StopSequencesInput({
const atCap = value.length >= maxEntries;
function commitDraft() {
// Reject empty / whitespace-only chips but preserve significant
// leading/trailing whitespace (stop matching is exact). Backend
// re-validates per provider.
if (!draft || !draft.trim()) return;
// Reject only the empty draft; preserve whitespace exactly (stop
// matching is byte-exact). OpenAI-compat / llama-server backends
// accept whitespace-only stops like "\n\n" for blank-line halts;
// pasting such a value into the input should round-trip rather
// than be silently dropped. Anthropic's helper strips whitespace
// entries on the wire so a chip that's invalid there cannot 400.
if (!draft) return;
if (atCap) return;
if (value.includes(draft)) {
setDraft("");