/** PC 与安卓真机续验。只使用已授权的独立账号/容器;发送前落盘,恢复只读核实。 */ import fs from 'node:fs'; import path from 'node:path'; import assert from 'node:assert/strict'; import { execFileSync } from 'node:child_process'; import { chromium } from 'playwright'; import { connectWebView } from './android-webview-cdp.mjs'; const out = path.resolve('test-results/full-flow-20261128'); const privateDir = path.resolve('.local-backup/full-flow-20261128'); fs.mkdirSync(out, { recursive: true }); fs.mkdirSync(privateDir, { recursive: true }); const priorDir = '.local-backup/acceptance-20261128'; const account = JSON.parse(fs.readFileSync(`${priorDir}/account.json`, 'utf8')); const prior = JSON.parse(fs.readFileSync(`${priorDir}/acceptance-state.json`, 'utf8')); const cfg = JSON.parse(fs.readFileSync('.claude/dev-login.json', 'utf8')); const agent = 'agent-node-app-' + account.agentId.toLowerCase(); assert.equal(agent, 'agent-node-app-dw20i0uvpx'); assert.equal(account.jobId, 'QxB0R9BeWv'); const stage = process.argv.find(a => a.startsWith('--stage='))?.slice(8) || 'status'; const stateFile = `${out}/flow-state.json`; const state = fs.existsSync(stateFile) ? JSON.parse(fs.readFileSync(stateFile)) : { run: 'FLOW_' + Date.now().toString(36), userId: account.id, agent, checks: [], data: [], }; const save = () => { fs.writeFileSync(stateFile + '.next', JSON.stringify(state, null, 2)); fs.renameSync(stateFile + '.next', stateFile); }; const check = (name, valid, details) => { state.checks.push({ name, pass: !!valid, at: new Date().toISOString(), ...(details ? { details } : {}) }); save(); console.log(JSON.stringify(state.checks.at(-1))); assert.ok(valid, name); }; const pause = ms => new Promise(resolve => setTimeout(resolve, ms)); const headers = { 'X-Parse-Application-Id': 'ncloudmaster', 'X-Parse-Master-Key': cfg.masterKey }; async function records(cls, where) { const url = new URL('https://server.fmode.cn/parse/classes/' + cls); url.searchParams.set('where', JSON.stringify(where)); url.searchParams.set('limit', '1000'); const response = await fetch(url, { headers, signal: AbortSignal.timeout(20000) }); assert.ok(response.ok, `读取 ${cls}: ${response.status}`); const body = await response.json(); assert.ok(!body.error, body.error); return body.results || []; } async function binding() { const rows = await records('FmodeMatrixBinding', { userPointer: { __type: 'Pointer', className: '_User', objectId: account.id }, agentId: agent, status: 'active' }); assert.equal(rows.length, 1); assert.ok(rows[0].accessToken); return rows[0]; } const threads = () => records('FmodeChatThread', { user: { __type: 'Pointer', className: '_User', objectId: account.id }, agentId: agent }); async function roomEvents(b, roomId) { const response = await fetch(b.homeserver + '/_matrix/client/v3/rooms/' + encodeURIComponent(roomId) + '/messages?dir=b&limit=200', { headers: { Authorization: 'Bearer ' + b.accessToken }, signal: AbortSignal.timeout(20000), }); assert.ok(response.ok, `事件回读: ${response.status}`); return (await response.json()).chunk || []; } async function proof(key, timeout = 180000) { const b = await binding(); const row = state[key]; assert.ok(row?.attempted, '发送动作必须先有账本'); const deadline = Date.now() + timeout; while (Date.now() < deadline) { if (!row.roomId) { const found = (await threads()).find(t => !t.isDeleted && (t.threadRoot === row.threadRoot || t.lastPreview?.includes(row.marker))); if (found) { Object.assign(row, { roomId: found.roomId, threadRoot: found.threadRoot, id: found.objectId }); save(); } } if (row.roomId) { const events = await roomEvents(b, row.roomId); const sent = events.filter(e => e.sender === b.userMxId && e.type === 'm.room.message' && e.content?.body?.includes(row.marker)); const reply = events.find(e => e.sender === b.agentMxId && e.type === 'm.room.message' && e.content?.['fmode.kind'] !== 'process' && e.content?.body?.includes(row.marker) && e.origin_server_ts >= (sent[0]?.origin_server_ts || Infinity)); const done = events.find(e => e.sender === b.agentMxId && e.type === 'm.reaction' && e.content?.['m.relates_to']?.key === '✅' && [sent[0]?.event_id, reply?.event_id].filter(Boolean).includes(e.content?.['m.relates_to']?.event_id)); row.sentIds = sent.map(e => e.event_id); save(); if (sent.length && reply && done) { row.proof = { sent: sent.map(e => e.event_id), reply: reply.event_id, completion: done.event_id, body: reply.content.body }; fs.writeFileSync(`${out}/${key}-events.json`, JSON.stringify(events, null, 2)); save(); check(key + ' 真实发送/目标回复/✅', true, row.proof); check(key + ' 输入消息只发送一次', sent.length === 1); return row; } } await pause(2500); } throw Error(key + ' 尚未收到完整回执;恢复只能 --stage=status,禁止重新发送'); } function recordAttempt(key, marker, details = {}) { assert.ok(!state[key]?.attempted, `${key} 已有动作记录,请用 status 核实,不可重发`); state[key] = { marker, attempted: true, at: new Date().toISOString(), ...details }; state.data.push({ kind: 'message-task', key, marker, agent, pending: true }); save(); } let native, browser; async function mobile() { return native ??= await connectWebView(); } async function navigateMobile(route) { const c = await mobile(); // 原生 WebView 的 URL 资源拦截器不等同于 SPA 服务器;先加载入口,再经路由事件跳转。 if (!(await c.evaluate(() => location.origin === 'https://localhost' && !!document.querySelector('app-root')?.children.length))) { await c.send('Page.navigate', { url: 'https://localhost/' }); await c.waitFor(() => document.readyState === 'complete' && !!document.querySelector('app-root')?.children.length); } await c.evaluate(route => { history.pushState(null, '', route); dispatchEvent(new PopStateEvent('popstate')); }, route); await c.waitFor(route => decodeURIComponent(location.pathname) === decodeURIComponent(route), route); return c; } const chatRoute = row => '/mobile/chat/' + agent + '/' + encodeURIComponent(row.threadRoot); async function shot(name) { await (await mobile()).screenshot(`${out}/${name}.png`); } async function closePreview() { const c = await mobile(); await c.evaluate(() => document.querySelector('[role="dialog"][aria-label^="预览 "] [aria-label="关闭预览"]')?.click()); await c.waitFor(() => !document.querySelector('[role="dialog"][aria-label^="预览 "]')); } try { save(); if (stage === 'baseline' || stage === 'status') { const list = await threads(); const b = await binding(); const inventory = { at: new Date().toISOString(), userId: account.id, agent, initialRoom: b.roomId, threads: list }; fs.writeFileSync(`${out}/${stage}-inventory.json`, JSON.stringify(inventory, null, 2)); console.log(JSON.stringify({ stage, userId: account.id, agent, threads: list.map(t => ({ id: t.objectId, roomId: t.roomId, root: t.threadRoot, deleted: !!t.isDeleted })) })); if (stage === 'baseline') { assert.ok(!state.baseline); state.baseline = inventory; save(); } else for (const key of ['mobileSend', 'offlineSend', 'pcSend']) if (state[key]?.attempted && !state[key]?.proof) await proof(key, 15000); } else if (stage === 'mobile-login') { const c = await mobile(); await c.evaluate(() => { localStorage.removeItem('fmode_session_token'); localStorage.removeItem('fmode_me'); }); await navigateMobile('/login'); await c.waitFor(() => [...document.querySelectorAll('button')].some(x => x.innerText === '使用账号密码登录')); await c.evaluate(() => [...document.querySelectorAll('button')].find(x => x.innerText === '使用账号密码登录').click()); await c.fill('input[placeholder="请输入账号"]', account.username); await c.fill('input[placeholder="请输入密码"]', account.password); await c.tap('[aria-label="同意协议"]'); await shot('android-password-form'); await c.tap('button.m-btn--primary'); await c.waitFor(() => location.pathname === '/mobile/messages', undefined, 60000); await c.waitFor(() => document.querySelectorAll('button.m-row').length > 0, undefined, 60000); const auth = await c.evaluate(() => ({ token: localStorage.getItem('fmode_session_token'), me: JSON.parse(localStorage.getItem('fmode_me')) })); assert.equal(auth.me.id, account.id); fs.writeFileSync(`${privateDir}/mobile-auth.json`, JSON.stringify(auth, null, 2)); check('安卓真实账号密码登录并进入会话列表', true, { userId: auth.me.id }); state.data.push({ kind: 'login-session', userId: account.id, source: 'android-password-login', at: new Date().toISOString() }); save(); await shot('android-password-login-success'); } else if (stage === 'mobile-previews') { const c = await navigateMobile('/mobile/messages'); await c.waitFor(() => [...document.querySelectorAll('button.m-row')].some(x => x.innerText.includes('ACCEPT_FILE_mx0a7xfs_fre'))); await c.evaluate(() => [...document.querySelectorAll('button.m-row')].find(x => x.innerText.includes('ACCEPT_FILE_mx0a7xfs_fre')).click()); await c.waitFor(() => location.pathname.includes('/mobile/chat/')); if (await c.evaluate(() => !!document.querySelector('[role="dialog"][aria-label^="预览 "]'))) await closePreview(); await c.waitFor(() => document.querySelectorAll('.file-tile').length >= 2, undefined, 60000); const layout = await c.evaluate(() => { const back = document.querySelector('[aria-label="返回"]')?.getBoundingClientRect(); const title = document.querySelector('.m-title')?.getBoundingClientRect(); return { back: back && {x:back.x,right:back.right,width:back.width,height:back.height}, title: title && {x:title.x,right:title.right}, overflow: document.documentElement.scrollWidth > innerWidth }; }); check('安卓聊天顶栏返回按钮不被标题遮挡', layout.back?.width >= 40 && (!layout.title || layout.title.x >= layout.back.right), layout); check('安卓聊天无横向溢出', !layout.overflow); for (const ext of ['md', 'html']) { await c.evaluate(ext => document.querySelector(`[aria-label="预览 acceptance-mx0a7xfs-fresh.${ext}"]`).click(), ext); await c.waitFor(() => !!document.querySelector('[role="dialog"][aria-label^="预览 "]')); if (ext === 'md') await c.waitFor(() => document.querySelector('[role="dialog"][aria-label^="预览 "]')?.innerText.includes('INPUT_EVIDENCE_mx0a7xfs_fresh')); else { await c.waitFor(() => { const f = document.querySelector('[role="dialog"][aria-label^="预览 "] iframe'); return f?.src?.startsWith('https://s3.fmode.cn/'); }); let frame; for (let n = 0; n < 30 && !frame; n++) { const tree = await c.send('Page.getFrameTree'); frame = (tree.frameTree.childFrames || []).find(x => x.frame.url.includes('acceptance') && x.frame.url.endsWith('.html')); if (!frame) await pause(500); } assert.ok(frame, 'HTML 实际子框架已加载'); const world = await c.send('Page.createIsolatedWorld', { frameId: frame.frame.id }); const body = await c.send('Runtime.evaluate', { expression: 'document.body.innerText', contextId: world.executionContextId, returnByValue: true }); check('安卓 HTML 真实框架内容含验收编号', body.result.value.includes('INPUT_EVIDENCE_mx0a7xfs_fresh')); } await c.tap('[role="dialog"][aria-label^="预览 "] [aria-label="复制链接"], [role="dialog"][aria-label^="预览 "] [aria-label="已复制链接"]'); await pause(300); check('安卓 ' + ext + ' 复制链接后不弹 tooltip', await c.evaluate(() => ![...document.querySelectorAll('[role="tooltip"]')].some(x => x.getBoundingClientRect().width > 0))); await shot('android-preview-' + ext + '-verified'); check('安卓 ' + ext + ' 预览', true); await closePreview(); } execFileSync('adb', ['shell', 'input', 'keyevent', '4']); await c.waitFor(() => location.pathname === '/mobile/messages'); check('安卓物理返回从聊天回会话列表', true); } else if (stage === 'mobile-send') { const c = await navigateMobile('/mobile/chat/' + agent + '/new'); await c.waitFor(() => document.querySelector('textarea') && !document.querySelector('textarea').disabled, undefined, 60000); const marker = state.run + '_ANDROID'; const prompt = `这是安卓真机验收消息,只回复 ${marker}。不要使用工具,不修改文件或配置。`; await c.fill('textarea', prompt); await pause(150); recordAttempt('mobileSend', marker, { prompt }); await c.evaluate(() => { const button = document.querySelector('button.m-send'); button.click(); button.click(); button.click(); }); await pause(1000); state.mobileSend.threadRoot = await c.evaluate(() => decodeURIComponent(location.pathname.split('/').at(-1))); save(); await proof('mobileSend'); await c.waitFor(marker => [...document.querySelectorAll('app-assistant-turn')].some(x => x.innerText.includes(marker)), marker, 60000); check('安卓三次连点后草稿清空', await c.evaluate(() => document.querySelector('textarea').value === '')); await shot('android-send-roundtrip'); } else if (stage === 'mobile-offline') { assert.ok(state.mobileSend?.proof); const c = await navigateMobile(chatRoute(state.mobileSend)); await c.waitFor(() => document.querySelector('textarea') && !document.querySelector('textarea').disabled); const marker = state.run + '_OFFLINE'; const prompt = `这是断网恢复验收,只回复 ${marker}。不要使用工具,不修改任何文件。`; await c.send('Network.emulateNetworkConditions', { offline: true, latency: 0, downloadThroughput: -1, uploadThroughput: -1 }); state.offlineNetworkActive = true; save(); await c.fill('textarea', prompt); await pause(100); recordAttempt('offlineSend', marker, { prompt, roomId: state.mobileSend.roomId, threadRoot: state.mobileSend.threadRoot }); await c.tap('button.m-send'); await pause(3500); const snapshot = await c.evaluate(() => ({ text: document.body.innerText.slice(-2000), draft: document.querySelector('textarea').value })); state.offlineSend.offlineSnapshot = snapshot; save(); await shot('android-offline-send'); check('断网发送保留可见的草稿/失败/连接提示', snapshot.draft.includes(marker) || /失败|重试|断开|连接中|发送中/.test(snapshot.text), snapshot); await c.send('Network.emulateNetworkConditions', { offline: false, latency: 0, downloadThroughput: -1, uploadThroughput: -1 }); state.offlineNetworkActive = false; save(); // SDK 自身排队重试;不点击重试或重新发送。 await proof('offlineSend'); await c.waitFor(marker => [...document.querySelectorAll('app-assistant-turn')].some(x => x.innerText.includes(marker)), marker, 60000); check('安卓断网恢复后真实回复可见', true); await shot('android-offline-recovered'); } else if (stage === 'pc-flow') { const base = 'http://127.0.0.1:51755'; browser = await chromium.launch({ headless: true, executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe' }); const context = await browser.newContext({ viewport: { width: 1440, height: 960 }, acceptDownloads: true }); const page = await context.newPage(); page.setDefaultTimeout(45000); const errors = []; page.on('pageerror', e => errors.push(e.message)); await page.goto(base + '/login', { waitUntil: 'domcontentloaded' }); await page.getByRole('button', { name: '账号登录', exact: true }).click(); await page.locator('input[placeholder="请输入账号"]').fill(account.username); await page.locator('input[placeholder="请输入密码"]').fill(account.password); await page.getByRole('button', { name: /^登\s*录$/ }).click(); await page.waitForURL(/\/desktop\/chat/, { timeout: 60000 }); check('PC 真实密码登录回已开通应用', true); state.data.push({ kind: 'login-session', source: 'pc-password-login', userId: account.id, at: new Date().toISOString() }); save(); await page.screenshot({ path: `${out}/pc-login-home.png`, fullPage: true }); await context.storageState({ path: `${privateDir}/pc-browser-state.json` }); for (const route of ['contacts', 'workbench', 'mine', 'my-containers', 'plan-access']) { await page.goto(base + '/desktop/' + route, { waitUntil: 'domcontentloaded' }); await page.waitForTimeout(1000); const snapshot = await page.evaluate(() => ({ url: location.pathname, text: document.body.innerText.slice(-2000), overflow: document.documentElement.scrollWidth > innerWidth })); fs.writeFileSync(`${out}/pc-${route}.json`, JSON.stringify(snapshot, null, 2)); check('PC 页面加载 ' + route, snapshot.url === '/desktop/' + route && snapshot.text.length > 10, snapshot); check('PC 无横向溢出 ' + route, !snapshot.overflow); await page.screenshot({ path: `${out}/pc-${route}.png`, fullPage: true }); } await page.goto(base + '/provision?jobId=' + account.jobId, { waitUntil: 'domcontentloaded' }); await page.getByRole('button', { name: '进入应用', exact: true }).waitFor({ state: 'visible', timeout: 60000 }); check('PC 回读既有开通工单完成状态,不重复开通', true); await page.getByRole('button', { name: '进入应用', exact: true }).click(); await page.waitForURL(/\/desktop\/chat/); await page.goto(base + '/desktop/chat/' + agent + '/' + encodeURIComponent(state.mobileSend.threadRoot), { waitUntil: 'domcontentloaded' }); await page.locator('app-assistant-turn').filter({ hasText: state.mobileSend.marker }).first().waitFor({ state: 'visible', timeout: 60000 }); check('PC 回读安卓真实回复,跨设备会话恢复', true); await page.screenshot({ path: `${out}/pc-android-readback.png`, fullPage: true }); for (const ext of ['md', 'html']) { await page.goto(base + '/desktop/chat/' + agent + '/' + encodeURIComponent(prior.filesRepaired.threadRoot), { waitUntil: 'domcontentloaded' }); const card = page.getByRole('button', { name: '预览 acceptance-mx0a7xfs-fresh.' + ext, exact: true }).first(); await card.waitFor({ state: 'visible', timeout: 60000 }); await card.click(); const dialog = page.getByRole('dialog', { name: '预览 acceptance-mx0a7xfs-fresh.' + ext, exact: true }); await dialog.waitFor({ state: 'visible' }); if (ext === 'md') await dialog.getByText('INPUT_EVIDENCE_mx0a7xfs_fresh', { exact: false }).first().waitFor(); else await dialog.frameLocator('iframe').locator('body').getByText('INPUT_EVIDENCE_mx0a7xfs_fresh', { exact: false }).first().waitFor(); check('PC 真实成果预览 ' + ext, true); await page.screenshot({ path: `${out}/pc-preview-${ext}.png`, fullPage: true }); } const fixtureDir = path.join(out, 'fixtures'); fs.mkdirSync(fixtureDir, { recursive: true }); const fixtureMarker = state.run + '_INPUT'; execFileSync('python', ['-c', `import sys,pathlib,zipfile,json\np=pathlib.Path(sys.argv[1]); marker=sys.argv[2]\n(p/'flow-input.txt').write_text('测试输入编号:'+marker,encoding='utf-8')\n(p/'flow-data.json').write_text(json.dumps({'marker':marker,'items':[1,2,3]},indent=2),encoding='utf-8')\ntext='BT /F1 20 Tf 60 760 Td (Fmode acceptance) Tj 0 -40 Td ('+marker+') Tj ET'\nobjects=[b'<< /Type /Catalog /Pages 2 0 R >>',b'<< /Type /Pages /Kids [3 0 R] /Count 1 >>',b'<< /Type /Page /Parent 2 0 R /MediaBox [0 0 595 842] /Resources << /Font << /F1 4 0 R >> >> /Contents 5 0 R >>',b'<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>',('<< /Length '+str(len(text))+' >>\\nstream\\n'+text+'\\nendstream').encode()]\ndata=b'%PDF-1.4\\n'; offsets=[0]\nfor n,obj in enumerate(objects,1):\n offsets.append(len(data)); data+=str(n).encode()+b' 0 obj\\n'+obj+b'\\nendobj\\n'\nxref=len(data);data+=b'xref\\n0 6\\n0000000000 65535 f \\n'+b''.join(('%010d 00000 n \\n'%o).encode() for o in offsets[1:])+('trailer\\n<< /Size 6 /Root 1 0 R >>\\nstartxref\\n'+str(xref)+'\\n%%EOF').encode();(p/'flow-document.pdf').write_bytes(data)\nwith zipfile.ZipFile(p/'flow-document.docx','w',zipfile.ZIP_DEFLATED) as z:\n z.writestr('[Content_Types].xml','')\n z.writestr('_rels/.rels','')\n z.writestr('word/document.xml','Fmode full flow acceptance'+marker+'')`, fixtureDir, fixtureMarker]); await page.goto(base + '/desktop/chat/' + agent + '/new', { waitUntil: 'domcontentloaded' }); await page.waitForFunction(() => document.querySelector('textarea') && !document.querySelector('textarea').disabled, undefined, { timeout: 60000 }); const names = ['flow-input.txt', 'flow-data.json', 'flow-document.pdf', 'flow-document.docx']; await page.locator('input[type="file"]').first().setInputFiles(names.map(n => path.join(fixtureDir, n))); await page.locator('.pending-holds').waitFor({ state: 'visible' }); check('PC 四种待发送附件展示', (await page.locator('.pending-holds').innerText()).includes('flow-document.pdf') && (await page.locator('.pending-holds').innerText()).includes('flow-document.docx')); await page.screenshot({ path: `${out}/pc-staged-files.png`, fullPage: true }); const marker = state.run + '_PC'; const prompt = `本轮 PC 文件验收:读取刚上传 flow-input.txt 中的输入编号并复述。只读取文件,不创建、修改、删除或发布任何文件。最终回复必须包含 ${marker} 和输入完整编号。不要执行其他操作。`; await page.locator('textarea').fill(prompt); recordAttempt('pcSend', marker, { prompt, fixtureMarker, inputNames: names }); await page.locator('button.send').click(); await page.waitForTimeout(2000); state.pcSend.threadRoot = decodeURIComponent(new URL(page.url()).pathname.split('/').at(-1)); save(); await proof('pcSend', 240000); check('PC 容器实际读取上传的文本内容', state.pcSend.proof.body.includes(fixtureMarker)); await page.locator('app-assistant-turn').filter({ hasText: marker }).last().waitFor({ state: 'visible', timeout: 60000 }); await page.screenshot({ path: `${out}/pc-real-roundtrip.png`, fullPage: true }); await page.reload({ waitUntil: 'domcontentloaded' }); await page.locator('app-assistant-turn').filter({ hasText: marker }).last().waitFor({ state: 'visible', timeout: 60000 }); check('PC 发送后刷新回读', true); for (const ext of ['pdf', 'docx', 'json', 'txt']) { const name = ext === 'pdf' || ext === 'docx' ? 'flow-document.' + ext : ext === 'json' ? 'flow-data.json' : 'flow-input.txt'; const card = page.locator('button').filter({ hasText: name }).filter({ hasNotText: '移除' }).first(); await card.waitFor({ state: 'visible', timeout: 60000 }); await card.click(); const dialog = page.getByRole('dialog', { name: '预览 ' + name, exact: true }); await dialog.waitFor({ state: 'visible' }); if (ext === 'pdf' || ext === 'docx') await dialog.locator('canvas').first().waitFor({ state: 'visible', timeout: 60000 }); else await dialog.getByText(fixtureMarker, { exact: false }).first().waitFor({ state: 'visible' }); check('PC 输入文件实际预览 ' + ext, true); await page.screenshot({ path: `${out}/pc-input-preview-${ext}.png`, fullPage: true }); const close = dialog.getByRole('button', { name: '关闭预览', exact: true }); if (!(await close.isVisible())) await dialog.getByRole('button', { name: '回到右侧', exact: true }).click(); await close.click(); await dialog.waitFor({ state: 'hidden' }); } check('PC 浏览器无运行时异常', errors.length === 0, errors); await context.storageState({ path: `${privateDir}/pc-browser-state.json` }); } else throw Error('未知 stage: ' + stage); } catch (error) { state.lastFailure = { stage, error: error.message, at: new Date().toISOString() }; save(); if (native) { await native.screenshot(`${out}/${stage}-failure.png`).catch(() => {}); } if (browser) { const page = browser.contexts()[0]?.pages()[0]; if (page) { await page.screenshot({ path: `${out}/${stage}-failure.png`, fullPage: true }).catch(() => {}); fs.writeFileSync(`${out}/${stage}-failure.json`, JSON.stringify({ url: page.url(), body: await page.locator('body').innerText().catch(() => '') }, null, 2)); } } throw error; } finally { if (native && state.offlineNetworkActive) { await native.send('Network.emulateNetworkConditions', { offline: false, latency: 0, downloadThroughput: -1, uploadThroughput: -1 }).catch(() => {}); state.offlineNetworkActive = false; save(); } native?.close(); await browser?.close(); }