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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeX9wuqeVAQNr22zQHWj2H
This commit is contained in:
Claude committed 2026-10-22 04:03:44 +00:00
1 parent f1f3c37500
commit 29fb02ae0e
11 files changed
+213 -34

No files matched your search

@@ -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.');
});
});
@@ -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();
});
+9 -3
View File
@@ -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 */}
<motion.div
className="absolute left-6 top-24 bottom-9 w-80 flex flex-col gap-3 z-[200] pointer-events-auto overflow-y-auto styled-scrollbar pl-2 pr-2 hud-zone"
className="absolute left-6 top-24 bottom-9 w-80 flex flex-col gap-3 z-[201] pointer-events-auto overflow-y-auto styled-scrollbar pl-2 pr-2 hud-zone"
style={{ direction: 'rtl' }}
animate={{ x: leftOpen ? 0 : -360 }}
transition={{ type: 'spring', damping: 30, stiffness: 250 }}
@@ -1010,9 +1010,15 @@ export default function Dashboard() {
{/* ONBOARDING MODAL */}
{showOnboarding && (
<OnboardingModal
onClose={() => setShowOnboarding(false)}
onClose={() => {
setShowOnboarding(false);
markChangelogSeen();
setShowChangelog(false);
}}
onOpenSettings={() => {
setShowOnboarding(false);
markChangelogSeen();
setShowChangelog(false);
setSettingsOpen(true);
}}
/>
@@ -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(() => {
@@ -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);
}
@@ -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<string, string> = {
@@ -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.')}
</div>
</div>
@@ -315,7 +315,7 @@ export default function InfonetShell({
}
>
<p className={`${variant === 'landing' ? 'text-[11px]' : ''} text-gray-400 uppercase tracking-[0.18em]`}>
AVAILABLE OBFUSCATED GATES:
AVAILABLE GATES:
</p>
<div className={`grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 ${variant === 'landing' ? 'gap-x-8 gap-y-1.5 mt-2' : 'gap-2 mt-2'}`}>
{GATES.map(gate => (
@@ -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);
}
@@ -12,13 +12,13 @@ export default function TrendingPosts() {
<div className="space-y-3">
<div className="text-sm text-gray-500 leading-relaxed">
<p className="text-amber-400/80 font-bold mb-1">TEST-NET ACTIVE</p>
<p>Gates are decentralized chatrooms running on the Infonet mesh. All messages are end-to-end encrypted via Wormhole.</p>
<p>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.</p>
<p className="mt-2">Type <span className="text-green-400 font-bold">gates</span> or <span className="text-green-400 font-bold">g/</span> to browse available rooms.</p>
</div>
<div className="mt-3 pt-3 border-t border-gray-800">
<p className="text-red-500 font-bold text-xs mb-1">SHADOWBROKER ADVISORY</p>
<p className="text-[11px] text-red-400/70 leading-relaxed">
This is a <span className="text-red-400 font-bold">testnet</span>. Treat all communications as <span className="text-red-400 font-bold">obfuscated, not encrypted</span>. 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 <span className="text-red-400 font-bold">testnet</span>. Message content is encrypted, but the code is <span className="text-red-400 font-bold">unaudited</span> and activity metadata is visible. Don&apos;t share anything that would hurt you if it leaked.
</p>
</div>
</div>
@@ -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({
<div className="w-full max-w-sm border border-cyan-900/40 bg-cyan-950/10 px-4 py-4">
<div className="text-sm font-mono tracking-[0.22em] text-cyan-300 mb-2">INFONET TERMINAL</div>
<p className="text-[12px] font-mono text-[var(--text-secondary)] leading-[1.6] text-left">
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.
</p>
{status && !error && (
<div className="mt-3 text-left text-[12px] font-mono text-cyan-300/85 leading-relaxed border border-cyan-900/30 bg-cyan-950/10 px-3 py-2">
@@ -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({
<div className="flex-1 min-h-0 flex flex-col border-l-2 border-cyan-800/25 bg-[#04070b]">
<div className="flex items-center justify-between gap-2 border-b border-cyan-900/40 px-2 py-1.5 shrink-0">
<div className="min-w-0 text-[12px] font-mono tracking-[0.14em] text-cyan-300/90 truncate">
{laneBusy ? 'wormhole · obfuscated lane starting' : 'infonet terminal'}
{laneBusy
? `connecting privately over tor · ${formatElapsed(laneElapsed)}${laneElapsed >= 90 ? ' · still working' : ''}`
: 'infonet terminal'}
</div>
<div className="flex items-center gap-1 shrink-0">
{!expanded ? (
+108
View File
@@ -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;
}