Skip to content

fix(desktop): 工作面板启动器可再打开一个浏览器页签 - #2490

Merged
vastsa merged 1 commit into
vastsa:mainfrom
zszz3:fix/browser-launcher-new-tab
Nov 21, 2026
Merged

vastsa merged 1 commit into
vastsa:mainfrom
zszz3:fix/browser-launcher-new-tab

Conversation

@zszz3

@zszz3 zszz3 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

问题

#2480:在工作面板里通过“+”打开内置浏览器后,再次点“+”选“浏览器”,开不出第二个浏览器页签。

原因

工作面板的启动器选“浏览器”时,页签 id 固定为 plugin:pi.browser/browser(pluginWorkPanelTab)。已经开着一个浏览器页签时,selectTool / replaceWorkPanelTabState 发现这个 id 已存在,就只切回原来的页签,并关掉刚新建的空白页签。

而对话里点链接走的是 browserPluginTab(url),每次都会生成新 id,所以点链接能开出多个浏览器页签(#1086 / e8684dd 已支持)。也就是说,只有从启动器手动打开这条路还把浏览器当成只能开一个。

修复

  • apps/desktop/src/lib/work-panel-tabs.ts 新增 launcherWorkPanelTab(tabs, tab):如果选的是浏览器,并且已经开着默认浏览器页签,就返回一个有独立 id 的空白浏览器页签;其他情况原样返回。
  • apps/desktop/src/components/workpanel/WorkPanel.tsx 的 selectTool 改用它。
  • 第一个浏览器页签仍然使用默认 id,Agent 默认打开的浏览器页面不受影响。审查、文件和其他插件视图重复打开时,仍然切回已有页签。
  • 同步更新 docs/spec/04-ux/09-interaction-patterns.md:插件视图只能开一个,浏览器例外,每个页面一个页签。

测试

  • work-panel-tabs.test.mjs 新增用户路径测试:连续两次在启动器里选“浏览器”,应该有两个浏览器页签,并且切到新开的那个,不留下空白启动页签;“审查”重复打开仍然只有一个页签。不带修复时失败,带修复后通过。
  • work-panel.test.mjs 里检查代码写法的断言改成新的写法。
  • E2E 测试:启动完整应用(Electron 主进程、渲染进程、host-core、内置浏览器插件),按用户操作点“+”选“浏览器”并打开页面一,再点“+”选“浏览器”,出现第二个页签并自动切换过去,在第二个页签打开页面二。之后核对两个页签各自保留自己的页面。不带修复时,第二次选“浏览器”不会出现第二个页签。
  • 真实使用测试:在完整应用里实际操作工作面板,确认两个浏览器页签可以并存、可以切换,内容互不影响。
  • desktop typecheck、lint、architecture 检查、docs:check、pnpm check:pr-base。

fixes #2480

Picking Browser from the work panel launcher reused the fixed
plugin:pi.browser/browser tab id, so once one browser tab was open the
pick only focused it and a second page could never be opened by hand.
Links already open each page in its own browser tab, so the launcher
was the one path still treating the browser as a singleton.

When a browser tab is already open, the launcher now opens a blank
browser tab with its own id. The first tab keeps the default id, and
every other tool view still focuses its single open tab.

fixes vastsa#2480

@aiuo-codepilot aiuo-codepilot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AIUO CodePilot · Preliminary review

Diff-only 初步审查(未运行测试、typecheck、lint 或仓库检查,无法验证运行时行为)。修改给启动器再次选择浏览器时生成独立 id 的空白浏览器页签,其他插件视图仍复用已有页签。未发现有确切新增行证据的确定缺陷;但 `sourceTabId` 替换路径与普通启动器路径的行为、并发创建多个页签时的 id 唯一性,以及旧状态迁移/序列化兼容性需在完整环境中验证。

No evidenced findings in the supplied diff.

Head: e66bb0c
Base: 48a6558
CI: success; mergeable: true.

Validation: code/tests NOT EXECUTED. Diff-only preliminary analysis; not approval. Human review and repository gates remain required.

@vastsa
vastsa merged commit 1830de1 into vastsa:main Nov 21, 2026
6 checks passed
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.

[Bug] 自带的内置浏览器插件没有办法多页签

2 participants