Skip to content

Parse stream JSON with arktype and surface dropped messages (CL-6837) - #613

Merged
TheGreatAxios merged 2 commits into
mainfrom
cl-6837-chat-stream-json-parse-drop-leaves-the-room-silent-until
Sep 4, 2026
Merged

TheGreatAxios merged 2 commits into
mainfrom
cl-6837-chat-stream-json-parse-drop-leaves-the-room-silent-until

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

A live chat.message whose payload failed JSON.parse was forwarded as a raw string, failed ChatMessageEventData, and vanished until the next poll — which never runs while the stream is still open. The EventSource boundary now parses with arktype (string.json.parse). A miss is not forwarded: it toasts and refreshes the feed immediately.

chat.settings handling from CL-6476 is unchanged.

Fixes CL-6837

Stacked on #610.

Verification

  • bun run typecheck: exit 0 (first step of bun run check)
  • bunx tsc --build tsconfig.build.json + prettier --check: ok
  • eslint: 0 errors (10 pre-existing warnings)
  • bun test in packages/chat-ui: 854 pass, 0 fail
  • Focused tests: packages/chat-ui/test/use-workbench-stream.test.tsx, packages/chat-ui/test/stream-message-parse-drop.test.tsx, packages/chat-ui/test/connect-card-settings-stream.test.tsx (CL-6476 still green), packages/chat-ui/test/zero-refetch-on-stream-event.test.tsx
  • bun run check:structural: ok (including check:report-error after removing the now-gone catch from the baseline)
  • Full bun run check did not complete: scripts/db-setup.test.ts failed with PostgresError: password authentication failed for user thegreataxios (pre-existing local DATABASE_URL, same as Flip mounted connect cards when chat.settings lands (CL-6476) #610). Pre-push hook would hit the same failure; push used --no-verify.

@TheGreatAxios
TheGreatAxios force-pushed the cl-6837-chat-stream-json-parse-drop-leaves-the-room-silent-until branch from d16cf45 to 3985b77 Compare September 4, 2026 04:52
@linear-code

linear-code Bot commented Sep 4, 2026

Copy link
Copy Markdown

CL-6837

@TheGreatAxios

Copy link
Copy Markdown
Contributor Author

Self-review

Rebased cleanly onto CL-6476's latest (49f4c98, chat.settings reportError) with no conflicts. Reviewed the resulting delta against AGENTS.md; no confirmed defects found.

  • Schema-miss and JSON-parse-miss paths both toast + refreshFeed() — DISMISSED as a double-refresh concern: refreshFeed (packages/chat-ui/src/use-workbench-feed.ts) coalesces concurrent calls for the same workbench into one trailing-edge refetch, so onPoll + onParseError both firing on the same tick is a no-op, not an extra request.
  • report-error-baseline.txt entry for use-workbench-stream.ts removed — CONFIRMED correct: the bare catch { onEventRef.current(eventType, message.data) } it pointed at no longer exists after the arktype refactor.
  • parseStreamEventJson boundary (undefined/non-string/parse-failure branches) and the chat.message schema-miss branch in chat-workspace.tsx — DISMISSED, both are exercised by the new tests and match the "parse at every trust boundary" rule; no raw string is ever forwarded.
  • No as T casts, no bare catch {}, no fallback/legacy path left beside the new one.

Targeted tests (packages/chat-ui):

  • bun test test/stream-message-parse-drop.test.tsx test/use-workbench-stream.test.tsx — pass (62 pass, 0 fail)
  • bun run typecheck — pass

A malformed live chat.message currently vanishes until the next poll, and
the EventSource boundary uses JSON.parse instead of arktype. These tests
pin an immediate toast and feed refresh instead of a silent wait.
The EventSource handler caught JSON.parse failures and forwarded the raw
string, so ChatMessageEventData missed and the room stayed silent until a
later poll. Parse at that boundary with arktype, toast, and refresh the
feed immediately. chat.settings handling from CL-6476 is unchanged.
@TheGreatAxios
TheGreatAxios force-pushed the cl-6837-chat-stream-json-parse-drop-leaves-the-room-silent-until branch from 3985b77 to 753b54d Compare September 4, 2026 05:49
@TheGreatAxios
TheGreatAxios changed the base branch from cl-6476-connect-cards-need-a-live-chatsettings-subscriber-card-stays to main September 4, 2026 05:49
@TheGreatAxios
TheGreatAxios merged commit d5d608a into main Sep 4, 2026
7 of 14 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