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

+156 -42
View File
@@ -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 &amp; 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 &amp; 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>
+41
View File
@@ -0,0 +1,41 @@
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref, useId, watch } from 'vue';
const open = defineModel<boolean>({ default: false });
const props = defineProps<{ title: string; busy?: boolean }>();
const dialog = ref<HTMLDialogElement | null>(null);
const titleId = useId(), bodyId = useId();
function close() { if (!props.busy) open.value = false; }
function closed() { if (!dialog.value?.open) open.value = false; }
// showModal() makes the page inert but lets Tab leave for the browser UI; wrap instead.
function trap(event: KeyboardEvent) {
const items = [...dialog.value?.querySelectorAll<HTMLElement>('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])') ?? []]
.filter(item => !item.matches(':disabled') && item.offsetParent !== null);
const first = items[0], last = items.at(-1);
if (!first || !last) { event.preventDefault(); return; }
const active = document.activeElement;
if (event.shiftKey && (active === first || !dialog.value?.contains(active))) { event.preventDefault(); last.focus(); }
else if (!event.shiftKey && (active === last || !dialog.value?.contains(active))) { event.preventDefault(); first.focus(); }
}
function sync() {
if (open.value && !dialog.value?.open) dialog.value?.showModal();
else if (!open.value && dialog.value?.open) dialog.value.close();
}
watch(open, sync, { flush: 'post' });
onMounted(sync);
onBeforeUnmount(() => dialog.value?.close());
</script>
<template>
<Teleport to="body">
<dialog ref="dialog" class="app-dialog" :aria-labelledby="titleId" :aria-describedby="bodyId" :aria-busy="busy || undefined"
@cancel.prevent="close" @close="closed" @keydown.tab="trap">
<header class="dialog-header">
<h2 :id="titleId">{{ title }}</h2>
<button class="dialog-close" type="button" aria-label="Close dialog" :disabled="busy" @click="close"><span aria-hidden="true">×</span></button>
</header>
<div :id="bodyId" class="dialog-body"><slot :close="close" /></div>
<div v-if="$slots.actions" class="dialog-actions"><slot name="actions" :close="close" /></div>
</dialog>
</Teleport>
</template>
+64
View File
@@ -0,0 +1,64 @@
<script setup lang="ts">
import { ref } from 'vue';
import TransferPanel from './TransferPanel.vue';
import type { SavedConnection, ConnectionActivity } from '../lib/connections.ts';
const props = defineProps<{ connection: SavedConnection }>();
const emit = defineEmits<{
status: [id: string, state: 'ready' | 'connecting' | 'connected'];
activity: [id: string, item: ConnectionActivity];
paired: [id: string, key: string];
}>();
const mode = ref<'send' | 'receive'>('send');
const sessionActive = ref(false), connected = ref(false);
const direction = ref<'send' | 'receive'>('send');
const panel = ref<InstanceType<typeof TransferPanel> | null>(null);
function status() { emit('status', props.connection.id, connected.value ? 'connected' : sessionActive.value ? 'connecting' : 'ready'); }
function navigate(next: 'send' | 'receive') {
if (connected.value) { direction.value = next; panel.value?.focusDirection(next); }
else if (!sessionActive.value) mode.value = next;
}
function sizeLabel(size: number) {
if (size < 1024) return `${size} B`;
const index = Math.min(5, Math.floor(Math.log(size) / Math.log(1024)));
return `${(size / 1024 ** index).toFixed(1)} ${['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'][index]}`;
}
</script>
<template>
<div class="connection-workspace">
<div class="session-column">
<div class="workspace-intro">
<h2>{{ connected ? 'Share files' : 'Start a session' }}</h2>
<p>{{ connected ? 'Your connection is ready.' : 'Exchange connection codes with your peer to start sharing.' }} Each direction sends one file at a time; both people can send on this connection.</p>
</div>
<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 ref="panel" :key="mode" :sending="mode === 'send'" :preferred-device="connection.peerKey"
@session-change="sessionActive = $event; status()" @connected-change="connected = $event; direction = mode; status()"
@activity="emit('activity', connection.id, $event)" @paired="emit('paired', connection.id, $event)" />
</div>
<aside class="activity-panel" aria-labelledby="activity-heading">
<div class="activity-heading"><h2 id="activity-heading">Activity</h2><span>{{ connection.history.length }}</span></div>
<div v-if="!connection.history.length" class="empty-activity">
<span class="empty-activity-icon" aria-hidden="true">↔</span>
<h3>A fresh connection</h3>
<p>Files you share here will appear in this timeline.</p>
<p class="activity-note">History stays in this browser. File contents aren’t kept here.</p>
</div>
<ol v-else class="activity-list" aria-label="Recent file results">
<li v-for="item in [...connection.history].reverse()" :key="item.id" class="activity-item">
<span class="activity-icon" aria-hidden="true">{{ item.direction === 'send' ? '↗' : '↙' }}</span>
<div>
<p class="activity-filename">{{ item.name }}</p>
<p class="activity-meta">{{ item.direction === 'send' ? 'Outgoing' : 'Incoming' }} · {{ sizeLabel(item.size) }}</p>
<p class="activity-result">{{ item.result === 'complete' ? 'Transfer complete' : item.result === 'declined' ? 'Declined' : 'Interrupted' }}</p>
<time :datetime="new Date(item.time).toISOString()">{{ new Date(item.time).toLocaleString([], { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }) }}</time>
</div>
</li>
</ol>
<p v-if="connection.history.length" class="activity-note">Last 50 transfers · Saved in this browser</p>
</aside>
</div>
</template>
+32 -43
View File
@@ -1,50 +1,49 @@
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue';
import { clearIdentityStorage, createIdentity, loadIdentityState, saveIdentityState, exportBackup, importBackup, type IdentityState } from '../lib/identity.ts';
import { onActivated, onMounted, ref, shallowRef, watch } from 'vue';
import { clearIdentityStorage, createIdentity, loadIdentityState, saveIdentityState, type IdentityState } from '../lib/identity.ts';
import { asError } from '../lib/validation.ts';
const props = defineProps<{ disabled: boolean }>();
const props = defineProps<{ disabled: boolean; preferredDevice?: string }>();
const emit = defineEmits<{ change: [state: IdentityState, enabled: boolean, expected: string] }>();
const supported = (() => { try { return location.protocol !== 'file:' && isSecureContext && !!crypto.subtle && !!window.indexedDB; } catch { return false; } })();
const supported = (() => { try { return isSecureContext && !!crypto.subtle && !!window.indexedDB; } catch { return false; } })();
const state = shallowRef<IdentityState>({ identity: null, contacts: [] });
const enabled = ref(false), expected = ref(''), working = ref(false), loaded = ref(false);
const error = ref(''), password = ref(''), confirmReplace = ref(false);
const backupUrl = ref('');
onBeforeUnmount(() => { if (backupUrl.value) URL.revokeObjectURL(backupUrl.value); });
const error = ref(''), confirmDelete = ref(false);
watch([state, enabled, expected], () => emit('change', state.value, enabled.value, expected.value));
onMounted(async () => {
if (!supported) return;
try { state.value = await loadIdentityState(); loaded.value = true; }
try {
state.value = await loadIdentityState(); loaded.value = true;
if (props.preferredDevice && state.value.contacts.some(item => item.key === props.preferredDevice)) expected.value = props.preferredDevice;
}
catch (err) { error.value = asError(err).message; }
});
onActivated(async () => {
// Another slot may have changed the shared identity or contact list while
// this workspace was cached. Never interrupt an active session to refresh it.
if (!loaded.value || props.disabled) return;
try {
const next = await loadIdentityState();
if (props.disabled) return;
if (next.identity?.publicKey !== state.value.identity?.publicKey) enabled.value = false;
if (!next.contacts.some(item => item.key === expected.value)) expected.value = '';
if (!expected.value && props.preferredDevice && next.contacts.some(item => item.key === props.preferredDevice)) expected.value = props.preferredDevice;
if (next.revision !== state.value.revision) confirmDelete.value = false;
state.value = next;
} catch (err) { error.value = asError(err).message; }
});
async function store(next: IdentityState) {
state.value = await saveIdentityState(next, state.value.revision);
if (backupUrl.value) { URL.revokeObjectURL(backupUrl.value); backupUrl.value = ''; }
}
async function run(action: () => Promise<void>) {
if (props.disabled || working.value) return;
working.value = true; error.value = '';
try { await action(); } catch (err) { error.value = asError(err).message; }
finally { working.value = false; password.value = ''; }
finally { working.value = false; }
}
function recover() { void run(async () => { if (!confirmReplace.value) return; await clearIdentityStorage(); state.value = { identity: null, contacts: [] }; loaded.value = true; confirmReplace.value = false; }); }
function recover() { void run(async () => { if (!confirmDelete.value) return; await clearIdentityStorage(); state.value = { identity: null, contacts: [] }; loaded.value = true; confirmDelete.value = false; }); }
function create() { void run(async () => { await store({ identity: await createIdentity(), contacts: [] }); enabled.value = true; }); }
function remove(key: string) { void run(async () => { await store({ ...state.value, contacts: state.value.contacts.filter(item => item.key !== key) }); if (expected.value === key) expected.value = ''; }); }
function reset() { void run(async () => { if (!confirmReplace.value) return; await store({ identity: null, contacts: [] }); enabled.value = false; expected.value = ''; confirmReplace.value = false; }); }
function backup() { void run(async () => {
const data = await exportBackup(state.value, password.value);
if (backupUrl.value) URL.revokeObjectURL(backupUrl.value);
backupUrl.value = URL.createObjectURL(new Blob([data], { type: 'application/json' }));
}); }
function restore(event: Event) {
const input = event.target as HTMLInputElement, file = input.files?.[0]; input.value = '';
if (!file) return;
void run(async () => {
if (state.value.identity && !confirmReplace.value) throw new Error('Confirm replacement before restoring a backup.');
if (file.size > 100000) throw new Error('Backup is too large.');
const next = await importBackup(await file.text(), password.value);
await store(next); enabled.value = false; expected.value = ''; confirmReplace.value = false;
});
}
function reset() { void run(async () => { if (!confirmDelete.value) return; await store({ identity: null, contacts: [] }); enabled.value = false; expected.value = ''; confirmDelete.value = false; }); }
async function remember(key: string, name: string) {
if (!state.value.identity) throw new Error('Create a local identity first.');
const next = { ...state.value, contacts: [...state.value.contacts.filter(item => item.key !== key), { key, name }] };
@@ -59,10 +58,7 @@ async function refreshForConnection() {
enabled.value = false; expected.value = '';
}
if (!next.contacts.some(contact => contact.key === expected.value)) expected.value = '';
if (next.revision !== state.value.revision) {
if (backupUrl.value) URL.revokeObjectURL(backupUrl.value);
backupUrl.value = ''; confirmReplace.value = false; password.value = '';
}
if (next.revision !== state.value.revision) confirmDelete.value = false;
state.value = next; loaded.value = true; error.value = '';
return { identity: enabled.value ? next.identity : null, expected: expected.value };
} catch (err) {
@@ -76,7 +72,7 @@ defineExpose({ remember, refreshForConnection });
<template>
<details v-if="supported">
<summary>Remembered devices</summary>
<p class="status">Opt in to a device identity stored in this browser. Temporary connections remain available. Clearing site data loses your identity and contacts. Trusted app code is required: it can use and export this identity.</p>
<p class="status">Opt in to a device identity stored in this browser. Temporary connections remain available. Clearing site data loses your identity and contacts. Trusted app code is required: it can use this identity.</p>
<fieldset class="device-settings" :disabled="disabled || working || !loaded">
<button v-if="!state.identity" @click="create">Create device identity</button>
<template v-else>
@@ -89,19 +85,12 @@ defineExpose({ remember, refreshForConnection });
</select>
<ul aria-label="Remembered devices"><li v-for="contact in state.contacts" :key="contact.key">{{ contact.name }} <button @click="remove(contact.key)" :aria-label="'Forget ' + contact.name">Forget</button></li></ul>
</template>
<label for="backup-password">Backup password (at least 12 characters)</label>
<input id="backup-password" v-model="password" type="password" autocomplete="new-password" maxlength="1024" />
<button :disabled="!state.identity || password.length < 12" @click="backup">Create encrypted backup</button>
<a v-if="backupUrl" :href="backupUrl" download="hellcon-device-backup.json">Save encrypted backup</a>
<p class="status">A backup contains your identity and contacts. Keep its password separately. Restoring the same backup on another browser gives that browser the same identity.</p>
<label v-if="state.identity"><input v-model="confirmReplace" type="checkbox" /> Replace or delete this browser’s identity and contacts</label>
<label for="restore-identity">Restore encrypted backup</label>
<input id="restore-identity" type="file" accept="application/json,.json" :disabled="password.length < 12 || (!!state.identity && !confirmReplace)" @change="restore" />
<button v-if="state.identity" :disabled="!confirmReplace" @click="reset">Delete identity and contacts</button>
<label v-if="state.identity"><input v-model="confirmDelete" type="checkbox" /> Delete this browser’s identity and contacts</label>
<button v-if="state.identity" :disabled="!confirmDelete" @click="reset">Delete identity and contacts</button>
</fieldset>
<div v-if="!loaded && error">
<label><input v-model="confirmReplace" type="checkbox" :disabled="disabled || working" /> Delete unreadable device storage, including identity and contacts</label>
<button :disabled="disabled || working || !confirmReplace" @click="recover">Clear device storage</button>
<label><input v-model="confirmDelete" type="checkbox" :disabled="disabled || working" /> Delete unreadable device storage, including identity and contacts</label>
<button :disabled="disabled || working || !confirmDelete" @click="recover">Clear device storage</button>
</div>
<p v-if="error" role="alert" class="error">{{ error }}</p>
</details>
+24
View File
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { ref, watch } from 'vue';
const props = defineProps<{ name: string; disabled?: boolean }>();
const emit = defineEmits<{ rename: [name: string] }>();
const draft = ref(props.name), editing = ref(false);
watch(() => props.name, value => { if (!editing.value) draft.value = value; });
function save() {
editing.value = false;
const name = draft.value.trim();
draft.value = name || props.name;
if (name && name !== props.name) emit('rename', name);
}
function finish(event: KeyboardEvent) { (event.target as HTMLInputElement).blur(); }
</script>
<template>
<div class="editable-name">
<label class="sr-only" for="connection-name">Connection name</label>
<input id="connection-name" v-model="draft" :size="Math.max(5, Math.min(draft.length + 2, 24))" :disabled="disabled" maxlength="80" autocomplete="off" spellcheck="false"
aria-describedby="connection-name-hint" @focus="editing = true" @blur="save" @keydown.enter.prevent="finish" />
<span class="name-edit-icon" aria-hidden="true">✎</span>
<span id="connection-name-hint" class="sr-only">Edit the name. Changes save when you leave this field.</span>
</div>
</template>
+1 -1
View File
@@ -3,7 +3,7 @@ import type { IceOptions, NetworkSettings } from '../lib/webrtc.ts';
import { STUN_PROVIDERS } from '../lib/webrtc.ts';
const settings = defineModel<NetworkSettings>({ 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 || '';
</script>
<template>
+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>
+109
View File
@@ -0,0 +1,109 @@
import { isRecord } from './validation.ts';
export const CONNECTION_LIMIT = 100;
export const HISTORY_LIMIT = 50;
export interface ConnectionActivity {
id: string;
time: number;
direction: 'send' | 'receive';
name: string;
size: number;
result: 'complete' | 'declined' | 'interrupted';
}
export interface SavedConnection {
id: string;
number: number;
name: string;
peerKey: string;
history: ConnectionActivity[];
}
export type ConnectionUpdate = { name: string } | { peerKey: string } | { activity: ConnectionActivity };
export function connectionName(value: string) {
const name = value.trim();
if (!name || name.length > 80) throw new Error('Use a connection name between 1 and 80 characters.');
return name;
}
export function updateConnection(current: SavedConnection, update: ConnectionUpdate): SavedConnection {
if ('name' in update) return { ...current, name: connectionName(update.name) };
if ('peerKey' in update) {
if (update.peerKey && !/^04[0-9a-f]{128}$/.test(update.peerKey)) throw new Error('Invalid paired device.');
return { ...current, peerKey: update.peerKey };
}
const item = update.activity;
if (typeof item.id !== 'string' || !item.id || !Number.isSafeInteger(item.time) || item.time < 0 || item.time > 8640000000000000 ||
typeof item.name !== 'string' || !item.name || item.name.length > 255 ||
!Number.isSafeInteger(item.size) || item.size < 0 || !['send', 'receive'].includes(item.direction) ||
!['complete', 'declined', 'interrupted'].includes(item.result)) throw new Error('Invalid connection activity.');
return { ...current, history: [...current.history.filter(previous => previous.id !== item.id), item].sort((a, b) => a.time - b.time).slice(-HISTORY_LIMIT) };
}
export function emptyConnection(number = 1): SavedConnection {
return { id: crypto.randomUUID(), number, name: `Con ${number}`, peerKey: '', history: [] };
}
function validateConnection(value: unknown): SavedConnection {
if (!isRecord(value) || typeof value.id !== 'string' || !value.id || !Number.isSafeInteger(value.number) || (value.number as number) < 1 ||
typeof value.name !== 'string' || typeof value.peerKey !== 'string' || !Array.isArray(value.history) || value.history.length > HISTORY_LIMIT) throw new Error('Saved connections are unreadable.');
let record: SavedConnection = { id: value.id, number: value.number as number, name: connectionName(value.name), peerKey: '', history: [] };
record = updateConnection(record, { peerKey: value.peerKey });
for (const item of value.history) {
if (!isRecord(item)) throw new Error('Saved activity is unreadable.');
record = updateConnection(record, { activity: item as unknown as ConnectionActivity });
}
return record;
}
async function database() {
return new Promise<IDBDatabase>((resolve, reject) => {
const request = indexedDB.open('hellcon-connections', 1);
request.onupgradeneeded = () => request.result.createObjectStore('connections', { keyPath: 'id' });
request.onsuccess = () => { request.result.onversionchange = () => request.result.close(); resolve(request.result); };
request.onerror = () => reject(new Error('Connection storage is unavailable.'));
request.onblocked = () => reject(new Error('Close other HellCon tabs to open connection storage.'));
});
}
// Read and write within one transaction so other tabs cannot overwrite a rename,
// device association, or history entry with a stale copy of the entire record.
async function change(action: (records: SavedConnection[], store: IDBObjectStore) => void) {
const db = await database();
try {
return await new Promise<SavedConnection[]>((resolve, reject) => {
const tx = db.transaction('connections', 'readwrite'), store = tx.objectStore('connections');
let records: SavedConnection[] = [], failure: unknown;
const read = store.getAll();
read.onsuccess = () => {
try {
records = read.result.map(validateConnection).sort((a, b) => a.number - b.number);
action(records, store);
} catch (error) { failure = error; tx.abort(); }
};
tx.oncomplete = () => resolve(records);
tx.onabort = tx.onerror = () => reject(failure || new Error('Could not save connections.'));
});
} finally { db.close(); }
}
export function loadConnections() {
return change((records, store) => {
if (!records.length) { const first = emptyConnection(); store.add(first); records.push(first); }
});
}
export async function addConnection() {
const records = await change((records, store) => {
if (records.length >= CONNECTION_LIMIT) throw new Error(`Keep up to ${CONNECTION_LIMIT} connections.`);
const record = emptyConnection(Math.max(0, ...records.map(item => item.number)) + 1);
store.add(record); records.push(record);
});
return records;
}
export function saveConnection(id: string, update: ConnectionUpdate) {
return change((records, store) => {
const index = records.findIndex(item => item.id === id);
if (index < 0) throw new Error('This connection is no longer saved. Reload the page.');
const record = updateConnection(records[index]!, update);
store.put(record); records[index] = record;
});
}
export function removeConnection(id: string) {
return change((records, store) => {
const index = records.findIndex(item => item.id === id);
if (index >= 0) { store.delete(id); records.splice(index, 1); }
if (!records.length) { const first = emptyConnection(); store.add(first); records.push(first); }
});
}
+4 -33
View File
@@ -20,9 +20,9 @@ export function parseHello(value: unknown): IdentityHello {
return { key: value.key as string, nonce: value.nonce as string };
}
export async function createIdentity(): Promise<Identity> {
// Extractable for explicit password-encrypted backups. Stored as a CryptoKey,
// never plaintext JSON. Same-origin JavaScript can still use/export this key.
const pair = await crypto.subtle.generateKey(curve, true, ['sign', 'verify']);
// Store the private key as a non-extractable CryptoKey. Same-origin JavaScript
// can still use it to sign, so the app code must remain trusted.
const pair = await crypto.subtle.generateKey(curve, false, ['sign', 'verify']);
return { publicKey: hex(await crypto.subtle.exportKey('raw', pair.publicKey)), privateKey: pair.privateKey };
}
export function hello(identity: Identity): IdentityHello {
@@ -75,7 +75,7 @@ export async function loadIdentityState(): Promise<IdentityState> {
validateContacts(state.contacts);
if (state.identity) {
unhex(state.identity.publicKey, 65);
if (!(state.identity.privateKey instanceof CryptoKey) || state.identity.privateKey.type !== 'private') throw new Error('Stored identity is invalid. Reset it or restore a backup.');
if (!(state.identity.privateKey instanceof CryptoKey) || state.identity.privateKey.type !== 'private') throw new Error('Stored identity is invalid. Clear device storage and create a new identity.');
}
return state;
} finally { db.close(); }
@@ -110,32 +110,3 @@ export async function clearIdentityStorage() {
});
} finally { db.close(); }
}
const iterations = 600000;
async function backupKey(password: string, salt: Uint8Array<ArrayBuffer>) {
if (password.length < 12 || password.length > 1024) throw new Error('Use a backup password between 12 and 1024 characters.');
const material = await crypto.subtle.importKey('raw', bytes(password), 'PBKDF2', false, ['deriveKey']);
return crypto.subtle.deriveKey({ name: 'PBKDF2', hash: 'SHA-256', salt, iterations }, material, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt']);
}
export async function exportBackup(state: IdentityState, password: string) {
if (!state.identity) throw new Error('Create a device identity first.');
const salt = crypto.getRandomValues(new Uint8Array(16)), iv = crypto.getRandomValues(new Uint8Array(12));
const data = bytes(JSON.stringify({ key: await crypto.subtle.exportKey('jwk', state.identity.privateKey), publicKey: state.identity.publicKey, contacts: validateContacts(state.contacts) }));
const encrypted = await crypto.subtle.encrypt({ name: 'AES-GCM', iv, additionalData: bytes('HellCon backup v1') }, await backupKey(password, salt), data);
return JSON.stringify({ format: 'hellcon-identity', version: 1, iterations, salt: hex(salt), iv: hex(iv), data: hex(encrypted) });
}
export async function importBackup(text: string, password: string): Promise<IdentityState> {
if (text.length > 100000) throw new Error('Backup is too large.');
try {
const value: unknown = JSON.parse(text);
if (!isRecord(value) || value.format !== 'hellcon-identity' || value.version !== 1 || value.iterations !== iterations || typeof value.data !== 'string' || value.data.length < 32) throw new Error();
const decrypted = await crypto.subtle.decrypt({ name: 'AES-GCM', iv: unhex(value.iv, 12), additionalData: bytes('HellCon backup v1') }, await backupKey(password, unhex(value.salt, 16)), unhex(value.data, value.data.length / 2));
const payload: unknown = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(decrypted));
if (!isRecord(payload) || !isRecord(payload.key)) throw new Error();
const publicKey = payload.publicKey as string;
const pub = await crypto.subtle.importKey('raw', unhex(publicKey, 65), curve, false, ['verify']);
const privateKey = await crypto.subtle.importKey('jwk', payload.key, curve, true, ['sign']);
const challenge = crypto.getRandomValues(new Uint8Array(32));
if (!await crypto.subtle.verify(signing, pub, await crypto.subtle.sign(signing, privateKey, challenge), challenge)) throw new Error();
return { identity: { publicKey, privateKey }, contacts: validateContacts(payload.contacts) };
} catch { throw new Error('Could not restore backup. Check the password and backup file.'); }
}
+128 -40
View File
@@ -6,7 +6,7 @@
--accent: #ff9b3d;
--accent-soft: rgba(255, 155, 61, 0.15);
--text: #e8eaf0;
--muted: #8b91a3;
--muted: #a0a7b8;
}
* {
@@ -20,27 +20,14 @@ body {
font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}
#app {
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
padding-inline: 0.9rem;
}
main {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
#app { height: 100dvh; min-height: 420px; }
.skip-link {
position: absolute;
left: 0.9rem;
top: 0.5rem;
transform: translateY(-200%);
z-index: 1;
z-index: 10;
padding: 0.55rem 0.8rem;
border-radius: 8px;
background: var(--accent);
@@ -54,18 +41,17 @@ main {
.panel {
width: 100%;
max-width: 680px;
background: var(--panel);
border: 1px solid var(--border);
border-radius: 12px;
padding: 1.5rem;
padding: 1.25rem;
display: flex;
flex-direction: column;
gap: 0.9rem;
}
h1 {
margin: 2rem 0 0.25rem;
margin: 0;
font-family: ui-monospace, 'Cascadia Code', monospace;
}
@@ -75,18 +61,11 @@ h1 {
font-size: 0.9rem;
}
.app-download {
color: var(--accent);
margin: -0.5rem 0 1.5rem;
font-size: 0.9rem;
}
.tabs {
display: flex;
gap: 0.5rem;
margin-bottom: 1rem;
width: 100%;
max-width: 680px;
}
.tabs button {
@@ -236,20 +215,6 @@ a.download {
margin: 0.2rem 0 0;
}
footer {
max-width: 680px;
width: 100%;
margin: 1.5rem 0 2.5rem;
padding: 0 0.25rem;
color: var(--muted);
font-size: 0.78rem;
line-height: 1.55;
}
footer p {
margin: 0;
}
.stun-select,
.stun-input {
width: 100%;
@@ -297,3 +262,126 @@ p.stun-hint {
.device-settings { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; border: 1px solid var(--border); border-radius: 8px; }
.device-settings input:not([type=checkbox]), .device-settings select, #contact-name { box-sizing: border-box; max-width: 100%; padding: 0.6rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
/* The connection shell stays in place while each workspace scrolls. */
.app-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); height: 100%; }
.sidebar { display: flex; flex-direction: column; gap: 1.25rem; background: #13161e; border-right: 1px solid var(--border); padding: 1.6rem 1rem 1rem; min-height: 0; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 0.8rem; padding: 0 0.5rem 1.25rem; }
.brand img { object-fit: contain; }
.brand-name { display: block; font-family: ui-monospace, monospace; font-weight: 700; font-size: 1.45rem; letter-spacing: -0.05em; }
.brand p { font-size: 0.75rem; color: var(--muted); margin: 0.25rem 0 0; }
.sidebar-section-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 0.65rem; }
.sidebar-section-heading h2, .eyebrow { text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.12em; color: var(--muted); margin: 0; font-weight: 650; }
.sidebar-section-heading > span { font-size: 0.72rem; color: var(--muted); }
.connection-nav { display: flex; flex-direction: column; gap: 0.35rem; }
.connection-link { display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; padding: 0.75rem 0.6rem; border-radius: 9px; }
.connection-link.selected { background: var(--accent-soft); border-color: #65472e; }
.connection-avatar { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #252a36; font-size: 0.88rem; color: var(--muted); }
.selected .connection-avatar { color: var(--accent); background: #473022; }
.connection-label { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; flex: 1; }
.connection-name { font-size: 0.87rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-preview { font-size: 0.72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #7c8495; flex-shrink: 0; }
.connection-dot.connected { background: #69d6a4; }
.connection-dot.connecting { background: var(--accent); }
.add-connection { display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-size: 0.82rem; background: transparent; border-style: dashed; }
.add-connection > span { font-size: 1.1rem; }
.sidebar-footer { margin-top: auto; padding: 1.5rem 0.65rem 0.25rem; color: var(--muted); font-size: 0.72rem; line-height: 1.65; }
.sidebar-tag { font-weight: 600; color: var(--text); }
.sidebar-footer p { margin: 0.5rem 0 1rem; }
summary { cursor: pointer; color: var(--muted); font-size: 0.83rem; padding: 0.4rem 0; }
summary:hover { color: var(--text); }
summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.privacy-details summary { font-size: 0.72rem; }
.main-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.connection-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 80px; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); background: #141720; }
.connection-title { min-width: 0; flex: 1; }
.title-line { display: flex; align-items: center; gap: 1rem; margin-top: 0.4rem; }
.title-line h1 { margin: 0; font-size: 1.35rem; font-weight: 600; font-family: inherit; overflow-wrap: anywhere; }
.header-action { font-size: 0.72rem; padding: 0.3rem 0.5rem; color: var(--muted); background: transparent; border-color: transparent; }
.session-badge { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.74rem; white-space: nowrap; border: 1px solid var(--border); border-radius: 20px; padding: 0.45rem 0.7rem; }
.session-badge.connected { color: #8ddbb6; border-color: #315344; }
.workspace-scroll { flex: 1; overflow-y: auto; padding: 2rem 2.25rem; }
.connection-workspace { display: grid; grid-template-columns: minmax(0, 720px) minmax(240px, 320px); gap: 2rem; max-width: 1200px; margin-inline: auto; align-items: start; }
.session-column { min-width: 0; }
.workspace-intro { margin-bottom: 1.4rem; }
.workspace-intro h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.4rem; }
.workspace-intro p { font-size: 0.85rem; color: var(--muted); line-height: 1.6; margin: 0; }
.tabs { width: fit-content; padding: 4px; gap: 4px; background: #1b1f2a; border: 1px solid var(--border); border-radius: 10px; }
.tabs button { padding: 0.45rem 1.5rem; font-size: 0.85rem; border: none; background: transparent; }
.tabs button.active { background: #3e3025; color: #ffb575; }
.panel { box-shadow: 0 6px 28px #00000012; }
.panel > .status { line-height: 1.6; margin: 0.1rem 0; }
.panel > button { align-self: start; font-size: 0.88rem; }
.dropzone { padding: 1.35rem 1rem; background: #141720; border-color: #414858; }
.dropzone p { font-size: 0.85rem; line-height: 1.65; margin: 0 0 1rem; }
input[type=file] { max-width: 100%; font-size: 0.8rem; }
input[type=file]::file-selector-button { border: 1px solid #505667; border-radius: 6px; padding: 0.45rem 0.65rem; margin-right: 0.6rem; background: #242a36; color: var(--text); cursor: pointer; }
.network-details > fieldset { margin-top: 0.65rem; }
.activity-panel { min-width: 0; border-left: 1px solid var(--border); padding-left: 1.5rem; }
.activity-heading { display: flex; align-items: center; gap: 0.6rem; }
.activity-heading h2 { font-size: 0.9rem; font-weight: 600; margin: 0; }
.activity-heading > span { font-size: 0.68rem; color: var(--muted); border-radius: 5px; padding: 0.15rem 0.35rem; background: #242936; }
.empty-activity { padding: 3.5rem 0.25rem; text-align: center; }
.empty-activity-icon { font-size: 1.6rem; display: grid; place-items: center; margin: 0 auto 1rem; width: 54px; height: 54px; border-radius: 16px; border: 1px solid var(--border); color: var(--muted); }
.empty-activity h3 { font-size: 0.88rem; font-weight: 500; margin: 0 0 0.6rem; }
.empty-activity p { font-size: 0.8rem; line-height: 1.7; color: var(--muted); }
p.activity-note { font-size: 0.7rem; color: var(--muted); line-height: 1.6; }
.empty-activity .activity-note { margin-top: 1.5rem; }
.activity-list { list-style: none; padding: 0; margin: 1.25rem 0; }
.activity-item { display: flex; gap: 0.7rem; padding: 1rem 0; border-bottom: 1px solid var(--border); font-size: 0.78rem; }
.activity-item > div { min-width: 0; }
.activity-icon { color: var(--accent); padding-top: 0.1rem; font-size: 1rem; }
.activity-filename { margin: 0; overflow-wrap: anywhere; font-weight: 500; }
.activity-meta, .activity-result { color: var(--muted); margin: 0.4rem 0; font-size: 0.72rem; }
.activity-item time { font-size: 0.68rem; color: var(--muted); }
.storage-error { color: #ffb4a9; background: #422725; border: 1px solid #8e5147; border-radius: 8px; padding: 1rem; font-size: 0.85rem; line-height: 1.6; }
.sidebar-toggle { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 1150px) {
.app-shell { grid-template-columns: 230px minmax(0, 1fr); }
.connection-workspace { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
.activity-panel { border-left: 0; border-top: 1px solid var(--border); padding: 1.5rem 0 0; }
.empty-activity { padding: 1.5rem 0; }
.connection-header { padding-inline: 1.5rem; }
.workspace-scroll { padding: 1.5rem; }
}
@media (max-width: 700px) {
#app { height: auto; min-height: 100dvh; }
.app-shell { display: flex; flex-direction: column; min-height: 100dvh; }
.sidebar { display: none; border-right: 0; border-bottom: 1px solid var(--border); max-height: 60dvh; }
.sidebar-open .sidebar { display: flex; }
.brand { padding-bottom: 0; }
.sidebar-footer { padding-top: 0; }
.connection-header { flex-wrap: wrap; padding: 1rem; min-height: 0; gap: 0.75rem; }
.sidebar-toggle { display: block; flex-basis: 100%; font-size: 0.8rem; text-align: left; background: transparent; padding: 0.5rem; }
.workspace-scroll { padding: 1.25rem 1rem; overflow: visible; }
.title-line { gap: 0.4rem; }
.title-line h1 { font-size: 1.15rem; }
.panel { padding: 1rem; }
.session-badge { font-size: 0.65rem; padding: 0.35rem 0.5rem; }
}
.title-line { flex-wrap: wrap; column-gap: 0.6rem; }
.editable-name { display: inline-flex; position: relative; max-width: min(100%, 26rem); min-width: 0; }
.editable-name input { width: 100%; min-width: 0; max-width: 100%; border: 1px solid transparent; border-radius: 7px; padding: 0.12rem 1.65rem 0.12rem 0.4rem; margin-left: -0.4rem; font: inherit; font-size: 1.35rem; font-weight: 600; color: var(--text); background: #ffffff03; text-overflow: ellipsis; transition: border-color 120ms, background 120ms; }
.editable-name input:hover { border-color: var(--border); background: #ffffff06; }
.editable-name input:focus { border-color: var(--accent); outline: none; background: var(--bg); }
.name-edit-icon { position: absolute; right: 0.65rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.9rem; pointer-events: none; opacity: 0.65; }
.editable-name:focus-within .name-edit-icon { color: var(--accent); opacity: 1; }
.app-dialog { width: min(460px, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); margin: auto; padding: 1.5rem; border: 1px solid #414858; border-radius: 14px; color: var(--text); background: var(--panel); box-shadow: 0 24px 100px #0009; overflow-y: auto; }
.app-dialog::backdrop { background: #080b12b8; backdrop-filter: blur(4px); }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.dialog-header h2 { margin: 0; font-size: 1.15rem; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.dialog-close { flex-shrink: 0; border-color: transparent; background: transparent; color: var(--muted); padding: 0 0.4rem; font-size: 1.4rem; line-height: 1.2; }
.dialog-body { color: var(--muted); font-size: 0.88rem; line-height: 1.7; margin-block: 1rem 1.5rem; }
.dialog-body p { margin: 0.75rem 0; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; }
.dialog-actions button { font-size: 0.85rem; }
button.danger { border-color: #b84d42; background: #672f2b; color: #ffe3df; }
button.danger:hover:not(:disabled) { border-color: #ff9185; background: #813b34; }
@media (max-width: 700px) {
.editable-name input { font-size: 1.15rem; }
.app-dialog { padding: 1.2rem; }
}