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:
1 parent
58c3e2af86
commit
5f8c6a1916
21 files changed
+879
-306
No files matched your search
+156
-42
@@ -1,50 +1,164 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import TransferPanel from './components/TransferPanel.vue';
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import ConnectionWorkspace from './components/ConnectionWorkspace.vue';
|
||||
import AppDialog from './components/AppDialog.vue';
|
||||
import EditableName from './components/EditableName.vue';
|
||||
import { addConnection, CONNECTION_LIMIT, emptyConnection, loadConnections, removeConnection, saveConnection, updateConnection, type ConnectionActivity, type ConnectionUpdate, type SavedConnection } from './lib/connections.ts';
|
||||
import { asError } from './lib/validation.ts';
|
||||
|
||||
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 logoUrl = `${import.meta.env.BASE_URL}HellNet_alt.png`;
|
||||
const connections = ref<SavedConnection[]>([]), selected = ref('');
|
||||
const states = ref<Record<string, 'ready' | 'connecting' | 'connected'>>({});
|
||||
const current = computed(() => connections.value.find(item => item.id === selected.value));
|
||||
const sidebarOpen = ref(false), adding = ref(false);
|
||||
const confirmingRemoval = ref(false), removing = ref(false);
|
||||
const error = ref(''), removalError = ref('');
|
||||
const heading = ref<HTMLElement | null>(null);
|
||||
let persistent = true, pending = 0, writes = Promise.resolve(), refreshRequested = false;
|
||||
let updates: BroadcastChannel | undefined;
|
||||
function select(id: string) {
|
||||
selected.value = id; confirmingRemoval.value = false; sidebarOpen.value = false;
|
||||
void nextTick(() => heading.value?.focus());
|
||||
}
|
||||
function applyRecords(records: SavedConnection[]) {
|
||||
connections.value = records;
|
||||
for (const id of Object.keys(states.value)) if (!records.some(item => item.id === id)) delete states.value[id];
|
||||
if (!records.some(item => item.id === selected.value)) select(records[0]!.id);
|
||||
}
|
||||
function setStatus(id: string, state: 'ready' | 'connecting' | 'connected') {
|
||||
if (connections.value.some(item => item.id === id)) states.value[id] = state;
|
||||
}
|
||||
function statusLabel(id: string) { return states.value[id] === 'connected' ? 'Connected' : states.value[id] === 'connecting' ? 'Connecting' : 'Ready to connect'; }
|
||||
async function refresh() {
|
||||
if (!persistent) return;
|
||||
if (pending || removing.value) { refreshRequested = true; return; }
|
||||
refreshRequested = false;
|
||||
try { const records = await loadConnections(); if (!pending && !removing.value) applyRecords(records); else refreshRequested = true; }
|
||||
catch (err) { error.value = asError(err).message; }
|
||||
}
|
||||
onMounted(async () => {
|
||||
try { connections.value = await loadConnections(); }
|
||||
catch (err) {
|
||||
persistent = false; connections.value = [emptyConnection()];
|
||||
error.value = `${asError(err).message} Connections and activity will only last for this tab.`;
|
||||
}
|
||||
selected.value = connections.value[0]!.id;
|
||||
if (typeof BroadcastChannel !== 'undefined') {
|
||||
updates = new BroadcastChannel('hellcon-connections');
|
||||
updates.onmessage = () => { void refresh(); };
|
||||
}
|
||||
window.addEventListener('focus', refresh);
|
||||
});
|
||||
onBeforeUnmount(() => { updates?.close(); window.removeEventListener('focus', refresh); });
|
||||
async function add() {
|
||||
if (adding.value || removing.value || connections.value.length >= CONNECTION_LIMIT) return;
|
||||
adding.value = true;
|
||||
try {
|
||||
await writes;
|
||||
if (persistent) connections.value = await addConnection();
|
||||
else connections.value.push(emptyConnection(Math.max(...connections.value.map(item => item.number)) + 1));
|
||||
select(connections.value.at(-1)!.id); updates?.postMessage('changed');
|
||||
} catch (err) { error.value = asError(err).message; }
|
||||
finally { adding.value = false; }
|
||||
}
|
||||
function update(id: string, change: ConnectionUpdate) {
|
||||
const index = connections.value.findIndex(item => item.id === id);
|
||||
if (index < 0) return;
|
||||
try { connections.value[index] = updateConnection(connections.value[index]!, change); }
|
||||
catch (err) { error.value = asError(err).message; return; }
|
||||
if (!persistent) return;
|
||||
pending++;
|
||||
writes = writes.then(async () => {
|
||||
try {
|
||||
const records = await saveConnection(id, change);
|
||||
if (pending === 1) applyRecords(records);
|
||||
updates?.postMessage('changed');
|
||||
} catch (err) {
|
||||
// Keep this tab's activity usable without pretending it reached storage.
|
||||
error.value = `${asError(err).message} Your latest changes may be lost when this tab closes.`;
|
||||
refreshRequested = true;
|
||||
} finally { pending--; if (!pending && refreshRequested) void refresh(); }
|
||||
});
|
||||
}
|
||||
function record(id: string, activity: ConnectionActivity) { update(id, { activity }); }
|
||||
function pair(id: string, peerKey: string) { update(id, { peerKey }); }
|
||||
async function remove() {
|
||||
if (!current.value || removing.value || adding.value) return;
|
||||
const id = current.value.id;
|
||||
removing.value = true; removalError.value = '';
|
||||
try {
|
||||
await writes;
|
||||
const records = persistent ? await removeConnection(id) : connections.value.filter(item => item.id !== id);
|
||||
applyRecords(records.length ? records : [emptyConnection()]);
|
||||
confirmingRemoval.value = false;
|
||||
updates?.postMessage('changed');
|
||||
} catch (err) { removalError.value = asError(err).message; }
|
||||
finally { removing.value = false; if (refreshRequested) void refresh(); }
|
||||
}
|
||||
const isLocal = location.protocol === 'file:';
|
||||
const canDownloadApp = import.meta.env.PROD && !isLocal;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a class="skip-link" href="#main-content">Skip to main content</a>
|
||||
<main id="main-content" tabindex="-1">
|
||||
<h1>HellCon</h1>
|
||||
<p class="subtitle">
|
||||
Browser-to-browser file sharing. No account or file-hosting backend.
|
||||
Direct WebRTC connections, with an optional relay you explicitly enable.
|
||||
</p>
|
||||
<a v-if="canDownloadApp" class="app-download" href="./hellcon-local.html" download="HellCon.html">Download app for local use</a>
|
||||
|
||||
<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 & receive to disk”.</p>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
<p>
|
||||
Files travel over encrypted WebRTC data channels (SCTP over DTLS).
|
||||
Compare both full fingerprints on first pairing, or authenticate an expected remembered device. This requires trusted
|
||||
browsers, a trusted copy of this app, and an authenticated comparison
|
||||
channel. The website host supplies JavaScript that can read your selected
|
||||
file; HTTPS protects delivery but cannot protect you from a malicious host.
|
||||
A TURN relay is used only after opt-in and carries encrypted traffic.
|
||||
</p>
|
||||
</footer>
|
||||
<div class="app-shell" :class="{ 'sidebar-open': sidebarOpen }">
|
||||
<aside id="connections-sidebar" class="sidebar" aria-label="Connections sidebar">
|
||||
<header class="brand">
|
||||
<img :src="logoUrl" width="38" height="38" alt="" />
|
||||
<div><span class="brand-name">HellCon</span><p>Direct file sharing</p></div>
|
||||
</header>
|
||||
<div class="sidebar-section-heading"><h2>Connections</h2><span>{{ connections.length }}</span></div>
|
||||
<nav class="connection-nav" aria-label="Connections">
|
||||
<button v-for="item in connections" :key="item.id" class="connection-link" :class="{ selected: selected === item.id }"
|
||||
:aria-current="selected === item.id ? 'page' : undefined" @click="select(item.id)">
|
||||
<span class="connection-avatar" aria-hidden="true">{{ item.name.slice(0, 1).toUpperCase() }}</span>
|
||||
<span class="connection-label"><span class="connection-name">{{ item.name }}</span><span class="connection-preview">{{ item.history.at(-1)?.name || (item.peerKey ? 'Remembered device' : 'No activity yet') }}</span></span>
|
||||
<span class="connection-dot" :class="states[item.id] || 'ready'" :aria-label="statusLabel(item.id)"></span>
|
||||
</button>
|
||||
</nav>
|
||||
<button class="add-connection" :disabled="adding || removing || !connections.length || connections.length >= CONNECTION_LIMIT" @click="add"><span aria-hidden="true">+</span> Add connection</button>
|
||||
<footer class="sidebar-footer">
|
||||
<span class="sidebar-tag">Browser to browser</span>
|
||||
<p>No accounts. Your connections stay on this device.</p>
|
||||
<details class="privacy-details">
|
||||
<summary>About privacy & connections</summary>
|
||||
<p>Files travel over encrypted WebRTC data channels. Compare full fingerprints on first pairing, or authenticate a remembered device. Reconnect by exchanging fresh codes.</p>
|
||||
<p>Trust your browser and the app’s host: its code can read selected files and use your device identity. HTTPS protects delivery. A TURN relay is used only after opt-in.</p>
|
||||
<p>Clearing site data removes saved connections, identities, and history.</p>
|
||||
</details>
|
||||
</footer>
|
||||
</aside>
|
||||
<main id="main-content" class="main-pane" tabindex="-1">
|
||||
<header class="connection-header">
|
||||
<button class="sidebar-toggle" :aria-expanded="sidebarOpen" aria-controls="connections-sidebar" @click="sidebarOpen = !sidebarOpen">{{ sidebarOpen ? 'Hide connections' : 'Show connections' }}</button>
|
||||
<template v-if="current">
|
||||
<div class="connection-title">
|
||||
<p class="eyebrow">Connection</p>
|
||||
<div class="title-line">
|
||||
<h1 ref="heading" class="sr-only" tabindex="-1">{{ current.name }}</h1>
|
||||
<EditableName :key="current.id" :name="current.name" :disabled="removing" @rename="update(current!.id, { name: $event })" />
|
||||
<button class="header-action" :disabled="adding || removing" @click="removalError = ''; confirmingRemoval = true">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
<span class="session-badge" :class="states[current.id] || 'ready'"><span class="connection-dot" :class="states[current.id] || 'ready'" aria-hidden="true"></span>{{ statusLabel(current.id) }}</span>
|
||||
</template>
|
||||
</header>
|
||||
<div class="workspace-scroll">
|
||||
<p v-if="error" class="storage-error" role="alert">{{ error }}</p>
|
||||
<template v-for="item in connections" :key="item.id">
|
||||
<KeepAlive>
|
||||
<ConnectionWorkspace v-if="selected === item.id" :connection="item" @status="setStatus" @activity="record" @paired="pair" />
|
||||
</KeepAlive>
|
||||
</template>
|
||||
<p v-if="!current" class="status">Opening your connections…</p>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
<AppDialog v-model="confirmingRemoval" :title="`Remove ${current?.name || 'connection'}?`" :busy="removing">
|
||||
<p>This ends its session and deletes its saved activity. Saved files and device identities are kept.</p>
|
||||
<p v-if="connections.length === 1">A fresh Con 1 will replace your last connection.</p>
|
||||
<p v-if="removalError" class="error" role="alert">{{ removalError }}</p>
|
||||
<template #actions="{ close }">
|
||||
<button :disabled="removing" autofocus @click="close">Keep connection</button>
|
||||
<button class="danger" :disabled="removing" @click="remove">{{ removing ? 'Removing…' : 'Remove connection' }}</button>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</template>
|
||||
Reference in new issue
Block a user