Files
buzz/mobile/lib/shared/widgets/agent_artwork_panel.dart
Tom Brow 220cec677a fix(mobile): keep community icons on originals and record thumbnail 404s at fetch (#8896)
Follow-up to #8879, addressing its review.

## Changes

- **Community icons load the original again.** `AvatarImageContent`
gained a `preferThumbnail` flag, off by default. People and agent
avatars turn it on (as #8879 did for every caller); `CommunityAvatar`
leaves it off. Community logos are often transparent PNGs, and the
relay's JPEG thumbnail renders transparency black. This matches desktop,
which shows community icons from the original.
- **A missing thumbnail is recorded where its 404 arrives.** Before,
only the mounted `Image`'s error builder recorded it. If the avatar
scrolled away before a slow 404 came back, the thumbnail URL kept a 30s
failure cooldown instead, and showing that avatar again at any size
during the cooldown rendered initials and never requested the original.
The fetch now records a 404 on a relay `/media/<sha256>.thumb.jpg` URL
in the missing-thumbnail set and puts no cooldown on it.

## Tests

Two journey tests in `avatar_image_test.dart`, both failing on main and
passing here:

- An avatar unmounts before its slow thumbnail 404 arrives, then mounts
again at another size: it requests the original once, renders it (valid
image bytes, no initials), and leaves no cooldown.
- A 36pt `CommunityAvatar` with a relay-hosted icon requests and shows
only the original.

`flutter analyze` is clean. In the full local `flutter test` run, only
12 push and notification tests fail, and they fail the same way on main
in this environment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 15:51:13 -08:00

70 lines
2.3 KiB
Dart

import 'dart:ui';
import 'package:flutter/material.dart';
import '../animated_avatar.dart';
import '../theme/theme.dart';
import 'avatar_image.dart';
/// A desktop-style profile container with static, faded portrait artwork.
class AgentArtworkPanel extends StatelessWidget {
const AgentArtworkPanel({
required this.imageUrl,
required this.child,
this.borderRadius,
super.key,
});
final String? imageUrl;
final Widget child;
final BorderRadius? borderRadius;
@override
Widget build(BuildContext context) {
final poster = parseAnimatedAvatarUrl(imageUrl)?.posterUrl ?? imageUrl;
return ClipRRect(
borderRadius: borderRadius ?? BorderRadius.circular(Radii.card),
child: ColoredBox(
color: context.colors.surfaceContainerLow,
child: Stack(
children: [
if (poster != null && !MediaQuery.highContrastOf(context))
Positioned.fill(
child: IgnorePointer(
child: ExcludeSemantics(
child: RepaintBoundary(
child: ShaderMask(
blendMode: BlendMode.dstIn,
shaderCallback: (bounds) => const LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Colors.white, Colors.transparent],
stops: [0.05, 0.7],
).createShader(bounds),
child: Opacity(
opacity: .55,
child: ImageFiltered(
imageFilter: ImageFilter.blur(
sigmaX: 40,
sigmaY: 40,
),
child: Transform.scale(
scale: 2,
child: AvatarImageContent(
imageUrl: poster,
preferThumbnail: true,
fallback: const SizedBox.shrink(),
),
),
),
),
),
),
),
),
),
child,
],
),
),
);
}
}