Skip to content

Load AI chart settings through evaluateJavascript and show chart errors as plain text - #7066

Merged
gpunto merged 2 commits into
developfrom
fix/and-2001-chart-webview
Nov 25, 2026
Merged

gpunto merged 2 commits into
developfrom
fix/and-2001-chart-webview

Conversation

@gpunto

@gpunto gpunto commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Goal

Closes AND-2001

The AI chart view built its page by pasting the chart JSON into an inline script and wrote chart errors into the page as HTML.

Implementation

  • The chart page is static HTML with no scripts. Chart.js and each chart's settings are passed in with evaluateJavascript, the settings as an escaped string literal.
  • Chart errors are shown as plain text.
  • The page's content policy no longer allows inline scripts or eval, and the WebView doesn't navigate away from the chart.
  • The jsdelivr fallback is removed; the page's policy already blocked it. Without the chart.umd.min.js asset the chart stays empty, as before.
  • A chart only redraws when its settings change, and the WebView is destroyed when it leaves the composition.
  • Removed the unused ChartDiagram copy from the AI sample.

Testing

  • New unit tests for the string literal escaping and the render script.
  • On an emulator (temporary instrumented test, not committed): a valid chart draws, invalid JSON shows the parse error as text, labels containing HTML-like text render as plain labels, and switching back to a valid chart draws it again.

@gpunto gpunto added the pr:improvement Improvement label Nov 24, 2026
@gpunto
gpunto force-pushed the fix/and-2001-chart-webview branch from 3a5ae0e to 9f81fe1 Compare November 24, 2026 14:15
@gpunto
gpunto force-pushed the fix/and-2001-chart-webview branch from 9f81fe1 to 8480553 Compare November 24, 2026 14:46
@github-actions

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.45 MB 6.45 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.80 MB 11.80 MB 0.00 MB 🟢
stream-chat-android-compose 13.48 MB 13.48 MB 0.00 MB 🟢
stream-chat-android-ai-compose 2.27 MB 2.27 MB 0.00 MB 🟢
stream-chat-android-ai-ondevice 1.67 MB 1.67 MB 0.00 MB 🟢
stream-chat-android-ai-a2ui 0.28 MB 0.28 MB 0.00 MB 🟢
stream-chat-android-ai-openui 0.82 MB 0.82 MB 0.00 MB 🟢

@gpunto
gpunto marked this pull request as ready for review November 24, 2026 15:13
@gpunto
gpunto requested a review from a team as a code owner November 24, 2026 15:13

@andremion andremion 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.

Looks good. A few optional suggestions inline.

@gpunto
gpunto enabled auto-merge November 25, 2026 10:14
@gpunto
gpunto added this pull request to the merge queue Nov 25, 2026
Merged via the queue into develop with commit b8b19ff Nov 25, 2026
20 checks passed
@gpunto
gpunto deleted the fix/and-2001-chart-webview branch November 25, 2026 11:23
@stream-android-release-bot stream-android-release-bot Bot added the released Included in a release label Nov 27, 2026
@stream-android-release-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v7.21.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:improvement Improvement released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants