Repository navigation
feat(ancs): show each app's real icon in notifications - #341
Conversation
62a2cdc to
b6e95c5
Compare
b6e95c5 to
78a067b
Compare
|
Thanks for the thorough review, all fair points.
|
zackb
left a comment
There was a problem hiding this comment.
I get TLS errors here on Arch. I think glib-networking is a new runtime dependency requirement. The flatpak and appimage work i think because its shipped with Platform.
Arch: PKGBUILD needs glib-networking dependency
Fedora: packaging/rpm/tether.spec needs glib-networking
Nix: nix/package.nix buildInputs needs glib-networking
Container: packaging/container/Dockerfile needs apt-get install glib-networking (probably ca-certs too?)
Since openssl is already a hard dependency, I'd prefer doing it the old boring way than add a new dependency to fetch app icons. https_get seems like about the same amount of code with plain old boring openssl + connect() and would remove the gio requirement completely.
ANCS names the sending app only by its bundle id, so a notification's icon came from a fixed table of about 40 apps and a theme that has their names. Most themes have none, so most notifications showed a category icon or Tether's own. When the user opts in, the daemon looks each notifying app up once in Apple's public App Store lookup (itunes.apple.com/lookup?bundleId=...), downloads its 128 px artwork from Apple's image CDN, and caches it in $XDG_CACHE_HOME/tether/app-icons, cut to the iPhone's rounded-square icon shape (App Store artwork is square). Popups and the notification list put the cached icon ahead of the existing theme and category fallbacks. The replay at the start of a session fetches icons too, so most apps have theirs before they next notify. - Off by default: it is the only request Tether makes to a third-party server, and it sends the bundle id and the locale's store country, nothing else. Settings switch, TUI row and `tether --bt-app-icons on|off`. - HTTPS over OpenSSL, already a dependency, verified against the system CA store. Artwork is only fetched from *.mzstatic.com and only stored when it is a PNG; responses are capped at 1 MB. - An app the store does not know is asked about again after a week; a network failure is retried on the app's next notification. - The icon is requested as soon as the app id is known, so it downloads while the app's name is looked up. HeldPopups holds a new app's popup until both are ready, up to two seconds, and stays the one place that drops a held popup withdrawn on the phone. Tested with unit tests for the pure parts (bundle id validation, lookup URL, store country, artwork URL, HTTP response parsing, PNG check, cache lookup, icon shape, fetching, held popups, config default) and by hand: an iPhone replay cached 8 real icons within seconds and popups showed them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bd5dfa9 to
b96972d
Compare
|
Thanks, and sorry about the TLS errors. |
|
Looks good! After the conflicts are resolved I'll merge it. Thanks for this. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
NM I just had claude fix the translations. Thanks for the cool feature. |
Problem
ANCS names the app behind a notification only by its bundle id. Tether picks the icon from a fixed table (about 40 apps), first by theme name, then by bundled glyph (15 apps), then by category. Most icon themes carry no brand icons (Yaru has none), so in practice most notifications showed a category icon or Tether's own.
Change
An opt-in setting, Show real app icons (off by default):
https://itunes.apple.com/lookup?bundleId=<id>&country=<cc>, the locale's store first, thenus), downloads the 128 px PNG artwork from Apple's image CDN, cuts it to the iPhone's rounded-square icon shape (the artwork is square), and caches it in$XDG_CACHE_HOME/tether/app-icons/<bundle id>.png.HeldPopupsholds a new app's popup until both are ready, up to 2 s. Measured, a fetch takes 0.1–0.6 s.tether --bt-app-icons on|off, man page and README line.Why opt-in: this is the only request Tether would make to a third-party server. It sends the bundle id and a two-letter store country, nothing else.
How:
*.mzstatic.comand only stored if it's a PNG. Responses are capped at 1 MB.apply_icon_shape) on RGBA pixels. The daemon decodes and re-encodes the PNG with gdk-pixbuf, which libnotify already requires; core gains no image dependency.Testing
test_app_icons.cpp): bundle-id validation (path and query escapes), lookup URL, store country from the locale, artwork URL selection and CDN restriction, HTTP response parsing including truncation, PNG check, cache lookup, the icon shape (transparent corners, opaque middle and edge midpoints, anti-aliased edge, symmetry, colour untouched, row stride), andfetchingstaying false for a cached or unknown app. PlusHeldPopupstests for the combined hold, a config-default test andcache_dir()in the path tests. Suite: 684 passing.com.expedia.booking) went from no icon to a released popup with its icon in 86–104 ms.update-pot.sh --checkandcheck-catalogs.shpass.Notes for review
Pairs with #342 (GNOME popups titled with the iPhone app, with its icon in the header); the two merge cleanly in either order.
🤖 Generated with Claude Code