TeamsPeach desktop client: Electron UI, Rust core bridge, TS6 stream viewer, CI
ci / linux-x64 (push) Failing after 1m26s
ci / linux-arm64-cross (push) Failing after 2m20s

This commit is contained in:
omar committed 2026-10-24 03:31:54 +03:00
commit 7287fdb63e
94 files changed
+33133

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
// Reads the executable header and reports {format, arch}. Used to refuse packaging a core built for
// another OS/CPU. node scripts/binary-arch.mjs <file> [--expect linux-arm64]
import { openSync, readSync, closeSync } from 'node:fs';
import { pathToFileURL } from 'node:url';
const PE_MACHINES = { 0x8664: 'x64', 0xaa64: 'arm64', 0x014c: 'ia32' };
const ELF_MACHINES = { 0x3e: 'x64', 0xb7: 'arm64', 0x03: 'ia32', 0x28: 'armv7l' };
const MACHO_CPUS = { 0x01000007: 'x64', 0x0100000c: 'arm64' };
export function binaryArch(file) {
const fd = openSync(file, 'r');
try {
const head = Buffer.alloc(4096);
const n = readSync(fd, head, 0, head.length, 0);
if (n >= 64 && head.readUInt16LE(0) === 0x5a4d) {
const pe = head.readUInt32LE(0x3c);
if (pe + 6 <= n && head.readUInt32LE(pe) === 0x00004550) {
return { os: 'win', arch: PE_MACHINES[head.readUInt16LE(pe + 4)] ?? `pe-0x${head.readUInt16LE(pe + 4).toString(16)}` };
}
}
if (n >= 20 && head.readUInt32BE(0) === 0x7f454c46) {
const little = head[5] === 1;
const machine = little ? head.readUInt16LE(18) : head.readUInt16BE(18);
return { os: 'linux', arch: ELF_MACHINES[machine] ?? `elf-0x${machine.toString(16)}` };
}
if (n >= 8 && head.readUInt32LE(0) === 0xfeedfacf) {
return { os: 'mac', arch: MACHO_CPUS[head.readUInt32LE(4)] ?? `macho-0x${head.readUInt32LE(4).toString(16)}` };
}
if (n >= 8 && head.readUInt32BE(0) === 0xcafebabe) return { os: 'mac', arch: 'universal' };
return { os: 'unknown', arch: 'unknown' };
} finally {
closeSync(fd);
}
}
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
const file = process.argv[2];
const expectIdx = process.argv.indexOf('--expect');
const info = binaryArch(file);
console.log(JSON.stringify({ file, ...info }));
if (expectIdx > 0) {
const want = process.argv[expectIdx + 1];
if (`${info.os}-${info.arch}` !== want) {
console.error(`expected ${want}, got ${info.os}-${info.arch}`);
process.exit(1);
}
}
}
+82
View File
@@ -0,0 +1,82 @@
// Offline smoke of a built core binary over its real stdio protocol (docs/bridge.md):
// ready → profile_get (missing) → profile_create → rename → restart → same UID + persisted nickname.
// No network, no server. Optional --wrapper runs the binary through an emulator (e.g. qemu-aarch64).
//
// node scripts/core-smoke.mjs <core-binary> [--wrapper "qemu-aarch64 -L /usr/aarch64-linux-gnu"]
import { spawn } from 'node:child_process';
import { mkdtempSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import readline from 'node:readline';
const binary = path.resolve(process.argv[2] ?? '');
const wi = process.argv.indexOf('--wrapper');
const wrapper = wi > 0 ? process.argv[wi + 1].split(' ').filter(Boolean) : [];
const dataDir = mkdtempSync(path.join(tmpdir(), 'teamspeach-core-smoke-'));
function start() {
const [cmd, ...pre] = wrapper.length ? wrapper : [binary];
const args = wrapper.length ? [...pre, binary, '--data-dir', dataDir] : ['--data-dir', dataDir];
const child = spawn(cmd, args, { stdio: ['pipe', 'pipe', 'inherit'] });
const waiting = new Map();
let ready;
const readyP = new Promise((r) => { ready = r; });
readline.createInterface({ input: child.stdout }).on('line', (line) => {
const msg = JSON.parse(line);
if (msg.event === 'ready') ready(msg);
else if (msg.id && waiting.has(msg.id)) {
waiting.get(msg.id)(msg);
waiting.delete(msg.id);
}
});
let n = 0;
const request = (cmd, args) => new Promise((resolve, reject) => {
const id = `s${++n}`;
const timer = setTimeout(() => reject(new Error(`${cmd} timed out`)), 60000);
waiting.set(id, (m) => {
clearTimeout(timer);
resolve(m);
});
child.stdin.write(`${JSON.stringify(args ? { id, cmd, args } : { id, cmd })}\n`);
});
const exited = new Promise((r) => child.on('exit', (code) => r(code)));
return { child, request, readyP, exited };
}
function check(cond, message) {
if (!cond) throw new Error(message);
console.log(`ok - ${message}`);
}
let code = 0;
try {
let core = start();
const ready = await Promise.race([core.readyP, new Promise((_, rej) => setTimeout(() => rej(new Error('no ready event')), 60000))]);
check(ready.protocol === 1, `ready protocol 1 (core ${ready.core_version})`);
let r = await core.request('profile_get');
check(r.ok && r.result.exists === false, 'fresh data dir has no profile');
r = await core.request('profile_create', { nickname: 'CI Probe' });
check(r.ok && typeof r.result.uid === 'string' && r.result.uid.length > 10, `profile created uid=${r.ok ? r.result.uid : '-'}`);
const uid = r.result.uid;
r = await core.request('profile_create', { nickname: 'Again' });
check(!r.ok && r.error.code === 'profile_exists', 'second profile_create refused');
r = await core.request('rename', { nickname: 'CI Renamed' });
check(r.ok && r.result.uid === uid && r.result.nickname === 'CI Renamed', 'rename keeps uid');
r = await core.request('rename', { nickname: 'x' });
check(!r.ok && r.error.code === 'invalid_nickname', 'short nickname rejected');
await core.request('shutdown');
check((await core.exited) === 0, 'clean shutdown exit 0');
core = start();
await core.readyP;
r = await core.request('profile_get');
check(r.ok && r.result.uid === uid && r.result.nickname === 'CI Renamed', 'restart: same uid and persisted nickname');
await core.request('shutdown');
await core.exited;
} catch (err) {
console.error(`not ok - ${err.message}`);
code = 1;
} finally {
rmSync(dataDir, { recursive: true, force: true });
}
process.exit(code);
+77
View File
@@ -0,0 +1,77 @@
// Packages TeamsPeach for one OS/arch. Refuses to package without a native core of exactly that
// OS/arch (header check), and ships the core's third-party notices next to it.
//
// node scripts/dist.mjs --os win|linux|mac --arch x64|arm64 [--core <path>] [--targets "nsis zip"]
//
// Default core path: core/target/<rust-triple>/release/…, else core/target/release/… (host build).
import { spawnSync } from 'node:child_process';
import { copyFileSync, existsSync, mkdirSync, rmSync, readdirSync, statSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { binaryArch } from './binary-arch.mjs';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const argv = process.argv.slice(2);
const opt = (n, d) => (argv.indexOf(`--${n}`) >= 0 ? argv[argv.indexOf(`--${n}`) + 1] : d);
const os = opt('os');
const arch = opt('arch');
const TRIPLES = {
'win-x64': 'x86_64-pc-windows-msvc',
'win-arm64': 'aarch64-pc-windows-msvc',
'linux-x64': 'x86_64-unknown-linux-gnu',
'linux-arm64': 'aarch64-unknown-linux-gnu',
'mac-x64': 'x86_64-apple-darwin',
'mac-arm64': 'aarch64-apple-darwin',
};
const key = `${os}-${arch}`;
if (!TRIPLES[key]) {
console.error(`unsupported --os/--arch ${key}; one of ${Object.keys(TRIPLES).join(', ')}`);
process.exit(2);
}
const exe = os === 'win' ? 'teamspeach-core.exe' : 'teamspeach-core';
const candidates = [
opt('core'),
path.join(root, 'core', 'target', TRIPLES[key], 'release', exe),
path.join(root, 'core', 'target', 'release', exe),
].filter(Boolean);
const core = candidates.find((c) => existsSync(c));
if (!core) {
console.error(`No core binary for ${key}. Looked at:\n ${candidates.join('\n ')}\nBuild it first: cargo build --release --locked --manifest-path core/Cargo.toml --target ${TRIPLES[key]}`);
process.exit(1);
}
const info = binaryArch(core);
if (info.os !== os || info.arch !== arch) {
console.error(`Core ${core} is ${info.os}-${info.arch}, not ${key}. Refusing to package.`);
process.exit(1);
}
const notices = path.join(root, 'core', 'THIRD_PARTY_NOTICES.md');
if (!existsSync(notices)) {
console.error('core/THIRD_PARTY_NOTICES.md is missing; it must ship with the binary.');
process.exit(1);
}
const stage = path.join(root, 'core-bin', key);
rmSync(stage, { recursive: true, force: true });
mkdirSync(stage, { recursive: true });
copyFileSync(core, path.join(stage, exe));
copyFileSync(notices, path.join(stage, 'THIRD_PARTY_NOTICES.md'));
console.log(`staged ${core} (${info.os}-${info.arch}, ${statSync(core).size} bytes) → ${stage}`);
const builderArgs = [`--${os}`, `--${arch}`, '--publish', 'never'];
const targets = opt('targets');
if (targets) builderArgs.splice(1, 0, ...targets.split(' '));
const cli = path.join(root, 'node_modules', 'electron-builder', 'cli.js');
const run = spawnSync(process.execPath, [cli, ...builderArgs], { cwd: root, stdio: 'inherit' });
if (run.status !== 0) process.exit(run.status ?? 1);
// Verify the packaged app really contains the core for this target.
const dist = path.join(root, 'dist');
const unpacked = readdirSync(dist).filter((d) => d.endsWith('-unpacked') || d === 'mac' || d === 'mac-arm64').map((d) => path.join(dist, d));
const packagedCore = unpacked
.map((d) => (os === 'mac' ? path.join(d, 'TeamsPeach.app', 'Contents', 'Resources', 'core', exe) : path.join(d, 'resources', 'core', exe)))
.find((p) => existsSync(p) && binaryArch(p).arch === arch);
if (!packagedCore) {
console.error('Packaged output does not contain resources/core for this target.');
process.exit(1);
}
console.log(`packaged core verified: ${packagedCore} (${JSON.stringify(binaryArch(packagedCore))})`);
+105
View File
@@ -0,0 +1,105 @@
// Static check that ELF64 files can be mapped on kernels with large pages (Asahi Linux uses 16 KiB):
// every PT_LOAD must have p_align >= PAGE and p_offset ≡ p_vaddr (mod PAGE).
// Also lists DT_NEEDED libraries and the highest GLIBC_x.y symbol version referenced.
//
// node scripts/elf-pagesize.mjs <file-or-dir> [...] [--page 16384] [--json out.json]
import { readFileSync, readdirSync, statSync, writeFileSync, openSync, readSync, closeSync } from 'node:fs';
import path from 'node:path';
const argv = process.argv.slice(2);
const pi = argv.indexOf('--page');
const PAGE = pi >= 0 ? Number(argv[pi + 1]) : 16384;
const ji = argv.indexOf('--json');
const valueIdx = new Set([pi, ji].filter((i) => i >= 0).map((i) => i + 1));
const inputs = argv.filter((a, i) => !a.startsWith('--') && !valueIdx.has(i));
function isElf(file) {
const fd = openSync(file, 'r');
try {
const b = Buffer.alloc(4);
return readSync(fd, b, 0, 4, 0) === 4 && b.readUInt32BE(0) === 0x7f454c46;
} finally {
closeSync(fd);
}
}
function walk(p, out) {
const st = statSync(p, { throwIfNoEntry: false });
if (!st) return;
if (st.isDirectory()) for (const e of readdirSync(p)) walk(path.join(p, e), out);
else if (st.isFile() && st.size > 64 && isElf(p)) out.push(p);
}
function inspect(file) {
const b = readFileSync(file);
if (b[4] !== 2 || b[5] !== 1) return { file, error: 'not ELF64 little-endian' };
const machine = b.readUInt16LE(18);
const phoff = Number(b.readBigUInt64LE(32));
const phentsize = b.readUInt16LE(54);
const phnum = b.readUInt16LE(56);
const shoff = Number(b.readBigUInt64LE(40));
const shentsize = b.readUInt16LE(58);
const shnum = b.readUInt16LE(60);
const loads = [];
let dynamic = null;
for (let i = 0; i < phnum; i += 1) {
const o = phoff + i * phentsize;
const type = b.readUInt32LE(o);
const offset = b.readBigUInt64LE(o + 8);
const vaddr = b.readBigUInt64LE(o + 16);
const filesz = b.readBigUInt64LE(o + 32);
const align = b.readBigUInt64LE(o + 48);
if (type === 1) {
const congruent = offset % BigInt(PAGE) === vaddr % BigInt(PAGE);
loads.push({ align: Number(align), ok: align >= BigInt(PAGE) && congruent, congruent });
} else if (type === 2) {
dynamic = { offset: Number(offset), size: Number(filesz) };
}
}
// DT_NEEDED via .dynamic + .dynstr (section headers), GLIBC versions via raw string scan.
const needed = [];
if (dynamic && shoff && shnum) {
let dynstr = null;
for (let i = 0; i < shnum; i += 1) {
const o = shoff + i * shentsize;
const type = b.readUInt32LE(o + 4);
const link = b.readUInt32LE(o + 40);
if (type === 6) {
const lo = shoff + link * shentsize;
dynstr = Number(b.readBigUInt64LE(lo + 24));
}
}
if (dynstr !== null) {
for (let o = dynamic.offset; o + 16 <= dynamic.offset + dynamic.size; o += 16) {
const tag = b.readBigInt64LE(o);
if (tag === 0n) break;
if (tag === 1n) {
const start = dynstr + Number(b.readBigUInt64LE(o + 8));
needed.push(b.toString('latin1', start, b.indexOf(0, start)));
}
}
}
}
const glibc = [...new Set(b.toString('latin1').match(/GLIBC_[0-9]+(\.[0-9]+)+/g) ?? [])]
.sort((x, y) => x.slice(6).split('.').map(Number).reduce((acc, n, i) => acc || n - (y.slice(6).split('.').map(Number)[i] ?? 0), 0));
return {
file,
machine: machine === 0xb7 ? 'aarch64' : machine === 0x3e ? 'x86-64' : `0x${machine.toString(16)}`,
minLoadAlign: loads.length ? Math.min(...loads.map((l) => l.align)) : null,
pageOk: loads.every((l) => l.ok),
needed,
maxGlibc: glibc.at(-1) ?? null,
};
}
const files = [];
for (const input of inputs) walk(path.resolve(input), files);
const results = files.map(inspect);
let bad = 0;
for (const r of results) {
if (r.error || !r.pageOk) bad += 1;
console.log(`${r.pageOk ? 'ok ' : 'FAIL'} ${r.machine ?? ''} align=${r.minLoadAlign} glibc=${r.maxGlibc ?? '-'} ${path.relative(process.cwd(), r.file)}${r.needed?.length ? ` needs ${r.needed.join(',')}` : ''}${r.error ? ` (${r.error})` : ''}`);
}
console.log(`${results.length} ELF files, ${bad} incompatible with ${PAGE}-byte pages`);
if (jsonOut) writeFileSync(jsonOut, JSON.stringify({ page: PAGE, results }, null, 2));
process.exit(bad ? 1 : 0);
+195
View File
@@ -0,0 +1,195 @@
// Browser-pipeline check of the viewer's media lifecycle inside the real Electron renderer.
// A throwaway RTCPeerConnection in the same page plays the streamer: it sends a canvas video and a
// generated 440 Hz tone, trickles ICE before its offer is delivered, and sends a realign offer.
// The real viewer code (watch.js + StreamViewerSession) receives it through an injected transport.
//
// This proves Chromium-side behaviour (track attach, playback, output-device routing, stop/switch
// while callbacks are pending). It is NOT TeamSpeak interoperability: see scripts/probe-stream.mjs.
//
// node scripts/loopback-stream.mjs --out docs/evidence/runtime/<name>
import { _electron as electron } from 'playwright-core';
import { mkdirSync, writeFileSync, mkdtempSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const require = createRequire(import.meta.url);
const electronPath = require('electron');
const argv = process.argv.slice(2);
const out = path.resolve(root, argv[argv.indexOf('--out') + 1] ?? 'loopback-out');
mkdirSync(out, { recursive: true });
const profile = mkdtempSync(path.join(tmpdir(), 'teamspeach-loopback-'));
const result = { startedAt: new Date().toISOString(), steps: [], console: [] };
const step = (name, data = {}) => {
result.steps.push({ name, ...data });
console.log(`[loopback] ${name}`, JSON.stringify(data));
};
// Runs in the page: builds a fake streamer bound to stream id `id`.
const installStreamer = () => {
window.__loop = {
async make(id) {
const watch = await import('/js/watch.js');
const ctx = new AudioContext();
const osc = ctx.createOscillator();
osc.frequency.value = 440;
const gain = ctx.createGain();
gain.gain.value = 0.2;
const dest = ctx.createMediaStreamDestination();
osc.connect(gain).connect(dest);
osc.start();
const canvas = document.createElement('canvas');
canvas.width = 640;
canvas.height = 360;
const g = canvas.getContext('2d');
let n = 0;
const timer = setInterval(() => {
g.fillStyle = `hsl(${(n += 7) % 360} 60% 50%)`;
g.fillRect(0, 0, 640, 360);
}, 33);
const ms = new MediaStream([canvas.captureStream(30).getVideoTracks()[0], dest.stream.getAudioTracks()[0]]);
const pc = new RTCPeerConnection();
for (const t of ms.getTracks()) pc.addTrack(t, ms);
const emit = (name, item) => watch.onStreamEvent({ event: 'stream', name, items: [{ id, clid: '999', ...item }] });
pc.onicecandidate = (e) => {
if (e.candidate) emit('notifystreamsignaling', { json: JSON.stringify({ cmd: 'iceCandidate', args: { mLine: e.candidate.sdpMLineIndex, mid: e.candidate.sdpMid, sdp: e.candidate.candidate } }) });
};
let answers = 0;
const transport = {
join: async () => {
await pc.setLocalDescription(await pc.createOffer());
// Deliver the offer a little later so trickled candidates arrive first (buffering path).
setTimeout(() => emit('notifyrespondjoinstreamrequest', { decision: '1', offer: pc.localDescription.sdp, msg: '' }), 150);
},
send: async (_id, _clid, json) => {
if (json.cmd === 'answer') {
await pc.setRemoteDescription({ type: 'answer', sdp: json.args.answer });
answers += 1;
if (answers === 1) {
// Realign offer, as a TS6 streamer does after the first answer.
setTimeout(async () => {
await pc.setLocalDescription(await pc.createOffer());
emit('notifystreamsignaling', { json: JSON.stringify({ cmd: 'offer', args: { offer: pc.localDescription.sdp } }) });
}, 200);
}
} else if (json.cmd === 'iceCandidate') {
await pc.addIceCandidate({ candidate: json.args.sdp, sdpMid: json.args.mid, sdpMLineIndex: json.args.mLine });
}
},
leave: async () => {
clearInterval(timer);
pc.close();
ctx.close();
},
};
return { transport, pc };
},
async start(id) {
const watch = await import('/js/watch.js');
const { transport } = await this.make(id);
watch.startWatching({ id, clientId: 999, name: `loop ${id}`, nickname: 'loopback', fields: { audio: '1' } }, transport);
},
async stop() {
const watch = await import('/js/watch.js');
watch.stopWatching();
},
};
};
let app;
let page;
let failed = null;
try {
// Synthetic capture device only: getUserMedia permission unlocks real output-device enumeration.
app = await electron.launch({ executablePath: electronPath, args: [root, '--use-fake-device-for-media-stream', '--use-fake-ui-for-media-stream'], env: { ...process.env, TEAMSPEACH_PROFILE_DIR: profile } });
page = await app.firstWindow();
page.on('console', (m) => result.console.push(`${m.type()}: ${m.text()}`));
page.on('pageerror', (e) => result.console.push(`pageerror: ${e.message}`));
await page.waitForSelector('#view-onboarding', { state: 'visible', timeout: 20000 });
await page.fill('#onboarding-nick', 'LoopbackTest');
await page.click('#onboarding-submit');
await page.waitForSelector('#view-app', { state: 'visible', timeout: 20000 });
// Not connected to any server: show the session area so the viewer panel is laid out.
await page.evaluate(() => {
document.querySelector('#connect-view').hidden = true;
document.querySelector('#session-view').hidden = false;
});
await page.evaluate(installStreamer);
await page.$eval('#stream-volume', (el) => {
el.value = '5';
el.dispatchEvent(new Event('input', { bubbles: true }));
});
const stats = () => page.evaluate(() => window.teamspeachDiagnostics.snapshot().watch);
const errorToasts = () => page.$$eval('.toast[data-kind="error"]', (els) => els.map((e) => e.textContent));
// 1. Switch while the first session's track-attach callback is pending, then stop/start rapidly.
await page.evaluate(async () => {
await window.__loop.start('A');
await window.__loop.stop();
await window.__loop.start('B');
});
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().watch.framesDecoded > 30, null, { timeout: 20000 });
await page.waitForTimeout(2000);
let s = await stats();
const srcIsCurrent = await page.evaluate(() => document.querySelector('#stream-video').srcObject?.getTracks().length ?? 0);
step('switch while pending', { state: s.state, framesDecoded: s.framesDecoded, offersApplied: s.offersApplied, answersSent: s.answersSent, inboundAudioPackets: s.inboundAudioPackets, tracksOnElement: srcIsCurrent, errors: await errorToasts() });
if (s.offersApplied < 2) throw new Error('realign offer was not answered');
if (!(s.inboundAudioPackets > 0)) throw new Error('no inbound audio packets');
// 2. Default output: no setSinkId call is needed and no error may appear.
step('default sink', { sinkId: s.sinkId, sinkError: s.sinkError, errors: await errorToasts() });
// 3. Select a concrete output device through the real settings UI while the stream plays.
await page.click('#btn-settings');
await page.waitForSelector('#settings-view', { state: 'visible' });
await page.click('#mic-test');
await page.waitForTimeout(1200);
await page.click('#mic-test');
await page.waitForTimeout(300);
const options = await page.$$eval('#output-device option', (os) => os.map((o) => ({ value: o.value, label: o.textContent })));
const device = options.find((o) => o.value);
if (device) {
await page.selectOption('#output-device', device.value);
await page.waitForTimeout(1500);
s = await stats();
const elementSink = await page.evaluate(() => document.querySelector('#stream-video').sinkId);
step('selected sink', { device: device.label, elementSinkMatches: elementSink === device.value, sinkError: s.sinkError, errors: await errorToasts() });
if (elementSink !== device.value) throw new Error('stream element not routed to selected device');
// Restart viewing with the device already selected: applied on `playing`.
await page.click('#settings-back');
await page.evaluate(() => {
document.querySelector('#connect-view').hidden = true;
document.querySelector('#session-view').hidden = false;
});
await page.evaluate(async () => {
await window.__loop.stop();
await window.__loop.start('C');
});
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().watch.inboundAudioPackets > 50, null, { timeout: 20000 });
s = await stats();
step('restart with selected sink', { sinkId: s.sinkId === device.value, sinkError: s.sinkError, framesDecoded: s.framesDecoded, inboundAudioPackets: s.inboundAudioPackets, errors: await errorToasts() });
await page.selectOption('#output-device', '').catch(() => {});
} else {
step('selected sink skipped', { reason: 'no non-default output device enumerated' });
}
await page.evaluate(() => { document.querySelector('#stream-video').style.visibility = 'hidden'; });
await page.screenshot({ path: path.join(out, '30-loopback-viewer-redacted.png') });
await page.evaluate(() => window.__loop.stop());
const errs = await errorToasts();
step('final', { errors: errs });
if (errs.length) throw new Error(`error toasts: ${errs.join(' | ')}`);
} catch (err) {
failed = err;
step('FAILED', { error: String(err.stack || err) });
} finally {
if (app) await app.close().catch(() => {});
rmSync(profile, { recursive: true, force: true });
}
result.ok = !failed;
result.note = 'Loopback inside Chromium: validates the browser media pipeline only, not TS6 interoperability.';
writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2));
console.log(`[loopback] ${result.ok ? 'OK' : 'FAILED'} → ${out}`);
process.exit(result.ok ? 0 : 1);
+131
View File
@@ -0,0 +1,131 @@
// Watches a real TS6 screenshare with the real TeamsPeach UI and records protocol/media evidence.
// Microphone is muted before connecting and push-to-talk is never pressed: nothing is transmitted.
// No video pixels are saved: the video element is hidden for the UI screenshot.
//
// node scripts/probe-stream.mjs --server 10.10.10.160:9987 --channel cs --out docs/evidence/runtime/<name> [--seconds 40]
import { _electron as electron } from 'playwright-core';
import { mkdirSync, writeFileSync, mkdtempSync, readFileSync, existsSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const require = createRequire(import.meta.url);
const electronPath = require('electron');
const argv = process.argv.slice(2);
const opt = (n, d) => (argv.indexOf(`--${n}`) >= 0 ? argv[argv.indexOf(`--${n}`) + 1] : d);
const server = opt('server');
const channelName = opt('channel', 'cs');
const seconds = Number(opt('seconds', '40'));
const nickname = opt('nick', 'TeamsPeach-Probe');
const out = path.resolve(root, opt('out', 'probe-stream-out'));
const profile = opt('profile') ? path.resolve(opt('profile')) : mkdtempSync(path.join(tmpdir(), 'teamspeach-probe-'));
mkdirSync(out, { recursive: true });
const result = { startedAt: new Date().toISOString(), server, channelName, profile, steps: [], samples: [], console: [] };
const step = (name, data = {}) => {
result.steps.push({ name, at: new Date().toISOString(), ...data });
console.log(`[probe] ${name}`, JSON.stringify(data));
};
const diag = (page) => page.evaluate(() => window.teamspeachDiagnostics.snapshot());
let app;
let page;
let failed = null;
try {
app = await electron.launch({ executablePath: electronPath, args: [root], env: { ...process.env, TEAMSPEACH_PROFILE_DIR: profile } });
page = await app.firstWindow();
page.on('console', (m) => result.console.push(`${m.type()}: ${m.text()}`));
page.on('pageerror', (e) => result.console.push(`pageerror: ${e.message}`));
await page.setViewportSize({ width: 1280, height: 800 }).catch(() => {});
const onboarding = await page.waitForSelector('#view-onboarding, #view-app', { state: 'visible', timeout: 20000 });
if ((await onboarding.getAttribute('id')) === 'view-onboarding') {
await page.fill('#onboarding-nick', nickname);
await page.click('#onboarding-submit');
await page.waitForSelector('#view-app', { state: 'visible', timeout: 20000 });
}
// Mute before connecting (applied by the core at connect).
await page.click('#btn-mute');
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().audio.input_muted === true, null, { timeout: 10000 });
step('muted before connect', { profile: (await diag(page)).profile });
await page.fill('#connect-address', server);
await page.click('#connect-submit');
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().conn === 'connected', null, { timeout: 60000 });
let d = await diag(page);
step('connected', { server: d.server, ownClientId: d.ownClientId, channel: d.ownChannel, audio: d.audio });
const findRow = (name) => Array.from(document.querySelectorAll('#tree .channel-row')).some((r) => r.querySelector('.row-label')?.textContent.trim().toLowerCase() === name.toLowerCase());
await page.waitForFunction(findRow, channelName, { timeout: 20000 }).catch(() => {});
const joined = await page.evaluate((name) => {
const rows = Array.from(document.querySelectorAll('#tree .channel-row'));
const row = rows.find((r) => r.querySelector('.row-label')?.textContent.trim().toLowerCase() === name.toLowerCase());
if (!row) return false;
row.querySelector('.row-btn').click();
return true;
}, channelName);
if (!joined) throw new Error(`channel "${channelName}" not found`);
await page.waitForFunction((name) => (window.teamspeachDiagnostics.snapshot().ownChannel ?? '').toLowerCase() === name.toLowerCase(), channelName, { timeout: 15000 });
d = await diag(page);
step('joined channel', { channel: d.ownChannel, members: d.clients.filter((c) => c.channel === d.clients.find((x) => x.id === d.ownClientId).channel).map((c) => c.nickname) });
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().streams.length > 0, null, { timeout: 25000 });
d = await diag(page);
step('streams discovered', { streams: d.streams });
const stream = d.streams[0];
await page.click(`#tree [data-key="u:${stream.clientId}"] .watch-btn`);
step('watch clicked', { streamId: stream.id, clientId: stream.clientId });
const deadline = Date.now() + seconds * 1000;
let firstFrameAt = null;
while (Date.now() < deadline) {
await page.waitForTimeout(2000);
d = await diag(page);
result.samples.push({ at: new Date().toISOString(), ...d.watch });
if (!firstFrameAt && d.watch.framesDecoded > 0) {
firstFrameAt = new Date().toISOString();
step('first decoded frame', { ...d.watch });
await page.evaluate(() => { document.querySelector('#stream-video').style.visibility = 'hidden'; });
await page.screenshot({ path: path.join(out, '20-watching-video-redacted.png') });
await page.evaluate(() => { document.querySelector('#stream-video').style.visibility = ''; });
}
if (['failed', 'declined', 'ended', 'removed', 'unsupported'].includes(d.watch.state)) {
step('session ended early', { ...d.watch, overlay: await page.textContent('#stream-overlay') });
await page.screenshot({ path: path.join(out, '21-watch-ended.png') });
break;
}
}
d = await diag(page);
step('final watch stats', { ...d.watch });
if (!(d.watch.framesDecoded > 0)) throw new Error('no video frames decoded');
await page.click('#stream-stop');
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().watch.state === 'idle', null, { timeout: 10000 });
step('stopped watching');
} catch (err) {
failed = err;
step('FAILED', { error: String(err.stack || err) });
if (page) {
await page.evaluate(() => { const v = document.querySelector('#stream-video'); if (v) v.style.visibility = 'hidden'; }).catch(() => {});
await page.screenshot({ path: path.join(out, 'fail.png') }).catch(() => {});
}
} finally {
if (page) {
await page.click('#btn-disconnect').catch(() => {});
await page.waitForTimeout(800);
}
if (app) await app.close().catch(() => {});
}
for (const name of ['renderer.log', 'core.log']) {
const file = path.join(profile, 'logs', name);
if (existsSync(file)) {
const lines = readFileSync(file, 'utf8').split(/\r?\n/).filter((l) => /watch|stream|state|error|warn/i.test(l));
writeFileSync(path.join(out, `${name}.filtered.txt`), lines.join('\n'));
}
}
result.finishedAt = new Date().toISOString();
result.ok = !failed;
writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2));
console.log(`[probe] ${result.ok ? 'OK' : 'FAILED'} → ${out}`);
process.exit(result.ok ? 0 : 1);
+31
View File
@@ -0,0 +1,31 @@
// Rasterizes build/icon.svg to build/icon.png (512×512, transparent) and app/renderer/assets/icon.png
// with Electron's own renderer, so no extra image tooling is needed.
// npx electron scripts/render-icon.cjs
const { app, BrowserWindow } = require('electron');
const fs = require('node:fs');
const path = require('node:path');
const root = path.resolve(__dirname, '..');
const svg = fs.readFileSync(path.join(root, 'build', 'icon.svg'), 'utf8');
app.whenReady().then(async () => {
const win = new BrowserWindow({
width: 512,
height: 512,
show: false,
transparent: true,
frame: false,
webPreferences: { offscreen: true },
});
win.webContents.setFrameRate(1);
const html = `<!doctype html><html><body style="margin:0;background:transparent">${svg.replace('<svg ', '<svg width="512" height="512" ')}</body></html>`;
await win.loadURL(`data:text/html;charset=utf-8,${encodeURIComponent(html)}`);
await new Promise((r) => setTimeout(r, 300));
const image = await win.webContents.capturePage({ x: 0, y: 0, width: 512, height: 512 });
const png = image.resize({ width: 512, height: 512 }).toPNG();
fs.writeFileSync(path.join(root, 'build', 'icon.png'), png);
fs.mkdirSync(path.join(root, 'app', 'renderer', 'assets'), { recursive: true });
fs.writeFileSync(path.join(root, 'app', 'renderer', 'assets', 'icon.png'), image.resize({ width: 256, height: 256 }).toPNG());
console.log('icon written');
app.quit();
});
+121
View File
@@ -0,0 +1,121 @@
// Real Electron UI smoke run (no mocks): first launch → onboarding → restart persistence → rename,
// optional live server connect. Uses a disposable profile directory so the user's profile is untouched.
//
// node scripts/smoke-ui.mjs --out docs/evidence/runtime/<name> [--server 10.10.10.160:9987] [--profile DIR]
//
// Writes screenshots and result.json (UIDs are public identifiers; no private key ever leaves the core).
import { _electron as electron } from 'playwright-core';
import { mkdirSync, writeFileSync, mkdtempSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const require = createRequire(import.meta.url);
const electronPath = require('electron');
const args = Object.fromEntries(process.argv.slice(2).reduce((acc, a, i, all) => {
if (a.startsWith('--')) acc.push([a.slice(2), all[i + 1] && !all[i + 1].startsWith('--') ? all[i + 1] : 'true']);
return acc;
}, []));
const out = path.resolve(root, args.out ?? 'smoke-out');
const profile = args.profile ? path.resolve(args.profile) : mkdtempSync(path.join(tmpdir(), 'teamspeach-smoke-'));
mkdirSync(out, { recursive: true });
const result = { startedAt: new Date().toISOString(), profile, steps: [], console: [] };
const step = (name, data = {}) => {
result.steps.push({ name, at: new Date().toISOString(), ...data });
console.log(`[smoke] ${name}`, JSON.stringify(data));
};
async function launch(label) {
const app = await electron.launch({
executablePath: electronPath,
env: { ...process.env, TEAMSPEACH_PROFILE_DIR: profile },
args: [root, ...(process.env.TEAMSPEACH_SMOKE_EXTRA_ARGS ?? '').split(' ').filter(Boolean), ...(args.fakemic ? ['--use-fake-device-for-media-stream', '--use-fake-ui-for-media-stream'] : [])],
});
const page = await app.firstWindow();
page.on('console', (msg) => result.console.push(`${label} ${msg.type()}: ${msg.text()}`));
page.on('pageerror', (err) => result.console.push(`${label} pageerror: ${err.message}`));
await page.setViewportSize({ width: 1280, height: 800 }).catch(() => {});
return { app, page };
}
const diag = (page) => page.evaluate(() => window.teamspeachDiagnostics.snapshot());
const visible = (page, sel) => page.waitForSelector(sel, { state: 'visible', timeout: 20000 });
const shot = async (page, name) => {
await page.waitForTimeout(300);
await page.screenshot({ path: path.join(out, name) });
step(`screenshot ${name}`);
};
let failed = null;
try {
// 1. First launch: onboarding must ask for a nickname once.
let { app, page } = await launch('run1');
await visible(page, '#view-onboarding');
await shot(page, '01-first-launch-onboarding.png');
await page.fill('#onboarding-nick', 'ab');
await page.click('#onboarding-submit');
const validation = await page.textContent('#onboarding-error');
step('short nickname rejected', { message: validation });
await page.fill('#onboarding-nick', 'PeachSmoke');
await page.click('#onboarding-submit');
await visible(page, '#view-app');
let d = await diag(page);
const uid1 = d.profile.uid;
step('profile created', { uid: uid1, nickname: d.profile.nickname });
await shot(page, '02-after-onboarding.png');
await app.close();
// 2. Restart: same identity, no onboarding.
({ app, page } = await launch('run2'));
await visible(page, '#view-app');
d = await diag(page);
step('restart keeps identity', { uid: d.profile.uid, nickname: d.profile.nickname, same: d.profile.uid === uid1 });
if (d.profile.uid !== uid1) throw new Error('UID changed after restart');
// 3. Rename in settings: UID must not change.
await page.click('#btn-settings');
await visible(page, '#settings-view');
await page.fill('#rename-input', 'PeachRenamed');
await page.click('#rename-submit');
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().profile.nickname === 'PeachRenamed', null, { timeout: 15000 });
d = await diag(page);
step('renamed', { uid: d.profile.uid, nickname: d.profile.nickname, status: await page.textContent('#rename-status'), same: d.profile.uid === uid1 });
if (d.profile.uid !== uid1) throw new Error('UID changed after rename');
await shot(page, '03-settings-renamed.png');
await app.close();
// 4. Restart again: rename persisted.
({ app, page } = await launch('run3'));
await visible(page, '#view-app');
d = await diag(page);
step('rename persisted', { uid: d.profile.uid, nickname: d.profile.nickname, ok: d.profile.uid === uid1 && d.profile.nickname === 'PeachRenamed' });
if (d.profile.nickname !== 'PeachRenamed') throw new Error('rename not persisted');
// 5. Optional live server connection.
if (args.server) {
await page.fill('#connect-address', args.server);
await page.click('#connect-submit');
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().conn === 'connected', null, { timeout: 60000 });
await page.waitForTimeout(1500);
d = await diag(page);
step('connected', { server: d.server, ownClientId: d.ownClientId, channel: d.ownChannel, clients: d.clients.length, videoCodecs: d.videoCodecs });
await shot(page, '04-connected.png');
await page.click('#btn-disconnect');
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().conn === 'disconnected', null, { timeout: 15000 });
step('disconnected');
}
await app.close();
} catch (err) {
failed = err;
step('FAILED', { error: String(err.stack || err) });
}
result.finishedAt = new Date().toISOString();
result.ok = !failed;
writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2));
console.log(`[smoke] ${result.ok ? 'OK' : 'FAILED'} → ${out}`);
process.exit(result.ok ? 0 : 1);
+210
View File
@@ -0,0 +1,210 @@
// Two real TeamsPeach instances (separate disposable profiles) on a live server:
// A transmits Chromium's synthetic microphone (open mic, then push-to-talk), B must receive
// talking events and decoded audio frames from the core; plus channel and private chat both ways.
//
// node scripts/smoke-voice.mjs --server 10.10.10.160:9987 --out docs/evidence/runtime/<name>
//
// The synthetic microphone (--use-fake-device-for-media-stream) replaces only the capture device;
// everything after getUserMedia (worklet, IPC, core Opus, server, decode, mix, playback) is the real path.
import { _electron as electron } from 'playwright-core';
import { mkdirSync, writeFileSync, mkdtempSync } from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { createRequire } from 'node:module';
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const require = createRequire(import.meta.url);
const electronPath = require('electron');
const argv = process.argv.slice(2);
const opt = (name, fallback) => {
const i = argv.indexOf(`--${name}`);
return i >= 0 ? argv[i + 1] : fallback;
};
const server = opt('server');
if (!server) {
console.error('--server is required');
process.exit(2);
}
const out = path.resolve(root, opt('out', 'smoke-voice-out'));
mkdirSync(out, { recursive: true });
const result = { startedAt: new Date().toISOString(), server, steps: [], console: [] };
const step = (name, data = {}) => {
result.steps.push({ name, at: new Date().toISOString(), ...data });
console.log(`[voice] ${name}`, JSON.stringify(data));
};
async function launch(label, nickname) {
const profile = mkdtempSync(path.join(tmpdir(), `teamspeach-${label}-`));
const app = await electron.launch({
executablePath: electronPath,
args: [root, '--use-fake-device-for-media-stream', '--use-fake-ui-for-media-stream'],
env: { ...process.env, TEAMSPEACH_PROFILE_DIR: profile },
});
const page = await app.firstWindow();
page.on('console', (m) => result.console.push(`${label} ${m.type()}: ${m.text()}`));
page.on('pageerror', (e) => result.console.push(`${label} pageerror: ${e.message}`));
await page.waitForSelector('#view-onboarding', { state: 'visible', timeout: 20000 });
await page.fill('#onboarding-nick', nickname);
await page.click('#onboarding-submit');
await page.waitForSelector('#view-app', { state: 'visible', timeout: 20000 });
return { app, page, profile };
}
const diag = (page) => page.evaluate(() => window.teamspeachDiagnostics.snapshot());
const waitDiag = (page, fn, arg, timeout = 20000) => page.waitForFunction(fn, arg, { timeout });
async function setRange(page, selector, value) {
await page.$eval(selector, (el, v) => {
el.value = String(v);
el.dispatchEvent(new Event('input', { bubbles: true }));
el.dispatchEvent(new Event('change', { bubbles: true }));
}, value);
}
async function connect(page) {
await page.fill('#connect-address', server);
await page.click('#connect-submit');
await waitDiag(page, () => window.teamspeachDiagnostics.snapshot().conn === 'connected', null, 60000);
}
let a;
let b;
let failed = null;
try {
a = await launch('A', 'PeachVoiceA');
b = await launch('B', 'PeachVoiceB');
step('profiles created', { a: (await diag(a.page)).profile, b: (await diag(b.page)).profile });
// B listens at zero playback gain so the test does not play tones on the speakers; frames still flow.
await b.page.click('#btn-settings');
await setRange(b.page, '#voice-volume', 0);
await b.page.click('#settings-back');
// Both connect in push-to-talk mode (nothing is sent until a key is held).
await connect(b.page);
await connect(a.page);
await a.page.waitForTimeout(1500);
const da = await diag(a.page);
const db = await diag(b.page);
step('both connected', { aClid: da.ownClientId, aChannel: da.ownChannel, bClid: db.ownClientId, bChannel: db.ownChannel });
if (da.ownChannel !== db.ownChannel) throw new Error('clients landed in different channels');
const ownCid = (s) => s.clients.find((c) => c.id === s.ownClientId)?.channel;
const others = db.clients.filter((c) => c.type !== 'query' && c.channel === ownCid(db) && c.id !== da.ownClientId && c.id !== db.ownClientId);
if (others.length > 0) throw new Error(`refusing to transmit test tones: channel occupied by ${others.map((c) => c.nickname).join(', ')}`);
// A: open microphone.
await a.page.click('#btn-settings');
await a.page.check('input[name="transmit"][value="open"]');
await a.page.click('#settings-back');
// Open mic: B must see A talking and receive audio frames.
await waitDiag(b.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), da.ownClientId, 20000);
await b.page.waitForTimeout(3000);
let sa = await diag(a.page);
let sb = await diag(b.page);
const playback = await b.page.evaluate(() => window.teamspeachDiagnostics.playback());
step('open mic received', { aFramesSent: sa.voice.framesSent, aTransmitting: sa.audio.transmitting, bTalking: sb.talking, bFramesPlayed: sb.voice.framesPlayed, bPlayback: playback });
if (sb.voice.framesPlayed < 50) throw new Error('B received too few audio frames');
await b.page.screenshot({ path: path.join(out, '10-b-sees-a-talking.png') });
await a.page.screenshot({ path: path.join(out, '11-a-open-mic.png') });
// Mute A: talking must stop on B and the mute flag must be visible.
await a.page.click('#btn-mute');
await waitDiag(b.page, (clid) => !window.teamspeachDiagnostics.snapshot().talking.includes(clid), da.ownClientId, 10000);
await b.page.waitForTimeout(800);
step('A muted, talking stopped on B');
await b.page.screenshot({ path: path.join(out, '12-b-sees-a-muted.png') });
await a.page.click('#btn-mute');
// Push-to-talk: switch A to PTT (default key F8), hold the key, release.
await a.page.click('#btn-settings');
await a.page.check('input[name="transmit"][value="ptt"]');
await a.page.click('#settings-back');
await a.page.waitForTimeout(1500);
sb = await diag(b.page);
step('PTT idle', { bTalkingIncludesA: sb.talking.includes(da.ownClientId) });
const before = (await diag(b.page)).voice.framesPlayed;
await a.page.keyboard.down('F8');
await waitDiag(b.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), da.ownClientId, 10000);
await a.page.waitForTimeout(1500);
await a.page.screenshot({ path: path.join(out, '13-a-ptt-held.png') });
await a.page.keyboard.up('F8');
await waitDiag(b.page, (clid) => !window.teamspeachDiagnostics.snapshot().talking.includes(clid), da.ownClientId, 10000);
step('PTT burst received', { bFramesDuringBurst: (await diag(b.page)).voice.framesPlayed - before });
// Reverse direction: B talks to A.
await b.page.click('#btn-settings');
await b.page.check('input[name="transmit"][value="open"]');
await b.page.click('#settings-back');
await waitDiag(a.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), db.ownClientId, 20000);
await a.page.waitForTimeout(2000);
sa = await diag(a.page);
step('reverse direction received', { aFramesPlayed: sa.voice.framesPlayed, aTalking: sa.talking });
// Deafen B while both have open mics: B must stop receiving (RX) and stop sending (TX); undeafen resumes both.
await a.page.click('#btn-settings');
await a.page.check('input[name="transmit"][value="open"]');
await a.page.click('#settings-back');
await waitDiag(b.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), da.ownClientId, 10000);
await b.page.click('#btn-deafen');
await waitDiag(b.page, () => window.teamspeachDiagnostics.snapshot().audio.output_muted === true, null, 10000);
await waitDiag(a.page, (clid) => !window.teamspeachDiagnostics.snapshot().talking.includes(clid), db.ownClientId, 10000);
await b.page.waitForTimeout(1000);
const rx0 = (await diag(b.page)).voice.framesPlayed;
const txA0 = (await diag(a.page)).voice.framesPlayed;
await b.page.waitForTimeout(2500);
const deaf = { bRxDelta: (await diag(b.page)).voice.framesPlayed - rx0, aRxFromBDelta: (await diag(a.page)).voice.framesPlayed - txA0, aSeesBTalking: (await diag(a.page)).talking.includes(db.ownClientId) };
await b.page.screenshot({ path: path.join(out, '17-b-deafened.png') });
step('B deafened', deaf);
if (deaf.bRxDelta !== 0 || deaf.aRxFromBDelta !== 0 || deaf.aSeesBTalking) throw new Error('deafen did not stop RX/TX');
await b.page.click('#btn-deafen');
await waitDiag(a.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), db.ownClientId, 10000);
const rx1 = (await diag(b.page)).voice.framesPlayed;
await b.page.waitForTimeout(2000);
step('B undeafened', { bRxDelta: (await diag(b.page)).voice.framesPlayed - rx1, aSeesBTalking: (await diag(a.page)).talking.includes(db.ownClientId) });
for (const p of [a.page, b.page]) {
await p.click('#btn-settings');
await p.check('input[name="transmit"][value="ptt"]');
await p.click('#settings-back');
}
// Chat: channel message A → B (the server may deny guests channel text: that error must be shown),
// private message B → A.
await a.page.fill('#chat-input', 'TeamsPeach smoke: channel message');
await a.page.press('#chat-input', 'Enter');
const channelOutcome = await Promise.race([
b.page.waitForSelector('text=TeamsPeach smoke: channel message', { timeout: 10000 }).then(() => ({ delivered: true })),
a.page.waitForSelector('.toast[data-kind="error"]', { timeout: 10000 }).then(async (el) => ({ delivered: false, error: await el.textContent() })),
]);
step('channel chat', channelOutcome);
await a.page.screenshot({ path: path.join(out, '14-a-channel-chat-result.png') });
await b.page.click(`#tree [data-key="u:${da.ownClientId}"] .row-btn`);
await b.page.fill('#chat-input', 'TeamsPeach smoke: private message');
await b.page.press('#chat-input', 'Enter');
await a.page.waitForSelector('#chat-tabs .chat-tab:has-text("PeachVoiceB")', { timeout: 10000 });
await a.page.click('#chat-tabs .chat-tab:has-text("PeachVoiceB")');
await a.page.waitForSelector('text=TeamsPeach smoke: private message', { timeout: 10000 });
step('private chat delivered');
await a.page.screenshot({ path: path.join(out, '15-a-private-chat.png') });
await b.page.screenshot({ path: path.join(out, '16-b-private-chat.png') });
} catch (err) {
failed = err;
step('FAILED', { error: String(err.stack || err) });
if (a) await a.page.screenshot({ path: path.join(out, 'fail-a.png') }).catch(() => {});
if (b) await b.page.screenshot({ path: path.join(out, 'fail-b.png') }).catch(() => {});
} finally {
for (const inst of [a, b]) {
if (!inst) continue;
await inst.page.click('#btn-disconnect').catch(() => {});
await inst.page.waitForTimeout(500);
await inst.app.close().catch(() => {});
}
}
result.finishedAt = new Date().toISOString();
result.ok = !failed;
writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2));
console.log(`[voice] ${result.ok ? 'OK' : 'FAILED'} → ${out}`);
process.exit(result.ok ? 0 : 1);