Fix: identify browser web apps and Store apps by AppUserModelID - #4
Open
luisgaertner wants to merge 5 commits into
Open
Fix: identify browser web apps and Store apps by AppUserModelID#4luisgaertner wants to merge 5 commits into
luisgaertner wants to merge 5 commits into
Conversation
…ity, disambiguate duplicate windows by title
Each workspace row gets a checkbox plus a select-all box in the header. Ticking rows reveals a bar to delete the whole selection after one confirmation, instead of removing workspaces one at a time.
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.
Description
Several kinds of window could not be identified correctly, because WindowAnchor identifies windows by executable path and window class only. That is not enough for windows that share an executable with something else.
Browser web apps. A web app installed from Chrome or Brave (e.g. Insilico Terminal) is not a separate process - it runs inside
chrome.exe/brave.exeand uses the same window class (Chrome_WidgetWin_1) as an ordinary browser window. So a PWA window was saved as "a Chrome window", and on restoreBuildProcessStartInfotook the browser branch and startedchrome.exe --restore-last-session, producing a plain browser window instead of the app. The process command line does not help either: launching a PWA (chrome_proxy.exe --app-id=...) only creates a window inside the already-running browser process.Store apps. Apps installed from the Microsoft Store live under
C:\Program Files\WindowsApps. Starting their executable by path runs them without package identity, so they cannot reach their packaged settings container - TradingView reopened in light theme instead of the user's dark theme.Two windows of the same app. Two TradingView charts (or two Explorer windows) share executable, window class and - for packaged apps - AppUserModelID, so restore could not tell them apart and sometimes placed each on the other's monitor.
Single-site browser windows. Sites without a PWA manifest cannot be installed as an app, but users still keep them in a dedicated window beside a normal multi-tab window. Such a window is indistinguishable from any other browser window, and
--restore-last-sessionrestores a session rather than a specific window.Approach
The
AppUserModelIDis the missing per-window identity. Chromium assigns every web-app window its own AUMID - that is how an installed web app gets its own taskbar group - and writes the same AUMID onto the Start-Menu shortcut it creates at install time. Packaged apps expose aPackageFamilyName!AppIdAUMID via their process.SHGetPropertyStoreForWindow+PKEY_AppUserModel_IDper window, falling back toGetApplicationUserModelIdon the process for packaged apps, whose windows usually carry no explicit AUMID.WebAppServiceindexes.lnkfiles under the Start Menu and Desktop and keeps those carrying a Chromium app switch (--app-id=/--app=), so a window's AUMID maps back to the shortcut that launches it.chrome.exe --app-id=<id>fallback), Store apps throughshell:AppsFolder\<AUMID>.IdentityCompatiblestops a browser entry from claiming a PWA window, or the reverse. Where several windows of one app remain ambiguous, they are ranked by title similarity (Sorensen-Dice over character bigrams), which is robust against volatile parts of a title such as a live price.Snapshots saved before this change carry no AUMID and keep the previous behaviour.
Also included
dedicatedBrowserUrlPatternsinsettings.json(a bare domain matches the whole site). Matching windows have their address-bar URL read via UI Automation and are reopened with--new-window <url>. When no patterns are configured, no URLs are read and snapshots are unchanged.Changes
Native/NativeMethods.Shell.csIPropertyStore,PROPVARIANT,IShellLinkW,IPersistFile,GetApplicationUserModelIdServices/WebAppService.csServices/BrowserUrlService.csModels/WindowRecord.cs,Models/WorkspaceEntry.csModels/AppSettings.csDedicatedBrowserUrlPatternsServices/WindowService.csMinimizeUserWindowsExceptServices/WorkspaceService.csServices/SettingsService.csServices/LayoutCoordinator.cs,App.xaml.csUI/SettingsWindow.xaml(.cs),UI/SaveWorkspaceDialog.xaml.csNote on
CONTRIBUTING.md: the new P/Invoke declarations went into a third file,Native/NativeMethods.Shell.cs, rather than the two listed there - the shell property system andIShellLinkCOM interfaces did not fit either the Window or Display file. Happy to merge them elsewhere if preferred.No new NuGet dependencies (
System.Windows.Automationships with the Windows Desktop SDK).Type of Change
Testing
Verified on Windows 11, two monitors, with a workspace containing two installed web apps (Insilico Terminal via Brave, aggr.trade via Chrome), two TradingView charts with different layouts, a single-site Brave window, ordinary Chrome and Brave windows, Store-installed Notepad, Explorer and Discord.
Saving logs one line per special window, e.g.
[WebApp] 'Insilico Terminal' detected (AUMID=Brave._crx_..., source=WEB_APP_SHORTCUT); plain browser windows continue through the normal path.Restoring a closed workspace brings both web apps back as app windows, TradingView back with its own dark theme, and the single-site window back at its URL alongside the normal multi-tab window.
Restoring with those windows already open repositions them instead of launching duplicates.
Two TradingView charts return to their own monitors rather than swapping.
Selecting several workspaces and deleting them removes exactly those, and the list refreshes with the selection cleared.
Tested on Windows 11
Tested on Windows 10
Tested with multiple monitors
Tested workspace save/restore
Tested file detection
Checklist
Known limitations
dedicatedBrowserUrlPatternshas no settings UI yet and must be added tosettings.jsonby hand.--app-id=<id>without--profile-directory, so it opens in the default profile. Logged as a warning.