diff --git a/docs/architecture.md b/docs/architecture.md index 085beae..0151184 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -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:` and `notes-links:` zones are uploaded; local library, collections, diff --git a/web/src/App.tsx b/web/src/App.tsx index b0b1b6f..ecf9135 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -259,6 +259,7 @@ function AppContent({ quick = false, onUseWithoutAccount }: { quick?: boolean; o ); if (!store) return publicNotice; if (quick) return ; + const accountSyncTest = import.meta.env.VITE_ECOSYSTEM_SYNC === "1" && !local && service !== null; const workspace = (
{incomingNotice} @@ -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} />
); - return import.meta.env.VITE_ECOSYSTEM_SYNC === "1" && !local && service + return accountSyncTest && service ? {workspace} : workspace; } diff --git a/web/src/ui/AccountView.tsx b/web/src/ui/AccountView.tsx index 64ad218..f80d2eb 100644 --- a/web/src/ui/AccountView.tsx +++ b/web/src/ui/AccountView.tsx @@ -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"); @@ -100,14 +101,14 @@ export function AccountView({

{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}

{step === "entry" ? (
@@ -270,7 +271,7 @@ export function AccountView({ )}

- {storageCopy(isDesktop()).warning} + {copy.warning}

@@ -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 (
-

{storageCopy(isDesktop()).approvalHeading}

-

{storageCopy(isDesktop()).approvalHelp}

+

{copy.approvalHeading}

+

{copy.approvalHelp}

{sas &&

{sas}

} {error &&

{error}

}
@@ -336,6 +339,7 @@ export function PendingDevice({ )}
+ {accountSyncTest &&

{copy.warning}

}
); diff --git a/web/src/ui/SettingsView.tsx b/web/src/ui/SettingsView.tsx index 437f7c1..9d90e9e 100644 --- a/web/src/ui/SettingsView.tsx +++ b/web/src/ui/SettingsView.tsx @@ -33,6 +33,7 @@ import { useDesktop } from "../desktop/DesktopShell"; import { isLocalSession } from "../data/local"; type SettingsProps = { + accountSyncTest?: boolean; sampleWorkspace?: boolean; desktopSurface?: boolean; sidebarExpanded?: boolean; @@ -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); @@ -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], @@ -238,6 +240,7 @@ export function SettingsView(props: SettingsProps) { // design: notes/settings-data function SettingsPaneContent({ sampleWorkspace = false, + accountSyncTest = false, desktopSurface, email, preferences, @@ -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), @@ -479,10 +484,10 @@ function SettingsPaneContent({ ) : section === "sync" || section === "apps" ? (
- Planned + {section === "sync" && syncTest ? "Account sync test" : "Planned"} {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."}
@@ -531,7 +536,7 @@ function SettingsPaneContent({
Export all notes - {storageCopy(isDesktop()).exportWarning} + {guidance.exportWarning}
diff --git a/web/src/ui/Workspace.tsx b/web/src/ui/Workspace.tsx index fc80442..0cd943c 100644 --- a/web/src/ui/Workspace.tsx +++ b/web/src/ui/Workspace.tsx @@ -140,7 +140,9 @@ export function Workspace({ onNoteLinkScopeRevoked, incomingNoteIntentActive = false, setupPreference = profileSetupPreference, + accountSyncTest = false, }: { + accountSyncTest?: boolean; incomingNoteIntentActive?: boolean; setupPreference?: SetupPreference; onNoteLinkScopeRevoked?: () => void; @@ -190,6 +192,9 @@ export function Workspace({ const createFocusTimer = useRef | 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" }) @@ -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(null); const [tagResultFocus, requestTagResultFocus] = useState(0); useLayoutEffect(() => { @@ -2002,7 +2008,7 @@ export function Workspace({ Orbyn Notes - {ecosystem ? "Beta · Account sync test" : "Beta · Local only"} + {syncTest ? "Beta · Account sync test" : "Beta · Local only"} {drawer && (
@@ -2831,7 +2837,7 @@ export function Workspace({

- {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"}.

@@ -2956,8 +2962,8 @@ export function Workspace({ data-note-actor-active={actor.id === selected && !searchActive} >

- {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}

{signOutError && (

@@ -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.

@@ -3394,7 +3401,7 @@ export function Workspace({

{ + localStorage.clear(); + vi.stubGlobal("matchMedia", () => ({ matches: false, addEventListener: vi.fn(), removeEventListener: vi.fn() })); + HTMLDialogElement.prototype.showModal = function () { this.setAttribute("open", ""); }; + HTMLDialogElement.prototype.close = function () { this.removeAttribute("open"); }; +}); +afterEach(() => { vi.restoreAllMocks(); vi.unstubAllGlobals(); }); + +async function open(accountSyncTest: boolean, email = "fixture@example.invalid") { + const store = { list: vi.fn().mockResolvedValue([]), subscribe: () => () => {}, erase: vi.fn() } as unknown as NotesStore; + render(); + fireEvent.click(await screen.findByRole("button", { name: "Settings" })); + return { store, settings: screen.getByRole("dialog", { name: "Settings" }) }; +} + +it("keeps test guidance before any controller or upload result exists", async () => { + const { settings, store } = await open(true); + fireEvent.click(within(settings).getByRole("button", { name: "Sync" })); + expect(await within(settings).findByText("Account sync test")).toBeVisible(); + expect(within(settings).getByText(/Notes and Planner task links can sync/)).toHaveTextContent("This sync test is not a backup."); + expect(within(settings).queryByText(/Notes stay on this device in this beta/)).not.toBeInTheDocument(); + fireEvent.click(within(settings).getByRole("button", { name: "Data and export" })); + expect(await within(settings).findByText(/Journal, Study, Clips, pins and version history stay local/)).toBeVisible(); + fireEvent.click(within(settings).getByRole("button", { name: "General" })); + fireEvent.click(await within(settings).findByRole("button", { name: "Sign out" })); + const signOut = screen.getByRole("dialog", { name: "Sign out of Notes?" }); + expect(within(signOut).getByText(/Copies already uploaded remain with your account/)).toBeVisible(); + expect(within(signOut).queryByText(/not backed up or synced/)).not.toBeInTheDocument(); + expect(store.erase).not.toHaveBeenCalled(); +}); + +it("retains truthful guidance when offline in the account test", async () => { + vi.spyOn(window.navigator, "onLine", "get").mockReturnValue(false); + await open(true); + expect(screen.getAllByText(/Account sync is unavailable while offline/).length).toBeGreaterThan(0); + expect(screen.queryByText(/This beta does not sync/)).not.toBeInTheDocument(); +}); + +it.each([false, true])("does not enroll or describe a local workspace as test sync (prop=%s)", async (mode) => { + const { settings } = await open(mode, LOCAL_LIBRARY_KEY); + fireEvent.click(within(settings).getByRole("button", { name: "Sync Planned" })); + expect(await within(settings).findByText("Notes stay on this device in this beta.")).toBeVisible(); + expect(within(settings).queryByText("Account sync test")).not.toBeInTheDocument(); +}); + +it("preserves normal account Settings when the provider gate is disabled", async () => { + const normal = await open(false); + fireEvent.click(within(normal.settings).getByRole("button", { name: "Sync Planned" })); + expect(await within(normal.settings).findByText("Notes stay on this device in this beta.")).toBeVisible(); +}); + +it("keeps sample settings Planned even if given a test capability", async () => { + render(); + fireEvent.click(screen.getByRole("button", { name: "Sync Planned" })); + expect(await screen.findByText(/Sample changes last until you leave or reload/)).toBeVisible(); + expect(screen.queryByText("Account sync test")).not.toBeInTheDocument(); +});