WIP V improve UX [snapshot task 2]

Add the connections workspace (sidebar, editable slots, per-slot activity,
removal dialog with focus wrapping), remove the downloadable local HTML and
unreleased identity backup/restore, and start the 0.0.5 draft changelog.
Restore the released 0.0.3/0.0.4 changelog entries. Enable focus emulation
in browser checks so background tabs receive focus/blur events.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SchluffeandClaude Opus 5.5 committed 2026-10-17 13:44:08 +02:00
1 parent 58c3e2af86
commit 5f8c6a1916
21 files changed
+879 -306

No files matched your search

+154 -23
View File
@@ -4,17 +4,19 @@ import { installBrowserContext, forceRelay, relayCandidateTypes, simulateSlowDis
import assert from 'node:assert/strict';
import { spawn } from 'node:child_process';
import { createServer } from 'node:http';
import { mkdtemp, mkdir, readFile, rm, stat } from 'node:fs/promises';
import { mkdtemp, mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises';
import { createReadStream } from 'node:fs';
import { tmpdir } from 'node:os';
import { dirname, extname, join, resolve } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { fileURLToPath } from 'node:url';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const axeSource = await readFile(join(root, 'node_modules/axe-core/axe.min.js'), 'utf8');
const provider = process.argv.includes('--default-network') ? 'pagequit' : 'none';
const turn = process.argv.includes('--turn');
const transport = process.argv.includes('--tcp') ? 'tcp' : 'udp';
const streaming = process.argv.includes('--stream-download');
const connections = process.argv.includes('--connections');
const screenshotDirectory = process.env.BROWSER_SCREENSHOT_DIR || (process.argv.includes('--screenshots') ? join(tmpdir(), 'hellcon-layout') : '');
const vite = turn ? await (await import('vite')).createServer({ server: { middlewareMode: true }, appType: 'spa' }) : null;
const profile = await mkdtemp(join(tmpdir(), 'hellcon-browser-'));
const server = createServer(async (req, res) => {
@@ -38,6 +40,11 @@ const browser = spawn(process.env.CHROMIUM_PATH || '/usr/bin/chromium', [
'--no-first-run', '--no-default-browser-check', `--user-data-dir=${profile}`, '--remote-debugging-pipe', 'about:blank',
], { stdio: ['ignore', 'ignore', 'pipe', 'pipe', 'pipe'] });
interface ProtocolResults {
'Emulation.setDeviceMetricsOverride': object;
'Emulation.setFocusEmulationEnabled': object;
'Page.captureScreenshot': { data: string };
'Page.bringToFront': object;
'Input.dispatchKeyEvent': object;
'Browser.setDownloadBehavior': object;
'Target.createTarget': { targetId: string };
'Target.attachToTarget': { sessionId: string };
@@ -96,6 +103,8 @@ async function page(url = origin) {
const { sessionId } = await call('Target.attachToTarget', { targetId, flatten: true });
await call('Runtime.enable', {}, sessionId);
await call('Page.enable', {}, sessionId);
// Background tabs otherwise skip focus/blur events, which the name editor relies on.
await call('Emulation.setFocusEmulationEnabled', { enabled: true }, sessionId);
await call('Page.addScriptToEvaluateOnNewDocument', { source: `(${installBrowserContext.toString()})()` }, sessionId);
if (streaming) await call('Page.addScriptToEvaluateOnNewDocument', { source: 'window.showSaveFilePicker = undefined;' }, sessionId);
if (turn) await call('Page.addScriptToEvaluateOnNewDocument', { source: `(${forceRelay.toString()})(${JSON.stringify(transport)})` }, sessionId);
@@ -164,7 +173,147 @@ async function connect(sender: string, receiver: string, size: number, changedId
}
}
try {
if (streaming) {
if (connections) {
const sender = await page(), receiver = await page(origin.replace('127.0.0.1', 'localhost'));
const selectConnection = (session: string, name: string) => evaluate(session, (name: string) => {
const button = [...document.querySelectorAll<HTMLButtonElement>('.connection-link')].find(item => item.querySelector('.connection-name')?.textContent === name);
if (!button) throw new Error('Missing connection: ' + name);
button.click();
}, name);
const screenshot = async (session: string, name: string) => {
if (!screenshotDirectory) return;
await mkdir(screenshotDirectory, { recursive: true });
await call('Page.bringToFront', {}, session);
const { data } = await call('Page.captureScreenshot', { format: 'png', captureBeyondViewport: false }, session);
await writeFile(join(screenshotDirectory, name + '.png'), Buffer.from(data, 'base64'));
};
await call('Emulation.setDeviceMetricsOverride', { width: 1440, height: 1000, deviceScaleFactor: 1, mobile: false }, sender);
assert.equal(await evaluate(sender, () => document.querySelector('.title-line h1')?.textContent), 'Con 1');
await checkAccessibility(sender, 'Connections desktop');
await screenshot(sender, 'connections-desktop');
await evaluate(sender, () => window.__hellcon.element<HTMLInputElement>('#connection-name').focus());
await input(sender, '#connection-name', 'Work laptop');
await evaluate(sender, () => window.__hellcon.element<HTMLInputElement>('#connection-name').blur());
await wait(sender, () => document.querySelector('.connection-name')?.textContent === 'Work laptop');
await evaluate(sender, () => window.__hellcon.element<HTMLInputElement>('#connection-name').focus());
await input(sender, '#connection-name', ' ');
await evaluate(sender, () => window.__hellcon.element<HTMLInputElement>('#connection-name').blur());
assert.equal(await evaluate(sender, () => window.__hellcon.element<HTMLInputElement>('#connection-name').value), 'Work laptop');
await evaluate(sender, () => window.__hellcon.element<HTMLInputElement>('#connection-name').focus());
await input(sender, '#connection-name', 'Work laptop ');
await call('Input.dispatchKeyEvent', { type: 'keyDown', key: 'Enter', code: 'Enter', windowsVirtualKeyCode: 13 }, sender);
await call('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Enter', code: 'Enter', windowsVirtualKeyCode: 13 }, sender);
assert.equal(await evaluate(sender, () => window.__hellcon.element<HTMLInputElement>('#connection-name').value), 'Work laptop');
assert.equal(await evaluate(sender, () => document.activeElement?.id === 'connection-name'), false);
await click(receiver, 'Receive');
await connect(sender, receiver, 4097);
const fingerprints = await evaluate(sender, () => [...document.querySelectorAll('.fp-row code')].map(item => item.textContent));
await click(sender, 'Add connection');
await wait(sender, () => document.querySelector('.title-line h1')?.textContent === 'Con 2');
assert.equal(await evaluate(sender, () => !!document.querySelector('.fingerprint')), false);
await click(receiver, 'Receive in memory (up to 64 MiB)');
await wait(sender, () => document.querySelector('.connection-link .connection-preview')?.textContent === 'browser-test.bin');
assert.equal(await evaluate(sender, () => document.querySelectorAll('.activity-item').length), 0, 'Hidden session activity must stay in its own slot');
await selectConnection(sender, 'Work laptop');
await wait(sender, () => document.querySelector('.session-badge')?.textContent?.includes('Connected'));
assert.deepEqual(await evaluate(sender, () => [...document.querySelectorAll('.fp-row code')].map(item => item.textContent)), fingerprints);
await evaluate(sender, () => window.__hellcon.chooseFile(1234, 'after-switch.bin'));
await wait(receiver, () => document.querySelector('.incoming')?.textContent?.includes('after-switch.bin'));
await click(receiver, 'Receive in memory (up to 64 MiB)');
await wait(sender, () => document.querySelectorAll('.activity-item').length === 2);
const received = await evaluate(receiver, async () => {
const bytes = new Uint8Array(await (await fetch(window.__hellcon.element<HTMLAnchorElement>('a.download').href)).arrayBuffer());
return { size: bytes.length, valid: bytes.every(byte => byte === 123) };
});
assert.deepEqual(received, { size: 1234, valid: true });
await click(sender, 'Disconnect'); await click(sender, 'Reset');
assert.equal(await evaluate(sender, () => document.querySelectorAll('.activity-item').length), 2, 'Reset must preserve slot history');
await checkAccessibility(sender, 'Connections with history');
await screenshot(sender, 'connections-history');
await selectConnection(sender, 'Con 2');
await evaluate(sender, () => window.__hellcon.chooseFile(10, 'draft.bin'));
await selectConnection(sender, 'Work laptop'); await selectConnection(sender, 'Con 2');
assert.equal(await evaluate(sender, () => [...document.querySelectorAll('.panel li')].some(item => item.textContent?.includes('draft.bin'))), true, 'Selected file state survives slot switching');
await call('Page.navigate', { url: origin }, sender);
await wait(sender, () => document.querySelectorAll('.activity-item').length === 2);
assert.equal(await evaluate(sender, () => document.querySelector('.title-line h1')?.textContent), 'Work laptop');
assert.equal(await evaluate(sender, () => document.querySelector('.session-badge')?.textContent), 'Ready to connect');
await selectConnection(sender, 'Con 2');
assert.equal(await evaluate(sender, () => document.querySelectorAll('.activity-item').length), 0);
assert.equal(await evaluate(sender, () => document.querySelector<HTMLInputElement>('#file-input')?.files?.length), 0, 'File contents must not persist after reload');
console.log('PASS: connections retain names and separate histories across reload; switching preserves live transfers and drafts; Reset preserves history.');
const other = await page();
await Promise.all([click(sender, 'Add connection'), click(other, 'Add connection')]);
await wait(sender, () => document.querySelectorAll('.connection-link').length === 4);
await wait(other, () => document.querySelectorAll('.connection-link').length === 4);
assert.deepEqual(await evaluate(sender, () => [...document.querySelectorAll('.connection-name')].map(item => item.textContent)), ['Work laptop', 'Con 2', 'Con 3', 'Con 4']);
console.log('PASS: concurrent tabs add distinct connection slots and synchronize their sidebars.');
await call('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 1, mobile: false }, sender);
await selectConnection(sender, 'Work laptop');
await checkAccessibility(sender, 'Connections mobile');
assert.equal(await evaluate(sender, () => document.documentElement.scrollWidth <= innerWidth), true, 'Mobile workspace must not overflow horizontally');
await screenshot(sender, 'connections-mobile');
await click(sender, 'Remove');
await wait(sender, () => !!document.querySelector('dialog[open]'));
await checkAccessibility(sender, 'Removal dialog mobile');
await screenshot(sender, 'connections-mobile-dialog');
await click(sender, 'Close dialog');
await wait(sender, () => !document.querySelector('dialog[open]'));
await click(sender, 'Show connections');
await checkAccessibility(sender, 'Connections mobile sidebar');
assert.equal(await evaluate(sender, () => getComputedStyle(window.__hellcon.element('.sidebar')).display), 'flex');
await screenshot(sender, 'connections-mobile-sidebar');
await selectConnection(sender, 'Con 2');
assert.equal(await evaluate(sender, () => getComputedStyle(window.__hellcon.element('.sidebar')).display), 'none');
console.log('PASS: mobile navigation opens and closes, fits the viewport, and passes accessibility checks.');
await call('Emulation.setDeviceMetricsOverride', { width: 1440, height: 1000, deviceScaleFactor: 1, mobile: false }, sender);
await selectConnection(sender, 'Work laptop');
await click(receiver, 'Reset');
await connect(sender, receiver, 1024);
await selectConnection(sender, 'Con 2');
await selectConnection(other, 'Work laptop');
await evaluate(other, () => window.__hellcon.element<HTMLButtonElement>('.header-action').focus());
await click(other, 'Remove');
await wait(other, () => !!document.querySelector('dialog[open]'));
assert.equal(await evaluate(other, () => document.activeElement?.textContent?.trim()), 'Keep connection', 'Dialog starts on its non-destructive action');
await checkAccessibility(other, 'Remove connection confirmation');
await screenshot(other, 'connections-remove-dialog');
for (let i = 0; i < 5; i++) {
await call('Input.dispatchKeyEvent', { type: 'keyDown', key: 'Tab', code: 'Tab', windowsVirtualKeyCode: 9 }, other);
await call('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Tab', code: 'Tab', windowsVirtualKeyCode: 9 }, other);
assert.equal(await evaluate(other, () => !!document.querySelector('dialog[open]')?.contains(document.activeElement)), true, 'Tab stays within the modal');
}
await call('Input.dispatchKeyEvent', { type: 'keyDown', key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 }, other);
await call('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 }, other);
await wait(other, () => !document.querySelector('dialog[open]'));
assert.equal(await evaluate(other, () => document.activeElement?.classList.contains('header-action')), true, 'Dialog restores focus to the opener');
await click(other, 'Remove');
await click(other, 'Keep connection');
assert.equal(await evaluate(other, () => document.querySelectorAll('.connection-link').length), 4);
await click(other, 'Remove'); await click(other, 'Remove connection');
await wait(other, () => document.querySelectorAll('.connection-link').length === 3);
await wait(sender, () => document.querySelectorAll('.connection-link').length === 3);
await wait(receiver, () => !document.querySelector('.incoming'));
await call('Page.navigate', { url: origin }, sender);
await wait(sender, () => !!document.querySelector('#stun-provider'));
assert.equal(await evaluate(sender, () => [...document.querySelectorAll('.connection-name')].some(item => item.textContent === 'Work laptop')), false);
for (let count = 3; count > 0; count--) {
const oldName = await evaluate(sender, () => document.querySelector('.title-line h1')?.textContent);
await click(sender, 'Remove'); await click(sender, 'Remove connection');
await wait(sender, () => !document.querySelector('dialog[open]'));
assert.equal(await evaluate(sender, () => document.querySelectorAll('.connection-link').length), Math.max(1, count - 1));
assert.notEqual(await evaluate(sender, () => document.querySelector('.title-line h1')?.textContent), oldName);
}
assert.equal(await evaluate(sender, () => document.querySelector('.title-line h1')?.textContent), 'Con 1');
assert.equal(await evaluate(sender, () => document.querySelectorAll('.activity-item').length), 0);
await call('Page.navigate', { url: origin }, sender);
await wait(sender, () => !!document.querySelector('#stun-provider'));
assert.deepEqual(await evaluate(sender, () => [...document.querySelectorAll('.connection-name')].map(item => item.textContent)), ['Con 1']);
console.log('PASS: removal can be cancelled, persists across reload, closes cached sessions in other tabs, and replaces the last slot with a fresh Con 1.');
assert.deepEqual(browserErrors, []);
} else if (streaming) {
const downloads = join(profile, 'downloads');
await mkdir(downloads);
await call('Browser.setDownloadBehavior', { behavior: 'allow', downloadPath: downloads });
@@ -202,25 +351,6 @@ try {
if (!turn) {
assert.equal(await evaluate(sender, () => document.querySelector<HTMLSelectElement>('#stun-provider')?.value), 'pagequit');
}
if (!turn) {
const localUrl = pathToFileURL(join(root, 'dist/hellcon-local.html')).href;
const localReceiver = await page(localUrl);
assert.equal(await evaluate(localReceiver, () => document.querySelector<HTMLSelectElement>('#stun-provider')?.value), 'pagequit');
assert.equal(await evaluate(localReceiver, () => document.querySelector('h1')?.textContent), 'HellCon');
await click(localReceiver, 'Receive');
assert.equal(await evaluate(localReceiver, () => !!document.querySelector('#offer-input')), true);
const localSender = await page(localUrl);
await connect(localSender, localReceiver, 1024);
assert.equal(await evaluate(localReceiver, () => [...document.querySelectorAll('button')].some(button => button.textContent?.includes('Receive as download'))), false, 'file:// must not offer service-worker downloads');
await click(localReceiver, 'Receive in memory (up to 64 MiB)');
await wait(localReceiver, () => !!document.querySelector('a.download'));
const data = await evaluate(localReceiver, async () => {
const bytes = new Uint8Array(await (await fetch(document.querySelector<HTMLAnchorElement>('a.download')!.href)).arrayBuffer());
return { length: bytes.length, valid: bytes.every(byte => byte === 123) };
});
assert.deepEqual(data, { length: 1024, valid: true });
console.log('PASS: standalone HTML opens from file:// and transfers a file between two local copies.');
}
await click(receiver, 'Receive');
await checkAccessibility(sender, 'Send');
await checkAccessibility(receiver, 'Receive');
@@ -358,6 +488,7 @@ try {
assert.equal(await evaluate(session, () => document.querySelector<HTMLInputElement>('#use-device-identity')!.checked), false, 'Reload defaults to a temporary connection');
await evaluate(session, () => document.querySelector<HTMLInputElement>('#use-device-identity')!.click());
const key = await evaluate(session, () => document.querySelector<HTMLSelectElement>('#expected-device')!.options[1]!.value);
assert.equal(await evaluate(session, () => document.querySelector<HTMLSelectElement>('#expected-device')!.value), key, 'The slot preselects its saved trusted peer after reload');
await input(session, '#expected-device', key);
await input(session, '#stun-provider', 'none');
}
@@ -422,7 +553,7 @@ try {
console.log('PASS: unreadable storage during connection setup cannot reuse a cached identity or contact.');
await evaluate(identityReceiver, () => {
const label = [...document.querySelectorAll('label')].find(el => el.textContent?.includes('Replace or delete'));
const label = [...document.querySelectorAll('label')].find(el => el.textContent?.includes('Delete this browser’s identity'));
label?.querySelector<HTMLInputElement>('input')?.click();
});
await click(identityReceiver, 'Delete identity and contacts');
+5 -1
View File
@@ -12,7 +12,11 @@ export function installBrowserContext() {
aborted: false,
releaseWrite: undefined as (() => void) | undefined,
click(label: string) {
const button = [...document.querySelectorAll('button')].find(button => button.textContent?.trim() === label);
const button = [...document.querySelectorAll('button')].find(button => {
const content = button.cloneNode(true) as HTMLButtonElement;
content.querySelectorAll('[aria-hidden="true"]').forEach(item => item.remove());
return button.getAttribute('aria-label') === label || content.textContent?.trim() === label;
});
if (!button || button.disabled) throw new Error(`Unavailable button: ${label}`);
button.click();
},
-25
View File
@@ -1,25 +0,0 @@
import { readFile, writeFile } from 'node:fs/promises';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const dist = resolve(dirname(fileURLToPath(import.meta.url)), '../dist');
let html = await readFile(join(dist, 'index.html'), 'utf8');
const scriptTag = /<script type="module"(?: [^>]*)? src="(\.\/assets\/[^"<>]+\.js)"><\/script>/;
const scriptPath = html.match(scriptTag)?.[1];
if (!scriptPath) throw new Error('Expected a Vite JavaScript asset in dist/index.html');
const [javascript, icon] = await Promise.all([
readFile(join(dist, scriptPath)),
readFile(join(dist, 'HellNet_alt.png')),
]);
const js = javascript.toString('utf8');
if (/<\/script/i.test(js)) throw new Error('Built JavaScript contains an unsafe inline closing tag');
html = html.replace(scriptTag, '');
html = html.replace('href="./HellNet_alt.png"', `href="data:image/png;base64,${icon.toString('base64')}"`);
html = html.replace('</body>', () => ` <script>${js}</script>\n </body>`);
if (/src="\.\/assets\/|href="\.\/assets\/|href="\.\/HellNet_alt\.png"/.test(html)) {
throw new Error('Standalone HTML still references external build assets');
}
await writeFile(join(dist, 'hellcon-local.html'), html);