Skip to content

fix(desktop): detect web apps in Windows Chrome/Edge and Google Chat - #195

Open
MaxFreedomPollard wants to merge 2 commits into
amicalhq:mainfrom
MaxFreedomPollard:fix/browser-app-type-detection
Open

MaxFreedomPollard wants to merge 2 commits into
amicalhq:mainfrom
MaxFreedomPollard:fix/browser-app-type-detection

Conversation

@MaxFreedomPollard

@MaxFreedomPollard MaxFreedomPollard commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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 same default is sent as appType with Amical Cloud requests (projectAccessibilityContext, amical-cloud-provider-state.ts line 105) and recorded in the dictation activity metadata (transcription-service.ts line 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

detectApplicationType in apps/desktop/src/pipeline/providers/formatting/formatter-prompt.ts only tries the URL patterns when it recognizes the foreground app as a browser (line 397). The check on line 393 compares the bundle identifier with BROWSER_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.cs line 318), and it resolves the tab URL for the processes listed in UrlResolver.AddressBarClassNames (UrlResolver.cs lines 19-31): chrome, msedge, brave, opera, vivaldi, chromium, firefox and zen. The reverse substring test happens to find firefox, brave, opera and vivaldi inside org.mozilla.firefox, com.brave.Browser, com.operasoftware.Opera and com.vivaldi.Vivaldi. But chrome is not a substring of com.google.Chrome (capital C), and msedge, chromium and zen match nothing. For those browsers the URL the helper resolved is ignored, the bundle-id tables don't know the process name, and the result is default.

The Google Chat pattern added in #116 is /chat\.google\com/ (line 352). In a regex literal, \c followed by a letter is a control escape, so the pattern matches chat.google followed by U+000F and m, and never chat.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.cs line 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.ts against the real formatter-prompt.ts under Node 22.23.3 with --experimental-strip-types. I used a minimal local stand-in for vitest's describe/it/expect and stubs for the two type-only imports (@amical/types and pipeline-types). None of that harness is part of this PR.

  • With this change: 10 passed, 0 failed.
  • With only formatter-prompt.ts reverted to main (b98f79f) and the new tests kept: 8 passed, 2 failed. "classifies web apps in Windows browsers by process name" gets "default" instead of "email" for chrome with mail.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 main it returns default for chrome, msedge, chromium and zen with mail.google.com, and email for firefox, brave, opera, vivaldi and com.google.Chrome. With the change all of them return email, notepad with the same hostname still returns default, and chat.google.com returns chat.

The tests pass hostnames rather than full URLs because normalizeAccessibilityContext in native-bridge-service.ts (line 149) reduces the URL to its hostname before detection.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved recognition of supported email, chat, and notes web apps in additional macOS and Windows browsers.
    • Fixed Google Chat website detection so it is correctly identified as a chat app.
    • Prevented web addresses and partial browser identifier matches from incorrectly classifying non-browser applications as browser-based apps.

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>
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4cf0a2d1-6a03-4d24-9d3e-c7f02da0e1e4
Commits

Reviewing files that changed from the base of the PR and between 8be3c82 and ab171ce.

Files selected for processing: 2
  • apps/desktop/src/pipeline/providers/formatting/formatter-prompt.ts
  • apps/desktop/tests/pipeline/formatter-prompt.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The formatter recognizes additional browser identifiers and Windows browser process names for URL-based app classification. It corrects the Google Chat URL pattern. Tests cover hostname classification in browser contexts and verify that matching URLs do not classify non-browser applications.

Changes: Browser URL app detection

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

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: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: detecting web apps in Windows Chrome and Edge, and fixing Google Chat detection.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
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.

❤️ Share

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.
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