Commit 68dfaf1
Claude Fix
fix: correct chat bubble count and ordering across all backends
Root cause (WebView, takes effect immediately, no rebuild needed):
sendMessage() created the pending model/spinner bubble synchronously
via addModelBubble('', true) right after calling Bridge.sendMessage()/
sendMessageWithImages(). Those Android bridge calls dispatch to the UI
thread asynchronously, so the spinner bubble was always inserted into
the DOM before the native onUserMessage/onAiMessage callbacks could
fire - making the spinner appear in its own bubble above the user's
message instead of below it. The pending model bubble is now created
exclusively by the native onAiMessage('', true) callback once
generation actually starts.
Native ordering bugs (require a rebuild to take effect):
- reasonWithCerebras / reasonWithMistral set _uiState = Loading before
appending the user message to chatMessagesFlow, so onAiMessage fired
before onUserMessage - same spinner-above-user-bubble bug at the
native level for these two backends.
- HUMAN_EXPERT branch in reason(): same ordering issue, and the
'already connected' path (postTaskToHumanExpert) never updated
chatMessagesFlow at all, so a follow-up message while already
connected never appeared as a bubble.
- MainActivity's chatMessagesFlow collector compared the last user
message by text content to decide whether to call onUserMessage.
Sending the exact same text twice in a row was therefore silently
swallowed (no second bubble at all). Now compares by the message's
unique id instead, so every distinct message always gets its bubble.1 parent 06765dd commit 68dfaf1
3 files changed
Lines changed: 18 additions & 9 deletions
File tree
- app/src/main/kotlin/com/google/ai/sample
- feature/multimodal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1717 | 1717 | | |
1718 | 1718 | | |
1719 | 1719 | | |
1720 | | - | |
| 1720 | + | |
1721 | 1721 | | |
1722 | 1722 | | |
1723 | 1723 | | |
1724 | 1724 | | |
1725 | 1725 | | |
1726 | | - | |
1727 | | - | |
1728 | | - | |
1729 | | - | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
1730 | 1730 | | |
1731 | 1731 | | |
1732 | 1732 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
834 | 834 | | |
835 | 835 | | |
836 | 836 | | |
837 | | - | |
| 837 | + | |
| 838 | + | |
838 | 839 | | |
839 | 840 | | |
840 | 841 | | |
| |||
1185 | 1186 | | |
1186 | 1187 | | |
1187 | 1188 | | |
1188 | | - | |
1189 | 1189 | | |
1190 | 1190 | | |
1191 | 1191 | | |
| |||
1205 | 1205 | | |
1206 | 1206 | | |
1207 | 1207 | | |
| 1208 | + | |
| 1209 | + | |
1208 | 1210 | | |
1209 | 1211 | | |
1210 | 1212 | | |
| |||
1311 | 1313 | | |
1312 | 1314 | | |
1313 | 1315 | | |
1314 | | - | |
1315 | 1316 | | |
1316 | 1317 | | |
1317 | 1318 | | |
| |||
1334 | 1335 | | |
1335 | 1336 | | |
1336 | 1337 | | |
| 1338 | + | |
| 1339 | + | |
1337 | 1340 | | |
1338 | 1341 | | |
1339 | 1342 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4199 | 4199 | | |
4200 | 4200 | | |
4201 | 4201 | | |
4202 | | - | |
| 4202 | + | |
| 4203 | + | |
| 4204 | + | |
| 4205 | + | |
| 4206 | + | |
| 4207 | + | |
| 4208 | + | |
4203 | 4209 | | |
4204 | 4210 | | |
4205 | 4211 | | |
| |||
0 commit comments