提交记录修改docs/getting-started.md+1 −1看文件
修改internal/workbench/initialization.go+2 −1看文件
修改ui/scripts/initialization-smoke.mjs+35 −0看文件
修改ui/scripts/packaged-startup-smoke.mjs+1 −1看文件
修改ui/src/initialization.jsx+6 −1看文件
修改ui/src/proxy-settings.jsx+3 −3看文件
| @@ -40,7 +40,7 @@ | ||
| 40 | 40 | |
| 41 | 41 | ### 选择环境存储位置 |
| 42 | 42 | |
| 43 | 删除:Windows 安装器中选择的是程序目录。如果希望镜像下载和虚拟磁盘都放在 D 盘,首次打开工作台后,点击“选择环境存储位置”,选一个专用空文件夹,例如 `D:\CageData`,点击“使用此位置”,再启动环境。macOS 和 Linux 的本机工作台也提供这个入口。Debian 环境默认设置下,虚拟磁盘在用户主目录的 `.claude-cage/state/lima`,镜像下载缓存在系统用户缓存目录下的 `lima`(Windows 为 `%LOCALAPPDATA%\lima`)。 | |
| 43 | 新增:Windows 安装器中选择的是程序目录。如果希望镜像下载和虚拟磁盘都放在 D 盘,首次登录后在独立初始化界面的“系统与存储”中选择专用空文件夹,例如 `D:\CageData`,点击“使用此位置”,再配置代理并开始安装。macOS 和 Linux 使用相同流程。安装、必要授权与网络检查完成后才进入工作台;中断后重新打开仍可继续。Debian 环境默认设置下,虚拟磁盘在用户主目录的 `.claude-cage/state/lima`,镜像下载缓存在系统用户缓存目录下的 `lima`(Windows 为 `%LOCALAPPDATA%\lima`)。 | |
| 44 | 44 | |
| 45 | 45 | 选择支持私有文件权限和稀疏文件的本地磁盘。Windows 可用 NTFS,Linux 可用 ext4、XFS 或 Btrfs。Mac 需要 APFS 卷并启用所有权。使用 Mac 外接盘时,在 Finder 的磁盘“显示简介”中取消“忽略此宗卷的所有权”。 |
| 46 | 46 | |
| @@ -22,6 +22,7 @@ type initializationView struct { | ||
| 22 | 22 | Required bool `json:"required"` |
| 23 | 23 | Started bool `json:"started"` |
| 24 | 24 | Tracked bool `json:"tracked"` |
| 25 | 新增: Prepared bool `json:"prepared"` | |
| 25 | 26 | } |
| 26 | 27 | |
| 27 | 28 | func (s *Server) initializationState() (initializationView, error) { |
| @@ -34,7 +35,7 @@ func (s *Server) initializationState() (initializationView, error) { | ||
| 34 | 35 | if json.Unmarshal(data, &record) != nil || record.Version != 1 { |
| 35 | 36 | return initializationView{}, errors.New("初始化记录无法读取,请保留现有数据并导出诊断包") |
| 36 | 37 | } |
| 37 | 删除: return initializationView{Required: !record.Completed || s.macSetupPending(), Started: record.Started, Tracked: true}, nil | |
| 38 | 新增: return initializationView{Required: !record.Completed || s.macSetupPending(), Started: record.Started, Tracked: true, Prepared: s.environmentPrepared()}, nil | |
| 38 | 39 | } |
| 39 | 40 | if !errors.Is(err, os.ErrNotExist) { |
| 40 | 41 | return initializationView{}, err |
| @@ -86,3 +86,38 @@ for (const [platform, system] of [["darwin", "macos"], ["windows", "windows-11"] | ||
| 86 | 86 | console.log(`PASS ${platform}: independent initialization, inline keyboard selection, back navigation, progress, refresh, retry, completion gate and reopen`); |
| 87 | 87 | } finally { await browser.close(); } |
| 88 | 88 | } |
| 89 | 新增: | |
| 90 | 新增:{ | |
| 91 | 新增: let imported = false, applied = false; | |
| 92 | 新增: const f = await createWorkbench({ initialization: { required: true, tracked: true }, beforeNavigate: async (page, state) => { | |
| 93 | 新增: state.status.local_vm_storage = true; | |
| 94 | 新增: await page.route("**/api/environment/storage", route => route.fulfill({ json: { directory: "/preview/cage-state", has_environment: false } })); | |
| 95 | 新增: await page.route("**/api/environment/guest-systems", route => route.fulfill({ json: { fresh: true, available: true, system: "macos" } })); | |
| 96 | 新增: await page.route("**/api/proxy", route => route.fulfill({ json: { active: applied, selected: applied ? "node" : "", sources: imported ? [{ id: "source", name: "自有节点", nodes: [{ id: "node", name: "本机测试代理", type: "socks5" }] }] : [], port: 17896, core_available: true } })); | |
| 97 | 新增: for (const action of ["import", "route"]) await page.route(`**/api/proxy/${action}`, route => { | |
| 98 | 新增: if (action === "import") imported = true; | |
| 99 | 新增: else applied = true; | |
| 100 | 新增: state.status.job = { id: action, kind: "proxy", running: false, message: "已完成" }; | |
| 101 | 新增: return route.fulfill({ json: state.status.job }); | |
| 102 | 新增: }); | |
| 103 | 新增: } }); | |
| 104 | 新增: try { | |
| 105 | 新增: const { page } = f; | |
| 106 | 新增: await page.getByRole("button", { name: "下一步:配置代理" }).click(); | |
| 107 | 新增: const start = page.getByRole("button", { name: "开始安装", exact: true }); | |
| 108 | 新增: assert.ok(await start.isDisabled()); | |
| 109 | 新增: await page.getByRole("button", { name: "添加来源", exact: true }).click(); | |
| 110 | 新增: await page.getByRole("button", { name: "手动节点", exact: true }).click(); | |
| 111 | 新增: await page.getByLabel("来源名称", { exact: true }).fill("自有节点"); | |
| 112 | 新增: await page.getByLabel("节点名称", { exact: true }).fill("本机测试代理"); | |
| 113 | 新增: await page.getByLabel("服务器", { exact: true }).fill("127.0.0.1"); | |
| 114 | 新增: await page.getByRole("button", { name: "导入并验证", exact: true }).click(); | |
| 115 | 新增: await page.getByRole("tab", { name: "节点", exact: true }).click(); | |
| 116 | 新增: await page.getByRole("button", { name: "选择节点 本机测试代理", exact: true }).click(); | |
| 117 | 新增: await page.getByRole("button", { name: "应用代理", exact: true }).click(); | |
| 118 | 新增: await page.getByText("已完成", { exact: true }).waitFor(); | |
| 119 | 新增: await page.waitForFunction(() => [...document.querySelectorAll('button')].some(button => button.textContent === '开始安装' && !button.disabled)); | |
| 120 | 新增: assert.deepEqual(f.errors, []); | |
| 121 | 新增: console.log("PASS first proxy: manual import, node selection and explicit apply unlock installation inside initialization"); | |
| 122 | 新增: } finally { await f.browser.close(); } | |
| 123 | 新增:} | |
| @@ -54,8 +54,8 @@ try { | ||
| 54 | 54 | await page.getByRole("button", { name: "下一步:配置代理", exact: true }).click(); |
| 55 | 55 | await page.getByRole("heading",{name:"连接你的网络代理",exact:true}).waitFor(); |
| 56 | 56 | assert.ok(await page.getByRole("button",{name:"开始安装",exact:true}).isDisabled(), "proxy must be applied before installation"); |
| 57 | 删除: if(evidence) await page.screenshot({ path:path.join(evidence,"initialization-proxy.png") }); | |
| 58 | 57 | await page.getByText("添加来源", { exact: true }).first().waitFor(); |
| 58 | 新增: if(evidence) await page.screenshot({ path:path.join(evidence,"initialization-proxy.png") }); | |
| 59 | 59 | assert.deepEqual(errors, []); |
| 60 | 60 | console.log(JSON.stringify({ checks: ["standalone initialization after account setup", "VM stopped throughout", "no workbench navigation before initialization", "SSH-only alternative", "proxy required before installation", packaged ? "packaged helper bootstrap" : "development helper bootstrap", "real session and APIs", "embedded production UI loaded", "private profile onboarding", "launch ticket removed"], version: entry.controller.version })); |
| 61 | 61 | } finally { |
| @@ -67,6 +67,7 @@ function Initialization({ initial, onComplete }) { | ||
| 67 | 67 | const pollNow = useRef(null); |
| 68 | 68 | const activation = useRef(false); |
| 69 | 69 | const actionPending = useRef(false); |
| 70 | 新增: const restored = useRef(false); | |
| 70 | 71 | const job = status?.job || {}; |
| 71 | 72 | const busy = submitting || Boolean(job.running); |
| 72 | 73 | const network = networkState(status); |
| @@ -96,6 +97,10 @@ function Initialization({ initial, onComplete }) { | ||
| 96 | 97 | if (results[1].status === "fulfilled") { |
| 97 | 98 | const install = results[1].value; |
| 98 | 99 | setPending(install?.pending || null); |
| 100 | 新增: if (!restored.current) { | |
| 101 | 新增: restored.current = true; | |
| 102 | 新增: if (initial.started && !initial.prepared && !account?.guest_system && !install?.pending && !next.job?.running && !next.job?.setup_progress && !next.ready) setStep("system"); | |
| 103 | 新增: } | |
| 99 | 104 | if (install?.activate && !activation.current) { |
| 100 | 105 | activation.current = true; |
| 101 | 106 | setStep("install"); |
| @@ -167,7 +172,7 @@ function Initialization({ initial, onComplete }) { | ||
| 167 | 172 | async function back() { |
| 168 | 173 | if (step === "proxy" && proxyDirty && !await confirm({ title: "放弃尚未应用的代理修改?", body: "已经保存并应用的代理会保留,当前未应用的表单修改会丢弃。", confirm: "放弃修改" })) return; |
| 169 | 174 | setProxyDirty(false); |
| 170 | 删除: setStep(step === "install" ? "proxy" : "system"); | |
| 175 | 新增: setStep(step === "install" ? "proxy" : pending || account?.guest_system ? "install" : "system"); | |
| 171 | 176 | } |
| 172 | 177 | const failed = Boolean(job.error || error); |
| 173 | 178 | const progress = job.setup_progress && { ...job, setup_progress: job.setup_progress }; |
| @@ -262,11 +262,11 @@ export function ProxySettings({ status, onApplied, onConfirm, onDirty, initializ | ||
| 262 | 262 | const route = routeDraft ?? savedRoute; |
| 263 | 263 | const routeChanged = JSON.stringify(route) !== JSON.stringify(savedRoute); |
| 264 | 264 | useEffect(() => { |
| 265 | 删除: onDirty?.(routeChanged); | |
| 265 | 新增: onDirty?.(routeChanged || initializing && Boolean(form)); | |
| 266 | 266 | return () => onDirty?.(false); |
| 267 | 删除: }, [onDirty, routeChanged]); | |
| 267 | 新增: }, [onDirty, routeChanged, initializing, Boolean(form)]); | |
| 268 | 268 | if (!proxy) |
| 269 | 删除: return <div className="proxy-loading">{error || "正在读取代理配置…"}</div>; | |
| 269 | 新增: return <div className="proxy-loading" role={error ? "alert" : "status"}>{error || "正在读取代理配置…"}</div>; | |
| 270 | 270 | const allNodes = proxy.sources.flatMap((s) => |
| 271 | 271 | s.nodes.map((n) => ({ ...n, source: s.name, sourceID: s.id })), |
| 272 | 272 | ); |

