Streamline the connections workspace
Rename and remove now live on each sidebar row instead of a header above the workspace. The pen swaps the row to an inline input (Enter or blur saves, Escape cancels and returns focus to the pen) and the remove control targets its own row without switching the open connection. The row shows a status dot with text; on mobile a bar beside Show connections shows the open connection and its status. The per-connection activity timeline and its saved transfer history are removed. Records from pre-release 0.0.5 builds lose their history field on first load. A removal dialog closes when another tab removes its connection, and focus moves to the next row after removing another one. The README is reorganized without repetition and corrects the TypeScript version; the 0.0.5 changelog now describes the net change since 0.0.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4323a8b774
commit
f320bfb541
11 files changed
+552
-650
No files matched your search
+62
-31
@@ -2,9 +2,8 @@
|
||||
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 InvitationDialog from './components/InvitationDialog.vue';
|
||||
import { addConnection, CONNECTION_LIMIT, emptyConnection, loadConnections, removeConnection, saveConnection, updateConnection, type ConnectionActivity, type ConnectionUpdate, type SavedConnection } from './lib/connections.ts';
|
||||
import { addConnection, CONNECTION_LIMIT, emptyConnection, loadConnections, removeConnection, saveConnection, updateConnection, type ConnectionUpdate, type SavedConnection } from './lib/connections.ts';
|
||||
import { takeFragment } from './lib/invitations.ts';
|
||||
import { asError } from './lib/validation.ts';
|
||||
|
||||
@@ -17,7 +16,10 @@ 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 confirmingRemoval = ref(false), removing = ref(false), removalId = ref('');
|
||||
const renamingId = ref(''), renameDraft = ref('');
|
||||
let renameContainer: HTMLElement | null = null;
|
||||
const removalTarget = computed(() => connections.value.find(item => item.id === removalId.value));
|
||||
const error = ref(''), removalError = ref('');
|
||||
const heading = ref<HTMLElement | null>(null);
|
||||
// An opened link awaiting review, and an accepted offer on its way to a slot.
|
||||
@@ -30,9 +32,30 @@ function select(id: string) {
|
||||
selected.value = id; confirmingRemoval.value = false; sidebarOpen.value = false;
|
||||
void nextTick(() => heading.value?.focus());
|
||||
}
|
||||
function startRename(item: SavedConnection, opener: HTMLButtonElement) {
|
||||
renameContainer = opener.closest<HTMLElement>('.connection-item');
|
||||
renamingId.value = item.id;
|
||||
renameDraft.value = item.name;
|
||||
void nextTick(() => { const input = document.querySelector<HTMLInputElement>('.connection-rename-input'); input?.focus(); input?.select(); });
|
||||
}
|
||||
function saveRename() {
|
||||
const id = renamingId.value;
|
||||
if (!id) return;
|
||||
renamingId.value = '';
|
||||
const name = renameDraft.value.trim();
|
||||
const item = connections.value.find(record => record.id === id);
|
||||
if (name && item && name !== item.name) update(id, { name });
|
||||
}
|
||||
function focusRenameAction() { void nextTick(() => renameContainer?.querySelector<HTMLButtonElement>('.edit-action')?.focus()); }
|
||||
function cancelRename() { renamingId.value = ''; focusRenameAction(); }
|
||||
function finishRename(event: KeyboardEvent) { (event.target as HTMLInputElement).blur(); focusRenameAction(); }
|
||||
function confirmRemove(id: string) { removalId.value = id; removalError.value = ''; confirmingRemoval.value = true; }
|
||||
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 === renamingId.value)) renamingId.value = '';
|
||||
// Close a removal prompt whose connection another tab already removed.
|
||||
if (!removing.value && !records.some(item => item.id === removalId.value)) confirmingRemoval.value = false;
|
||||
if (!records.some(item => item.id === selected.value)) select(records[0]!.id);
|
||||
}
|
||||
function setStatus(id: string, state: 'ready' | 'connecting' | 'connected') {
|
||||
@@ -50,7 +73,7 @@ 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.`;
|
||||
error.value = `${asError(err).message} Connections will only last for this tab.`;
|
||||
}
|
||||
selected.value = connections.value[0]!.id;
|
||||
if (typeof BroadcastChannel !== 'undefined') {
|
||||
@@ -99,13 +122,12 @@ function update(id: string, change: ConnectionUpdate) {
|
||||
if (pending === 1) applyRecords(records);
|
||||
updates?.postMessage('changed');
|
||||
} catch (err) {
|
||||
// Keep this tab's activity usable without pretending it reached storage.
|
||||
// Keep this tab usable without pretending the change 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 }); }
|
||||
// Connection setup re-reads the record so trust forgotten in another tab is
|
||||
// never reused from this tab's copy. A failed read stops setup.
|
||||
async function trust(id: string) {
|
||||
@@ -117,14 +139,21 @@ async function trust(id: string) {
|
||||
return record;
|
||||
}
|
||||
async function remove() {
|
||||
if (!current.value || removing.value || adding.value) return;
|
||||
const id = current.value.id;
|
||||
if (!removalTarget.value || removing.value || adding.value) return;
|
||||
const id = removalTarget.value.id, wasSelected = id === selected.value;
|
||||
const index = connections.value.findIndex(item => item.id === 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;
|
||||
await nextTick();
|
||||
// Focus the newly opened row, or the row that took the removed row's place.
|
||||
const row = wasSelected ? document.querySelector('.connection-item.selected') : document.querySelectorAll('.connection-item')[Math.min(index, connections.value.length - 1)];
|
||||
const link = row?.querySelector<HTMLButtonElement>('.connection-link');
|
||||
if (link?.offsetParent) link.focus();
|
||||
else heading.value?.focus();
|
||||
updates?.postMessage('changed');
|
||||
} catch (err) { removalError.value = asError(err).message; }
|
||||
finally { removing.value = false; if (refreshRequested) void refresh(); }
|
||||
@@ -141,12 +170,20 @@ async function remove() {
|
||||
</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>
|
||||
<div v-for="item in connections" :key="item.id" class="connection-item" :class="{ selected: selected === item.id }">
|
||||
<button v-if="renamingId !== item.id" class="connection-link" :aria-current="selected === item.id ? 'page' : undefined" @click="select(item.id)">
|
||||
<span class="connection-name">{{ item.name }}</span>
|
||||
<span class="connection-status-line"><span class="connection-dot" :class="states[item.id] || 'ready'" aria-hidden="true"></span><span class="connection-status">{{ statusLabel(item.id) }}</span></span>
|
||||
</button>
|
||||
<div v-else class="connection-edit">
|
||||
<input v-model="renameDraft" class="connection-rename-input" :aria-label="`New name for ${item.name}`" aria-describedby="rename-hint" maxlength="80" autocomplete="off" spellcheck="false"
|
||||
@blur="saveRename" @keydown.enter.prevent="finishRename" @keydown.esc.prevent="cancelRename" />
|
||||
<span class="connection-status-line"><span class="connection-dot" :class="states[item.id] || 'ready'" aria-hidden="true"></span><span class="connection-status">{{ statusLabel(item.id) }}</span></span>
|
||||
</div>
|
||||
<button v-if="renamingId !== item.id" class="connection-action edit-action" :aria-label="`Rename ${item.name}`" :title="`Rename ${item.name}`" :disabled="removing" @click="startRename(item, $event.currentTarget as HTMLButtonElement)"><span aria-hidden="true">✎</span></button>
|
||||
<button class="connection-action remove-action" :aria-label="`Remove ${item.name}`" :title="`Remove ${item.name}`" :disabled="adding || removing" @click="confirmRemove(item.id)"><span aria-hidden="true">✕</span></button>
|
||||
</div>
|
||||
<span id="rename-hint" class="sr-only">Press Enter or leave the field to save. Press Escape to cancel.</span>
|
||||
</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">
|
||||
@@ -156,7 +193,7 @@ async function remove() {
|
||||
<summary>About privacy & connections</summary>
|
||||
<p>Files travel over encrypted WebRTC data channels. Compare full fingerprints on first pairing, or let a connection authenticate its 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>
|
||||
<p>Clearing site data removes saved connections and identities.</p>
|
||||
</details>
|
||||
<a class="source-link" href="https://gitea.pagequit.net/Schluffe/HellCon" target="_blank" rel="noopener noreferrer" aria-label="View HellCon source code on Gitea">
|
||||
<img :src="giteaIconUrl" width="20" height="20" alt="" />
|
||||
@@ -165,34 +202,28 @@ async function remove() {
|
||||
</footer>
|
||||
</aside>
|
||||
<main id="main-content" class="main-pane" tabindex="-1">
|
||||
<header class="connection-header">
|
||||
<h1 v-if="current" ref="heading" class="sr-only" tabindex="-1">{{ current.name }}</h1>
|
||||
<div class="mobile-bar">
|
||||
<div v-if="current" class="mobile-current">
|
||||
<span class="mobile-current-name" aria-hidden="true">{{ current.name }}</span>
|
||||
<span class="connection-status-line"><span class="connection-dot" :class="states[current.id] || 'ready'" aria-hidden="true"></span><span class="mobile-current-status">{{ statusLabel(current.id) }}</span></span>
|
||||
</div>
|
||||
<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"><span class="header-action-icon" aria-hidden="true">✕</span> 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>
|
||||
<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" :load-trust="trust" :invitation="handoff?.connection === item.id ? handoff : null"
|
||||
@status="setStatus" @activity="record" @update="update" @invitation-taken="handoff = null" />
|
||||
@status="setStatus" @update="update" @invitation-taken="handoff = null" />
|
||||
</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 and remembered device. Saved files and your device identity are kept.</p>
|
||||
<AppDialog v-model="confirmingRemoval" :title="`Remove ${removalTarget?.name || 'connection'}?`" :busy="removing">
|
||||
<p>This ends its session and forgets its remembered device. Saved files and your device identity 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 }">
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { nextTick, ref, watch } from 'vue';
|
||||
import TransferPanel from './TransferPanel.vue';
|
||||
import type { SavedConnection, ConnectionActivity, ConnectionUpdate } from '../lib/connections.ts';
|
||||
import type { SavedConnection, ConnectionUpdate } from '../lib/connections.ts';
|
||||
const props = defineProps<{ connection: SavedConnection; loadTrust: (id: string) => Promise<SavedConnection>; invitation?: { code: string } | null }>();
|
||||
const emit = defineEmits<{
|
||||
status: [id: string, state: 'ready' | 'connecting' | 'connected'];
|
||||
activity: [id: string, item: ConnectionActivity];
|
||||
update: [id: string, change: ConnectionUpdate];
|
||||
invitationTaken: [];
|
||||
}>();
|
||||
@@ -28,48 +27,20 @@ watch(() => props.invitation, async invitation => {
|
||||
await nextTick();
|
||||
panel.value?.importCode(invitation.code);
|
||||
}, { immediate: true });
|
||||
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'" :connection="connection" :load-trust="() => loadTrust(connection.id)"
|
||||
@session-change="sessionActive = $event; status()" @connected-change="connected = $event; direction = mode; status()"
|
||||
@activity="emit('activity', connection.id, $event)" @update="emit('update', connection.id, $event)" />
|
||||
<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>
|
||||
<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 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'" :connection="connection" :load-trust="() => loadTrust(connection.id)"
|
||||
@session-change="sessionActive = $event; status()" @connected-change="connected = $event; direction = mode; status()"
|
||||
@update="emit('update', connection.id, $event)" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,24 +0,0 @@
|
||||
<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>
|
||||
@@ -13,7 +13,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, ConnectionUpdate, SavedConnection } from '../lib/connections.ts';
|
||||
import type { ConnectionUpdate, SavedConnection } from '../lib/connections.ts';
|
||||
|
||||
type Step = 'session-ready' | 'idle' | 'gathering' | 'offer-ready' | 'answer-ready' | TransferState;
|
||||
interface Session {
|
||||
@@ -48,7 +48,7 @@ const receiveState = ref<TransferState | null>(null);
|
||||
const outgoing = ref<FileMetadata | null>(null);
|
||||
const receiveProgress = ref(0);
|
||||
const lastDirection = ref<'send' | 'receive'>('send');
|
||||
const emit = defineEmits<{ sessionChange: [active: boolean]; connectedChange: [connected: boolean]; activity: [item: ConnectionActivity]; update: [change: ConnectionUpdate] }>();
|
||||
const emit = defineEmits<{ sessionChange: [active: boolean]; connectedChange: [connected: boolean]; update: [change: ConnectionUpdate] }>();
|
||||
const inputCode = ref('');
|
||||
const outputCode = ref('');
|
||||
const step = ref<Step>('idle');
|
||||
@@ -132,8 +132,8 @@ function saveDownload() {
|
||||
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'; }
|
||||
if (outgoing.value && sendState.value && !['done', 'closed'].includes(sendState.value)) sendState.value = 'closed';
|
||||
if (incoming.value && receiveState.value && !['done', 'closed'].includes(receiveState.value)) receiveState.value = 'closed';
|
||||
}
|
||||
active = null; connected.value = false; queuedFiles.value = []; emit('sessionChange', false);
|
||||
managedCredentials.value = null; settings.value.allowTurn = false;
|
||||
@@ -191,9 +191,6 @@ function pickFiles(event: Event) {
|
||||
if (event.target instanceof HTMLInputElement) event.target.value = '';
|
||||
}
|
||||
function removeQueued(id: number) { active?.transfer?.remove(id); }
|
||||
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';
|
||||
@@ -234,14 +231,12 @@ 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, meta, 'complete');
|
||||
void session.diagnostics.capture();
|
||||
if (blob) { revokeDownload(); downloadUrl.value = URL.createObjectURL(blob); downloadName.value = meta.name; saveDownload(); }
|
||||
},
|
||||
onDecline: (direction, meta) => {
|
||||
onDecline: direction => {
|
||||
if (active !== session) return;
|
||||
if (direction === 'send') sendState.value = null; else { receiveState.value = null; incoming.value = null; }
|
||||
remember(direction, meta, 'declined');
|
||||
if (lastDirection.value === direction) {
|
||||
const other = direction === 'send' ? receiveState.value : sendState.value;
|
||||
step.value = other && other !== 'done' ? other : 'session-ready';
|
||||
|
||||
+13
-29
@@ -1,15 +1,6 @@
|
||||
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;
|
||||
@@ -18,9 +9,8 @@ export interface SavedConnection {
|
||||
peerKey: string;
|
||||
// Per-connection opt-in to include this browser's identity in codes.
|
||||
rememberDevice: boolean;
|
||||
history: ConnectionActivity[];
|
||||
}
|
||||
export type ConnectionUpdate = { name: string } | { peerKey: string } | { rememberDevice: boolean } | { activity: ConnectionActivity };
|
||||
export type ConnectionUpdate = { name: string } | { peerKey: string } | { rememberDevice: boolean };
|
||||
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.');
|
||||
@@ -33,26 +23,15 @@ export function updateConnection(current: SavedConnection, update: ConnectionUpd
|
||||
return { ...current, peerKey: update.peerKey };
|
||||
}
|
||||
if ('rememberDevice' in update) return { ...current, rememberDevice: update.rememberDevice === true };
|
||||
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) };
|
||||
throw new Error('Invalid connection update.');
|
||||
}
|
||||
export function emptyConnection(number = 1): SavedConnection {
|
||||
return { id: crypto.randomUUID(), number, name: `Con ${number}`, peerKey: '', rememberDevice: false, history: [] };
|
||||
return { id: crypto.randomUUID(), number, name: `Con ${number}`, peerKey: '', rememberDevice: false };
|
||||
}
|
||||
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: '', rememberDevice: value.rememberDevice === true, 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;
|
||||
typeof value.name !== 'string' || typeof value.peerKey !== 'string') throw new Error('Saved connections are unreadable.');
|
||||
return updateConnection({ id: value.id, number: value.number as number, name: connectionName(value.name), peerKey: '', rememberDevice: value.rememberDevice === true }, { peerKey: value.peerKey });
|
||||
}
|
||||
async function database() {
|
||||
return new Promise<IDBDatabase>((resolve, reject) => {
|
||||
@@ -63,8 +42,8 @@ async function database() {
|
||||
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,
|
||||
// paired device, or history entry with a stale copy of the entire record.
|
||||
// Read and write within one transaction so other tabs cannot overwrite a rename
|
||||
// or paired device with a stale copy of the entire record.
|
||||
async function change(action: (records: SavedConnection[], store: IDBObjectStore) => void) {
|
||||
const db = await database();
|
||||
try {
|
||||
@@ -74,7 +53,12 @@ async function change(action: (records: SavedConnection[], store: IDBObjectStore
|
||||
const read = store.getAll();
|
||||
read.onsuccess = () => {
|
||||
try {
|
||||
records = read.result.map(validateConnection).sort((a, b) => a.number - b.number);
|
||||
records = read.result.map((raw: unknown) => {
|
||||
const record = validateConnection(raw);
|
||||
// Pre-release 0.0.5 builds saved filenames here. Remove them on the first load.
|
||||
if (isRecord(raw) && 'history' in raw) store.put(record);
|
||||
return record;
|
||||
}).sort((a, b) => a.number - b.number);
|
||||
action(records, store);
|
||||
} catch (error) { failure = error; tx.abort(); }
|
||||
};
|
||||
|
||||
+24
-60
@@ -279,16 +279,24 @@ p.stun-hint {
|
||||
.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 h2 { 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-item { position: relative; border: 1px solid transparent; border-radius: 9px; }
|
||||
.connection-item.selected { background: var(--accent-soft); border-color: #65472e; }
|
||||
.connection-link, .connection-edit { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 0.4rem; min-width: 0; width: 100%; min-height: 64px; padding: 0.55rem 4.2rem 0.55rem 0.7rem; }
|
||||
.connection-link { text-align: left; background: transparent; border: 0; border-radius: 8px; }
|
||||
.connection-link:hover:not(:disabled) { background: #ffffff08; }
|
||||
.connection-edit { padding-right: 2.4rem; }
|
||||
.connection-name { color: var(--text); font-size: 0.87rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.connection-status-line { display: flex; align-items: center; gap: 0.45rem; min-width: 0; color: var(--muted); font-size: 0.72rem; }
|
||||
.connection-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.connection-action { position: absolute; top: 0.45rem; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 0.9rem; }
|
||||
.connection-action:hover:not(:disabled), .connection-action:focus-visible { color: var(--accent); }
|
||||
.edit-action { right: 2.25rem; }
|
||||
.remove-action { right: 0.35rem; }
|
||||
.remove-action:hover:not(:disabled), .remove-action:focus-visible { color: #ff9185; }
|
||||
.connection-rename-input { width: 100%; min-width: 0; border: 1px solid var(--accent); border-radius: 6px; padding: 0.28rem 0.35rem; background: var(--bg); color: var(--text); font: inherit; font-size: 0.87rem; font-weight: 600; }
|
||||
.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); }
|
||||
@@ -306,19 +314,8 @@ 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 var(--space-xl); 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; }
|
||||
.header-action-icon { margin-right: 0.15rem; opacity: 0.65; }
|
||||
.header-action:hover:not(:disabled), .header-action:focus-visible { color: #ff9185; }
|
||||
.header-action:hover:not(:disabled) .header-action-icon, .header-action:focus-visible .header-action-icon { opacity: 1; }
|
||||
.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: var(--space-2xl) 2.25rem; }
|
||||
.connection-workspace { display: grid; grid-template-columns: minmax(0, 720px) minmax(240px, 320px); gap: var(--space-2xl); max-width: 1200px; margin-inline: auto; align-items: start; }
|
||||
.session-column { min-width: 0; }
|
||||
.connection-workspace { width: 100%; max-width: 720px; min-width: 0; margin-inline: auto; }
|
||||
.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; }
|
||||
@@ -338,32 +335,11 @@ input[type=file]::file-selector-button { border: 1px solid #505667; border-radiu
|
||||
.code-details > .code-entry { margin-top: var(--space-md); }
|
||||
.code-entry { display: flex; flex-direction: column; gap: var(--space-md); min-width: 0; }
|
||||
.code-entry > button { align-self: start; font-size: 0.88rem; }
|
||||
.activity-panel { min-width: 0; border-left: 1px solid var(--border); padding-left: var(--space-xl); }
|
||||
.activity-heading { display: flex; align-items: center; gap: var(--space-sm); }
|
||||
.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: var(--space-xl); }
|
||||
.activity-list { list-style: none; padding: 0; margin: var(--space-lg) 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; }
|
||||
.mobile-bar { 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: var(--space-2xl); }
|
||||
.activity-panel { border-left: 0; border-top: 1px solid var(--border); padding: var(--space-xl) 0 0; }
|
||||
.empty-activity { padding: var(--space-xl) 0; }
|
||||
.connection-header { padding-inline: var(--space-xl); }
|
||||
.workspace-scroll { padding: var(--space-xl); }
|
||||
}
|
||||
@media (max-width: 700px) {
|
||||
@@ -373,23 +349,14 @@ p.activity-note { font-size: 0.7rem; color: var(--muted); line-height: 1.6; }
|
||||
.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; }
|
||||
.mobile-bar { display: flex; align-items: center; gap: 0.75rem; margin: 0.75rem 1rem 0; }
|
||||
.mobile-current { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-width: 0; }
|
||||
.mobile-current-name { font-size: 0.95rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.mobile-current-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.sidebar-toggle { flex-shrink: 0; margin-left: auto; font-size: 0.8rem; background: transparent; padding: 0.5rem; }
|
||||
.workspace-scroll { padding: var(--space-lg) 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; }
|
||||
@@ -401,7 +368,4 @@ p.activity-note { font-size: 0.7rem; color: var(--muted); line-height: 1.6; }
|
||||
.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; }
|
||||
}
|
||||
@media (max-width: 700px) { .app-dialog { padding: 1.2rem; } }
|
||||
Reference in new issue
Block a user