Skip to content

feat(browser): tell browsers apart, and let the user choose one - #1072

Merged
leookun merged 3 commits into
baocode-dev:mainfrom
hatricks-s:feat/browser-choice-and-identity
Nov 17, 2026
Merged

leookun merged 3 commits into
baocode-dev:mainfrom
hatricks-s:feat/browser-choice-and-identity

Conversation

@hatricks-s

@hatricks-s hatricks-s commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Issue: #1071

Settings → Browser could not tell two Chromium browsers apart (Cent Browser reports the brand Google Chrome), did not say which browser the file-access note was about, and gave no way to pick the browser the agents use. With several browsers connected the tools always used the last connected — and when that was a browser left running with no window, every call failed with Chrome's No current window.

What changed

  • Which browser it is. The native host (macos/BrowserBridge/host.c, used on Linux too, and windows/BrowserBridge/host.cpp) reports its browser's executable: the process that started it, walking past the cmd.exe Windows starts it with. The extension reports the Chromium version from UA-CH's fullVersionList, falling back to the user agent. displayName takes the name from the executable where the brand is borrowed (centbrowser → Cent Browser, microsoft edge → Microsoft Edge, …), the brand otherwise.
  • Choosing one. Settings → Browser shows each connected browser with its own name, Chromium <version>, the executable's path and the extension's version. Each row has Use This Browser; the choice is kept as settings.json's browser.preferred (the executable's path). The tools use that browser while it is connected; when it is not, they use the last connected and the settings say which, until it connects again.
  • No window. groups() catches No current window: tabs.list answers with no shared tabs and tabs.create opens a window. The file-access note names its browser now.

The extension's version is 0.2.1.

How it was tested

With Flutter 3.47.5 (the FLUTTER_VERSION in Checks) on Windows:

  • flutter analyze --fatal-infos: no issues.
  • dart format --output=none --set-exit-if-changed on the changed Dart files: clean.
  • flutter test test/browser/browser_bridge_test.dart test/browser/browser_welcome_test.dart test/settings/browser_page_test.dart test/l10n_test.dart: 29 passed, 6 skipped (the socket tests skip on Windows). The new test also passes on Windows with its skip removed for the run.
  • windows/BrowserBridge/host.cpp: compiles with g++ -std=c++17 -Wall -Wextra -Werror (MinGW), _WIN32_WINNT=0x0600.

Checklist

@github-actions github-actions Bot added needs-issue Pull request without an accepted issue (PR gate) too-large Pull request over about 400 changed lines (PR gate) labels Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Thanks for the pull request! It doesn't follow CONTRIBUTING.md yet:

  • Too large: 406 lines changed (tests and generated files not counted; about 400 at most). Split it into steps that each build and pass their tests, agreed in the issue.

感谢提交!这个 PR 还不符合 CONTRIBUTING.md:

  • 太大:改动 406 行(不含测试和生成文件,上限约 400 行)。请拆成几步,每步都能单独编译、通过测试,并先在 Issue 里商量好怎么拆。

yanyh added 2 commits November 17, 2026 12:50
The native host says the executable of the browser it runs in, walking
past the cmd.exe Windows starts it with; the extension says its Chromium
version beside the brand (Cent Browser's UA says Google Chrome, its
version does not).

A browser left running with no window now answers tabs.list with none
shared instead of failing every call with "No current window", and
tabs.create opens a window for it.
Settings → Browser now says each connected browser's own name (Cent
Browser is not Google Chrome), its engine and version, and the path of
its executable, so two alike-branded browsers can be told apart. Each
row has "Use This Browser": the choice is kept as settings.json's
browser.preferred, and the agents' tools use that browser while it is
connected (the last connected when none is chosen). A chosen browser
that is not connected is said as such, not switched away from.

The file-access note says which browser it is about.
@hatricks-s
hatricks-s force-pushed the feat/browser-choice-and-identity branch from 8751392 to a4250be Compare November 17, 2026 04:50
@github-actions github-actions Bot removed too-large Pull request over about 400 changed lines (PR gate) needs-issue Pull request without an accepted issue (PR gate) labels Nov 17, 2026
- With the browser chosen in Settings → Browser not connected, the tools
  use the last connected rather than failing; the settings say which,
  until it connects again.
- The history finds a request's live tab in the browser the tools use.
- dart format; the analyzer's null-aware elements.

Co-Authored-By: BaoCode <noreply@baocode.dev>
@github-actions github-actions Bot added the too-large Pull request over about 400 changed lines (PR gate) label Nov 17, 2026
@leookun
leookun merged commit 3d74618 into baocode-dev:main Nov 17, 2026
1 of 2 checks passed
@hatricks-s

Copy link
Copy Markdown
Contributor Author

Thanks for the fix — the fallback reads better than the error. I kept it as is and trimmed the names and three comments to get the gate's count from 406 to 398. Ran Flutter 3.47.5 (the Checks version) locally on Windows: flutter analyze --fatal-infos clean, dart format clean, and the related tests pass (29 passed, 6 skipped — socket tests skip on Windows); the new test passes on Windows too with its skip removed for the run. The body now says how it was tested.

leolee-code pushed a commit to leolee-code/baocode that referenced this pull request Nov 17, 2026
…ode-dev#1072)

* feat(browser): Say which browser and engine each one is

The native host says the executable of the browser it runs in, walking
past the cmd.exe Windows starts it with; the extension says its Chromium
version beside the brand (Cent Browser's UA says Google Chrome, its
version does not).

A browser left running with no window now answers tabs.list with none
shared instead of failing every call with "No current window", and
tabs.create opens a window for it.

* feat(browser): Name browsers truly, and let the user choose one

Settings → Browser now says each connected browser's own name (Cent
Browser is not Google Chrome), its engine and version, and the path of
its executable, so two alike-branded browsers can be told apart. Each
row has "Use This Browser": the choice is kept as settings.json's
browser.preferred, and the agents' tools use that browser while it is
connected (the last connected when none is chosen). A chosen browser
that is not connected is said as such, not switched away from.

The file-access note says which browser it is about.

* fix(browser): a chosen browser away, the last connected is used

- With the browser chosen in Settings → Browser not connected, the tools
  use the last connected rather than failing; the settings say which,
  until it connects again.
- The history finds a request's live tab in the browser the tools use.
- dart format; the analyzer's null-aware elements.

---------

Co-authored-by: yanyh <yanyh@glodon.com>
Co-authored-by: leo <leokuncn@gmail.com>
(cherry picked from commit 3d74618)
@hatricks-s
hatricks-s deleted the feat/browser-choice-and-identity branch November 18, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

too-large Pull request over about 400 changed lines (PR gate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants