feat: add browser launcher registry

This commit is contained in:
QiuSW
2026-07-22 14:57:27 +08:00
parent cf828aec21
commit 23be05210b
5 changed files with 350 additions and 3 deletions
+1 -1
View File
@@ -14,7 +14,7 @@
| ID | 任务 | 依赖 | 状态 |
| --- | --- | --- | --- |
| T-101 | 实现启动、registry、Wait 和 profile 占用检测 | T-003 | TODO |
| T-101 | 实现启动、registry、Wait 和 profile 占用检测 | T-003 | DONE |
| T-102 | 实现 Windows 进程身份查询和外部实例保守识别 | T-101 | TODO |
| T-103 | 实现优雅关闭、强制关闭和 Job Object 进程树 | T-102 | TODO |
| T-104 | Chrome/Edge 双实例、异常退出和权限失败 smoke | T-103 | TODO |
+2 -2
View File
@@ -4,10 +4,10 @@
- 日期:2026-07-22
- 阶段:文档与交互原型准备
- 代码:已建立 Go module `chub`、`cmd/chub` 入口、logging 测试基座、浏览器 domain/application 合约和 Chrome/Edge 参数/发现模块,T-001 至 T-003 已完成
- 代码:已建立 Go module `chub`、`cmd/chub` 入口、logging 测试基座、浏览器 domain/application 合约、Chrome/Edge 参数/发现模块和启动 registry,T-001 至 T-003、T-101 已完成
- UI:尚未实现;P0 页面需要先制作 HTML 原型
- 浏览器核心:设计参考来自 `D:\OPC\shop_helm\internal\platform\chrome`,尚未复制或接入本项目
- blocker:无;下一个任务为 T-101
- blocker:无;下一个任务为 T-102
## 当前目录
+37
View File
@@ -0,0 +1,37 @@
---
id: T-101
title: 实现启动、registry、Wait 和 profile 占用检测
phase: 1
deps: [T-003]
status: DONE
created: 2026-07-22
owner: codex
---
## 需求与背景
Chub 需要在启动真实 Windows 进程前建立本进程实例 registry,防止并发启动相同 user data dir,并在浏览器退出后及时释放占用。
## 方案与边界
- `internal/platform/browser/Launcher` 通过 `CommandRunner` 启动参数数组。
- profile registry 以规范化 user data dir 为 key,支持 pending reservation 和重复启动错误。
- `ProcessHandle.Wait` 支持 context 取消观察,但取消不会终止浏览器。
- 进程退出后后台 monitor 释放 registry;`InspectProfile` 只报告本进程 registry。
- 本任务不识别外部进程、不强制关闭、不管理 Job Object。
## 验收要点
- 两个不同 profile 可并行启动。
- 同 profile 第二次启动返回 `ErrProfileOccupied` 并包含 PID。
- 进程退出后 profile 可再次启动。
- Wait 取消不会终止进程。
- `go test ./...`、`go vet ./...` 通过。
## 执行记录
- 状态:DONE
- 变更:新增可注入 CommandRunner、OS runner、profile registry、tracked process 和 fake runner 回归测试。
- 验证:`gofmt`、`go test ./...`、`go vet ./...` 均通过。
- 阻塞:无。
- 残余风险:registry 只代表 Chub 当前进程;外部 profile 占用需 T-102 处理。