Skip to content

fix: prevent code from showing up in the chat panel - #140

Merged
jgindin merged 3 commits into
mainfrom
no-more-json-in-chat
Jul 31, 2026
Merged

fix: prevent code from showing up in the chat panel#140
jgindin merged 3 commits into
mainfrom
no-more-json-in-chat

Conversation

@jgindin

@jgindin jgindin commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Description

Create new ChatCleaner service to handle all the cleansing.

Strip markdown code fences and XML/HTML.

Separate thought candidate parts into thinking property in LLM client. Handle cross-chunk streaming XML/HTML thinking tags (, , ) and multi-line formatted JSON arrays. Prevent false-positive layout snapshot classification on non-JSON bracketed text.

Refactor Standalone3pLlmClient.chatStream into a high-level coordinator method delegating parameter construction, chunk part parsing, XML thought extraction, and stream consumption to private helper methods.

Recognize partial JSON arrays starting with '[' and containing A2UI keys ("version", "createSurface", or "updateComponents"). This prevents raw incomplete JSON text from displaying in the chat bubble during active LLM streaming.

Pre-launch Checklist

  • I signed the [CLA].
  • I read the [Contributors Guide].
  • I read the [Style Guide].
  • I have added updates to the [CHANGELOG].
  • I updated/added relevant documentation.
  • My code changes (if any) have tests.
  • If my branch is on fork, I have verified that scripts/e2e_test.sh passes.

Create new ChatCleaner service to handle all the cleansing.

Strip markdown code fences and XML/HTML.

Separate thought candidate parts into thinking property in LLM client.
Handle cross-chunk streaming XML/HTML thinking tags (<thought>,
<thinking>, <reasoning>) and multi-line formatted JSON arrays.
Prevent false-positive layout snapshot classification on non-JSON
bracketed text.

Refactor Standalone3pLlmClient.chatStream into a high-level
coordinator method delegating parameter construction, chunk part
parsing, XML thought extraction, and stream consumption to private
helper methods.

Recognize partial JSON arrays starting with '[' and containing A2UI keys
("version", "createSurface", or "updateComponents"). This prevents raw
incomplete JSON text from displaying in the chat bubble during active
LLM streaming.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new ChatCleaner service to centralize the cleaning and processing of raw LLM chat messages, including stripping pulse indicators, XML thinking tags, and markdown code fences. It refactors ChatPanel, ChatCoordinator, and Standalone3pLlmClient to utilize this service, improving streaming layout snapshot detection and thought extraction. Feedback highlights opportunities to enhance partial JSON array detection in ChatCleaner.cleanPayload during active streaming, and to clean up an unused state parameter in Standalone3pLlmClient.

Comment thread shell/src/app/chat/chat-service/chat-cleaner.ts
Comment thread shell/src/app/chat/llm-client/standalone-3p-llm-client.ts Outdated
Comment thread shell/src/app/chat/llm-client/standalone-3p-llm-client.ts
jgindin added 2 commits July 30, 2026 15:42
Replace any parameter types in parseChunkParts and consumeStream with
GenerateContentResponse and AsyncIterable<GenerateContentResponse> from
@google/genai.
Support partial JSON arrays starting with '[' and containing A2UI keys in
ChatCleaner.cleanPayload. Remove unused state parameter from
Standalone3pLlmClient.extractXmlThoughts.
@github-actions

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

Your automated preview is successfully live (commit 7014e7c):
👉 Launch PR Preview

Note: This environment will be wiped automatically when the PR is merged or closed.

@wrenj

wrenj commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

lgtm to unblock, but why not use structured output?

json schema
text
a2ui

@jgindin
jgindin merged commit f4a1323 into main Jul 31, 2026
13 checks passed
@jgindin
jgindin deleted the no-more-json-in-chat branch July 31, 2026 17:10
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.

2 participants