Skip to content

fix: render multimodal session content safely#73

Merged
rusty4444 merged 1 commit into
rusty4444:mainfrom
ruben2000de:fix/multimodal-session-content
Jul 14, 2026
Merged

fix: render multimodal session content safely#73
rusty4444 merged 1 commit into
rusty4444:mainfrom
ruben2000de:fix/multimodal-session-content

Conversation

@ruben2000de

@ruben2000de ruben2000de commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Agent disclosure: This change was prepared, tested, and submitted by Metis, an AI coding agent, acting on behalf of @ruben2000de. Ruben authorized the contribution and validated the fix on his Pixel 8a.

Bug Description

Opening a session that contains OpenAI-style multipart message content shows a blank/white chat screen instead of rendering the conversation.

ADB logcat reports:

type 'List<dynamic>' is not a subtype of type 'String?' in type cast
#0 _ChatScreenState._buildBody (chat_screen.dart:690)

Root Cause

ChatScreen cast every message's content field directly to String?. Hermes sessions can also contain OpenAI-compatible content arrays, for example text parts and image_url parts. The unchecked cast throws during widget construction, leaving the screen blank.

Fix

  • Add messageContentToText to normalize both legacy string content and multipart content arrays.
  • Preserve text parts and render image/file parts as safe placeholders.
  • Render unknown structured parts as an explicit placeholder instead of crashing the whole chat view.
  • Use the normalizer for user/assistant bubbles, filtering, and tool-message extraction.
  • Add regression coverage for strings, text arrays, mixed text/image content, nulls, and unknown parts.

How to Verify

  1. Connect the Android client to a Hermes gateway.
  2. Open a session containing a message whose content is a list with text and/or image_url parts.
  3. Confirm the session renders instead of showing a blank screen.

Test Plan

  • Added regression tests for legacy and multipart content.
  • flutter analyze --fatal-infos — no issues found.
  • flutter test — all 37 tests passed.
  • Manually reproduced on a Pixel 8a with the v1.0.9 APK, then verified the same session renders in the patched side-by-side build.
  • Checked ADB logcat after opening the affected session; no Flutter exception remains.

Maintainer Notes

  • Review scope is intentionally small: one commit, three files.
  • No dependency, configuration, storage, API, or migration changes.
  • Maintainer edits are enabled on the source branch.
  • GitHub Actions is awaiting the standard first-time fork-contributor approval; the same analyze/test commands have already passed locally.

Risk Assessment

Low — the change is isolated to display-time conversion of message content. Existing string messages remain unchanged, while non-string content now degrades to text/placeholders instead of throwing during rendering.

@rusty4444 rusty4444 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed by Hermes Agent.

Approve: the new messageContentToText helper correctly preserves legacy string content, handles multimodal text/image/file parts without throwing, and replaces unsafe string casts in chat rendering. Targeted local check passed: flutter test test/message_content_test.dart.

Note: this PR has no GitHub CI checks reported, so automation will not merge it despite approval.

@rusty4444
rusty4444 merged commit 115ed22 into rusty4444:main Jul 14, 2026
1 check 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.

2 participants