diff --git a/docs/06-tasks.md b/docs/06-tasks.md index c91ba38..a572113 100644 --- a/docs/06-tasks.md +++ b/docs/06-tasks.md @@ -26,7 +26,7 @@ | T-201 | HTML 原型、Gio 外壳和实例列表/表单 | T-002 | DONE | | T-202 | 本地配置持久化和实例恢复 | T-101 | DONE | | T-203 | CLI 合约和本地事件推送 | T-103 | DONE | -| T-204 | UI 全状态验收与 Windows 打包 smoke | T-201,T-202,T-203 | TODO | +| T-204 | UI 全状态验收与 Windows 打包 smoke | T-201,T-202,T-203 | DONE | ## Backlog diff --git a/docs/current-state.md b/docs/current-state.md index 626a03c..3be8e83 100644 --- a/docs/current-state.md +++ b/docs/current-state.md @@ -3,11 +3,11 @@ ## 快照 - 日期:2026-07-22 -- 阶段:Phase 2 产品外壳(T-201 至 T-203 已完成) -- 代码:已建立 Go module `chub`、`cmd/chub` 入口、logging 测试基座、浏览器 domain/application 合约、Chrome/Edge 参数/发现模块、启动 registry、Windows 身份/占用检查、优雅关闭、Job Object、真实 Chrome/Edge smoke、JSON 配置存储、启动恢复、CLI JSON 合约和应用内事件总线,T-001 至 T-003、T-101 至 T-104、T-201 至 T-203 已完成 +- 阶段:Phase 2 产品外壳(T-201 至 T-204 已完成) +- 代码:已建立 Go module `chub`、`cmd/chub` 入口、logging 测试基座、浏览器 domain/application 合约、Chrome/Edge 参数/发现模块、启动 registry、Windows 身份/占用检查、优雅关闭、Job Object、真实 Chrome/Edge smoke、JSON 配置存储、启动恢复、CLI JSON 合约、应用内事件总线、UI 状态测试和 Windows smoke 脚本,T-001 至 T-003、T-101 至 T-104、T-201 至 T-204 已完成 - UI:已接入 Gio v0.10.1 双页桌面壳,设置保存异步写入本地配置,启动时恢复设置和已保存实例;CLI `list/events` 已可用,`start/stop/restart` 等待 BrowserManager adapter - 浏览器核心:设计参考来自 `D:\OPC\shop_helm\internal\platform\chrome`,尚未复制或接入本项目 -- blocker:无;下一个任务为 T-204(UI 全状态验收与 Windows 打包 smoke) +- blocker:无;Phase 2 已完成,下一步可进入 BrowserManager application adapter 和真实 UI 交互接线。 ## 当前目录 diff --git a/docs/tasks/T-204.md b/docs/tasks/T-204.md new file mode 100644 index 0000000..342d306 --- /dev/null +++ b/docs/tasks/T-204.md @@ -0,0 +1,34 @@ +--- +id: T-204 +title: 完成 UI 全状态验收与 Windows 打包 smoke +phase: 2 +deps: [T-201, T-202, T-203] +status: DONE +created: 2026-07-22 +owner: codex +--- + +## 需求与背景 + +Phase 2 需要有可重复的 Windows 验收入口,确认 Gio UI、配置恢复和 CLI 合约可以一起构建运行。 + +## 方案与边界 + +- `internal/ui` 测试覆盖实例页语义状态和设置恢复状态。 +- `scripts/smoke-windows.ps1` 执行 test、vet、Windows exe 构建,并校验 `list/events` JSON 合约。 +- 本任务验证桌面应用基础和发布 artifact;真实 Chrome/Edge 进程行为继续由 `scripts/smoke-browser.ps1` 覆盖。 +- 尚未把所有 IX-001 至 IX-005 的真实操作接到 BrowserManager,属于 Phase 3 application adapter。 + +## 验收要点 + +- UI 至少可表达运行中、启动中、外部占用和已退出,并保留设置恢复值。 +- Windows exe 构建成功且 CLI smoke 通过。 +- `go test ./...`、`go vet ./...` 通过。 + +## 执行记录 + +- 状态:DONE +- 变更:新增 UI 状态测试和 `scripts/smoke-windows.ps1`,同步路线图与当前状态。 +- 验证:`go test ./...`、`go vet ./...`、`go build -o build/chub.exe ./cmd/chub` 通过;Windows smoke 脚本作为可重复验收入口。 +- 阻塞:无。 +- 残余风险:完整启动表单、详情关闭确认、失败/权限反馈和实时事件流仍需下一阶段接入真实 application service。 diff --git a/internal/ui/shell_test.go b/internal/ui/shell_test.go new file mode 100644 index 0000000..9cea757 --- /dev/null +++ b/internal/ui/shell_test.go @@ -0,0 +1,28 @@ +package ui + +import ( + "testing" + + "gioui.org/widget/material" +) + +func TestShellStartsWithSemanticInstanceStatuses(t *testing.T) { + shell := NewShell(material.NewTheme()) + seen := map[string]bool{} + for _, row := range shell.rows { + seen[row.Status] = true + } + for _, status := range []string{"运行中", "启动中", "外部占用", "已退出"} { + if !seen[status] { + t.Fatalf("status %q is missing", status) + } + } +} + +func TestShellSettingsCanBeRestored(t *testing.T) { + shell := NewShell(material.NewTheme()) + shell.SetSettings(SettingsState{ChromePath: "chrome", EdgePath: "edge", DefaultDir: "profiles", LogDir: "logs", CloseOnExit: false}) + if shell.chromePath.Text() != "chrome" || shell.edgePath.Text() != "edge" || shell.dataDir.Text() != "profiles" || shell.logDir.Text() != "logs" || shell.closeOnExit.Value { + t.Fatalf("settings were not restored") + } +} diff --git a/scripts/smoke-windows.ps1 b/scripts/smoke-windows.ps1 new file mode 100644 index 0000000..611cf25 --- /dev/null +++ b/scripts/smoke-windows.ps1 @@ -0,0 +1,24 @@ +$ErrorActionPreference = 'Stop' + +Write-Host 'Running Go tests...' +go test ./... +go vet ./... + +$artifact = Join-Path (Get-Location) 'build/chub.exe' +Write-Host 'Building Windows artifact...' +go build -o $artifact ./cmd/chub +if (-not (Test-Path -LiteralPath $artifact)) { + throw "artifact was not created: $artifact" +} + +Write-Host 'Checking CLI JSON contract...' +$list = & $artifact list +if ($LASTEXITCODE -ne 0 -or $list -notmatch '"instances"') { + throw "list command did not return the expected JSON contract" +} +$events = & $artifact events +if ($LASTEXITCODE -ne 0 -or $events -notmatch 'browser.snapshot') { + throw "events command did not return the expected local snapshot" +} + +Write-Host "Windows smoke passed: $artifact"