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 }">
|
||||
|
||||
Reference in new issue
Block a user