Repository navigation
feat(desktop): show the installed apps each style applies to - #287
Merged
Merged
Conversation
hadrysm
force-pushed
the
feat/style-app-banners
branch
2 times, most recently
from
October 16, 2026 09:32
d5dccea to
10215d0
Compare
The Style page cannot show which installed apps a style applies to, because nothing lists installed apps. Electron's app.getFileIcon cannot supply the icons either: on macOS 27 it returns one generic placeholder for every .app, and size "large" crashes Electron. Protocol 12 adds apps.list and icons.render. The helper scans /Applications, /System/Applications and ~/Applications, plus one level of plain subfolders, reads each Info.plist directly, and draws NSWorkspace icons into 64x64 PNGs, all on a utility queue. Main asks for the list only when the hub calls getInstalledApps, lowercases and dedupes bundle ids, and asks for icons only for catalog apps it has not rendered yet. Icons stay in memory for the life of main. A malformed list entry is dropped and the rest kept. If the helper does not answer within five seconds, the list rejects and the next call starts over. BROWSER_BUNDLE_IDS mirrors the helper's browser list for the coming app picker, and a test keeps the two equal.
Each Style tab described its category in a fixed caption that named example apps whether or not they were installed. Each tab now reads "This style applies in personal messengers" (workplace messengers, all major email apps, all other apps) followed by the icons of the matching installed apps, in catalog order. Up to four show, and "+N" names the rest in its tooltip and accessible label. An app without an icon, or whose icon fails to load, shows its first letter. The list is fetched once each time the page opens, and a failure shows no icons.
The icon cache was keyed by path alone, so an app that updated its icon in place, or was removed and reinstalled at the same path, kept its old icon until Voice restarted, and removed apps were never evicted. Each apps.listed entry now carries modifiedMs, the later of the bundle directory's and its Info.plist's modification times. Main keeps an icon only while the latest list has the same path with the same modifiedMs, and drops every other cached icon on each list. Protocol 12 is unreleased, so the field joins it without a bump.
…ter an app update
hadrysm
force-pushed
the
feat/style-app-banners
branch
from
October 16, 2026 10:49
0ce3fa2 to
8415cc7
Compare
…its fetch A list that completed while an icon request was in flight invalidated the memo, but the mounted tile got the old request back and nothing asked for the current list afterwards. The answer to an obsolete request still shows, and the load goes on to ask for the current list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #281
Why
Each Style tab described its category in a fixed caption, such as "Used in workplace messengers like Slack and Teams." The caption named example apps whether or not they were installed, so the user could not see where a style would apply on their own Mac.
Each tab now shows a banner: "This style applies in personal messengers" (workplace messengers, all major email apps, all other apps), followed by the real icons of the installed apps in that category. Up to four icons show, then "+N". The helper lists the installed apps and renders the icons, and main caches the icons in memory.
Scope
apps.listscans/Applications,/System/Applicationsand~/Applications, plus one level of plain subfolders such asUtilities. It reads eachInfo.plistdirectly and answersapps.listed { apps: { bundleId, name, path, modifiedMs, browser }[] }.browseris true for the apps the helper reads a page host from, so the app owns the browser list alone, wheremodifiedMsis the later of the bundle directory's and itsInfo.plist's modification times. The name isCFBundleDisplayName, thenCFBundleName, then the file name. Bundles without an id are skipped.icons.render { id, paths }drawsNSWorkspace.shared.icon(forFile:)into 64x64 PNGs and answersicons.rendered { id, icons: { path, png }[] }, so main matches each reply to its request. Both commands run on a utility queue. The pure plist-to-entry function,installedApp(info:path:), lives inVoiceHelperCore.main/protocol.ts: version 12 and the two events. A malformed entry is dropped while decoding, and the rest of the list survives.main/installed-apps.ts: main asks for the list only when the hub callsgetInstalledApps, never at startup.list()lowercases and dedupes bundle ids and returns without waiting for any icon.icons(bundleIds)renders the icons a tile asks for, in helper lines of at most 32 paths, and leaves out any the helper could not render. Icons stay in memory, keyed by path, and are reused only while the latest list has the same path with the samemodifiedMs, so an app updated in place or reinstalled gets its new icon, and removed apps are dropped from the cache on every list. Each render reply is matched to its request by id; a reply to a timed-out request is dropped. Concurrent list calls share one request. If the helper does not answer within 5 s, the list rejects and the page shows no icons. The next open starts over.shared/api.ts:InstalledApp = { bundleId: BundleId; name: string; browser: boolean },HubApi.getInstalledApps()andHubApi.getAppIcons(bundleIds), which returns PNG data URLs by bundle id. Paths never reach the renderer.shared/app-categories.ts:parseBundleIds(raw)reads the bundle ids out of the untrusted IPC argument. PR 6 leaves browsers out of its picker by the helper'sbrowserflag; there is no TS copy of the browser list.renderer/styleView.ts,Style.tsx,useInstalledApps.ts,AppIcon.tsx,appIcons.ts: the banner shows the installed apps of the tab's category in catalog order, using the catalog's display names, and an app installed under two catalog ids (classic and new Teams) once. EachAppIcontile asks for its own icon throughuseAppIcon(bundleId); the tiles mounted in one tick share onegetAppIconscall, an icon stays in the renderer while the window is open, and an id the helper could not render is forgotten so a later mount asks again. A tile shows the app's first letter until its icon arrives, or when the image fails to load. Each icon has the app name as its accessible name and its tooltip. "+N" names the hidden apps in its label and tooltip. Other shows no icons. The page fetches the list once each time it opens.features/style.mddescribes the banners.Tradeoffs
app.getFileIconcannot. On this Mac (macOS 27, Electron 44) it returns the same generic placeholder for every.app: Messages, Slack, Mail, WhatsApp, Discord, Teams and Terminal all gave byte-identical PNGs.size: "large"crashed Electron with SIGTRAP.NSWorkspace.shared.icon(forFile:)returns the real icon.Blast Radius
The helper and the app refuse each other across the version bump, as they already do.
native/voice-helper/scripts/helper.mjspins version 12. Nothing new runs at startup or during dictation. Opening Style sends oneapps.list, plus oneicons.renderthe first time. The installed-app list is never logged or persisted.Verification
swift test --filter 'InstalledApp|Protocol': 17 tests pass. They cover id present, missing, blank or not a string; the display name,CFBundleNameand file-name fallbacks; a padded name; and the exact JSON of both commands and both events.vp test runonprotocol.test.ts,installed-apps.test.ts,styleView.test.ts,app-categories.test.ts,style.test.ts,hub.test.ts,helper.test.tsanddictation.test.ts: 262 tests pass.tsc --noEmitpasses. The tests cover:icons.render;modifiedMs) and an app removed then reinstalled at the same path, both rendered again;apps.listreturns 105 bundles, including Terminal from/System/Applications/Utilities.icons.renderdrops a missing path and returns real 64x64 Slack and Mail icons.["Messages","WhatsApp","Discord"].getInstalledAppsround trip from the renderer: 132 ms on the first open (list plus 6 icons), and 14 ms on each of three later opens (list only, icons cached). The helper alone measured 89 ms for a coldapps.listand 12 to 15 ms for a cold 2-iconicons.render.apps.list.apps.listand 0icons.render.main.loghas no app name or path.Personal, Work, Email and Other:
Review round 2
Changed after review (reports 04, 06, 07): protocol 12 is defined once, with
icons.render { id, paths }andicons.rendered { id, icons }here instead of in PR 6, andapps.listedentries carrybrowserfrom the helper's own list, which deletes the TSBROWSER_BUNDLE_IDSmirror and its Swift-source regex test.list()no longer waits for a render; icons became a per-tile concern (AppIcon.tsx,appIcons.ts) over a newgetAppIconschannel, with main rendering at most 32 paths per helper line. The module-globallistedStampsis gone: the cache is written from the stamps of the list the request was built on. The banner dedupes a name shipped under two ids,installedAppsis declared beforestartHelperlikedictation,parseBundleIdsparses the IPC argument, and the fake helper answersapps.listandicons.render.Proof:
swift buildandswift test --filter 'InstalledAppTests|Protocol'(12 tests) pass;tsc --noEmitpasses;vp test runon installed-apps, protocol, appIcons, styleView, style, hub and helper tests passes (150 tests), including a render split into 32 + 3 paths, a late reply to a timed-out render that does not complete the next one, an unrenderable id asked for again on the next request, same-tick batching, and the Teams dedupe (the test fails when the dedupe guard is removed). The real helper lists 105 apps and flags Google Chrome, Helium and Safari as browsers. Live, in test mode with the real helper: Personal shows Messages, WhatsApp and Discord, Work shows Slack and Microsoft Teams, Email shows Mail, Other shows none, all as<img>tiles with the app name as the accessible name;getInstalledApps90 ms, 40 cold icons 475 ms in two helper lines, the same 40 warm 5 ms;main.loghas no app path.dictatewas not run; it is out of this change's path.Opening Style, round 2:
style-open-r2.mp4
Switching tabs (round 1):
style-banners.mp4
Review round 3
Changed after round 2 (reports 08 and 09): an icon asked for before the first installed-app list completed got
{}and never retried, so a chip mounted from saved settings on a cold open stayed a letter.icons()in main now waits for the list in flight, or runs the first one, before resolving paths, and returns{}only when that list fails. The renderer's icon memo used to keep the first PNG for the life of the window, which defeated main's path-and-stamp freshness after an app update. The memo now carries a generation:listInstalledApps()inappIcons.tslists and then invalidates, a stale icon stays on show until its refetch replaces it, anduseAppIconsubscribes to the loader so a mounted tile re-requests after each list. The helper's secondisBrowseroverload is gone; the installed-app scan calls PR 5's optional one.Proof:
vp test runon installed-apps, appIcons and styleView passes (27 tests). The six new tests were red on the previous head ({}against Mail's icon in main; noinvalidateorsubscribeon the loader) and cover an icon asked for while the first list is in flight, before any list, and when the list never arrives; invalidation keeping the icon on show and refetching once; a stale icon forgotten when the refetch leaves it out; and, through the realcreateIconLoaderover the realcreateInstalledApps, an app updated in place keepingicon-v1on show untilicon-v2arrives, plus a remount after an unchanged list that asks main and gets memory, with no newicons.render.tsc --noEmit,vp lintandvp fmt --checkpass on the changed files.swift buildandswift test --filter InstalledApp(8 tests) pass. Live, in test mode with the real helper and the desktop lock: Personal shows Messages, WhatsApp and Discord as<img>tiles on open, Work adds Slack and Microsoft Teams, and after Home and back to Style the three Personal tiles are<img>again.main.loghas no app path or name.dictatewas not run; it is outside this change's path and the user's Voice.app was running.Review round 4
Changed after round 3 (report 10): a list that completed while an icon request was in flight invalidated the memo, but the mounted tile got the old request back and nothing asked for the current list afterwards, so an updated icon could stay old or a missing one stay a letter. The answer to an obsolete request still shows, since it is never older than what it replaces, and the load goes on to ask for the current list. Proof: four new loader tests (obsolete answer with an icon, with no icon, and failing; and a second invalidation during the follow-up) were red on the previous head and pass now, with the hook's subscribe-then-load wiring. Live, Personal still shows Messages, WhatsApp and Discord as
<img>tiles on open and after Home and back.