Skip to content

Epic 2 chat - #167

Open
jgindin wants to merge 6 commits into
mainfrom
epic-2-chat
Open

Epic 2 chat#167
jgindin wants to merge 6 commits into
mainfrom
epic-2-chat

Conversation

@jgindin

@jgindin jgindin commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Description

Second in a series of refactorings to clean up the A2UI Composer code.

Chat Coordinator Decomposition & Pure Syntax Healing

  • Extracts parseAndHealJsonLines as an uncoupled pure function to parse and repair incomplete or streaming LLM JSON payloads.
  • Extracts ChatPromptFactoryService (system prompt assembly) and ChatErrorFormatterService (user-facing error formatting) out of ChatCoordinator.
  • Deconstructs monolithic stream-handling methods in ChatCoordinator into single-responsibility helper methods.
  • Replaces unsafe type assertions with strict TypeScript runtime and structural bounds.

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 SafeUrlValidatorService for http/https validation.
Create DomainOriginVerificationService for strict iframe networking validation.
Wire bypassSecurityTrustResourceUrl inside rendered-frame.ts through the rigorous URL validator.
Swap the check in preview-bridge.ts for the strict origin verification.
Fix LLM concurrency in ChatCoordinator submitPrompt.
Fix Monaco model.dispose() in a2ui-composer-monaco-editor.
Inject takeUntilDestroyed in api-key-selector.ts and renderer-selector.ts.
Delete debug/mock-rules/ entirely.
Rip out console.error patch hacks from ChatCoordinator.
Delete obsolete storage key ACTIVE_DRAFT.

@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 refactors the chat pipeline by modularizing ChatCoordinator into separate services for payload parsing, error formatting, and prompt generation, while also removing the MockRules debug panel. Additionally, it introduces strict origin verification in PreviewBridge and safe URL validation for the rendered frame. The review feedback highlights a critical bug in sanitizeValue where the logic to strip out rules and mock* properties was omitted, along with a corresponding gap in unit test assertions. Feedback also recommends hardening isConnectivityError against nullish inputs with guard clauses and tests, and replacing the deprecated substr() method with slice() in MonacoEditor.

Comment thread shell/src/app/chat/a2ui-payload-parser/a2ui-payload-parser.ts
Comment thread shell/src/app/chat/a2ui-payload-parser/a2ui-payload-parser.spec.ts
Comment thread shell/src/app/shared/monaco-editor/monaco-editor.ts
@github-actions

Copy link
Copy Markdown
Contributor

⚡ A2UI Composer PR Preview

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

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

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