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

+24 -15
View File
@@ -11,6 +11,7 @@ import { MEMORY_LIMIT, validateMetadata } from '../lib/transfer.ts';
import { FileSession, QUEUE_LIMIT, type QueueItem } from '../lib/session.ts';
import { ConnectionDiagnostics } from '../lib/connection-diagnostics.ts';
import { createDownloadDestination, supportsStreamingDownload } from '../lib/download.ts';
import type { ConnectionActivity } from '../lib/connections.ts';
type Step = 'session-ready' | 'idle' | 'gathering' | 'offer-ready' | 'answer-ready' | TransferState;
interface Session {
@@ -27,7 +28,7 @@ interface Session {
timer?: ReturnType<typeof setTimeout>;
}
const props = defineProps<{ sending?: boolean }>();
const props = defineProps<{ sending?: boolean; preferredDevice?: string }>();
const devices = ref<InstanceType<typeof DeviceSettings> | null>(null);
const deviceState = shallowRef<IdentityState>({ identity: null, contacts: [] });
const identityStatus = ref(''), contactName = ref('');
@@ -37,7 +38,7 @@ async function saveContact() {
const session = active;
if (!session?.remoteHello || !connected.value || !canRemember.value || savingContact.value) return;
savingContact.value = true;
try { await devices.value?.remember(session.remoteHello.key, contactName.value.trim()); canRemember.value = false; contactName.value = ''; }
try { await devices.value?.remember(session.remoteHello.key, contactName.value.trim()); emit('paired', session.remoteHello.key); canRemember.value = false; contactName.value = ''; }
catch (err) { error.value = asError(err).message; }
finally { savingContact.value = false; }
}
@@ -49,8 +50,7 @@ const receiveState = ref<TransferState | null>(null);
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]; connectedChange: [connected: boolean] }>();
const emit = defineEmits<{ sessionChange: [active: boolean]; connectedChange: [connected: boolean]; activity: [item: ConnectionActivity]; paired: [key: string] }>();
const inputCode = ref('');
const outputCode = ref('');
const step = ref<Step>('idle');
@@ -77,8 +77,8 @@ const choosing = ref(false);
const dragover = ref(false);
const diagnosticLines = ref<string[]>([]);
let latestDiagnostics: ConnectionDiagnostics | null = null;
const iceEndpoint = location.protocol === 'file:' ? '' : import.meta.env.VITE_ICE_ENDPOINT || '';
const defaultStun = location.protocol === 'file:' ? '' : import.meta.env.VITE_STUN_URL || '';
const iceEndpoint = import.meta.env.VITE_ICE_ENDPOINT || '';
const defaultStun = import.meta.env.VITE_STUN_URL || '';
const settings = ref<NetworkSettingsModel>({ stunChoice: defaultStun ? 'custom' : 'pagequit', customStun: defaultStun, allowTurn: false, managedTurn: !!iceEndpoint, turnUrl: '', username: '', credential: '' });
const managedCredentials = ref<IceOptions | null>(null);
const canSaveToDisk = typeof window.showSaveFilePicker === 'function';
@@ -110,6 +110,10 @@ function revokeDownload() {
}
function dispose() {
const old = active;
if (old) {
if (outgoing.value && sendState.value && !['done', 'closed'].includes(sendState.value)) { remember('send', outgoing.value, 'interrupted'); sendState.value = 'closed'; }
if (incoming.value && receiveState.value && !['done', 'closed'].includes(receiveState.value)) { remember('receive', incoming.value, 'interrupted'); receiveState.value = 'closed'; }
}
active = null; connected.value = false; queuedFiles.value = []; emit('sessionChange', false);
managedCredentials.value = null; settings.value.allowTurn = false;
if (!old) return;
@@ -133,7 +137,7 @@ function reset(keepNetwork = false) {
fps.value = incoming.value = null;
verified.value = copied.value = choosing.value = false;
progress.value = 0; receiveProgress.value = 0; step.value = 'idle'; streamedDownload.value = false;
sendState.value = receiveState.value = null; outgoing.value = null; history.value = [];
sendState.value = receiveState.value = null; outgoing.value = null;
}
function fail(session: Session, err: unknown) {
if (active !== session) return;
@@ -165,7 +169,9 @@ function pickFiles(event: Event) {
if (event.target instanceof HTMLInputElement) event.target.value = '';
}
function removeQueued(id: number) { active?.transfer?.remove(id); }
function remember(message: string) { history.value = [...history.value.slice(-49), message]; }
function remember(direction: ConnectionActivity['direction'], meta: FileMetadata, result: ConnectionActivity['result']) {
emit('activity', { id: crypto.randomUUID(), time: Date.now(), direction, name: meta.name, size: meta.size, result });
}
function disconnect() {
dispose(); step.value = 'closed';
if (sendState.value && sendState.value !== 'done') sendState.value = 'closed';
@@ -184,6 +190,7 @@ function attach(session: Session, channel: RTCDataChannel) {
if (session.identityContext) {
identityStatus.value = session.expected === session.remoteHello?.key ? 'Remembered device authenticated for this connection.' : 'Device proof checked. You can remember this manually verified device.';
canRemember.value = !deviceState.value.contacts.some(contact => contact.key === session.remoteHello?.key);
if (!canRemember.value && session.remoteHello && (!props.preferredDevice || props.preferredDevice === session.remoteHello.key)) emit('paired', session.remoteHello.key);
}
} },
onQueue: items => { if (active === session) queuedFiles.value = items; },
@@ -203,14 +210,14 @@ function attach(session: Session, channel: RTCDataChannel) {
onComplete: (direction, { blob, meta }) => {
if (active !== session) return;
if (direction === 'send') progress.value = 100; else receiveProgress.value = 100;
remember(`${direction === 'send' ? 'Sent' : 'Received'}: ${meta.name}`);
remember(direction, meta, 'complete');
void session.diagnostics.capture();
if (blob) { revokeDownload(); downloadUrl.value = URL.createObjectURL(blob); downloadName.value = meta.name; }
},
onDecline: (direction, meta) => {
if (active !== session) return;
if (direction === 'send') sendState.value = null; else { receiveState.value = null; incoming.value = null; }
remember(`Declined: ${meta.name}`);
remember(direction, meta, 'declined');
if (lastDirection.value === direction) {
const other = direction === 'send' ? receiveState.value : sendState.value;
step.value = other && other !== 'done' ? other : 'session-ready';
@@ -402,7 +409,7 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); })
<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>
<p>Choose or drop files.</p>
<input id="file-input" type="file" multiple @change="pickFiles" />
</div>
<p v-if="!connected && selectedFiles.length" class="status">{{ selectedFiles.length }} file(s) selected</p>
@@ -411,9 +418,12 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); })
<p v-if="outgoing" class="status">Sending: {{ outgoing.name }} — {{ stateLabel(sendState) }} ({{ progress }}%)</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>
</section>
<DeviceSettings ref="devices" :disabled="busy || connected || savingContact" @change="deviceChange" />
<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>
<DeviceSettings ref="devices" :preferred-device="preferredDevice" :disabled="busy || connected || savingContact" @change="deviceChange" />
<details class="network-details">
<summary>Network settings</summary>
<NetworkSettings v-model="settings" :disabled="busy || connected" :managed-credentials="managedCredentials" />
</details>
<p v-if="!connected" class="status">Exchange codes privately. They contain your IP address and connection details.</p>
<template v-if="!sending">
<label class="step" for="offer-input">Paste the sender’s connection code</label>
<textarea id="offer-input" v-model="inputCode" :maxlength="MAX_SIGNAL_LENGTH" :disabled="busy" />
@@ -470,7 +480,6 @@ onBeforeUnmount(() => { dispose(); revokeDownload(); clearTimeout(copyTimer); })
</details>
<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">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>