-
Notifications
You must be signed in to change notification settings - Fork 649
refactor: yobrowser tools #1357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # YoBrowser Session 单实例实施计划 | ||
|
|
||
| ## 1. 主进程模型 | ||
|
|
||
| 1. `YoBrowserPresenter` 用 `Map<sessionId, SessionBrowserState>` 替代全局单状态。 | ||
| 2. 每个 `SessionBrowserState` 仅包含一个 `WebContentsView`、一个 `BrowserTab`、attach 信息、可见性和最后一次 bounds。 | ||
| 3. `load_url` 负责首次懒加载:创建 browser、发起 sidepanel open、等待 host ready、再导航。 | ||
|
|
||
| ## 2. 工具路由 | ||
|
|
||
| 1. `YoBrowserToolDefinitions` 仅注册 `load_url`、`get_browser_status`、`cdp_send`。 | ||
| 2. `YoBrowserToolHandler.callTool` 必须接收 `conversationId` 并据此路由 session。 | ||
| 3. `AgentToolManager` 和 `ToolPresenter` 把这 3 个名字视为内建 YoBrowser 工具。 | ||
| 4. MCP 同名工具在定义收集阶段直接过滤。 | ||
|
|
||
| ## 3. Renderer 行为 | ||
|
|
||
| 1. `BrowserPanel` 接收 `sessionId`,所有 presenter 调用都显式带 sessionId。 | ||
| 2. 切换 session 时先 detach 旧 session browser。 | ||
| 3. 若旧 session 状态不是 `working`,立即 destroy。 | ||
| 4. 若旧 session 状态是 `working`,加入 `pendingBrowserDestroySessionIds`,等状态变更后再 destroy。 | ||
| 5. YoBrowser 事件 payload 带 `sessionId`,只更新当前 panel 对应的会话。 | ||
|
|
||
| ## 4. 独立 browser 下线 | ||
|
|
||
| 1. 删除 `src/renderer/browser` 旧壳入口。 | ||
| 2. `windowPresenter` 中旧 `browser` window 类型不再创建独立窗口,统一回退到 chat window。 | ||
| 3. 清理 `tabPresenter` 中依赖 `browserTabId` 的 YoBrowser 分支。 | ||
|
|
||
| ## 5. 测试策略 | ||
|
|
||
| 1. main: | ||
| - tool definitions 只剩 3 个新工具。 | ||
| - 旧工具名报 unknown tool。 | ||
| - `load_url` 懒加载与 host-ready 流程成立。 | ||
| - session 间 browser state 隔离。 | ||
| 2. renderer: | ||
| - `BrowserPanel` 仅响应当前 session 事件。 | ||
| - session 切换时的 detach / destroy / pending destroy 成立。 | ||
| 3. 回归: | ||
| - `cdp_send` 仍走 offload。 | ||
| - disabled tools 存储和展示使用新工具名。 |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # YoBrowser Session 单实例任务拆分 | ||
|
|
||
| 1. 收敛共享类型与 presenter 接口到 session-aware 单实例模型。 | ||
| 2. 重写 `YoBrowserPresenter` 的 session 状态管理、attach、detach、destroy 流程。 | ||
| 3. 将 tool definitions / handler / agent routing 切到 `load_url`、`get_browser_status`、`cdp_send`。 | ||
| 4. 在 renderer sidepanel 中按 `sessionId` 驱动 browser panel,并实现 `working` 态延迟销毁。 | ||
| 5. 删除旧独立 browser shell 与 `browserTabId` 相关残留。 | ||
| 6. 更新 main / renderer / agent presenter 测试到新工具名和新生命周期。 | ||
| 7. 更新规格与架构文档,并跑格式化、i18n、lint、关键测试。 |
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the stale implementation reference for the
local://CDP guard.The mention of
BrowserTab.ensureSession()looks outdated for the new session-scoped architecture; point this line to the current guard location used in the presenter/tool handler path.🤖 Prompt for AI Agents