Skip to content

fix(ancs): wait for the app's name before a new app's first popup - #344

Merged
zackb merged 1 commit into
zackb:mainfrom
fernando2393:pr/first-popup-app-name
Nov 24, 2026
Merged

zackb merged 1 commit into
zackb:mainfrom
fernando2393:pr/first-popup-app-name

Conversation

@fernando2393

Copy link
Copy Markdown
Contributor

Problem

The first notification from an app asks the phone for the app's display name, but the popup is shown straight away with a name guessed from the bundle id. So AliExpress (com.alibaba.iAliexpress) pops up as "IAliexpress". The notification list is fixed up when the name arrives a moment later, but the popup never is.

Change

A notification that would pop up waits for its app's name, for up to 2 s (HeldPopups):

  • When the answer arrives, the held notifications are released with the real name.
  • A timeout, or an answer with no name, releases them with the guessed name. That guess is then kept, so the app's later notifications don't wait again.
  • Backlog (PreExisting) never pops up, so the session-start replay is never held.
  • If the session ends or the device changes, anything still held is released right away.

Only an app's first notification in a session can wait. The name is cached after that.

Testing

  • Unit tests for HeldPopups: release by app, expiry and release-all. The suite passes (654).
  • Running it on my own setup with my iPhone: the first popup from an app tether hasn't seen before now shows its real name.

🤖 Generated with Claude Code

@zackb
zackb self-requested a review November 23, 2026 21:24

@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 think this is the right approach and better than what currently ships.

I am slightly concerned with the hold condition delaying the the whole on_notification. Would this slow down OTP/GUI broadcast/observe_message_notification, timestamps at emit. If "Messages" never pops up, but its first notification still waits. The PR text says "a notification that would pop up". To make the code match, add should_show_desktop_popup(notification) to the hold condition I think. This respects the "muted" and disabled settings.

Comment thread src/core/src/bluetooth/ancs/client.cpp Outdated
@@ -521,10 +527,16 @@ namespace tether::bluetooth::ancs {
if (!response.app_id.empty() && !name.empty()) {

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.

nit: i think this if can be merged? and not write app_names[response.app_id] twice

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done: one if, app_names written once, and the lock isn't held during emit.

}

void HeldPopups::hold(Notification notification, int64_t now) {
held_.push_back({std::move(notification), now + WAIT_SECONDS});

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.

if the same uid is held twice (replay spams) it will show two popups? I think this should overwrite instead of append. But i could be wrong. g_ancs_popups[uid] on line 493 ish

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. It now replaces the held entry in place (keeping its deadline), with a test.

The first notification from an app asks the phone for the app's display name,
but the popup was shown at once, with a name guessed from the bundle id
("IAliexpress" for com.alibaba.iAliexpress); the list caught up a moment
later, the popup never did.

A notification that would pop up now waits for its app's name, at most two
seconds (HeldPopups, with unit tests). The answer releases it renamed; a
timeout or an answer with no name releases it with the guess, and the guess is
remembered so that app's later notifications do not wait again. Backlog never
pops up, so the replay at session start is never held. A session that ends
releases what it held.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fernando2393

Copy link
Copy Markdown
Contributor Author

Thanks! Good call on the hold condition: it now only holds what should_show_desktop_popup() would show, so Messages and backlog are never delayed. The one case left is a third-party app's first notification in a session, which can be held up to 2 s along with its broadcast. Holding the same uid again replaces the entry (with a test), and the two ifs are merged without writing app_names twice.

@fernando2393
fernando2393 force-pushed the pr/first-popup-app-name branch from c80517c to ad72c43 Compare November 23, 2026 21:52
@zackb
zackb merged commit 25995dc into zackb:main Nov 24, 2026
7 checks passed
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