Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ It is disabled by default and never enrolls an account-free workspace. Notes and
Planner use the same configured Engine account with separate approved devices,
keys and local databases. This does not replace the installed desktop builds.

Account entry explains the test's possible uploads before sign-in or approval.
Workspace storage guidance uses the same stable capability gate as the account
sync provider, including its initial render; it does not treat controller creation
or that gate as an enrollment/upload receipt. Settings, offline, export and sign-out
copy retain the test's module exclusions and no-backup limitation. Account-free,
sample and normal builds retain their local-only guidance.

The library writer atomically stages immutable per-note edit events with local
changes. Only this device's `notes-sync:<device UUID>` and
`notes-links:<device UUID>` zones are uploaded; local library, collections,
Expand Down
4 changes: 3 additions & 1 deletion web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ function AppContent({ quick = false, onUseWithoutAccount }: { quick?: boolean; o
);
if (!store) return publicNotice;
if (quick) return <QuickNoteWindow key={session.accountId} store={store} />;
const accountSyncTest = import.meta.env.VITE_ECOSYSTEM_SYNC === "1" && !local && service !== null;
const workspace = (
<div className="notes-entry-layout">
{incomingNotice}
Expand All @@ -274,13 +275,14 @@ function AppContent({ quick = false, onUseWithoutAccount }: { quick?: boolean; o
incomingNoteIntentActive={incoming.hasPending || incoming.state !== null}
formatNoteLink={incoming.format}
session={session}
accountSyncTest={accountSyncTest}
onSignOut={() => signOut(true)}
onUseLocal={useLocal}
/>
</Suspense>
</div>
);
return import.meta.env.VITE_ECOSYSTEM_SYNC === "1" && !local && service
return accountSyncTest && service
? <EcosystemProvider store={storeHandles?.sync ?? store} service={service} identity={session}>{workspace}</EcosystemProvider>
: workspace;
}
Expand Down
14 changes: 9 additions & 5 deletions web/src/ui/AccountView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function AccountView({
onUseLocal?: () => void;
onUseWithoutAccount?: () => void;
}) {
const copy = storageCopy(isDesktop(), import.meta.env.VITE_ECOSYSTEM_SYNC === "1" ? "account-sync-test" : "local-only");
const [step, setStep] = useState<
"entry" | "invite" | "register" | "verify" | "signin" | "second"
>("entry");
Expand Down Expand Up @@ -100,14 +101,14 @@ export function AccountView({
</h1>
<p>
{step === "entry"
? storageCopy(isDesktop()).entry
? copy.entry
: step === "verify"
? `Enter the 8-character code sent to ${email}.`
: step === "invite"
? "New accounts need an invite code."
: step === "second"
? "Enter your authenticator code."
: storageCopy(isDesktop()).account}
: copy.account}
</p>
{step === "entry" ? (
<div className="stack">
Expand Down Expand Up @@ -270,7 +271,7 @@ export function AccountView({
<button type="button" disabled={busy} onClick={onUseLocal ?? onUseWithoutAccount}>Use without an account</button>
)}
<p className="local-copy">
{storageCopy(isDesktop()).warning}
{copy.warning}
</p>
</section>
</main>
Expand All @@ -285,14 +286,16 @@ export function PendingDevice({
onSession: (s: AccountSession) => void;
onSignOut: () => void;
}) {
const accountSyncTest = import.meta.env.VITE_ECOSYSTEM_SYNC === "1";
const copy = storageCopy(isDesktop(), accountSyncTest ? "account-sync-test" : "local-only");
const [sas, setSas] = useState("");
const [error, setError] = useState("");
const [busy, setBusy] = useState(false);
return (
<main className="account-page">
<section className="account-card">
<h1>{storageCopy(isDesktop()).approvalHeading}</h1>
<p>{storageCopy(isDesktop()).approvalHelp}</p>
<h1>{copy.approvalHeading}</h1>
<p>{copy.approvalHelp}</p>
{sas && <p className="sas">{sas}</p>}
{error && <p role="alert">{error}</p>}
<div className="stack">
Expand Down Expand Up @@ -336,6 +339,7 @@ export function PendingDevice({
)}
<button onClick={onSignOut}>Sign out</button>
</div>
{accountSyncTest && <p className="local-copy">{copy.warning}</p>}
</section>
</main>
);
Expand Down
13 changes: 9 additions & 4 deletions web/src/ui/SettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { useDesktop } from "../desktop/DesktopShell";
import { isLocalSession } from "../data/local";

type SettingsProps = {
accountSyncTest?: boolean;
sampleWorkspace?: boolean;
desktopSurface?: boolean;
sidebarExpanded?: boolean;
Expand Down Expand Up @@ -60,6 +61,7 @@ export function SettingsView(props: SettingsProps) {
} = props;
const desktopContext = useDesktop();
const desktop = props.desktopSurface ?? !!desktopContext;
const syncTest = !!props.accountSyncTest && !props.sampleWorkspace && !isLocalSession({ email });
const sidebarPinned = props.sidebarExpanded ?? desktopContext?.sidebarPinned ?? desktopContext?.sidebarExpanded ?? true;
const [find, setFind] = useState("");
const [pointerInside, setPointerInside] = useState(false);
Expand Down Expand Up @@ -174,7 +176,7 @@ export function SettingsView(props: SettingsProps) {
[
["general", "General", Settings, false],
["editor", "Editor", Type, false],
["sync", "Sync", RefreshCw, true],
["sync", "Sync", RefreshCw, !syncTest],
["study", "Study", Layers, false],
["journal", "Journal", Sun, false],
["apps", "Connected apps", Plug, true],
Expand Down Expand Up @@ -238,6 +240,7 @@ export function SettingsView(props: SettingsProps) {
// design: notes/settings-data
function SettingsPaneContent({
sampleWorkspace = false,
accountSyncTest = false,
desktopSurface,
email,
preferences,
Expand All @@ -264,6 +267,8 @@ function SettingsPaneContent({
const desktopContext = useDesktop();
const desktop = desktopSurface ?? !!desktopContext;
const local = isLocalSession({ email });
const syncTest = accountSyncTest && !sampleWorkspace && !local;
const guidance = storageCopy(isDesktop(), syncTest ? "account-sync-test" : "local-only");
const editor = useEditorPreferences();
const registerGuard = useCallback(
(value: SettingsLeaveGuard | null) => register(pane, value),
Expand Down Expand Up @@ -479,10 +484,10 @@ function SettingsPaneContent({
) : section === "sync" || section === "apps" ? (
<div className="settings-row">
<div>
<b>Planned</b>
<b>{section === "sync" && syncTest ? "Account sync test" : "Planned"}</b>
<small>
{section === "sync"
? sampleWorkspace ? "Sample changes last until you leave or reload. Sync is unavailable." : "Notes stay on this device in this beta."
? syncTest ? "Notes and Planner task links can sync with your account. Journal, Study, Clips, pins and version history stay local. This sync test is not a backup." : sampleWorkspace ? "Sample changes last until you leave or reload. Sync is unavailable." : "Notes stay on this device in this beta."
: "Connections to other apps and browser extensions aren’t available in this beta."}
</small>
</div>
Expand Down Expand Up @@ -531,7 +536,7 @@ function SettingsPaneContent({
<div>
<b>Export all notes</b>
<small>
{storageCopy(isDesktop()).exportWarning}
{guidance.exportWarning}
</small>
</div>
<button onClick={onExport}>Export all notes</button>
Expand Down
31 changes: 19 additions & 12 deletions web/src/ui/Workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ export function Workspace({
onNoteLinkScopeRevoked,
incomingNoteIntentActive = false,
setupPreference = profileSetupPreference,
accountSyncTest = false,
}: {
accountSyncTest?: boolean;
incomingNoteIntentActive?: boolean;
setupPreference?: SetupPreference;
onNoteLinkScopeRevoked?: () => void;
Expand Down Expand Up @@ -190,6 +192,9 @@ export function Workspace({
const createFocusTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
const localSession = isLocalSession(session);
const ecosystem = useEcosystemEnabled();
// App's stable gate covers startup; an already active provider also owns this mode.
// Neither signal is an upload receipt, and local workspaces never enroll.
const syncTest = !localSession && (accountSyncTest || ecosystem);
const accountLabel = localSession ? "Local workspace" : session.email;
const accountInitial = useMemo(() => {
const first = new Intl.Segmenter(undefined, { granularity: "grapheme" })
Expand Down Expand Up @@ -523,6 +528,7 @@ export function Workspace({
// design: notes/layout-narrow
const [drawer, setDrawer] = useState(false);
const desktop = useDesktop();
const guidance = storageCopy(!!desktop, syncTest ? "account-sync-test" : "local-only");
const mainRef = useRef<HTMLElement>(null);
const [tagResultFocus, requestTagResultFocus] = useState(0);
useLayoutEffect(() => {
Expand Down Expand Up @@ -2002,7 +2008,7 @@ export function Workspace({
<Menu size={18} />
</button>
<b>Orbyn Notes</b>
<span>{ecosystem ? "Beta · Account sync test" : "Beta · Local only"}</span>
<span>{syncTest ? "Beta · Account sync test" : "Beta · Local only"}</span>
</header>
{drawer && (
<button
Expand Down Expand Up @@ -2279,8 +2285,8 @@ export function Workspace({
</button>
</nav>
<footer>
<p role="status" title={ecosystem ? "Account sync is enabled for this test. Export a copy before clearing local app data." : offline ? storageCopy(!!desktop).offline : storageCopy(!!desktop).encryptedHelp}>
{offline && !ecosystem ? <><svg aria-hidden="true" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"><path d="M4 4l16 16M8 7.5A5.5 5.5 0 0 1 17.4 10 4 4 0 0 1 19.6 17M15 18H7.5a4 4 0 0 1-1.2-7.8" /></svg> Offline · Local only</> : ecosystem ? "◉ Beta · Account sync test" : "◉ Beta · Local only"}
<p role="status" title={offline ? guidance.offline : guidance.encryptedHelp}>
{offline && !syncTest ? <><svg aria-hidden="true" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"><path d="M4 4l16 16M8 7.5A5.5 5.5 0 0 1 17.4 10 4 4 0 0 1 19.6 17M15 18H7.5a4 4 0 0 1-1.2-7.8" /></svg> Offline · Local only</> : syncTest ? "◉ Beta · Account sync test" : "◉ Beta · Local only"}
</p>
<button
className="nav"
Expand Down Expand Up @@ -2367,9 +2373,9 @@ export function Workspace({
className="workspace-route"
inert={searchActive}
>
{offline && (ecosystem || !!newDraft) && module === "notes" && (
{offline && (syncTest || !!newDraft) && module === "notes" && (
<p className="banner">
{storageCopy(!!desktop).offline}
{guidance.offline}
</p>
)}
{sourceOwner && sourceOwners.error && (
Expand Down Expand Up @@ -2642,7 +2648,7 @@ export function Workspace({
{linkedOnly && linkedQuery?.status !== "ready"
? "Checking links"
: `${visible.length} ${visible.length === 1 ? "note" : "notes"}`}
{offline && !ecosystem && <span className="notes-library-offline"> · Offline · Local only</span>}
{offline && !syncTest && <span className="notes-library-offline"> · Offline · Local only</span>}
</span>
</div>
<div className="actions notes-library-toolbar">
Expand Down Expand Up @@ -2831,7 +2837,7 @@ export function Workspace({
</button>
</div>
<p className="library-local-copy">
{ecosystem ? "Notes sync is enabled for this test account. Export a copy" : "This beta doesn’t sync or back up notes. Export a copy"}
{syncTest ? "Notes can sync with your account in this test. Export a copy" : "This beta doesn’t sync or back up notes. Export a copy"}
{" "}before clearing{" "}
{desktop ? "app data" : "this browser’s data"}.
</p>
Expand Down Expand Up @@ -2956,8 +2962,8 @@ export function Workspace({
data-note-actor-active={actor.id === selected && !searchActive}
>
<NoteEditor
offline={offline && !ecosystem}
localPresentation={!ecosystem}
offline={offline && !syncTest}
localPresentation={!syncTest}
active={actor.id === selected && !searchActive}
key={actor.id}
note={actor}
Expand Down Expand Up @@ -3167,6 +3173,7 @@ export function Workspace({
}}
>
<SettingsView
accountSyncTest={syncTest}
studyOwner={
sourceOwners.collections
? {
Expand Down Expand Up @@ -3220,7 +3227,7 @@ export function Workspace({
}}
>
<p>
{localSession ? "Your saved local notes stay on this device. They are not backed up or synced. Export a copy to keep them." : storageCopy(!!desktop).signOut}
{localSession ? "Your saved local notes stay on this device. They are not backed up or synced. Export a copy to keep them." : guidance.signOut}
</p>
{signOutError && (
<p className="error" role="alert">
Expand Down Expand Up @@ -3326,7 +3333,7 @@ export function Workspace({
This permanently removes this account’s notes and Trash, tags, pins
and version history, Study decks, cards and reviews, saved Clips,
and protected Journal entries, habits and recovery drafts from this
device. {ecosystem ? "Copies already uploaded to your account remain there. Permanent erase is unavailable in this sync test. " : "There is no synced copy. "}This can’t be undone. Your account
device. {syncTest ? "Copies already uploaded to your account remain there. Permanent erase is unavailable in this sync test. " : "There is no synced copy. "}This can’t be undone. Your account
stays signed in.
</p>
<p>
Expand Down Expand Up @@ -3394,7 +3401,7 @@ export function Workspace({
</label>
<button
disabled={
ecosystem ||
ecosystem || syncTest ||
busy ||
libraryAction.busy ||
!!libraryAction.error ||
Expand Down
18 changes: 16 additions & 2 deletions web/src/ui/storageCopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ const desktopCopy: typeof browserCopy = {
openingError: "Notes needs working app storage and encryption. Nothing was opened or changed. Try reopening Notes and check that this app can store data on this device.",
};

export function storageCopy(desktop: boolean) {
return desktop ? desktopCopy : browserCopy;
export type StorageMode = "local-only" | "account-sync-test";

export function storageCopy(desktop: boolean, mode: StorageMode = "local-only") {
const copy = desktop ? desktopCopy : browserCopy;
if (mode === "local-only") return copy;
const place = desktop ? "this app on this device" : "this browser";
return {
...copy,
entry: `${copy.entry} Account sync test.`,
account: "Your Orbyn account · account sync test.",
warning: "Development sync test. After sign-in and device approval, existing and new notes may sync with your account. Journal, Study, Clips, pins and version history stay local. Export a copy before testing.",
encryptedHelp: `Notes save encrypted in ${place} and can sync with your account in this test. Export a copy before clearing ${desktop ? "app" : "browser"} data.`,
offline: `You’re offline. Notes still save in ${place}. Account sync is unavailable while offline.`,
signOut: `Signing out pauses account sync on this device. Your encrypted notes stay in ${place}. Copies already uploaded remain with your account. Export a copy before clearing ${desktop ? "app" : "browser"} data.`,
exportWarning: `Export a copy before clearing ${desktop ? "app" : "browser"} data. Journal, Study, Clips, pins and version history stay local. This sync test is not a backup.`,
};
}
Loading