Repository navigation
feat(browser): 侧栏浏览器清除数据(关联 #359) - #368
Merged
freedomkk-qfeng merged 4 commits intoNov 26, 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
…0.2.2 tool pipeline Since the upgrade to DSH 0.2.2 (ECNU#276), ctx.tools.execute takes only a model batch ({ calls, signal, agent, toolSet }). The runner behind browser_read and browser_act still passed one call ({ callId, name, arguments, parent }), so every page read or action in the desktop app failed with "Tool batch execution failed". The plugin's test replaced ctx.tools.execute with a hand-written stand-in and was not in CI, so it kept passing. The runner now prepares, dispatches and completes each Playwright MCP call through ToolExecutionPipeline, as DSH's program tool calls do (tool-executor-ptc): under the run's root call, Agent, step tool set, signal and token as parent, so the browser permission still lets the run's own calls through without asking again. Context that hooks add to those calls is deferred to the run's result, and a call that concludes the turn concludes it. read-act.test.mjs now runs the tools in DSH's real registry, executor and pipeline from the pinned Runtime, with only Playwright MCP's tools as stand-ins, and installs the plugin's guard, permission and screenshot note as its apply does. It checks each MCP call's place in the run's call tree, one approval per run, a rejected run not running, step admission, stopping a run, and hook context reaching the batch. CI runs it next to the Sidebar launch test.
… data The Sidebar browser keeps sign-ins and site data for each workspace, in memory, and nothing short of restarting the app cleared them. Clearing now lives in one place in the main process (sidebar-browser-data.mjs), reached from three entries: - "Clear data for this site…" on a page's menu, for that site in the page's workspace; - a row in Settings → General, for every workspace; - the Agent's browser_clear_data, for the site of the page it last read or its whole workspace, asked for outside Full Access. A site's cookies go on every subdomain, the storage of each of its origins the workspace loaded, and the workspace's HTTP cache, which Electron cannot clear by origin for resources other pages loaded. The open pages concerned then reload, bypassing what their renderers hold in memory, and clearing answers once they have. Closes ECNU#359
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.
关联 #359
本 PR 基于 #366(右键菜单)和 #367(runner 修复),包含这两个 PR 的提交,请先审它们。清除数据的改动只在最后一个提交里。Agent 的
site范围要用browser_read读过的网页,测试也要在真实的 DSH 工具管线里跑,所以要先有 runner 修复。问题
侧栏浏览器的登录状态和网站数据按工作区存在内存里,同一工作区的对话共用一份,重启应用才会清空。界面上没有清除入口,Agent 读、写、删 Cookie 的调试命令都被拦下,Playwright MCP 自带的 Cookie 工具在侧栏里也用不了。想换账号,或让 Agent 从未登录的状态重新开始,只能重启应用。
修改
清除和随后的重新加载只在主进程实现一份(新文件
dsh-electron/src/sidebar-browser-data.mjs),有三个入口:browser_clear_data,scope为site(Agent 最后用browser_read读过的网页所在的网站,和browser_act用同一个网页)或workspace(本工作区的所有网站)。清除的内容:
clearData({ origins, originMatchingMode: 'origin-in-all-contexts' })。网站按可注册域划分,用 Cookie 的 Domain 能否设置来探测公共后缀:登录 Cookie 常设在主域上,只清一个来源会留下登录。clearCache()清掉这个工作区的整个 HTTP 缓存:Electron 按来源清不到只作为资源加载过的同站来源的缓存。清缓存不会让其他网站退出登录。session.clearData()。清除后:
reloadIgnoringCache():普通的重新加载会沿用渲染进程内存里清除前的脚本。browser_act发现网页已经换了就不执行,返回新网页让 Agent 重新判断。工具的返回文字也提醒 Agent 先重新读网页。文档:插件 README(中英文)的「确认」和「桌面侧栏」两节写明了这些入口和影响。
取舍
settings.general.item。各工作区的存储分区在 DSH 分配时经过我们的桌面桥,由桌面桥记录,不依赖分区命名。验证
sidebar-browser.test.mjs(锁定的 Electron 44.0.0,真实 broker 和sidebar-client.js),新增清除测试:site先提示读网页;很长的网页地址只发来源;端点报错和连接中断时 Agent 收到的说明。sidebar-browser.test.mjs3 次都是 13/13。www.qa.test、sso.qa.test和网站级 Cookie 被清除,other.test保留;网页重新加载后本地存储和 IndexedDB 都为空。other.test,审批卡写明网站和影响范围。Agent 清工作区:全部清空。probe-native-desktop.mjs,本地构建的壳)新增一项:经真实桌面桥分配的工作区分区,从设置页清除。macOS 上 27 项全部通过。site范围清除,审批卡写明网站和影响范围;www.qa.test、sso.qa.test和网站级 Cookie 及存储被清除,other.test保留。workspace范围,6 个 Cookie 全部清除,打开网页确认后才回答。