Skip to content

refactor: migrate pubky images to coil#846

Draft
ovitrif wants to merge 3 commits intofeat/pubky-profilefrom
feat/pubky-async-image
Draft

refactor: migrate pubky images to coil#846
ovitrif wants to merge 3 commits intofeat/pubky-profilefrom
feat/pubky-async-image

Conversation

@ovitrif
Copy link
Collaborator

@ovitrif ovitrif commented Mar 13, 2026

Stacked PR on top of:

Migrates pubky image loading from a manual ViewModel + two-tier cache (PubkyImageCache) to Coil 3, simplifying the architecture and reducing custom code.

Description

  • Add Coil 3 dependency (io.coil-kt.coil3:coil-compose:3.2.0)
  • Create PubkyImageFetcher — a Coil Fetcher that handles pubky:// URIs via PubkyService.fetchFile(), including JSON file descriptor indirection
  • Create ImageModule — Hilt module providing a singleton ImageLoader with memory cache (15% app memory) and disk cache (cacheDir/pubky-images/)
  • Replace PubkyImage composable internals: remove PubkyImageViewModel and use Coil's SubcomposeAsyncImage with loading/error slots
  • Remove PubkyImageCache (replaced by Coil's built-in caching)
  • Remove PubkyRepo.fetchImage() / cachedImage() (image loading now handled entirely by Coil)
  • Update PubkyRepo.signOut() to evict pubky images from Coil caches
  • Add unit tests for PubkyImageFetcher (factory filtering, raw data, JSON descriptor following)
  • Update PubkyRepoTest to reflect removed image methods
  • Update docs/pubky.md to document the new architecture

Preview

No visual changes — same loading spinner, circular-clipped image, and error fallback.

QA Notes

  • Verify pubky profile images load correctly on the contacts and profile screens
  • Verify images are cached (navigate away and back — should load instantly)
  • Verify sign-out clears cached images (sign out, sign in with different account)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ovitrif ovitrif self-assigned this Mar 13, 2026
@ovitrif ovitrif requested a review from ben-kaufman March 13, 2026 04:03
@claude

This comment has been minimized.

@ovitrif ovitrif added this to the 2.2.0 milestone Mar 13, 2026
@ovitrif ovitrif removed the request for review from ben-kaufman March 13, 2026 04:18
ovitrif and others added 2 commits March 13, 2026 06:06
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ovitrif ovitrif force-pushed the feat/pubky-async-image branch from 0a0d9cc to 5f6e98d Compare March 13, 2026 11:08
Copy link
Member

@jvsena42 jvsena42 left a comment

Choose a reason for hiding this comment

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

Very nice refactor!

@claude
Copy link

claude bot commented Mar 13, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@ovitrif
Copy link
Collaborator Author

ovitrif commented Mar 13, 2026

Very nice refactor!

Thank you!
I still have to go over why Claude picked SubcomposeAsyncImage and let it convince me, the coil docs say it's less performant than the more-common AsyncImage.

Drafting the PR to avoid accidental merges until that's cleared.

@ovitrif ovitrif marked this pull request as draft March 13, 2026 11:49
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