Skip to content

feat(ancs): show each app's real icon in notifications - #341

Merged
zackb merged 2 commits into
zackb:mainfrom
fernando2393:pr/real-app-icons
Nov 26, 2026
Merged

zackb merged 2 commits into
zackb:mainfrom
fernando2393:pr/real-app-icons

Conversation

@fernando2393

@fernando2393 fernando2393 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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):

  • The first time an app notifies, the daemon asks Apple's public App Store lookup for it (https://itunes.apple.com/lookup?bundleId=<id>&country=<cc>, the locale's store first, then us), 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.
  • Popups and the GTK notification list use the cached icon first, ahead of today's theme/glyph/category fallbacks, which still apply offline or for an app the store doesn't know. The replay at session start triggers fetches too, so most apps have their icon before they next notify. The icon is requested as soon as the app id is known, so the download overlaps the app-name lookup; HeldPopups holds a new app's popup until both are ready, up to 2 s. Measured, a fetch takes 0.1–0.6 s.
  • Settings switch, TUI row, 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:

  • HTTPS with OpenSSL (already required) over a plain socket, verified against the system CA store; HTTP/1.0 so bodies are never chunked. No new build or runtime dependency.
  • Artwork is only fetched from *.mzstatic.com and only stored if it's a PNG. Responses are capped at 1 MB.
  • One background worker, so each app is looked up once per run. An app the store doesn't know is retried after a week; a network failure is retried on its next notification.
  • The shape is a superellipse (|x|^5 + |y|^5 <= 1, the usual stand-in for the iOS mask), anti-aliased with 4×4 supersampling, in a pure function (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

  • 22 new unit tests (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), and fetching staying false for a cached or unknown app. Plus HeldPopups tests for the combined hold, a config-default test and cache_dir() in the path tests. Suite: 684 passing.
  • By hand on Ubuntu 26.04 / GNOME 50 with an iPhone: one session replay cached 9 real icons (Instagram, WhatsApp, Facebook, Reminders, Uber, WHOOP, Yahoo Finance, Solflare, Ledger Live) within seconds, shaped, and popups showed them. A never-seen app (Expedia, com.expedia.booking) went from no icon to a released popup with its icon in 86–104 ms.
  • Translations: 5 new strings in all 15 catalogs (machine-assisted, like the existing ones). update-pot.sh --check and check-catalogs.sh pass.

Notes for review

  • I'm happy to change the default or the setting's wording if you'd prefer.

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

Comment thread src/core/src/app_icons.cpp Resolved
Comment thread src/daemon/main.cpp Resolved
Comment thread src/daemon/main.cpp Resolved
Comment thread src/daemon/main.cpp Resolved
Comment thread src/daemon/main.cpp Resolved
Comment thread src/daemon/main.cpp Resolved
@fernando2393

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, all fair points.

  • 429 / non-200: only a 200 answer with no app now marks it missing; 429 and other errors leave nothing behind, so the app is retried. Lookups are spaced 3 s apart (Apple's ~20/min), and a 429 pauses them for a minute. lookup_outcome() makes that decision and is unit-tested.
  • Detached thread: when_ready and its timer thread are gone. The notifier waits on its own GLib context (200 ms checks, 2 s max), so nothing runs after it's destroyed, and a popup withdrawn on the phone while it waits isn't shown.
  • Disabled setting: the cached icon is only used when the option is on.
  • popup_icons / shape_app_icon: both are out of main.cpp. The icon choice is in notification.cpp, keyed off spec.app_id, and the shaping sits next to the other pixbuf code. main.cpp is back to its call sites plus a 4-line prefetch, and the misplaced comment is fixed.

@zackb zackb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

Comment thread src/daemon/notification.cpp Resolved
Comment thread src/daemon/notification.cpp Resolved
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]>
@fernando2393

fernando2393 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks, and sorry about the TLS errors. https_get is now plain OpenSSL and connect(), verified against the system CA store, so there's no glib-networking requirement and no packaging changes.

@zackb

zackb commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Looks good! After the conflicts are resolved I'll merge it. Thanks for this.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zackb
zackb merged commit 8e441d2 into zackb:main Nov 26, 2026
7 checks passed
@zackb

zackb commented Nov 26, 2026

Copy link
Copy Markdown
Owner

NM I just had claude fix the translations. Thanks for the cool feature.

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