Repository navigation
fix(desktop): detect web apps in Windows Chrome/Edge and Google Chat - #195
MaxFreedomPollard wants to merge 2 commits into
Conversation
detectApplicationType in formatting/formatter-prompt.ts maps a browser
tab's hostname to an app type (email, chat, notes) only when it
recognizes the foreground app as a browser. On Windows the native
helper reports the process name as the bundle identifier, and the
browser check matched it only as a case-sensitive substring of a macOS
bundle id. That happens to work for firefox, brave, opera and vivaldi,
but not for chrome ("com.google.Chrome") or msedge, nor for chromium or
zen. So Gmail, Slack or Google Docs open in Chrome or Edge on Windows
were classified as "default" and formatted with the generic rules, even
though the Windows helper resolves the tab URL for those browsers
(UrlResolver.AddressBarClassNames). Those process names are now
recognized as browsers, case-insensitively.
The Google Chat pattern was /chat\.google\com/. "\c" is a control
escape there, so the pattern looked for "chat.google" followed by
U+000F and "m", and chat.google.com was never classified as chat on
either platform. It is now /chat\.google\.com/.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Browser detection and URL tests apps/desktop/src/pipeline/providers/formatting/formatter-prompt.ts, apps/desktop/tests/pipeline/formatter-prompt.test.ts |
Browser matching includes additional bundle IDs and Windows process names. The Google Chat pattern matches a literal period. Tests cover hostname classification and non-browser applications. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: haritabh-z01
Merge Risk: 
Minimal · up to ab171
-
No concrete merge-blocking defect was established in the reviewed browser-detection changes.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
The macOS helper resolves a URL for these browsers, but the formatter did not treat them as browsers, so web apps in them fell back to "default". Drop the reverse substring match in the browser check. The explicit Windows process-name list now covers what it matched, and the reverse direction only let short names such as "google" count as a browser. Fold the browser test fixture into ctx and drop the notepad case, which the Windows helper cannot produce.
Description
On Windows, a web app open in Chrome or Edge is never classified by its URL. Dictating into Gmail, Slack or Google Docs there gets app type
default, so the local formatters (OpenRouter, Ollama, OpenAI-compatible) build their prompt with the generic rules and examples instead of the email, chat or notes ones. The samedefaultis sent asappTypewith Amical Cloud requests (projectAccessibilityContext,amical-cloud-provider-state.tsline 105) and recorded in the dictation activity metadata (transcription-service.tsline 1137). The same tabs are classified correctly on macOS, and on Windows in Firefox, Brave, Opera and Vivaldi.Separately, Google Chat (
chat.google.com) is never classified as chat on either platform.Root cause
detectApplicationTypeinapps/desktop/src/pipeline/providers/formatting/formatter-prompt.tsonly tries the URL patterns when it recognizes the foreground app as a browser (line 397). The check on line 393 compares the bundle identifier withBROWSER_BUNDLE_IDS, which are macOS bundle ids, using a case-sensitive substring test in both directions.The Windows helper reports the process name as the bundle identifier (
FocusService.csline 318), and it resolves the tab URL for the processes listed inUrlResolver.AddressBarClassNames(UrlResolver.cslines 19-31):chrome,msedge,brave,opera,vivaldi,chromium,firefoxandzen. The reverse substring test happens to findfirefox,brave,operaandvivaldiinsideorg.mozilla.firefox,com.brave.Browser,com.operasoftware.Operaandcom.vivaldi.Vivaldi. Butchromeis not a substring ofcom.google.Chrome(capital C), andmsedge,chromiumandzenmatch nothing. For those browsers the URL the helper resolved is ignored, the bundle-id tables don't know the process name, and the result isdefault.The Google Chat pattern added in #116 is
/chat\.google\com/(line 352). In a regex literal,\cfollowed by a letter is a control escape, so the pattern matcheschat.googlefollowed by U+000F andm, and neverchat.google.com.Fix
Add
WINDOWS_BROWSER_PROCESS_NAMES, the same eight names the Windows helper resolves URLs for, and treat a bundle identifier that equals one of them (case-insensitively) as a browser. The existing macOS check is unchanged. Exact matching keeps other Windows processes out, and they never carry a URL anyway because the helper resolves one only for these browsers (AccessibilityContextService.csline 78). The Google Chat pattern is now/chat\.google\.com/.Verification
I could not install the workspace dependencies in my environment, so I have not run
pnpm test,pnpm type:check, prettier or eslint. CI will be the first full run.Instead I ran the real
apps/desktop/tests/pipeline/formatter-prompt.test.tsagainst the realformatter-prompt.tsunder Node 22.23.3 with--experimental-strip-types. I used a minimal local stand-in for vitest'sdescribe/it/expectand stubs for the two type-only imports (@amical/typesandpipeline-types). None of that harness is part of this PR.formatter-prompt.tsreverted tomain(b98f79f) and the new tests kept: 8 passed, 2 failed. "classifies web apps in Windows browsers by process name" gets"default"instead of"email"forchromewithmail.google.com, and "recognizes Google Chat" gets"default"instead of"chat". The macOS case and the non-browser case pass both before and after.I also called the function directly. On
mainit returnsdefaultforchrome,msedge,chromiumandzenwithmail.google.com, andemailforfirefox,brave,opera,vivaldiandcom.google.Chrome. With the change all of them returnemail,notepadwith the same hostname still returnsdefault, andchat.google.comreturnschat.The tests pass hostnames rather than full URLs because
normalizeAccessibilityContextinnative-bridge-service.ts(line 149) reduces the URL to its hostname before detection.🤖 Generated with Claude Code
Summary by CodeRabbit