From bab0f0f702f894e6cdcd9f2a27db562a3a8ab52f Mon Sep 17 00:00:00 2001 From: taisuii <93462725+taisuii@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:08:55 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20=E6=94=BE=E5=AE=BD=20?= =?UTF-8?q?CI=20=E4=B8=8A=E4=B8=8D=E5=A4=9F=E7=94=A8=E7=9A=84=E7=BB=88?= =?UTF-8?q?=E7=AB=AF=E4=B8=8E=20shell=20=E7=AD=89=E5=BE=85=E7=AA=97?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI runner 上 PowerShell 冷启动超过 20 秒,但 waitPrompt 的等待窗口 硬编码 20 秒、check:ui 等提示符 15 秒、shell-encoding 每个命令 timeoutMs 30 秒,内层全部比外层用例的 timeout 还短。 本机实测终端输入本身正常(裸 CR 与 CRLF 都能提交,win32-input-mode 键事件反而失败),此前多轮调输入编码方向不对。把等待窗口调到与 实际耗时匹配,不改输入逻辑。 --- scripts/check-ui.mjs | 4 ++-- sidecar/test/shell-encoding.test.mjs | 16 ++++++++-------- sidecar/test/workspace-tabs.test.mjs | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/scripts/check-ui.mjs b/scripts/check-ui.mjs index c58eaafb68..167bdfe86d 100644 --- a/scripts/check-ui.mjs +++ b/scripts/check-ui.mjs @@ -1184,11 +1184,11 @@ try { for (const scheme of (process.env.JSRA_UI_SCHEME ? [process.env.JSRA_UI_SC await page.waitForFunction(() => document.activeElement?.matches('.terminal-screen .xterm-helper-textarea')); // 等 shell 真正打印提示符并完成 PSReadLine 绑定,再模拟用户输入(冷启动的 Windows 尤其慢)。 const promptRe = process.platform === 'win32' ? /PS [^>\r\n]*>/ : /[$#] /; - const promptDeadline = Date.now() + 15000; + const promptDeadline = Date.now() + 45000; while (!promptRe.test((await rpc('terminal-snapshot', { sessionId: workChat.id, id: terminalId })).output)) { if (Date.now() > promptDeadline) throw Error('Terminal prompt not ready'); await page.waitForTimeout(100); } await page.waitForTimeout(800); await page.keyboard.type(process.platform === 'win32' ? "Write-Output ('UI_TERMINAL_' + 'VERIFIED')" : "printf 'UI_TERMINAL_%s\\n' 'VERIFIED'"); await page.keyboard.press('Enter'); - const terminalDeadline = Date.now() + 12000; + const terminalDeadline = Date.now() + 30000; while (!(await rpc('terminal-snapshot', { sessionId: workChat.id, id: terminalId })).output.includes('UI_TERMINAL_VERIFIED')) { if (Date.now() > terminalDeadline) throw Error('Terminal UI input failed'); await page.waitForTimeout(50); } ok(await page.getByRole('menu').count() === 0, '[' + scheme + '] 终端输入回车不能重新打开新建标签菜单'); await page.screenshot({ path: path.join(SHOTS, scheme + '-terminal-tabs.png') }); diff --git a/sidecar/test/shell-encoding.test.mjs b/sidecar/test/shell-encoding.test.mjs index 3d8bfaec17..c8825c097c 100644 --- a/sidecar/test/shell-encoding.test.mjs +++ b/sidecar/test/shell-encoding.test.mjs @@ -13,7 +13,7 @@ const tmp = () => fs.mkdtempSync(path.join(os.tmpdir(), 'wdh-enc-')); test('shell output survives PowerShell console code page', { skip: !win }, async () => { const dir = tmp(); try { - const r = await shellWorkspace(dir, { cmd: 'Write-Output "中文里程碑:扫描完成 584 台,命中 3"', timeoutMs: 30000 }); + const r = await shellWorkspace(dir, { cmd: 'Write-Output "中文里程碑:扫描完成 584 台,命中 3"', timeoutMs: 90000 }); assert.equal(r.isError, false); assert.match(r.text, /中文里程碑:扫描完成 584 台,命中 3/); assert.doesNotMatch(r.text, /\uFFFD/); @@ -25,9 +25,9 @@ test('reading a UTF-8 Chinese file and matching it works', { skip: !win }, async fs.mkdirSync(root, { recursive: true }); fs.writeFileSync(path.join(root, 'note.txt'), '里程碑:已完成 584 台主机探测\n第二行\n', 'utf8'); try { - const read = await shellWorkspace(dir, { cmd: 'Get-Content note.txt', timeoutMs: 30000 }); + const read = await shellWorkspace(dir, { cmd: 'Get-Content note.txt', timeoutMs: 90000 }); assert.match(read.text, /里程碑:已完成 584 台主机探测/); - const matched = await shellWorkspace(dir, { cmd: 'Get-Content note.txt | Select-String "里程碑"', timeoutMs: 30000 }); + const matched = await shellWorkspace(dir, { cmd: 'Get-Content note.txt | Select-String "里程碑"', timeoutMs: 90000 }); assert.match(matched.text, /里程碑/); } finally { killAllJobs(dir); } }); @@ -36,13 +36,13 @@ test('writing through PowerShell then reading back keeps Chinese intact', { skip const dir = tmp(), root = path.join(dir, 'workspace'); fs.mkdirSync(root, { recursive: true }); try { - const written = await shellWorkspace(dir, { cmd: 'Set-Content -Path out.txt -Value "回环中文"; Out-File -FilePath out2.txt -InputObject "第二份"', timeoutMs: 30000 }); + const written = await shellWorkspace(dir, { cmd: 'Set-Content -Path out.txt -Value "回环中文"; Out-File -FilePath out2.txt -InputObject "第二份"', timeoutMs: 90000 }); assert.equal(written.isError, false); // PowerShell 5.1 的 -Encoding utf8 会写 BOM;宿主读取必须剥掉,否则正文开头多一个不可见字符。 const raw = fs.readFileSync(path.join(root, 'out.txt'), 'utf8'); assert.match(raw.replace(/^\uFEFF/, ''), /^回环中文/); - await shellWorkspace(dir, { cmd: 'Write-Output ok', timeoutMs: 30000 }); - const back = await shellWorkspace(dir, { cmd: 'Get-Content out.txt, out2.txt', timeoutMs: 30000 }); + await shellWorkspace(dir, { cmd: 'Write-Output ok', timeoutMs: 90000 }); + const back = await shellWorkspace(dir, { cmd: 'Get-Content out.txt, out2.txt', timeoutMs: 90000 }); assert.match(back.text, /回环中文/); assert.match(back.text, /第二份/); assert.doesNotMatch(back.text, /\uFFFD/); @@ -54,7 +54,7 @@ test('Chinese directory and file names round-trip', { skip: !win }, async () => try { const r = await shellWorkspace(dir, { cmd: 'New-Item -ItemType Directory -Force -Path "中文目录" | Out-Null; Write-Output "创建成功" | Tee-Object -FilePath "中文目录/报告.txt"; Get-Content "中文目录/报告.txt"', - timeoutMs: 30000, + timeoutMs: 90000, }); assert.equal(r.isError, false); assert.match(r.text, /创建成功/); @@ -65,7 +65,7 @@ test('Chinese directory and file names round-trip', { skip: !win }, async () => test('error text is readable instead of mojibake', { skip: !win }, async () => { const dir = tmp(); try { - const r = await shellWorkspace(dir, { cmd: 'throw "中文错误:目标不可达"', timeoutMs: 30000 }); + const r = await shellWorkspace(dir, { cmd: 'throw "中文错误:目标不可达"', timeoutMs: 90000 }); assert.equal(r.isError, true); assert.match(r.text, /中文错误:目标不可达/); assert.doesNotMatch(r.text, /\uFFFD/); diff --git a/sidecar/test/workspace-tabs.test.mjs b/sidecar/test/workspace-tabs.test.mjs index 2563e6d674..0c8ac9c338 100644 --- a/sidecar/test/workspace-tabs.test.mjs +++ b/sidecar/test/workspace-tabs.test.mjs @@ -16,8 +16,10 @@ function fixture(t) { t.after(async () => { await manager.closeAll(); assert.equal(path.dirname(directory), os.tmpdir()); assert.ok(path.basename(directory).startsWith('dh-tabs-')); fs.rmSync(directory, { recursive: true, force: true }); }); return { s, manager, directory }; } -const wait = async (check, message = 'Terminal verification timed out') => { const end = Date.now() + 20000; while (!check()) { if (Date.now() > end) throw Error(message); await new Promise(r => setTimeout(r, 25)); } }; -const waitPrompt = async (s, id) => { if (process.platform !== 'win32') return; await wait(() => /PS [^>\r\n]*>/.test(s.terminals.snapshot(id).output), 'PowerShell prompt timed out'); await new Promise(r => setTimeout(r, 800)); }; +const wait = async (check, message = 'Terminal verification timed out', budget = 20000) => { + const end = Date.now() + budget; while (!check()) { if (Date.now() > end) throw Error(message); await new Promise(r => setTimeout(r, 25)); } }; +// CI runner 上 PowerShell 冷启动要 20s 以上,提示符窗口必须单独放宽,否则内层比用例的 timeout 还短。 +const waitPrompt = async (s, id) => { if (process.platform !== 'win32') return; await wait(() => /PS [^>\r\n]*>/.test(s.terminals.snapshot(id).output), 'PowerShell prompt timed out', 45000); await new Promise(r => setTimeout(r, 800)); }; const expectOutput = async (check, s, id) => { try { await wait(check); } catch (error) { const tail = s.terminals.snapshot(id).output.slice(-600); throw Error(error.message + '; output tail=' + JSON.stringify(tail)); } }; const runCommand = async (s, id, command) => { s.terminals.input(id, command); await new Promise(r => setTimeout(r, 500)); s.terminals.input(id, '\r'); }; test('work tabs preserve stable IDs and choose a neighbour on close; v1 migrates network into browser', () => { From b9c63d160166a7c9d224424a04f7f7ff521e67b9 Mon Sep 17 00:00:00 2001 From: taisuii <93462725+taisuii@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:14:00 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20check:ui=20=E7=9A=84?= =?UTF-8?q?=E6=96=AD=E8=A8=80=E7=AA=97=E5=8F=A3=E6=8C=89=20CI=20=E5=AE=9E?= =?UTF-8?q?=E9=99=85=E8=80=97=E6=97=B6=E6=94=BE=E5=AE=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit integration 在 CI 上从终端那处推进后又卡在等响应文本(10 秒)。 3s/8s/10s 的断言窗口在冷启动的 runner 上都不够,统一放到 30 秒以上, Playwright 默认断言超时也从 30 秒提到 60 秒。 --- scripts/check-ui.mjs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/check-ui.mjs b/scripts/check-ui.mjs index 167bdfe86d..3e840e2521 100644 --- a/scripts/check-ui.mjs +++ b/scripts/check-ui.mjs @@ -202,6 +202,8 @@ fs.mkdirSync(SHOTS, { recursive: true }); async function checkWindowChrome(scheme) { for (const nativeTitlebar of [false, true]) { const context = await browser.newContext({ viewport: { width: 1440, height: 900 }, colorScheme: scheme }); + // CI runner 上冷启动和首次渲染明显更慢,默认 30 秒的断言窗口不够。 + context.setDefaultTimeout(60000); const page = await context.newPage(); page.on('pageerror', error => console.error('Window chrome runtime error: ' + error.message)); try { @@ -679,10 +681,10 @@ try { for (const scheme of (process.env.JSRA_UI_SCHEME ? [process.env.JSRA_UI_SC await page.locator('.settings-nav').getByRole('button', { name: '外观', exact: true }).click(); const opposite = scheme === 'dark' ? 'light' : 'dark'; await page.locator('.theme-option').filter({ hasText: opposite === 'dark' ? '深色' : '浅色' }).click(); - await page.locator('html[data-theme="' + opposite + '"]').waitFor({ state: 'attached', timeout: 3000 }); + await page.locator('html[data-theme="' + opposite + '"]').waitFor({ state: 'attached', timeout: 30000 }); ok(await page.locator('html').getAttribute('data-theme') === opposite, '[' + scheme + '] 主题切换没有生效'); await page.locator('.theme-option').filter({ hasText: '跟随系统' }).click(); - await page.locator('html[data-theme="' + scheme + '"]').waitFor({ state: 'attached', timeout: 3000 }); + await page.locator('html[data-theme="' + scheme + '"]').waitFor({ state: 'attached', timeout: 30000 }); ok(await page.locator('html').getAttribute('data-theme') === scheme, '[' + scheme + '] 跟随系统没有恢复'); await page.locator('.screen-head button').first().click(); @@ -775,7 +777,7 @@ try { for (const scheme of (process.env.JSRA_UI_SCHEME ? [process.env.JSRA_UI_SC await page.getByRole('button', { name: '恢复网页执行', exact: true }).waitFor(); await page.screenshot({ path: path.join(SHOTS, scheme + '-browser-paused.png') }); await page.getByRole('button', { name: '恢复网页执行', exact: true }).click(); - await page.getByRole('button', { name: '恢复网页执行', exact: true }).waitFor({ state: 'detached', timeout: 8000 }).catch(async e => { throw new Error(e.message + '\n通知:' + (await page.locator('[data-sonner-toast]').allTextContents()).join(' | ')); }); + await page.getByRole('button', { name: '恢复网页执行', exact: true }).waitFor({ state: 'detached', timeout: 30000 }).catch(async e => { throw new Error(e.message + '\n通知:' + (await page.locator('[data-sonner-toast]').allTextContents()).join(' | ')); }); await debugUiCdp.detach(); await page.keyboard.press('Control+Alt+3'); @@ -787,7 +789,7 @@ try { for (const scheme of (process.env.JSRA_UI_SCHEME ? [process.env.JSRA_UI_SC await page.getByRole('button', { name: '刷新', exact: true }).click(); await page.keyboard.press('Control+Alt+3'); } - await page.locator('.req-row').filter({ hasText: /api/ }).first().waitFor({ timeout: 15000 }); + await page.locator('.req-row').filter({ hasText: /api/ }).first().waitFor({ timeout: 45000 }); const pauseNetwork = page.getByRole('button', { name: '暂停抓取网络请求', exact: true }); ok(await pauseNetwork.getAttribute('aria-pressed') === 'true', '[' + scheme + '] 记录中状态应显示暂停操作'); await pauseNetwork.click(); @@ -799,7 +801,7 @@ try { for (const scheme of (process.env.JSRA_UI_SCHEME ? [process.env.JSRA_UI_SC ok(await page.locator('.bar').filter({ has: page.getByPlaceholder('过滤 URL / 参数名') }).innerText().then(text => !/网络请求\s*\d/.test(text)), '[' + scheme + '] 不应重复网络请求标题与数量'); await page.locator('.req-row').filter({ hasText: /api/ }).first().click(); await page.locator('.detail-tabs').getByRole('tab', { name: '响应', exact: true }).click(); - await page.waitForFunction(() => document.querySelector('.detail-body')?.textContent.includes('UI capture verified'), { timeout: 10000 }); + await page.waitForFunction(() => document.querySelector('.detail-body')?.textContent.includes('UI capture verified'), { timeout: 30000 }); ok((await page.locator('.detail-body').innerText()).includes('UI capture verified'), '[' + scheme + '] 请求响应没有正确显示'); await page.screenshot({ path: path.join(SHOTS, scheme + '-network.png') }); await page.keyboard.press('Control+Alt+2'); From 0493f84fc3a21dd80b7231c883cc8d21cee1a82a Mon Sep 17 00:00:00 2001 From: taisuii <93462725+taisuii@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:20:59 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20=E7=BB=88=E7=AB=AF?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E7=9A=84=E5=86=85=E5=B1=82=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E4=B8=8E=E5=A4=96=E5=B1=82=20timeout=20=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit expectOutput 仍在用默认 20 秒窗口,而 CI 上两个终端跑三个命令要 20 秒以上,用例因此间歇性失败。把内层等待提到 40 秒,外层 timeout 提到能真正覆盖内层总和。 --- sidecar/test/workspace-tabs.test.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sidecar/test/workspace-tabs.test.mjs b/sidecar/test/workspace-tabs.test.mjs index 0c8ac9c338..1fc6f354bd 100644 --- a/sidecar/test/workspace-tabs.test.mjs +++ b/sidecar/test/workspace-tabs.test.mjs @@ -20,7 +20,7 @@ const wait = async (check, message = 'Terminal verification timed out', budget = const end = Date.now() + budget; while (!check()) { if (Date.now() > end) throw Error(message); await new Promise(r => setTimeout(r, 25)); } }; // CI runner 上 PowerShell 冷启动要 20s 以上,提示符窗口必须单独放宽,否则内层比用例的 timeout 还短。 const waitPrompt = async (s, id) => { if (process.platform !== 'win32') return; await wait(() => /PS [^>\r\n]*>/.test(s.terminals.snapshot(id).output), 'PowerShell prompt timed out', 45000); await new Promise(r => setTimeout(r, 800)); }; -const expectOutput = async (check, s, id) => { try { await wait(check); } catch (error) { const tail = s.terminals.snapshot(id).output.slice(-600); throw Error(error.message + '; output tail=' + JSON.stringify(tail)); } }; +const expectOutput = async (check, s, id) => { try { await wait(check, 'Terminal verification timed out', 40000); } catch (error) { const tail = s.terminals.snapshot(id).output.slice(-600); throw Error(error.message + '; output tail=' + JSON.stringify(tail)); } }; const runCommand = async (s, id, command) => { s.terminals.input(id, command); await new Promise(r => setTimeout(r, 500)); s.terminals.input(id, '\r'); }; test('work tabs preserve stable IDs and choose a neighbour on close; v1 migrates network into browser', () => { let dock = addDockTab(emptyDock(), 'files'), original = dock.activeId; dock = addDockTab(dock, 'document', { path: 'report.md', workspace: 'test' }); @@ -50,7 +50,7 @@ test('rapid browser selection serializes the latest intent and rejects missing p const tabs = new BrowserTabs(s); const a = tabs.select('a'), b = tabs.select('b'); await Promise.all([a, b]); assert.deepEqual(seen, ['b']); await assert.rejects(tabs.select('missing'), /已关闭/); }); -test('interactive terminal enforces permission, accepts real input and closes with its chat', { timeout: 60000 }, async t => { +test('interactive terminal enforces permission, accepts real input and closes with its chat', { timeout: 150000 }, async t => { const { s, manager } = fixture(t), id = crypto.randomUUID(); s.setMode('read-only'); await assert.rejects(s.terminals.open({ id }), /只读/); s.setMode('standard'); s.approve = async () => false; await assert.rejects(s.terminals.open({ id }), /未批准/); assert.equal(s.terminals.entries.size, 0); @@ -71,7 +71,7 @@ test('terminal approval never changes an unrelated Agent automation run', async assert.equal(s.pending.size, 1); assert.ok(!s.permissionBlocked); assert.equal(s.activeRun.status, 'running'); s.replyApproval([...s.pending.keys()][0], { allow: false }); await rejected; }); -test('multiple terminals isolate output and closing one keeps its sibling usable', { timeout: 75000 }, async t => { +test('multiple terminals isolate output and closing one keeps its sibling usable', { timeout: 210000 }, async t => { const { s } = fixture(t), a = crypto.randomUUID(), b = crypto.randomUUID(); s.setMode('full-access'); await Promise.all([s.terminals.open({ id: a }), s.terminals.open({ id: b })]); await Promise.all([waitPrompt(s, a), waitPrompt(s, b)]); From a455a154a6ba0c01e999a5d3ccfe0e434e6f3c11 Mon Sep 17 00:00:00 2001 From: taisuii <93462725+taisuii@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:21:23 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20=E7=BB=88=E7=AB=AF?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E4=B8=8E=E5=9B=9E=E8=BD=A6=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E5=86=99=E5=85=A5=EF=BC=8C=E9=81=BF=E5=85=8D=E8=A2=AB=E6=8B=A6?= =?UTF-8?q?=E8=85=B0=E6=88=AA=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 日志出现过 ISOLATED_' 后换行、再补 ('FIRST') 的截断,命令因此 永远不完整。分两次写入时 500ms 的间隔在慢 runner 上不可靠。 --- sidecar/test/workspace-tabs.test.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sidecar/test/workspace-tabs.test.mjs b/sidecar/test/workspace-tabs.test.mjs index 1fc6f354bd..a57d890139 100644 --- a/sidecar/test/workspace-tabs.test.mjs +++ b/sidecar/test/workspace-tabs.test.mjs @@ -21,7 +21,9 @@ const wait = async (check, message = 'Terminal verification timed out', budget = // CI runner 上 PowerShell 冷启动要 20s 以上,提示符窗口必须单独放宽,否则内层比用例的 timeout 还短。 const waitPrompt = async (s, id) => { if (process.platform !== 'win32') return; await wait(() => /PS [^>\r\n]*>/.test(s.terminals.snapshot(id).output), 'PowerShell prompt timed out', 45000); await new Promise(r => setTimeout(r, 800)); }; const expectOutput = async (check, s, id) => { try { await wait(check, 'Terminal verification timed out', 40000); } catch (error) { const tail = s.terminals.snapshot(id).output.slice(-600); throw Error(error.message + '; output tail=' + JSON.stringify(tail)); } }; -const runCommand = async (s, id, command) => { s.terminals.input(id, command); await new Promise(r => setTimeout(r, 500)); s.terminals.input(id, '\r'); }; +// 命令与回车分两次写入时,慢的 runner 上回车可能先到,命令被拦腰截断(实测出现过 +// `ISOLATED_'` 后换行再补 `('FIRST')`)。一次写完,由终端自己按 UTF-8 字符顺序处理。 +const runCommand = async (s, id, command) => { s.terminals.input(id, command + '\r'); }; test('work tabs preserve stable IDs and choose a neighbour on close; v1 migrates network into browser', () => { let dock = addDockTab(emptyDock(), 'files'), original = dock.activeId; dock = addDockTab(dock, 'document', { path: 'report.md', workspace: 'test' }); dock = addDockTab(dock, 'terminal'); dock = closeDockTab(dock, dock.activeId); assert.equal(dock.tabs.length, 2); assert.equal(dock.tabs[0].id, original); assert.equal(dock.activeId, dock.tabs[1].id); From 78530deed056cc4b1f9c98e906bf2109770bd1cd Mon Sep 17 00:00:00 2001 From: taisuii <93462725+taisuii@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:31:36 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=B7=B2=E5=88=A0=E9=99=A4=E7=9A=84=20workspace-set=20?= =?UTF-8?q?=E9=80=9A=E9=81=93=E5=B9=B6=E6=94=BE=E5=AE=BD=20packaged=20PTY?= =?UTF-8?q?=20=E7=AD=89=E5=BE=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit check:plugins 仍在调 invoke('workspace-set'),该通道随托管工作区 一起被移除了,运行时报「未知通道」。check-sidecar 的 packaged PTY 用例同样只有 15 秒等待窗口,CI 上不够。 --- scripts/check-plugins.mjs | 1 - scripts/check-sidecar.mjs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/check-plugins.mjs b/scripts/check-plugins.mjs index fe6e95be67..faa357fc2f 100644 --- a/scripts/check-plugins.mjs +++ b/scripts/check-plugins.mjs @@ -244,7 +244,6 @@ try { embedMode: 'screencast', }); const session = (await invoke('session-list')).focused; - await invoke('workspace-set', { sessionId: session, managed: true }); const opened = await invoke('browser-launch', { sessionId: session, url: 'http://127.0.0.1:' + site.address().port + '/browser-fixture', diff --git a/scripts/check-sidecar.mjs b/scripts/check-sidecar.mjs index 4d0c087341..cd8f4b9044 100644 --- a/scripts/check-sidecar.mjs +++ b/scripts/check-sidecar.mjs @@ -53,7 +53,7 @@ try { await invoke('terminal-open', { sessionId, id: terminalId, cols: 90, rows: 25 }); await invoke('terminal-input', { sessionId, id: terminalId, data: process.platform === 'win32' ? "Write-Output ('PACKAGED_' + 'TERMINAL_OK')\r" : "printf 'PACKAGED_%s\\n' 'TERMINAL_OK'\r" }); let terminalOutput = ''; - const terminalDeadline = Date.now() + 15000; + const terminalDeadline = Date.now() + 60000; while (!terminalOutput.includes('PACKAGED_TERMINAL_OK')) { if (Date.now() > terminalDeadline) throw Error('Packaged PTY input/output failed'); terminalOutput = (await invoke('terminal-snapshot', { sessionId, id: terminalId })).output; await new Promise(r => setTimeout(r, 50)); } await invoke('terminal-close', { sessionId, id: terminalId }); if (fs.existsSync(marker)) throw new Error('Executable loaded untrusted bunfig preload'); From 3f57b63afbf606b91a9d6cbe2e3b18628640d9a7 Mon Sep 17 00:00:00 2001 From: taisuii <93462725+taisuii@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:43:49 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20check:plugins=20?= =?UTF-8?q?=E6=98=BE=E5=BC=8F=E5=BB=BA=E4=BC=9A=E8=AF=9D=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E4=BE=9D=E8=B5=96=E4=B8=BA=20null=20=E7=9A=84=20focus?= =?UTF-8?q?ed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 托管工作区移除后测试里没有会话,session-list 的 focused 是 null, browser-launch 直接报「会话不存在」。改为用 folderProof 签一个单次 目录凭证、建项目和会话后再验证 WDH 浏览器。 --- scripts/check-plugins.mjs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/check-plugins.mjs b/scripts/check-plugins.mjs index faa357fc2f..a6e0bbd891 100644 --- a/scripts/check-plugins.mjs +++ b/scripts/check-plugins.mjs @@ -6,6 +6,7 @@ import crypto from 'node:crypto'; import { spawn } from 'node:child_process'; import WebSocket from 'ws'; import { chromium } from '@zhizhuodemao/patchright'; +import { folderProof } from '../sidecar/grants.mjs'; const root = process.cwd(), parent = path.resolve('.tmp'); fs.mkdirSync(parent, { recursive: true }); @@ -243,7 +244,16 @@ try { headless: true, embedMode: 'screencast', }); - const session = (await invoke('session-list')).focused; + // 插件页本身不依赖会话,但验证已下载的 WDH 浏览器需要一个真实会话。 + // 项目必须挂已授权目录:用和 UI 同一套 folderProof 给自己签一个单次凭证。 + const grant = { sessionId: 'plugin-check', path: process.cwd(), expiresAt: Date.now() + 60000 }; + grant.signature = folderProof(token, grant); + const project = await invoke('project-save', { + scope: 'plugin-check', + project: { name: 'plugin-check-' + Date.now(), folders: [{ key: 'main', grant }], primaryKey: 'main' }, + }); + const created = await invoke('session-create', { projectId: project.id, title: 'plugin check' }); + const session = created.id; const opened = await invoke('browser-launch', { sessionId: session, url: 'http://127.0.0.1:' + site.address().port + '/browser-fixture', @@ -268,7 +278,7 @@ try { async () => (await invoke('plugins-list')).official.find((p) => p.id === 'wdh').enabled === false, 'disabled WDH', ); - const sid = (await invoke('session-list')).focused; + const sid = session; if ((await invoke('list-tools', { sessionId: sid })).some((t) => t.name === 'browser_open')) throw Error('Disabled WDH tools still registered'); if (pageErrors.length) throw Error(pageErrors.join('\n')); From ea577ec3d9863616eff50a5114828a1426e4d754 Mon Sep 17 00:00:00 2001 From: taisuii <93462725+taisuii@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:54:31 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20check:plugins=20?= =?UTF-8?q?=E5=A4=8D=E7=94=A8=20CI=20=E5=B7=B2=E8=A3=85=E5=A5=BD=E7=9A=84?= =?UTF-8?q?=20CloakBrowser=20=E5=86=85=E6=A0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 内核固定为 CloakBrowser 后不再支持系统 Chrome,测试原来每次开新的 临时数据目录,里面永远没有内核,browser-launch 直接报未安装。 改为优先使用 JSRA_UI_DATA_DIR(CI 在该目录下装过内核),并在 workflow 里把这个 env 传给 check:plugins。 --- .github/workflows/ci.yml | 2 ++ scripts/check-plugins.mjs | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2105f48a5..ccb5a40a53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,6 +78,8 @@ jobs: env: JSRA_UI_DATA_DIR: ${{ runner.temp }}\ui-data - run: npm run check:plugins + env: + JSRA_UI_DATA_DIR: ${{ runner.temp }}\ui-data - uses: actions/upload-artifact@v4 if: failure() with: diff --git a/scripts/check-plugins.mjs b/scripts/check-plugins.mjs index a6e0bbd891..91e234a6f1 100644 --- a/scripts/check-plugins.mjs +++ b/scripts/check-plugins.mjs @@ -10,8 +10,12 @@ import { folderProof } from '../sidecar/grants.mjs'; const root = process.cwd(), parent = path.resolve('.tmp'); fs.mkdirSync(parent, { recursive: true }); -const data = fs.mkdtempSync(path.join(parent, 'plugins-ui-')), - token = crypto.randomBytes(20).toString('hex'), +// CI 在 JSRA_UI_DATA_DIR 下已经装好 CloakBrowser 内核;复用同一个目录,不要每次开新的临时目录。 +const data = process.env.JSRA_UI_DATA_DIR + ? path.join(path.resolve(process.env.JSRA_UI_DATA_DIR), 'WebDecryptHub') + : path.join(fs.mkdtempSync(path.join(parent, 'plugins-ui-')), 'WebDecryptHub'); +fs.mkdirSync(data, { recursive: true }); +const token = crypto.randomBytes(20).toString('hex'), pending = new Map(); let socket, sequence = 0, From a8347952aa2fc268b5ad0f964678d3fdebb033bf Mon Sep 17 00:00:00 2001 From: taisuii <93462725+taisuii@users.noreply.github.com> Date: Sun, 1 Nov 2026 22:02:44 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=B5=8B=E8=AF=95:=20check:plugins=20?= =?UTF-8?q?=E4=B8=8D=E5=81=87=E8=AE=BE=E9=A6=96=E6=AC=A1=E5=BC=95=E5=AF=BC?= =?UTF-8?q?=E4=B8=80=E5=AE=9A=E5=87=BA=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 复用 JSRA_UI_DATA_DIR 时 onboarding 已完成,「稍后」按钮不会渲染, 硬等 15 秒必然超时。改为按存在与否处理。 --- scripts/check-plugins.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/check-plugins.mjs b/scripts/check-plugins.mjs index 91e234a6f1..aa6c14932e 100644 --- a/scripts/check-plugins.mjs +++ b/scripts/check-plugins.mjs @@ -179,10 +179,12 @@ try { pageErrors = []; page.on('pageerror', (error) => pageErrors.push(error.message)); await page.goto(`http://127.0.0.1:${site.address().port}/?port=${port}&token=${token}`); + // 首次引导只在全新数据目录出现;复用已有目录时它不会弹,不能硬等。 const skip = page.getByRole('button', { name: '稍后', exact: true }); - await skip.waitFor({ state: 'visible', timeout: 15000 }); - await skip.click(); - await page.locator('.setup-dialog').waitFor({ state: 'detached' }); + if (await skip.count()) { + await skip.click(); + await page.locator('.setup-dialog').waitFor({ state: 'detached' }); + } const rail = page.getByRole('button', { name: '展开会话列表' }); if (await rail.count()) await rail.first().click(); await page.locator('.rail-nav').getByRole('button', { name: '插件', exact: true }).click();