Skip to content

feat(chat): show the photos of a conversation - #374

Merged
Mamel0uk merged 16 commits into
mainfrom
feature/photo-receive
Nov 18, 2026
Merged

Mamel0uk merged 16 commits into
mainfrom
feature/photo-receive

Conversation

@Mamel0uk

@Mamel0uk Mamel0uk commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part of #281. Photo messages now show their photo in the thread for both people, and the inbox says "Photo" for a photo sent alone.

Builds on #373 (send a photo), which is merged: this PR is now based on main.

What

  • A photo message downloads its photo once and decodes it off the main thread. While it loads, a placeholder of the same size shows, so the list doesn't jump. If the download fails, it shows "Couldn't load the photo · Tap to retry".
  • A photo's message is written before the photo is uploaded, with photoPending true (from feat(chat): send and load photo messages #352). While it's pending, the bubble shows the loading placeholder and doesn't try to download anything. As soon as the sender marks it uploaded, the photo is downloaded. So a missing photo that isn't pending is a real error and shows "Couldn't load" at once. A photo whose upload never finished (Android killed the sender's app mid-upload) stays on the loading placeholder.
  • Inbox: a conversation whose last message is a photo without a caption shows an image icon and "Photo".
  • Figma: photo messages, loading, inbox.

Why

#36: both people should see the photo, not only the person who sent it.

Update (Nov 18): rebased on #352's review fix. The first version waited 1, 2, 4, 8 and 15 s after a NOT_FOUND because it couldn't tell "still uploading" from "missing". #352 now has photoPending, so that backoff is gone (46b687a).

Update (Nov 18, later): #373 is merged, so this is rebased onto main without its commits. No code change: the tree is the same as before the rebase.

Validation

  • ./gradlew ktfmtCheck assemble lint check pass locally.
  • 18 new tests: download once, error and retry, nothing downloaded while the photo is pending and the download once it's marked uploaded, the bubbles (TalkBack text, fixed size, pending placeholder, tap to retry), and the inbox preview.
  • No photo of the screen, since 2 account needed for it.

AI use

Claude Code (Claude Opus 5.5) wrote the code and tests step by step, with each commit approved by me, and split the original branch into these PRs. I checked every diff.

@Mamel0uk
Mamel0uk force-pushed the feature/photo-receive branch from 0248044 to 175d86d Compare November 18, 2026 13:01
@Mamel0uk
Mamel0uk force-pushed the feature/photo-receive branch from 175d86d to 8a0de89 Compare November 18, 2026 14:00
@Mamel0uk
Mamel0uk force-pushed the feature/photo-receive branch from 8a0de89 to c7ea7da Compare November 18, 2026 16:11
@Mamel0uk
Mamel0uk force-pushed the feature/photo-receive branch 3 times, most recently from 84dbbb6 to 8528b37 Compare November 18, 2026 18:31
Base automatically changed from feature/photo-send to main November 18, 2026 19:28
Mamel0uk and others added 10 commits November 18, 2026 20:29
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A photo's message reaches the conversation before the photo reaches
Storage, so a download that finds no photo now keeps the bubble loading
and tries again for about 30 s instead of failing. When this device
finishes sending a photo, its bubble tries again at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A photo sent without a caption previews as an empty text, so its inbox
row shows "Photo" with a small image icon instead of an empty line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two test tags on one node keep only the first, so the error
placeholder was tagged messagePhoto and photoLoadError was never
found. Each state now gets a single tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mamel0uk
Mamel0uk force-pushed the feature/photo-receive branch from 8528b37 to 2311956 Compare November 18, 2026 19:30
@Mamel0uk
Mamel0uk marked this pull request as ready for review November 18, 2026 19:37
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Good work. The pending/uploaded split removes the earlier backoff guesswork. The same-size placeholder avoids list jumps, and failed downloads are separate from undecodable photos. Only the failed-download case offers a retry, which is right. The tests cover the pending→uploaded transition and retry.

I have just found a bug:
ConversationScreen.kt L745–L757, BubblePhoto produceState: the decoded bitmap lives only in the composition. Bytes are cached in the ViewModel, but each bubble that scrolls out of the LazyColumn and back decodes the photo again. It flashes the spinner and decodes up to 1024px each time, despite "downloads once and decodes off the main thread". ListingDetailPhotos.kt (L218–L230) hoists a decoded map for this reason. Hoist the decoded bitmaps above the list in the same way, or at least remember them per path outside the item.

The following are nits:

  1. ConversationViewModel.kt L107, photoLoadErrors: it is Map<String, AppError> but only the keys are used. The UI always shows "Couldn't load the photo · Tap to retry". For PERMISSION_DENIED or NOT_FOUND, retrying won't help. Either use a Set<String> or show error.message() / hide Retry for those errors.

  2. ConversationScreen.kt L798, PhotoLoadError: Modifier.clickable(onClick = onRetry) has no role or onClickLabel. Add role = Role.Button so TalkBack announces it as a button.

  3. ConversationScreen.kt L778, the loading placeholder: its contentDescription is "Photo", the same as the loaded image, so TalkBack users can't tell it is still loading. Consider "Photo, loading".

  4. No screenshot of the UI was provided, and it is a UI PR. ConversationPhotosPreview exists, so a screenshot of that preview plus the Figma comparison would help reviewers.

  5. Tests: the inbox tests cover a photo alone and my own photo. Add a case for a photo with a caption, which should show the caption and no "Photo" icon.

-❓ ConversationScreen.kt L659: fixedWidth = photo != null combined with ContentScale.Crop at a fixed 200dp height crops portrait photos with no way to see the whole photo. Is that intended per Figma?

Mamel0uk and others added 2 commits November 18, 2026 21:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mamel0uk and others added 3 commits November 18, 2026 22:01
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mamel0uk

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Fixed in these commits:

  • Bug, re-decoding on scroll (e3de7bf): the decoded bitmaps are now kept above the LazyColumn in rememberDecodedPhotos, same idea as ListingDetailPhotos. A bubble that scrolls out and back shows its photo straight away. There's a test that freezes the clock while scrolling back and checks the photo is drawn on the first frame. It fails on the old code.
  • 1. photoLoadErrors (e14b662): I kept the map and now actually use the error. For NOT_FOUND and PERMISSION_DENIED the bubble just says "Couldn't load the photo" and isn't tappable. Other errors still offer "Tap to retry".
  • 2. (ee52f7f): the retry area has role = Role.Button and the "Retry" click label.
  • 3. (5cb794c): the placeholder now reads "Photo, loading" and switches to "Photo" once the image is shown.
  • 4. I'll add a screenshot of the preview and the Figma frame to the description.
  • 5. (30a428e): added an inbox test for a photo with a caption. It shows the caption and no "Photo".

About the crop: yes, it's on purpose. The Figma bubble is a fixed-size photo, and keeping the height fixed at 200dp means the list doesn't jump when a photo finishes loading. Opening a photo full screen to see all of it would be a nice follow-up, but it's not part of #281. I can open an issue for it if you think it's worth it.

@Mamel0uk
Mamel0uk requested a review from adrimikh November 18, 2026 21:05
@sonarqubecloud

Copy link
Copy Markdown

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

Thank you for your changes, LGTM!

@Mamel0uk
Mamel0uk merged commit 60232a2 into main Nov 18, 2026
3 checks passed
@Mamel0uk
Mamel0uk deleted the feature/photo-receive branch November 18, 2026 21:17
@Mamel0uk Mamel0uk self-assigned this Nov 19, 2026
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