Skip to content

fix(chat): drop unparsable special-tag payloads instead of dumping raw JSON - #6142

Merged
j15z merged 3 commits into
stagingfrom
fix/options-tag-rendering
Aug 1, 2026
Merged

fix(chat): drop unparsable special-tag payloads instead of dumping raw JSON#6142
j15z merged 3 commits into
stagingfrom
fix/options-tag-rendering

Conversation

@j15z

@j15z j15z commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Chat messages with a broken special-tag JSON payload (extra brace, missing key quote, stray ]}, trailing comma) were rendering the entire raw JSON as prose — the parser only dropped payloads that parsed but failed their shape guard
  • Split the old never-json class in two: a body that opens like a JSON payload ({", [{, [") but won't parse is now not-parsable and gets dropped like wrong-shape; prose-ish bodies ({the Q4 report}, unquoted-key slips, bare scalars) are not-a-payload and still render verbatim
  • New wasAttemptedPayload opener predicate draws that line; the discarded-tag guard covers the new class so a message that is only a broken payload renders blank instead of resurrecting the JSON via the raw-content fallback
  • Added tests for the three production repro shapes plus the inline-tag, blank-message, and must-still-render cases

Type of Change

  • Bug fix

Testing

81 unit tests passing across both special-tags test files. Verified manually in Chat against the full fixture matrix: broken payloads drop, prose survives, valid cards render and stay interactive, nested-tag rescue holds, blank-message fallback guard holds. Lint and all boundary/audit checks pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 1, 2026 12:30am

Request Review

@cursor

cursor Bot commented Jul 31, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes core parseSpecialTags classification and streaming suppression for all JSON-bodied chat tags; wrong heuristics could drop intended prose or still flash broken JSON, but behavior is heavily test-covered.

Overview
Fixes chat rendering where broken special-tag JSON (syntax errors) was shown as raw prose because only payloads that parsed but failed shape guards were discarded.

Classification splits unparseable bodies via wasAttemptedPayload ({" / [{ / [" plus a key-value colon outside strings): not-parsable is dropped like wrong-shape; not-a-payload (prose-in-braces, bare scalars, etc.) still renders verbatim. endsInsideJsonString limits raw-marker rescans to mispaired quotes so tag names quoted inside broken JSON are not mistaken for nested tags.

Streaming keeps pending for fumbled payloads whose top-level value has closed but only JSON debris follows, avoiding a flash of raw JSON before the close tag arrives.

Tests cover production typo shapes, inline tags, blank messages, and frame-by-frame streaming stability.

Reviewed by Cursor Bugbot for commit d49122a. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The parser now distinguishes malformed attempted payloads from prose and suppresses only the former.

  • Requires both a JSON-like opener and an outside-string key/value colon before treating an unparseable body as an attempted payload.
  • Preserves brace-wrapped quoted prose while discarding malformed special-tag payloads.
  • Keeps broken payloads suppressed throughout streaming and adds regression coverage for production examples, inline tags, blank messages, nested markers, and prose preservation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/special-tags/special-tags.tsx Refines malformed-body classification and streaming suppression while fixing the previously reported prose-deletion path.
apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/special-tags/special-tags.test.ts Adds focused regression coverage for malformed payload suppression and preservation of quoted or brace-wrapped prose.

Reviews (3): Last reviewed commit: "improvement(chat): require key-value col..." | Re-trigger Greptile

@j15z

j15z commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9775580. Configure here.

@j15z

j15z commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d49122a. Configure here.

@j15z
j15z merged commit a5ca810 into staging Aug 1, 2026
27 checks passed
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.

1 participant