Repository navigation
feat(browser): 侧栏网页可按桌面宽度显示,Agent 可切换当前标签页(关联 #360) - #369
Merged
freedomkk-qfeng merged 9 commits intoNov 27, 2026
Merged
Conversation
A page in the Sidebar browser showed nothing on a right click. The desktop bridge now opens a native menu for what was clicked, in the application's language: link items (new tab, system browser, copy address), image items (copy image, copy address), editing or copy for fields and selected text, and back, forward and reload elsewhere. New tabs and the system browser go through the same paths as the Sidebar's own toolbar and DSH's popup checks. The broker marks a page whose latest input came from its Agent, so the Agent's right clicks and menu keys reach the page's own handlers without showing a menu on the user's screen. Closes ECNU#358
A page in the Sidebar laid out at the width of its tab, about 576 pixels by default, where many sites switch to their phone layout. By default a page in a tab narrower than 1280 pixels now lays out 1280 wide and shows scaled down to fill its tab. Only the guest element's own inline style changes: scaled from its top-left corner, with negative margins so the tab keeps its own size. It is sized as soon as it is found, so a page loads in its desktop layout, and the Agent's clicks, typing and screenshots use the same width. Settings → General chooses desktop width or the Sidebar's width for every page, as the browser plugin's volatile sidebarWidth setting; a page's menu chooses it for one tab until the app quits. In the Sidebar the broker refuses Emulation.setDeviceMetricsOverride, which only browser_resize sends, telling the Agent that the user chooses the width. The desktop smoke now checks that the browser plugin's settings are served, which they are only once it activates, and in its full run opens a Sidebar page, switches its width in settings and clicks the scaled-down page. Closes ECNU#360
Member
|
感谢这次实现和比较完整的验证。桌面宽度模式对一些窄屏下会隐藏导航、影响 Agent 操作的网站有价值,我们希望保留这个能力,但调整一下默认行为,并补齐 Agent 的调用入口:
验证时请补一下默认布局、Agent 切换及切回、标签页隔离,以及切换后点击/截图坐标正确、不会主动刷新丢失未提交内容的场景。麻烦看看按这个方向调整是否合适,谢谢! |
…desktop-width # Conflicts: # source-receipt.json
… its tab's layout Sidebar pages now lay out at the Sidebar's width unless the user chooses desktop width in Settings or for one tab from its menu. The Agent's new browser_layout tool switches the tab it acts on between the two, through the same per-tab choice and fitting: it marks Playwright's current page with a script, and the broker lays out the page that carried the mark and answers once the page has its new width. The browser_resize refusal points to it.
Contributor
Author
|
已按这个方向调整,改动在 832497c,正文已更新:
补充的验证(详见正文「验证」):
|
…read for browser_clear_data browser_clear_data said it clears the website of the page last read with browser_read, but browser_act and browser_layout show the page they leave the Agent on as well, and that page is the one it clears the website of. Say so in the tool and in both READMEs. Test that browser_layout alone sets the website the approval names and the request clears; and that a tab laid out at desktop width alone keeps that width, and its menu the choice, as clearing reloads its page and as the setting applies anew, while the other tab still follows the Sidebar.
A Sidebar tab's new document may run its first script before Chromium gives it its size: innerWidth is 0 there, and the page is resized a moment later. It shows when several pages reload at once, as clearing a workspace's data reloads them, and on a slow machine, as on the macOS CI. Plain Electron webviews show it too, and none do with RenderDocument disabled. The tests and the full desktop smoke now take the widths a page sees once it has one, and wait for the unmarked webview's page to have its size.
Draft
This comment has been minimized.
This comment has been minimized.
This was referenced Nov 27, 2026
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.
关联 #360
宽度的改动在 f6fc14f 和 832497c 里,按审查意见调整的部分都在 832497c。#366、#368 合并后又合入了 main:两边都改过的地方(侧栏端点的请求处理、右键菜单、设置页、插件里的工具注册)在合并提交 55c836b 里解决;清除数据和切换布局一起用时的说明和测试在 b8815d2 里补上。Chromium 有时让新网页的第一个脚本量到宽度 0(见“已知问题”),两处测试断言和一处冒烟检查在 4423a51 里按这一点调整。
问题
侧栏网页按标签页的实际宽度排版。右侧栏默认是窗口宽度的 45%(1280 像素宽的窗口里约 576 像素),很多网站在这个宽度下换成手机布局,菜单收起、部分功能不显示;Agent 在这样的布局下更容易失败(见 #360 的对比)。Agent 调用
browser_resize后,用户在侧栏里只看到网页的左边一部分,直到 Agent 断开。修改
browser_layout(mode: "desktop" | "sidebar"):只改 Agent 当前操作的标签页,和右键菜单改的是同一个选择,用户可以从右键菜单改回来;不改用户的设置,不影响其他标签页和其他对话。只有对话自己的 Agent 有这个工具,子 Agent 用独立浏览器,没有它。browser_layout的结果和browser_read、browser_act的一样附上网页,所以browser_clear_data说明里的“最后读到的网页”也包括它,说明和 README 都按这个写。browser_layout的结果说明网页现在实际按多宽排版(确认排好才报宽度,否则说明还没排好),并像browser_read一样附上切换后的网页。网页不刷新;结果里提醒 Agent:在加载时决定布局的网页要刷新后才换,只有用户没有未保存的内容时才能刷新。browser_layout切到桌面宽度。browser_resize:broker 拦截Emulation.setDeviceMetricsOverride(Playwright 只有这个工具发这条命令,截视口、整页和元素都不用它),报错指向browser_layout,并说明用户的两个入口。sidebarWidth,默认sidebar,这是 DSH 0.2.2 插件设置的做法:DSH 按组合配置里的条目eduwork-browser保存,设置页按同一个条目读写。插件关掉 DSH 自动生成的表单,自己在「通用设置」里放这一行。@deepseek-ai/schemastery的 peer 钉为锁定的 3.19.0,volatile()需要它。做法与取舍
browser_layout先用browser_evaluate在 Playwright 的当前页执行一段带随机标记的脚本,broker 转发这条命令时,在这个页自己的 CDP 会话上记下标记;插件再把模式和标记 POST 到这个对话的侧栏端点(和 CDP 同一个本机端点,只接受 Host 进程的请求)。broker 只认这个对话当前连接留下的、没用过的标记,Agent 空闲或断开时清掉。没有按标签页序号选:用户中途关掉前面的标签页时,序号会变。innerWidth变到对应宽度(按应用和网页的缩放换算),整个请求最多 2 秒,超时时如实告诉 Agent。设置变化和右键菜单的状态上报不带编号,不会被当成回答。browser_resize:Playwright MCP 的基础工具去不掉,DSH 也不能按工具名隐藏。试过在侧栏提示里写明它不起作用,用户说了具体尺寸时,真实模型仍会先调用一次,所以没有加。transform: scale()从左上角缩小,再用负外边距让它在布局里不占位置,所以标签页的大小不受它影响,侧栏仍能拖窄。data-sidebar-browser-frame属性(feat(browser): 对话的 Agent 直接操作侧栏浏览器标签页(关联 #212) #250 已在用),以及 DSH 不给这个元素设内联尺寸。DSH 没有标记的 webview 照常跟随侧栏宽度,菜单里也不显示勾选项。下面的冒烟项在升级 DSH 或 Electron 后打候选包时守护这两点。setZoomFactor按网站记录,新网站会先按窄宽度加载;enableDeviceEmulation刷新或截图后就失效;CDP 模拟加缩放会让 Playwright 的点击失败;CSSzoom会让 Agent 的截图放大到 2844×3791。验证
sidebar-browser.test.mjs(锁定的 Electron 44.0.0,真实 broker 和sidebar-client.js),按网页的布局宽度和“显示框正好铺满标签页”核对:setViewportSize被拒,提示指向browser_layout;关闭标签页后不再跟踪它。read-act.test.mjs:browser_layout的调用顺序(打标记、POST、读页)、结果文字、读页失败时清掉旧的读页记录、桌面应用拒绝时报错、子 Agent 没有这个工具。只调用browser_layout、没有调用browser_read就清除网站时,审批里写的和请求里清除的都是这个网页的网站。desktop-smoke.mjs:settings-over-official-pipe(macOS 和 Windows 每次打包的验收都跑)断言浏览器插件的设置条目存在、取值有效、不自动生成表单,并且产品默认值是sidebar。插件没有激活时这个条目不存在,以前的打包验收不检查插件有没有激活;用没有激活浏览器插件的旧包核对过,这一项会失败。sidebar-page-at-desktop-width:在设置里选桌面宽度,新会话里打开侧栏网页(冒烟脚本在 127.0.0.1 上自己起的页面),核对首次加载宽度、铺满和缩小画面上的点击;再在设置里切到跟随侧边栏、切回桌面宽度,核对宽度变化、网页没有重新加载、Host 上的取值,最后再点一次。browser_layout切到桌面宽度:网页 1280 宽,显示桌面导航,缩小后铺满标签页;用户输入但没提交的文字还在;设置不变;Agent 的点击命中按钮,截图 1280×1655;右键菜单里已勾选。browser_resize被拒,提示指向browser_layout。browser_layout切到桌面宽度,再用语言筛选和右上角的排序,最后的地址带language:Python和s=stars&o=desc,网页 1280 宽、铺满 576 宽的标签页。当天学校模型每一步要 40–110 秒,15 分钟的测试上限到时 Agent 还没写出回答;browser_layout这一步用时 0.35 秒。browser_layout(sidebar),回答“已把侧边栏这个标签页恢复为跟随侧边栏宽度(现在按 576 px 排版),筛选和排序都还在”,并补上了上一轮没来得及给的结果。网页 576 宽、铺满标签页,地址里的筛选和排序参数都在,没有刷新。browser_resize被拒后,Agent 按当前尺寸截图,再用提问卡问用户是把侧边栏拖到约 800 像素宽,还是把这个标签页切到桌面宽度;它说明高度由窗口决定,800×600 这个精确尺寸在侧边栏里做不到。已知问题
sidebar-browser.test.mjs里有两个测试在 main 上就偶发失败,与本 PR 无关:Windows 虚拟机里的each conversation drives only its own tabs(main 4 次失败 3 次);conversations working at once keep their own marker and the user's focus(macOS 上 main 8 次失败 2 次;本分支开发过程中整套测试跑了 24 次,这一项失败 1 次;合入 main 后又跑了 12 次,失败 1 次)。