From 29fb02ae0ecb7c387afb9c464be33aa98b9a9fdd Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 04:03:44 +0000 Subject: [PATCH] Make the InfoNet UI less hostile without changing its security - Turn raw backend codes (wormhole_required_for_*, control_plane_request_failed:403, gate_mls_compose_failed, ...) into sentences that say what to do next, via one shared helper used by gate rooms, key sharing, the Wormhole panel and mail. - Fix contradictory privacy copy: the gates card said everything was end-to-end encrypted while the advisory beside it said nothing was encrypted. Both now describe what the code does: encrypted content, visible metadata, unaudited. - Show a running timer while Tor connects instead of a static "obfuscated lane starting", and say up front that the first start can take up to a minute. - Replace the TOFU jargon on first contact with what to do and why. - New installs no longer get the changelog stacked on top of setup. - Keep the expanded chat panel above the map status bar, which was covering the terminal input. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UeX9wuqeVAQNr22zQHWj2H --- .../src/__tests__/mesh/friendlyError.test.ts | 38 ++++++ .../mesh/infonetShellGateDirectory.test.tsx | 2 +- frontend/src/app/page.tsx | 12 +- frontend/src/components/ChangelogModal.tsx | 9 ++ .../InfonetTerminal/GateKeySharingPanel.tsx | 5 +- .../components/InfonetTerminal/GateView.tsx | 15 +-- .../InfonetTerminal/InfonetShell.tsx | 2 +- .../InfonetTerminal/MessagesView.tsx | 17 +-- .../InfonetTerminal/TrendingPosts.tsx | 4 +- .../MeshChat/InfonetTerminalPanel.tsx | 35 ++++-- frontend/src/mesh/friendlyError.ts | 108 ++++++++++++++++++ 11 files changed, 213 insertions(+), 34 deletions(-) create mode 100644 frontend/src/__tests__/mesh/friendlyError.test.ts create mode 100644 frontend/src/mesh/friendlyError.ts diff --git a/frontend/src/__tests__/mesh/friendlyError.test.ts b/frontend/src/__tests__/mesh/friendlyError.test.ts new file mode 100644 index 00000000..1a434c4a --- /dev/null +++ b/frontend/src/__tests__/mesh/friendlyError.test.ts @@ -0,0 +1,38 @@ +import { describe, expect, it } from 'vitest'; + +import { friendlyInfonetError } from '@/mesh/friendlyError'; + +describe('friendlyInfonetError', () => { + it('maps transport and wormhole codes to a warmup message', () => { + for (const code of [ + 'wormhole_required_for_gate_compose', + 'hidden transport required for infonet posting', + 'dm send requires private transport', + ]) { + expect(friendlyInfonetError(code)).toMatch(/private connection is still starting/); + } + }); + + it('maps control plane status codes', () => { + expect(friendlyInfonetError('control_plane_request_failed:403')).toMatch(/only available on the computer/); + expect(friendlyInfonetError(new Error('Failed to fetch'))).toMatch(/Could not reach/); + expect(friendlyInfonetError('control_plane_rate_limited')).toMatch(/Wait a few seconds/); + }); + + it('warns about changed contact keys', () => { + expect(friendlyInfonetError('contact trust state does not allow gate keys: mismatch')).toMatch( + /security keys changed/, + ); + expect(friendlyInfonetError('remote prekey changed — verify before sending')).toMatch(/safety codes/); + }); + + it('keeps unknown machine codes for support but wraps them in a sentence', () => { + expect(friendlyInfonetError('weird_new_failure', 'Could not post.')).toBe('Could not post. (weird_new_failure)'); + }); + + it('passes ordinary sentences through and falls back on empty input', () => { + expect(friendlyInfonetError('Write a message first.')).toBe('Write a message first.'); + expect(friendlyInfonetError('', 'Nope.')).toBe('Nope.'); + expect(friendlyInfonetError(undefined)).toBe('Something went wrong. Try again.'); + }); +}); diff --git a/frontend/src/__tests__/mesh/infonetShellGateDirectory.test.tsx b/frontend/src/__tests__/mesh/infonetShellGateDirectory.test.tsx index 5067f899..8e968e41 100644 --- a/frontend/src/__tests__/mesh/infonetShellGateDirectory.test.tsx +++ b/frontend/src/__tests__/mesh/infonetShellGateDirectory.test.tsx @@ -50,7 +50,7 @@ describe('InfonetShell gate directory', () => { vi.advanceTimersByTime(2500); }); - expect(screen.getByText('AVAILABLE OBFUSCATED GATES:')).toBeTruthy(); + expect(screen.getByText('AVAILABLE GATES:')).toBeTruthy(); expect(screen.getByRole('button', { name: /\[>\]\s*infonet/i })).toBeTruthy(); expect(screen.getByRole('button', { name: /\[>\]\s*gathered-intel/i })).toBeTruthy(); }); diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index af56d262..8078c093 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -26,7 +26,7 @@ import AIIntelPanel from '@/components/AIIntelPanel'; import GlobalTicker from '@/components/GlobalTicker'; import ErrorBoundary from '@/components/ErrorBoundary'; import OnboardingModal, { useOnboarding } from '@/components/OnboardingModal'; -import ChangelogModal, { useChangelog } from '@/components/ChangelogModal'; +import ChangelogModal, { markChangelogSeen, useChangelog } from '@/components/ChangelogModal'; import StartupWarmupModal, { useStartupWarmupNotice } from '@/components/StartupWarmupModal'; import type { ActiveLayers, KiwiSDR, Scanner, SelectedEntity } from '@/types/dashboard'; import { @@ -614,7 +614,7 @@ export default function Dashboard() { {/* LEFT HUD CONTAINER — mirrors right side: one scroll container, scrollbar on LEFT edge */} setShowOnboarding(false)} + onClose={() => { + setShowOnboarding(false); + markChangelogSeen(); + setShowChangelog(false); + }} onOpenSettings={() => { setShowOnboarding(false); + markChangelogSeen(); + setShowChangelog(false); setSettingsOpen(true); }} /> diff --git a/frontend/src/components/ChangelogModal.tsx b/frontend/src/components/ChangelogModal.tsx index 6ddd21a7..de22f7bd 100644 --- a/frontend/src/components/ChangelogModal.tsx +++ b/frontend/src/components/ChangelogModal.tsx @@ -140,6 +140,15 @@ const CONTRIBUTORS: ChangelogContributor[] = [ }, ]; +/** A brand-new install has nothing to catch up on; skip this version's notes. */ +export function markChangelogSeen() { + try { + localStorage.setItem(STORAGE_KEY, 'true'); + } catch { + /* storage unavailable: the modal just shows once more */ + } +} + export function useChangelog() { const [show, setShow] = useState(false); useEffect(() => { diff --git a/frontend/src/components/InfonetTerminal/GateKeySharingPanel.tsx b/frontend/src/components/InfonetTerminal/GateKeySharingPanel.tsx index 55889ca5..f8b0becc 100644 --- a/frontend/src/components/InfonetTerminal/GateKeySharingPanel.tsx +++ b/frontend/src/components/InfonetTerminal/GateKeySharingPanel.tsx @@ -3,6 +3,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { KeyRound } from 'lucide-react'; import { getContacts } from '@/mesh/meshIdentity'; +import { friendlyInfonetError } from '@/mesh/friendlyError'; import { acceptWormholeGateInvite, declineWormholeGateInvite, @@ -58,7 +59,7 @@ export default function GateKeySharingPanel({ gateId, onKeyChanged }: GateKeySha setInvites(await fetchWormholeGateInvites()); if (gateId) setSharing(await fetchWormholeGateKeySharing(gateId)); } catch (error) { - setNotice(error instanceof Error ? error.message : 'Key sharing unavailable'); + setNotice(friendlyInfonetError(error, 'Key sharing is unavailable right now.')); } }, [gateId]); @@ -73,7 +74,7 @@ export default function GateKeySharingPanel({ gateId, onKeyChanged }: GateKeySha setNotice(await action()); await refresh(); } catch (error) { - setNotice(error instanceof Error ? error.message : 'Request failed'); + setNotice(friendlyInfonetError(error)); } finally { setBusy(false); } diff --git a/frontend/src/components/InfonetTerminal/GateView.tsx b/frontend/src/components/InfonetTerminal/GateView.tsx index 38634cc0..ea3d0e28 100644 --- a/frontend/src/components/InfonetTerminal/GateView.tsx +++ b/frontend/src/components/InfonetTerminal/GateView.tsx @@ -33,6 +33,7 @@ import { } from '@/mesh/wormholeIdentityClient'; import { gateEnvelopeDisplayText, gateEnvelopeState, isEncryptedGateEnvelope } from '@/mesh/gateEnvelope'; import { validateEventPayload } from '@/mesh/meshSchema'; +import { friendlyInfonetError } from '@/mesh/friendlyError'; import GateKeySharingPanel from './GateKeySharingPanel'; const GATE_INTROS: Record = { @@ -530,7 +531,7 @@ export default function GateView({ await applyGateMessages(snapshot.messages as GateMessage[]); return true; } catch (error) { - setRoomError(error instanceof Error ? error.message : 'Failed to load gate room'); + setRoomError(friendlyInfonetError(error, 'Could not load this room.')); return false; } finally { setLoading(false); @@ -648,7 +649,7 @@ export default function GateView({ } const ready = await refreshGate({ force: true }); if (!ready) { - setRoomError(error instanceof Error ? error.message : 'Failed to load gate room'); + setRoomError(friendlyInfonetError(error, 'Could not load this room.')); scheduleRetry(); return; } @@ -804,11 +805,7 @@ export default function GateView({ } catch (error) { const errMsg = error instanceof Error ? error.message : 'Gate post failed'; // Suppress technical sequence/replay errors — just show a clean retry hint - if (/replay|sequence/i.test(errMsg)) { - setRoomError('Message could not be posted — try again'); - } else { - setRoomError(errMsg); - } + setRoomError(friendlyInfonetError(errMsg, 'Your post did not go through. Try again.')); } finally { setBusy(false); } @@ -970,8 +967,8 @@ export default function GateView({ {status?.has_local_access ? `LIVE ROOM READY • ${status.identity_scope || entryMode || 'gate'} access` : loading - ? 'CONNECTING TO OBFUSCATED GATE LANE...' - : String(status?.detail || 'Gate access still syncing')} + ? 'CONNECTING TO ROOM...' + : friendlyInfonetError(status?.detail, 'This room is still syncing. Try again in a moment.')} diff --git a/frontend/src/components/InfonetTerminal/InfonetShell.tsx b/frontend/src/components/InfonetTerminal/InfonetShell.tsx index 98b7c02a..e7230b76 100644 --- a/frontend/src/components/InfonetTerminal/InfonetShell.tsx +++ b/frontend/src/components/InfonetTerminal/InfonetShell.tsx @@ -315,7 +315,7 @@ export default function InfonetShell({ } >

- AVAILABLE OBFUSCATED GATES: + AVAILABLE GATES:

{GATES.map(gate => ( diff --git a/frontend/src/components/InfonetTerminal/MessagesView.tsx b/frontend/src/components/InfonetTerminal/MessagesView.tsx index 3e010322..ee96edc9 100644 --- a/frontend/src/components/InfonetTerminal/MessagesView.tsx +++ b/frontend/src/components/InfonetTerminal/MessagesView.tsx @@ -124,6 +124,7 @@ import { rootWitnessContinuityLabel, } from '@/mesh/contactTrustSummary'; import GateKeySharingPanel from './GateKeySharingPanel'; +import { friendlyInfonetError } from '@/mesh/friendlyError'; type ViewTab = 'mailbox' | 'compose' | 'requests' | 'contacts' | 'restricted'; type MailFolder = 'inbox' | 'sent' | 'junk' | 'spam' | 'trash'; @@ -611,7 +612,7 @@ function normalizeMailError(message: string): string { ) { return 'This contact is saved. Messages can be saved now and will send automatically when the contact is reachable.'; } - return detail; + return friendlyInfonetError(detail, 'Secure mail hit a problem. Try again.'); } function shouldSaveMailForLater(message: string): boolean { @@ -1925,7 +1926,7 @@ export default function MessagesView({ onBack, onOpenDeadDrop }: MessagesViewPro } if (requiresVerifiedFirstContact(contacts[recipient])) { setComposeStatus(''); - setComposeError('Import a signed invite first. Unverified TOFU first-contact requests are disabled.'); + setComposeError('Add this person as a contact first: paste the contact invite they shared with you. This node only accepts new contacts from invites, so nobody can pose as them.'); return; } @@ -2187,7 +2188,7 @@ export default function MessagesView({ onBack, onOpenDeadDrop }: MessagesViewPro setActiveTab('mailbox'); setSelectedFolder('sent'); } catch (error) { - setComposeError(error instanceof Error ? error.message : 'contact request failed'); + setComposeError(friendlyInfonetError(error, 'Contact request did not go through. Try again.')); } finally { setInviteBusy(false); } @@ -2385,7 +2386,7 @@ export default function MessagesView({ onBack, onOpenDeadDrop }: MessagesViewPro await refreshDmAddressHandles(); } catch (error) { if (!automatic) { - setComposeError(error instanceof Error ? error.message : 'Contact address could not be created.'); + setComposeError(friendlyInfonetError(error, 'Contact address could not be created. Try again.')); } } finally { setDmAddressBusy(''); @@ -2458,7 +2459,7 @@ export default function MessagesView({ onBack, onOpenDeadDrop }: MessagesViewPro ); await refreshDmAddressHandles(); } catch (error) { - setComposeError(error instanceof Error ? error.message : 'DM address revoke failed'); + setComposeError(friendlyInfonetError(error, 'Could not revoke that address. Try again.')); } finally { setDmAddressBusy(''); } @@ -2497,7 +2498,7 @@ export default function MessagesView({ onBack, onOpenDeadDrop }: MessagesViewPro setDmAddressCopyStatus(`Renamed ${shortHandle(address.handle)} to ${label}.`); await refreshDmAddressHandles(); } catch (error) { - setComposeError(error instanceof Error ? error.message : 'DM address label update failed'); + setComposeError(friendlyInfonetError(error, 'Could not rename that address. Try again.')); } finally { setDmAddressBusy(''); } @@ -2635,7 +2636,7 @@ export default function MessagesView({ onBack, onOpenDeadDrop }: MessagesViewPro : `Contact accepted: ${displayNameForPeer(mail.senderId, getContacts())}.`, ); } catch (error) { - setComposeError(error instanceof Error ? error.message : 'accept failed'); + setComposeError(friendlyInfonetError(error, 'Could not accept the request. Try again.')); } finally { setBusy(false); } @@ -2706,7 +2707,7 @@ export default function MessagesView({ onBack, onOpenDeadDrop }: MessagesViewPro : `Request denied: ${displayNameForPeer(mail.senderId, getContacts())}.`, ); } catch (error) { - setComposeError(error instanceof Error ? error.message : 'deny failed'); + setComposeError(friendlyInfonetError(error, 'Could not decline the request. Try again.')); } finally { setBusy(false); } diff --git a/frontend/src/components/InfonetTerminal/TrendingPosts.tsx b/frontend/src/components/InfonetTerminal/TrendingPosts.tsx index e6c4a105..e1971d4c 100644 --- a/frontend/src/components/InfonetTerminal/TrendingPosts.tsx +++ b/frontend/src/components/InfonetTerminal/TrendingPosts.tsx @@ -12,13 +12,13 @@ export default function TrendingPosts() {

TEST-NET ACTIVE

-

Gates are decentralized chatrooms running on the Infonet mesh. All messages are end-to-end encrypted via Wormhole.

+

Gates are chatrooms on the Infonet mesh. Posts are encrypted for members who hold the room key; which room you post in, and when, is still visible.

Type gates or g/ to browse available rooms.

SHADOWBROKER ADVISORY

- This is a testnet. Treat all communications as obfuscated, not encrypted. Do not assume full privacy, anonymity, or end-to-end encryption. Transport security is experimental and unaudited. Use at your own risk. + This is a testnet. Message content is encrypted, but the code is unaudited and activity metadata is visible. Don't share anything that would hurt you if it leaked.

diff --git a/frontend/src/components/MeshChat/InfonetTerminalPanel.tsx b/frontend/src/components/MeshChat/InfonetTerminalPanel.tsx index 1e386a90..7fc35e3a 100644 --- a/frontend/src/components/MeshChat/InfonetTerminalPanel.tsx +++ b/frontend/src/components/MeshChat/InfonetTerminalPanel.tsx @@ -4,6 +4,26 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; import { Shield } from 'lucide-react'; import { beginInfonetTerminalSession } from '@/lib/infonetTerminalSession'; import InfonetShell from '@/components/InfonetTerminal/InfonetShell'; +import { friendlyInfonetError } from '@/mesh/friendlyError'; + +/** Seconds since `running` became true, ticking once a second; 0 when idle. */ +function useElapsedSeconds(running: boolean): number { + const [elapsed, setElapsed] = useState(0); + useEffect(() => { + if (!running) { + setElapsed(0); + return; + } + const started = Date.now(); + const timer = setInterval(() => setElapsed(Math.floor((Date.now() - started) / 1000)), 1000); + return () => clearInterval(timer); + }, [running]); + return elapsed; +} + +function formatElapsed(seconds: number): string { + return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`; +} type Props = { active: boolean; @@ -33,7 +53,7 @@ function InfonetIntro({
INFONET TERMINAL

- Obfuscated Wormhole lane for the Infonet shell. Leave this tab to shut Wormhole down. + Private chat and rooms over Tor. Entering starts a private connection (the first start can take up to a minute); leaving this tab disconnects it.

{status && !error && (
@@ -76,6 +96,7 @@ export default function InfonetTerminalPanel({ const prepStartedRef = useRef(false); const shellOpen = active && sessionActive; + const laneElapsed = useElapsedSeconds(laneBusy); const resetSession = useCallback(() => { setSessionActive(false); @@ -114,7 +135,7 @@ export default function InfonetTerminalPanel({ if (prepStartedRef.current) return; prepStartedRef.current = true; setLaneError(''); - setLaneStatus('Starting Wormhole obfuscated lane…'); + setLaneStatus('Connecting privately over Tor… the first start can take up to a minute.'); setLaneBusy(true); try { await onEnterWormhole(); @@ -122,11 +143,7 @@ export default function InfonetTerminalPanel({ } catch (err) { prepStartedRef.current = false; setSessionActive(false); - const message = - typeof err === 'object' && err !== null && 'message' in err - ? String((err as { message?: string }).message) - : 'Could not start Wormhole.'; - setLaneError(message); + setLaneError(friendlyInfonetError(err, 'Could not start the private connection. Try again.')); setLaneStatus(''); } finally { setLaneBusy(false); @@ -173,7 +190,9 @@ export default function InfonetTerminalPanel({
- {laneBusy ? 'wormhole · obfuscated lane starting' : 'infonet terminal'} + {laneBusy + ? `connecting privately over tor · ${formatElapsed(laneElapsed)}${laneElapsed >= 90 ? ' · still working' : ''}` + : 'infonet terminal'}
{!expanded ? ( diff --git a/frontend/src/mesh/friendlyError.ts b/frontend/src/mesh/friendlyError.ts new file mode 100644 index 00000000..9d469a63 --- /dev/null +++ b/frontend/src/mesh/friendlyError.ts @@ -0,0 +1,108 @@ +/** + * Turn backend/control-plane error codes into sentences a user can act on. + * + * Raw codes such as `wormhole_required_for_gate_compose` or + * `control_plane_request_failed:403` are useful for debugging but read as + * hostile in the UI. Unknown machine-style codes keep the code in brackets so + * support can still identify them. + */ + +interface Rule { + test: (lower: string) => boolean; + text: string; +} + +const has = (...needles: string[]) => (lower: string) => needles.some((n) => lower.includes(n)); + +const RULES: Rule[] = [ + { + test: has('failed to fetch', 'networkerror', 'network error', 'backend_unavailable', 'load failed'), + text: 'Could not reach your ShadowBroker backend. Check that it is running, then try again.', + }, + { + test: has('local_control_plane_unavailable'), + text: 'The local ShadowBroker service is not answering yet. Give it a moment and try again.', + }, + { + test: has('control_plane_rate_limited', 'rate limit', 'too many requests', 'cooldown'), + text: 'That was a lot of requests in a short time. Wait a few seconds and try again.', + }, + { + test: has('control_plane_request_failed:401', 'control_plane_request_failed:403', 'access denied', 'forbidden'), + text: 'This action is only available on the computer running ShadowBroker.', + }, + { + test: has( + 'wormhole_required', + 'hidden transport required', + 'wormhole required', + 'transport tier insufficient', + 'requires private transport', + 'private lane', + 'preparing_private_lane', + ), + text: 'The private connection is still starting. This usually takes under a minute the first time; your message is kept until it is ready.', + }, + { + test: has('privacy_core_attestation', 'privacy-core', 'privacy core'), + text: 'The private messaging library is not set up on this node. Restart ShadowBroker with the start script so it can build and register it.', + }, + { + test: has('gate access still syncing', 'gate_state_stale', 'gate state resynced', 'gate_state_resync'), + text: 'This room is still syncing. Try again in a moment.', + }, + { + test: has('gate_local_runtime_required', 'local gate crypto is unavailable'), + text: 'This browser cannot run the room encryption locally. Open ShadowBroker in the desktop app or a current Chrome, Edge or Firefox.', + }, + { + test: has('gate_envelope_required', 'gate_envelope_encrypt_failed', 'gate secret unavailable', 'gatesecretunavailable'), + text: 'This room key is not ready on this node yet. Try again in a moment.', + }, + { + test: has('no active gate identity', 'not mapped into the mls group'), + text: 'Join the room first, then post.', + }, + { + test: has('gate_mls_compose_failed', 'gate_sign_failed', 'gate post failed', 'replay', 'sequence'), + text: 'Your post did not go through. Try again.', + }, + { + test: has(': mismatch', 'continuity_broken', 'identity changed', 'prekey changed', 'key mismatch'), + text: "This contact's security keys changed. Compare safety codes with them before sending anything sensitive.", + }, + { + test: has('verified first contact required', 'import a signed invite', 'not a dm contact'), + text: 'Add this person as a contact first: paste the contact address or invite they shared with you.', + }, + { + test: has('prekey bundle not found', 'prekey lookup unavailable', 'delivery key has not reached', 'recipient unresolved'), + text: "That contact isn't reachable yet. Ask them to open ShadowBroker, or to share a fresh contact address.", + }, + { + test: has('dm_mls_initiate_failed', 'dm_mls_accept_failed', 'dm session', 'session_expired'), + text: 'The secure chat session with this contact needs to be re-established. Send the message again; if it keeps failing, re-add the contact.', + }, + { + test: has('invite not found or expired'), + text: 'That invite has expired or was already handled.', + }, +]; + +const MACHINE_CODE = /^[a-z0-9_.:-]+$/; + +export function friendlyInfonetError(raw: unknown, fallback = 'Something went wrong. Try again.'): string { + const text = String( + raw instanceof Error ? raw.message : typeof raw === 'string' ? raw : (raw as { message?: string })?.message || '', + ).trim(); + if (!text) return fallback; + const lower = text.toLowerCase(); + for (const rule of RULES) { + if (rule.test(lower)) return rule.text; + } + // Snake_case codes are not sentences; keep the code for support. + if (MACHINE_CODE.test(text) && !text.includes(' ')) { + return `${fallback} (${text})`; + } + return text; +}