A Tauri menu-bar app runs the same sync engine as `lunesync run`. It connects from the website with no code typed (lune://join and lune://pair links), shows status in the menu bar, and lets a person resolve held secrets, held big changes and kept-both notes side by side. Uninstall shares and hands over first, then removes only what Lune created. Releases are signed on the hub that holds the key (`lunehub release keygen/publish`); other hubs `release import` them. Apps verify the signature and the signed version. Clients older than the previous release are asked to update and keep saving locally. A device can now be on several hubs at once (own and workplace), each with its own key; the CLI takes --team when it matters. The supervisor and status summary moved into core, shared by the CLI and the app. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
3.4 KiB
TypeScript
85 lines
3.4 KiB
TypeScript
import { StrictMode, useEffect, useState } from 'react';
|
|
import { createRoot } from 'react-dom/client';
|
|
import { api, SignedOut, type CanvasData } from './api';
|
|
import { Canvas } from './Canvas';
|
|
import { JoinWithApp } from './MacApp';
|
|
import './styles.css';
|
|
|
|
/** Sign in with a code from one of your devices (no passwords, §8). */
|
|
function SignIn({ onDone }: { onDone: () => void }) {
|
|
const expired = new URLSearchParams(location.search).has('expired');
|
|
const [code, setCode] = useState('');
|
|
const [error, setError] = useState(expired ? 'That sign-in link was used or expired. Run `lunesync open` again, or use a code.' : '');
|
|
const submit = async (e: React.FormEvent) => {
|
|
e.preventDefault();
|
|
try {
|
|
await api.signin(code);
|
|
history.replaceState(null, '', '/');
|
|
onDone();
|
|
} catch (err) {
|
|
setError((err as Error).message);
|
|
}
|
|
};
|
|
return (
|
|
<main className="page">
|
|
<form className="card" onSubmit={submit}>
|
|
<span className="eyebrow">Lune</span>
|
|
<h1 className="disp">Sign in to the team canvas</h1>
|
|
<label htmlFor="code">Code from one of your devices</label>
|
|
<input id="code" className="field code" value={code} onChange={(e) => setCode(e.target.value)} placeholder="K7QD-4MXA" autoComplete="one-time-code" autoFocus />
|
|
{error && <p className="error" role="alert">{error}</p>}
|
|
<button className="btn btn-primary" type="submit" disabled={!code.trim()}>Sign in</button>
|
|
<p className="muted">Get a code with <code>lunesync pair</code>, or run <code>lunesync open</code> on a device to skip this page.</p>
|
|
</form>
|
|
</main>
|
|
);
|
|
}
|
|
|
|
/** What an invite link shows in a browser: get the Mac app and join from it, or join a server from the terminal. */
|
|
function Join() {
|
|
const link = location.href;
|
|
return (
|
|
<main className="page">
|
|
<div className="card">
|
|
<span className="eyebrow">Lune · invite</span>
|
|
<h1 className="disp">You're invited to a team</h1>
|
|
<JoinWithApp link={link} />
|
|
<details>
|
|
<summary className="muted">Joining from a server or the terminal instead</summary>
|
|
<pre className="cmd">lunesync join {link} --name "My server"</pre>
|
|
</details>
|
|
</div>
|
|
</main>
|
|
);
|
|
}
|
|
|
|
function App() {
|
|
const [data, setData] = useState<CanvasData | null>(null);
|
|
const [state, setState] = useState<'loading' | 'signin' | 'ready' | 'error'>('loading');
|
|
const [error, setError] = useState('');
|
|
|
|
const load = async () => {
|
|
try {
|
|
setData(await api.canvas());
|
|
setState('ready');
|
|
} catch (e) {
|
|
if (e instanceof SignedOut) setState('signin');
|
|
else {
|
|
setError((e as Error).message);
|
|
setState('error');
|
|
}
|
|
}
|
|
};
|
|
useEffect(() => {
|
|
if (!location.pathname.startsWith('/join/')) load();
|
|
}, []);
|
|
|
|
if (location.pathname.startsWith('/join/')) return <Join />;
|
|
if (state === 'signin') return <SignIn onDone={load} />;
|
|
if (state === 'error') return <main className="page"><div className="card"><p className="error">{error}</p><button className="btn" onClick={load}>Try again</button></div></main>;
|
|
if (!data) return <main className="page" aria-busy="true" />;
|
|
return <Canvas data={data} reload={load} onSignOut={async () => { await api.signout().catch(() => {}); setState('signin'); }} />;
|
|
}
|
|
|
|
createRoot(document.getElementById('root')!).render(<StrictMode><App /></StrictMode>);
|