WIP II improve UX [snapshot task 2]

This commit is contained in:
Schluffe committed 2026-10-16 16:01:56 +02:00
1 parent cd66321ea6
commit b2bab26981
7 files changed
+53 -19

No files matched your search

+2 -1
View File
@@ -7,7 +7,8 @@
- Preserve the previous memory download until the next file is accepted.
- Add bounded queues (32 files per side), sending in both directions, per-file
progress and results, queue removal, and incoming-file decline.
- Add explicit Disconnect; setup roles stay locked while connected. Disconnect
- 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.
- Upgrade connection/session framing to v3 with per-file identifiers. Both peers
must update; v2 codes are rejected before connection setup.
+3 -2
View File
@@ -52,8 +52,9 @@ disk writes. To cancel an already active transfer, disconnect; cancelling only a
active file is not supported. Completed memory downloads remain available after
disconnect. Save a previous memory download before accepting another file;
acceptance replaces it. **Reset** discards the memory download and returns to
setup. Send/Receive chooses who starts the connection and is locked during the
session. Both people can send using the session's file picker.
setup. Before connecting, Send/Receive chooses who starts the connection. Once
verified, these controls navigate to the sending and receiving sections without
reconnecting. The initial receiver can click **Send**, then **Add files to send**.
Keep both tabs open. Switching browser tabs or apps does not explicitly cancel
the session, although browsers and mobile operating systems can suspend pages.
+2 -2
View File
@@ -22,8 +22,8 @@ that compatibility path with protocol v3; both peers now need the current build.
## 2. Multiple files and transfers in either direction — implemented
Session ownership is independent of the initial Send/Receive setup choice. Setup
tabs stay locked while a session exists. Both people can select or drop multiple
Session ownership is independent of the initial Send/Receive setup choice. After
verification, Send/Receive navigates between sections while preserving the session. Both people can select or drop multiple
files and add more while transferring. Each local queue is capped at 32 including
its active outgoing file; a rolling list retains the last 50 results.
+8 -2
View File
@@ -274,7 +274,13 @@ try {
input.files = files.files; input.dispatchEvent(new Event('change', { bubbles: true }));
});
await evaluate(sender, () => window.__hellcon.element<HTMLButtonElement>('button[aria-label="Remove remove-me.bin"]').click());
await click(receiver, 'Send');
assert.equal(await evaluate(receiver, () => document.activeElement?.getAttribute('aria-labelledby')), 'send-heading');
await evaluate(receiver, () => window.__hellcon.chooseFile(8193, 'return.bin'));
await click(receiver, 'Receive');
assert.equal(await evaluate(receiver, () => document.activeElement?.getAttribute('aria-labelledby')), 'receive-heading');
await click(sender, 'Receive');
assert.equal(await evaluate(sender, () => document.activeElement?.getAttribute('aria-labelledby')), 'receive-heading');
await wait(sender, () => !!document.querySelector('.incoming'));
await wait(receiver, () => !!document.querySelector('.incoming'));
await click(receiver, 'Decline file');
@@ -291,9 +297,9 @@ try {
assert.deepEqual(received, { length: size, valid: true });
await checkAccessibility(session, 'Bidirectional session');
}
assert.equal(await evaluate(sender, () => [...document.querySelectorAll('.tabs button')].every(button => (button as HTMLButtonElement).disabled)), true);
assert.equal(await evaluate(sender, () => [...document.querySelectorAll('.tabs button')].every(button => !(button as HTMLButtonElement).disabled)), true);
assert.deepEqual(await evaluate(sender, () => [...document.querySelectorAll('.fp-row code')].map(e => e.textContent)), originalFingerprints);
console.log('PASS: simultaneous bidirectional transfers, multiple-file queue, removal, decline, exact bytes, and locked setup tabs.');
console.log('PASS: simultaneous bidirectional transfers, multiple-file queue, removal, decline, exact bytes, and live Send/Receive navigation without reconnecting.');
await click(sender, 'Reset'); await click(receiver, 'Reset');
assert.equal(await evaluate(sender, () => window.__hellcon.element('[role=status]').textContent), 'Choose a file to start.');
+13 -4
View File
@@ -4,6 +4,13 @@ import TransferPanel from './components/TransferPanel.vue';
const mode = ref<'send' | 'receive'>('send');
const sessionActive = ref(false);
const connected = ref(false);
const direction = ref<'send' | 'receive'>('send');
const panel = ref<InstanceType<typeof TransferPanel> | null>(null);
function navigate(next: 'send' | 'receive') {
if (connected.value) { direction.value = next; panel.value?.focusDirection(next); }
else if (!sessionActive.value) mode.value = next;
}
const isLocal = location.protocol === 'file:';
const canDownloadApp = import.meta.env.PROD && !isLocal;
</script>
@@ -20,12 +27,14 @@ const canDownloadApp = import.meta.env.PROD && !isLocal;
<p v-if="canDownloadApp || isLocal" class="status">For large files in the downloaded local version, use desktop Chrome on the receiving machine and choose “Choose destination &amp; receive to disk”.</p>
<div class="tabs" role="group" aria-label="Transfer mode">
<button :disabled="sessionActive" :class="{ active: mode === 'send' }" :aria-pressed="mode === 'send'" @click="mode = 'send'">Send</button>
<button :disabled="sessionActive" :class="{ active: mode === 'receive' }" :aria-pressed="mode === 'receive'" @click="mode = 'receive'">Receive</button>
<div class="tabs" role="group" :aria-label="connected ? 'Transfer sections' : 'Connection setup'">
<button :disabled="sessionActive && !connected" :class="{ active: (connected ? direction : mode) === 'send' }" :aria-pressed="(connected ? direction : mode) === 'send'" @click="navigate('send')">Send</button>
<button :disabled="sessionActive && !connected" :class="{ active: (connected ? direction : mode) === 'receive' }" :aria-pressed="(connected ? direction : mode) === 'receive'" @click="navigate('receive')">Receive</button>
</div>
<TransferPanel :key="mode" :sending="mode === 'send'" @session-change="sessionActive = $event" />
<p v-if="connected" class="status">Connected — either person can send files. Send and Receive jump to those sections without interrupting transfers.</p>
<p v-else-if="sessionActive" class="status">Finish connecting and verifying first. Then either person can send and receive.</p>
<TransferPanel ref="panel" :key="mode" :sending="mode === 'send'" @session-change="sessionActive = $event" @connected-change="connected = $event; direction = mode" />
</main>
<footer>
+22 -8
View File
@@ -2,7 +2,7 @@
import { asError } from '../lib/validation.ts';
import type { Fingerprints, IceOptions, NetworkSettings as NetworkSettingsModel } from '../lib/webrtc.ts';
import type { FileMetadata, TransferState, FileDestination } from '../lib/transfer.ts';
import { computed, onBeforeUnmount, ref } from 'vue';
import { computed, onBeforeUnmount, ref, watch } from 'vue';
import NetworkSettings from './NetworkSettings.vue';
import { acceptAnswerCode, createAnswerCode, createOfferCode, createPeerConnection, fetchTurnOptions, iceConfiguration, getFingerprints, MAX_SIGNAL_LENGTH, STUN_PROVIDERS } from '../lib/webrtc.ts';
import { MEMORY_LIMIT, validateMetadata } from '../lib/transfer.ts';
@@ -30,7 +30,7 @@ const outgoing = ref<FileMetadata | null>(null);
const receiveProgress = ref(0);
const lastDirection = ref<'send' | 'receive'>('send');
const history = ref<string[]>([]);
const emit = defineEmits<{ sessionChange: [active: boolean] }>();
const emit = defineEmits<{ sessionChange: [active: boolean]; connectedChange: [connected: boolean] }>();
const inputCode = ref('');
const outputCode = ref('');
const step = ref<Step>('idle');
@@ -43,6 +43,15 @@ const incoming = ref<FileMetadata | null>(null);
const downloadUrl = ref('');
const downloadName = ref('');
const connected = ref(false);
const sendSection = ref<HTMLElement | null>(null);
const receiveSection = ref<HTMLElement | null>(null);
watch(connected, value => emit('connectedChange', value));
function focusDirection(direction: 'send' | 'receive') {
const section = direction === 'send' ? sendSection.value : receiveSection.value;
section?.focus({ preventScroll: true });
section?.scrollIntoView({ block: 'start', behavior: 'auto' });
}
defineExpose({ focusDirection });
const choosing = ref(false);
const dragover = ref(false);
@@ -324,7 +333,8 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); })
<template>
<div class="panel">
<template v-if="sending || connected">
<section v-if="sending || connected" ref="sendSection" class="transfer-section" tabindex="-1" aria-labelledby="send-heading">
<h2 id="send-heading" class="step">Send files</h2>
<label class="step" for="file-input">{{ connected ? 'Add files to send' : 'Choose files' }}</label>
<div class="dropzone" :class="{ dragover }" @dragover.prevent="dragover = true" @dragleave="dragover = false" @drop.prevent="dragover = false; pickFiles($event)">
<p>Choose or drop files. Each direction sends one file at a time; both people can send on this connection.</p>
@@ -334,7 +344,8 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); })
<ul v-if="!connected && selectedFiles.length"><li v-for="(item, index) in selectedFiles" :key="index">{{ item.name }} — {{ formatBytes(item.size) }}</li></ul>
<ul v-if="queuedFiles.length" aria-label="Files waiting to send"><li v-for="item in queuedFiles" :key="item.id">{{ item.file.name }} — {{ formatBytes(item.file.size) }} <button @click="removeQueued(item.id)" :aria-label="'Remove ' + item.file.name">Remove</button></li></ul>
<p v-if="outgoing" class="status">Sending: {{ outgoing.name }} — {{ stateLabel(sendState) }} ({{ progress }}%)</p>
</template>
<div v-if="outgoing" class="progress" role="progressbar" :aria-valuenow="progress" aria-valuemin="0" aria-valuemax="100" aria-label="Sending progress"><div :style="{ width: progress + '%' }"></div></div>
</section>
<NetworkSettings v-model="settings" :disabled="busy || connected" :managed-credentials="managedCredentials" />
<p class="status">Connection codes are not encrypted: they can reveal your IP address and connection details to anyone who sees them. Exchange them privately with your intended peer.</p>
<template v-if="!sending">
@@ -359,6 +370,9 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); })
<p class="status">Compare every byte over an authenticated channel an attacker cannot alter (for example, an in-person comparison). Your fingerprint must match their “Their fingerprint”, and vice versa. If either differs, cancel. Both people must confirm before the filename or contents are sent.</p>
<button class="primary" :disabled="verified || step === 'done'" @click="verify">{{ verified ? 'Fingerprints confirmed' : 'Both fingerprints match — confirm' }}</button>
</div>
<section v-if="connected || incoming || downloadUrl" ref="receiveSection" class="transfer-section" tabindex="-1" aria-labelledby="receive-heading">
<h2 id="receive-heading" class="step">Receive files</h2>
<p v-if="!incoming" class="status">Waiting for your peer to send a file. You can send files yourself using Send above.</p>
<div v-if="incoming && receiveState === 'choose-storage'" class="incoming">
<button :disabled="choosing" @click="declineFile">Decline file</button>
<p>{{ incoming.name }} — {{ formatBytes(incoming.size) }}</p>
@@ -370,8 +384,10 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); })
<p v-if="incoming.size > MEMORY_LIMIT && !canSaveToDisk && !canStreamDownload" class="error">This browser cannot save directly to disk. Use a browser with file-system saving support or send a smaller file.</p>
</div>
<p v-if="incoming && receiveState !== 'choose-storage'" class="status">Receiving: {{ incoming.name }} — {{ stateLabel(receiveState) }} ({{ receiveProgress }}%)</p>
<div v-if="outgoing" class="progress" role="progressbar" :aria-valuenow="progress" aria-valuemin="0" aria-valuemax="100" aria-label="Sending progress"><div :style="{ width: progress + '%' }"></div></div>
<div v-if="incoming" class="progress" role="progressbar" :aria-valuenow="receiveProgress" aria-valuemin="0" aria-valuemax="100" aria-label="Receiving progress"><div :style="{ width: receiveProgress + '%' }"></div></div>
<div v-if="downloadUrl" class="file-chip"><span>{{ downloadName }}</span><a class="download" :href="downloadUrl" :download="downloadName">Save file</a></div>
<p v-if="downloadUrl && receiveState === 'choose-storage'" class="status">Save the previous file before accepting this one. Accepting replaces its memory download.</p>
</section>
<p class="status" role="status">{{ status }}</p>
<p v-if="error" class="error" role="alert">{{ error }}</p>
<details v-if="diagnosticLines.length">
@@ -380,13 +396,11 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); })
<label class="step" for="connection-diagnostics">Diagnostic log (select and copy)</label>
<textarea id="connection-diagnostics" :value="diagnosticLines.join('\n')" readonly rows="12" @focus="selectCode" />
</details>
<div v-if="downloadUrl" class="file-chip"><span>{{ downloadName }}</span><a class="download" :href="downloadUrl" :download="downloadName">Save file</a></div>
<p v-if="downloadUrl && receiveState === 'choose-storage'" class="status">Save the previous file before accepting this one. Accepting replaces its memory download.</p>
<p v-if="!connected && step === 'done'" class="status">Connection ended. Exchange fresh codes to send more files.</p>
<p v-if="connected" class="status">Connection verified. Either person can add files. Keep both tabs open.</p>
<ul v-if="history.length" aria-label="Recent file results"><li v-for="(entry, index) in history" :key="index">{{ entry }}</li></ul>
<button v-if="connected || busy" @click="disconnect">Disconnect</button>
<button v-if="step !== 'idle'" @click="reset()">{{ busy ? 'Cancel connection' : 'Reset' }}</button>
<p class="status">Send/Receive chooses who starts the connection. Disconnect before changing this setup choice. You can switch to your messenger to copy and paste codes; keep this page open until receipt is confirmed.</p>
<p class="status">Before connecting, Send/Receive chooses who starts. Once connected, use either button to jump between sending and receiving without disconnecting. You can switch to your messenger to copy and paste codes; keep this page open until receipt is confirmed.</p>
</div>
</template>
+3
View File
@@ -291,3 +291,6 @@ p.stun-hint {
.fp-row code { overflow-wrap: anywhere; line-height: 1.7; font-size: 0.8rem; }
.file-chip span { overflow-wrap: anywhere; min-width: 0; }
.incoming { display: flex; flex-direction: column; gap: 0.7rem; overflow-wrap: anywhere; }
.transfer-section { display: flex; flex-direction: column; gap: 0.9rem; scroll-margin-top: 1rem; min-width: 0; }
.transfer-section:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 4px; }