From 5f8c6a1916216267ee4b206064a9f3ec590ef9e0 Mon Sep 17 00:00:00 2001 From: Schluffe Date: Sat, 17 Oct 2026 13:44:08 +0200 Subject: [PATCH] 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 --- CHANGELOG.md | 24 ++- README.md | 70 +++++---- docs/device-identities.md | 31 ++-- docs/ux-roadmap.md | 34 +++-- package.json | 4 +- scripts/browser-check.ts | 177 +++++++++++++++++++--- scripts/browser-context.ts | 6 +- scripts/build-local.ts | 25 ---- src/App.vue | 198 +++++++++++++++++++------ src/components/AppDialog.vue | 41 +++++ src/components/ConnectionWorkspace.vue | 64 ++++++++ src/components/DeviceSettings.vue | 75 ++++------ src/components/EditableName.vue | 24 +++ src/components/NetworkSettings.vue | 2 +- src/components/TransferPanel.vue | 39 +++-- src/lib/connections.ts | 109 ++++++++++++++ src/lib/identity.ts | 37 +---- src/style.css | 168 ++++++++++++++++----- tests/connections.test.ts | 32 ++++ tests/identity.test.ts | 24 +-- vite.config.ts | 1 - 21 files changed, 879 insertions(+), 306 deletions(-) delete mode 100644 scripts/build-local.ts create mode 100644 src/components/AppDialog.vue create mode 100644 src/components/ConnectionWorkspace.vue create mode 100644 src/components/EditableName.vue create mode 100644 src/lib/connections.ts create mode 100644 tests/connections.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 69397e7..8a1bcbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,18 @@ # Changelog -## Unreleased +## [0.0.5] - Draft (unreleased) +### Added + +- Add a messenger-style workspace with a connections sidebar, editable slot + names, session status, and a persistent activity timeline per connection. +- Preserve live sessions and file selections while switching slots. Save names, + paired-device associations, and the last 50 transfer results locally; keep + manual reconnection with fresh codes. Add collapsible mobile navigation. - Add opt-in hosted device identities and saved contacts, with fresh mutual signatures bound to both connection fingerprints before remembered verification. -- Add contact removal, identity reset, and password-encrypted backup/restore. +- Add contact removal and identity reset. Identity-enabled signaling uses v4; temporary v3 sessions remain available. - - Keep verified sessions open for “Send another file”, with separate acceptance and storage for each file. - Preserve the previous memory download until the next file is accepted. @@ -15,9 +21,19 @@ - Add explicit Disconnect and live Send/Receive navigation. The initial receiver can use Send to add files without reconnecting. Disconnect aborts unfinished writes while preserving the last completed memory download. +- Document the hosted-first, serverless UX roadmap. + +### Changed + - Upgrade connection/session framing to v3 with per-file identifiers. Both peers must update; v2 codes are rejected before connection setup. -- Document the hosted-first, serverless UX roadmap. +- New device identity private keys are non-extractable. + +### Removed + +- The downloadable single-file HTML app (`hellcon-local.html`), its + **Download app for local use** link, and `file://` support. Serve the `dist/` + build over HTTPS or open it on localhost instead. ## [0.0.4] - 2026-10-16 diff --git a/README.md b/README.md index 0f35690..329e44c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # HellCon -Current version: **0.0.4**. See the [changelog](CHANGELOG.md) for release notes +Current version: **0.0.5** (draft). See the [changelog](CHANGELOG.md) for release notes and compatibility changes. Browser-to-browser file sharing with Vue 3 and WebRTC. No accounts, signaling @@ -8,6 +8,33 @@ backend, or server-side file storage. You exchange connection codes manually. Direct connections are the default. TURN relaying is optional and requires explicit opt-in by both people; no relay is configured automatically. +## Connections workspace + +The sidebar holds your connections, starting with **Con 1**. Use **Add connection** +for another empty slot. Edit the name directly in the header; it saves when you +leave the field or press Enter. Empty names revert to the previous name. +Use **Remove** beside the name to open a confirmation dialog. Confirming removal +ends that slot's sessions in open tabs; downloaded files and saved device identities +remain. Removing the last slot leaves a fresh **Con 1**. +Each slot has its own setup, live session, and activity timeline. Switching slots +keeps active transfers and selected files alive while this tab stays open. +On small screens, **Show connections** opens the sidebar. + +Connection names, associated remembered devices, and the last 50 transfer results +per slot are saved in this browser. History includes filenames, sizes, directions, +times, and completion/decline/interruption results. It does not save file contents, +connection codes, or relay credentials. **Reset** clears the current session but +keeps the slot and history. Closing or reloading the page ends live sessions and +discards selected files; reconnect by exchanging fresh codes. The sidebar reports +this tab's session status, not remote device presence. + +Remembering a verified device associates it with the current slot. On returning, +that device is preselected if it is still trusted; enable your identity before +exchanging fresh codes to use remembered verification. Existing saved contacts +remain available in **Remembered devices**. Clearing site data removes saved +connections and trust. Storage failures are shown explicitly; temporary sessions +remain available. Up to 100 connection slots are supported. + ## How it works 1. The person starting the connection selects one or more files and configures STUN (PageQuit by default, Google, @@ -63,7 +90,7 @@ the session, although browsers and mobile operating systems can suspend pages. Pending verification/acceptance expires after five minutes; stalled transfers expire after one minute. Idle verified sessions stay open. Lost connections need fresh codes. File transfers use protocol **v3**; pre-v3 connection codes are -rejected before connecting. The local HTML supports the same manual flow. +rejected before connecting. If an answer is rejected as invalid, correct the pasted answer and click Connect again; the sender keeps its existing offer while it is still awaiting an answer. @@ -110,17 +137,15 @@ A changed or missing identity requires manual comparison and never overwrites a saved contact. Nicknames stay local. Public identities in codes can link sessions. Use **Forget** to remove a contact, or explicitly delete your identity and contacts. -Encrypted backup/restore includes both, protected by a password of at least 12 -characters. Keep that password separately. Clearing site data loses saved trust; -restoring a backup on another browser gives it the same identity. Browser-stored -keys remain accessible to trusted app code and are not protection against a -malicious host. Identity use defaults off after reload. Storage failure leaves -temporary connections available; downloaded local HTML stays manual. +Clearing site data loses saved trust and requires pairing again. Browser-stored +keys remain usable by trusted app code and are not protection against a malicious +host. Identity use defaults off after reload. Storage failure leaves temporary +connections available. Identity-enabled codes use signaling version **4** and require the new build. Temporary codes retain version **3**. If only one peer enables identity, the current build uses manual comparison without remembering that connection. -See [the identity protocol and backup format](docs/device-identities.md). +See [the identity protocol and storage](docs/device-identities.md). ## Network privacy and optional TURN @@ -207,28 +232,12 @@ policies must permit same-origin workers and frames. No third-party helper, download backend, or additional hosting service is required. Closing/resetting an unfinished transfer aborts it; interrupted transfers must restart. -## Download and run locally +## Build and self-host -Run `bun run build`, then open `dist/hellcon-local.html` directly in a browser. -This single HTML file includes the app code, styles, and icon. A hosted production -build also offers **Download app for local use**. Download that file instead of -using the browser's **Save Page As** command, which may save only the hosted page -without its required assets. You can share the downloaded HTML file with the -other participant; both can open it from disk. No web server is needed to load -the app itself. - -The app still needs network access to connect peers on different machines, and -the selected STUN or TURN servers must be reachable. A `file://` copy cannot use -the host's managed TURN credential endpoint; enter your own relay details when -needed. Service-worker downloads are **disabled for `file://` copies**; there is -no hosted helper dependency in the local version. For large local transfers, -use desktop Chrome with its native save picker and select **Choose destination -& receive to disk**. Brave may disable that API even though it is Chromium-based. -Native disk access still depends on browser settings and platform support. -The 64 MiB in-memory receive option remains available. - -To self-host the regular multi-file build, serve the whole `dist/` directory, -including `assets/`. Serve it over HTTPS for access from other machines. +From a clone of the repository, run `bun install --frozen-lockfile` and +`bun run build`. Serve the whole `dist/` directory, including `assets/` and +`download/`, using a static web server over HTTPS. For local build inspection, +run `bun run preview` and open the printed localhost URL. ## Development @@ -325,6 +334,7 @@ bun run typecheck bun run test bun run build bun run test:browser # local Chromium integration checks against dist/ +bun run test:browser --connections # sidebar, persistence, live switching, and mobile layout bun run test:download # real hosted downloads, including 120 MiB, with native picker disabled bun run test:cross-browser # Brave sender → Firefox receiver bun run preview # local build inspection only diff --git a/docs/device-identities.md b/docs/device-identities.md index e14ffae..60b3e88 100644 --- a/docs/device-identities.md +++ b/docs/device-identities.md @@ -1,7 +1,7 @@ # Remembered-device protocol and storage Phase 3 adds optional hosted-browser identities. Temporary sessions still use -manual fingerprint comparison. The local HTML never opens identity storage. +manual fingerprint comparison. This is an application protocol design and implementation review, not an independent cryptographic audit. @@ -54,36 +54,27 @@ to diagnostic logs, and nicknames are not sent to peers. ## Storage and recovery IndexedDB holds a CryptoKey private key, the public key, and at most 100 contacts. -Keys are extractable to support user-requested backups. Browser storage does not -protect against compromised app code, a hostile host, or compromised browser. +New private keys are non-extractable; existing stored keys remain usable. +Browser storage does not protect against compromised app code, a hostile host, +or compromised browser: app code can still use a stored key to sign. The identity-use checkbox defaults off after page load. Clearing site data loses identity and contacts; an empty store never creates trust automatically. Storage errors leave temporary sessions available. Unreadable storage can be explicitly -cleared before restoring a backup. Atomic revision checks reject stale writes -from other tabs instead of overwriting a newer identity or contact list. Controls for deletion/restoration -require explicit replacement consent and are disabled during a session. +cleared before creating a new identity and pairing again. Atomic revision checks +reject stale writes from other tabs instead of overwriting a newer identity or +contact list. Identity deletion requires explicit consent and is disabled during +a session. Before each identity-enabled connection, settings are read again from storage. A contact forgotten in another tab loses automatic verification on the next connection; a replaced or deleted local identity requires opting in again. A failed refresh stops setup instead of using cached trust. -The v1 backup is JSON containing `format: "hellcon-identity"`, `version: 1`, -`iterations: 600000`, a 16-byte random salt, 12-byte random IV, and ciphertext. -Salt, IV, and ciphertext use lowercase hex. PBKDF2-HMAC-SHA-256 with 600,000 -iterations derives an AES-256-GCM key from the password (12–1024 characters, -UTF-8 without normalization). AES-GCM uses the default 128-bit authentication -tag and additional authenticated data `HellCon backup v1`. The encrypted JSON -contains the private JWK, public key, and contacts. Passwords are cleared from -the UI after operations and are never stored. Backup input is capped at 100 KB; -unsupported versions/iteration counts, malformed fields, wrong passwords, failed -authentication tags, invalid contacts, and mismatched private/public keys are -rejected before replacing stored data. Restoring a backup clones that identity; -there is no central revocation service. Contacts must forget a compromised key. +There is no central revocation service. Contacts must forget a compromised key. Review checks: both role directions, substitution of either identity, alteration of either nonce or fingerprint, forged signatures, replay into fresh contexts, -metadata gating during asynchronous verification, backup tampering and incorrect -passwords, and persistence/reconnection with real browser CryptoKeys. These +metadata gating during asynchronous verification, non-extractable private keys, +and persistence/reconnection with real browser CryptoKeys. These checks do not replace an independent protocol review. Web Crypto algorithm and key-storage reference: diff --git a/docs/ux-roadmap.md b/docs/ux-roadmap.md index 61ccf6a..7960c15 100644 --- a/docs/ux-roadmap.md +++ b/docs/ux-roadmap.md @@ -1,9 +1,25 @@ # Serverless UX roadmap -The hosted HTTPS app is the primary experience. The downloadable HTML must keep -working for basic manual connection and file transfer; it need not match hosted -conveniences. No signaling backend, peer presence service, automatic offline-peer -reconnection, or silent TURN fallback is in scope. +The app runs over HTTPS or on localhost. No signaling backend, peer presence +service, automatic offline-peer reconnection, or silent TURN fallback is in scope. + +## Connection workspace — implemented + +The app title and connection list live in a sidebar. The first slot is **Con 1**; +users add subsequent slots explicitly and can rename them. Selecting a slot opens +its setup, transfer controls, and persistent activity timeline. Cached workspaces +keep live sessions and file selections intact while navigating between slots. +The sidebar collapses on mobile; network configuration is expandable. + +IndexedDB stores slot names, paired-device associations, and up to 50 transfer +results per slot. Each result includes its direction, filename, size, timestamp, +and completion/decline/interruption status. File contents and connection codes +are never stored. Slot mutations are transactional and other tabs refresh their +lists after changes. Storage failures show an explicit warning. + +Disconnect and Reset retain history. Reloading ends live sessions and requires +fresh codes; saved identities can authenticate a remembered peer. A slot's device +association only preselects an existing trusted contact and does not grant trust. ## 1. Send another file on a verified connection — implemented first @@ -43,7 +59,7 @@ survive disconnect until Reset or the next acceptance. Protocol v3 rejects old connection codes before setup. Tests cover simultaneous queues, empty files, separate acceptance, removal, decline, stale IDs/receipts, queue caps, storage cancellation, and verification gates. Browser checks exercise -both directions, real bytes, accessibility, streaming downloads, and the local HTML. +both directions, real bytes, accessibility, and streaming downloads. ## 3. Remember trusted devices — implemented @@ -56,13 +72,13 @@ saved codes never authenticate a peer. Changed or missing identities require manual comparison and never replace saved contacts automatically. Temporary sessions remain the default, and every file still requires acceptance. -Contact removal, identity deletion, encrypted backup/restore, storage failure +Contact removal, identity deletion, storage failure fallback, unreadable-storage recovery, and conflicting-tab write protection are -implemented. The local HTML remains manual. Identity-enabled signaling uses v4; +implemented. Identity-enabled signaling uses v4; temporary connections retain v3. Browser keys remain accessible to app code. Tests cover proof forgery and replay, altered session bindings, metadata gating, -wrong backup passwords and tampering, persistence across reload, changed identities, +persistence across reload, changed identities, storage denial/recovery, and protocol-version validation. Design and review notes are in [the device identity protocol](device-identities.md); this is not an independent cryptographic audit. @@ -79,7 +95,7 @@ exchange remains necessary. Keep pasteable codes as the universal fallback. Bound and validate payloads, handle stale/incompatible links, and test practical URL limits across messengers and mobile browsers. Do not promise a short link without a storage service. Consider compressed payloads and QR only after checking -real payload sizes and decoding limits. Local HTML only needs manual codes. +real payload sizes and decoding limits. ## 5. Guided connection flow diff --git a/package.json b/package.json index d5c4ce0..47a37fe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hellcon", "private": true, - "version": "0.0.4", + "version": "0.0.5", "license": "MIT", "type": "module", "scripts": { @@ -10,7 +10,7 @@ "turn:up": "docker compose --env-file .env.development up -d", "turn:down": "docker compose --env-file .env.development down", "test:turn": "node scripts/browser-check.ts --turn", - "build": "vue-tsc --noEmit && vite build && node scripts/build-local.ts", + "build": "vue-tsc --noEmit && vite build", "preview": "vite preview", "test": "node --test tests/*.test.ts", "test:browser": "node scripts/browser-check.ts", diff --git a/scripts/browser-check.ts b/scripts/browser-check.ts index 6d0a6b4..2108d1a 100644 --- a/scripts/browser-check.ts +++ b/scripts/browser-check.ts @@ -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('.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('#connection-name').focus()); + await input(sender, '#connection-name', 'Work laptop'); + await evaluate(sender, () => window.__hellcon.element('#connection-name').blur()); + await wait(sender, () => document.querySelector('.connection-name')?.textContent === 'Work laptop'); + await evaluate(sender, () => window.__hellcon.element('#connection-name').focus()); + await input(sender, '#connection-name', ' '); + await evaluate(sender, () => window.__hellcon.element('#connection-name').blur()); + assert.equal(await evaluate(sender, () => window.__hellcon.element('#connection-name').value), 'Work laptop'); + await evaluate(sender, () => window.__hellcon.element('#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('#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('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('#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('.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('#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('#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('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('#use-device-identity')!.checked), false, 'Reload defaults to a temporary connection'); await evaluate(session, () => document.querySelector('#use-device-identity')!.click()); const key = await evaluate(session, () => document.querySelector('#expected-device')!.options[1]!.value); + assert.equal(await evaluate(session, () => document.querySelector('#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('input')?.click(); }); await click(identityReceiver, 'Delete identity and contacts'); diff --git a/scripts/browser-context.ts b/scripts/browser-context.ts index 1834fef..0c55b21 100644 --- a/scripts/browser-context.ts +++ b/scripts/browser-context.ts @@ -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(); }, diff --git a/scripts/build-local.ts b/scripts/build-local.ts deleted file mode 100644 index 652ea51..0000000 --- a/scripts/build-local.ts +++ /dev/null @@ -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 = /\n `); -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); diff --git a/src/App.vue b/src/App.vue index 3265781..c0b3c75 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,50 +1,164 @@ diff --git a/src/components/AppDialog.vue b/src/components/AppDialog.vue new file mode 100644 index 0000000..851508e --- /dev/null +++ b/src/components/AppDialog.vue @@ -0,0 +1,41 @@ + + + diff --git a/src/components/ConnectionWorkspace.vue b/src/components/ConnectionWorkspace.vue new file mode 100644 index 0000000..f14980b --- /dev/null +++ b/src/components/ConnectionWorkspace.vue @@ -0,0 +1,64 @@ + + + diff --git a/src/components/DeviceSettings.vue b/src/components/DeviceSettings.vue index 8c2e259..fc18367 100644 --- a/src/components/DeviceSettings.vue +++ b/src/components/DeviceSettings.vue @@ -1,50 +1,49 @@ + + diff --git a/src/components/NetworkSettings.vue b/src/components/NetworkSettings.vue index 845c4ca..365c151 100644 --- a/src/components/NetworkSettings.vue +++ b/src/components/NetworkSettings.vue @@ -3,7 +3,7 @@ import type { IceOptions, NetworkSettings } from '../lib/webrtc.ts'; import { STUN_PROVIDERS } from '../lib/webrtc.ts'; const settings = defineModel({ required: true }); defineProps<{ disabled?: boolean; managedCredentials?: IceOptions | null }>(); -const iceEndpoint = location.protocol === 'file:' ? '' : import.meta.env.VITE_ICE_ENDPOINT || ''; +const iceEndpoint = import.meta.env.VITE_ICE_ENDPOINT || '';