Account connection
-
{pairing ? "Finish in your browser." : resumeAuthorization ? "Connect this computer to continue." : "Connect this computer."}
+
{pairing ? "Finish in your browser." : resumeAuthorization ? "Connect this computer to continue." : "Connect this computer to mdbase"}
{pairing
? "Sign in and approve this computer. This window updates automatically, and there is no code to copy."
: resumeAuthorization
? "Your application request will keep waiting. Sign in so you can choose a folder on this computer, then continue the same request."
- : "Sign in so approved applications can find collections on this computer. Folder locations remain private."}
+ : "Sign in so applications can discover your collections and you can manage their access. Local folders remain on this computer, and their locations stay private."}
{pairError && {pairError}
}
{pairing ? (
diff --git a/apps/desktop/test/deep-link.test.mjs b/apps/desktop/test/deep-link.test.mjs
index 5b0dfdddd..0c078a98d 100644
--- a/apps/desktop/test/deep-link.test.mjs
+++ b/apps/desktop/test/deep-link.test.mjs
@@ -19,7 +19,7 @@ test("authorization links preserve the exact request route", () => {
});
test("other supported links retain their existing routes", () => {
- assert.equal(routeForDeepLink("mdbase-connect://paired"), "overview");
+ assert.equal(routeForDeepLink("mdbase-connect://paired"), "paired");
assert.equal(
routeForDeepLink("mdbase-connect://mirror?collection=collection-1"),
"collections:mirror:collection-1"
diff --git a/apps/desktop/test/onboarding-state.test.mjs b/apps/desktop/test/onboarding-state.test.mjs
new file mode 100644
index 000000000..665d8f23d
--- /dev/null
+++ b/apps/desktop/test/onboarding-state.test.mjs
@@ -0,0 +1,84 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import {
+ COMPLETION_RECEIPT_KEY,
+ TRANSFER_RECEIPT_KEY,
+ clearTransferProgress,
+ clearTransferReceipt,
+ consumePairingCompleted,
+ markPairingCompleted,
+ readCompletionReceipt,
+ readTransferReceipt,
+ readTransferProgress,
+ writeTransferProgress,
+ writeTransferReceipt,
+ writeCompletionReceipt
+} from "../src/renderer/onboarding-state.mts";
+
+function storage(initial = {}) {
+ const values = new Map(Object.entries(initial));
+ return {
+ getItem: (key) => values.get(key) ?? null,
+ setItem: (key, value) => values.set(key, value),
+ removeItem: (key) => values.delete(key)
+ };
+}
+
+test("pairing completion is consumed once", () => {
+ const target = storage();
+ assert.equal(consumePairingCompleted(target), false);
+ markPairingCompleted(target);
+ assert.equal(consumePairingCompleted(target), true);
+ assert.equal(consumePairingCompleted(target), false);
+});
+
+test("collection completion receipts survive renderer restarts", () => {
+ const target = storage();
+ const receipt = { collectionId: "collection-1", collectionName: "Notes", authority: "local", path: "/Notes" };
+ writeCompletionReceipt(target, receipt);
+ assert.deepEqual(readCompletionReceipt(target), receipt);
+});
+
+test("invalid completion receipt data is discarded", () => {
+ const target = storage({ [COMPLETION_RECEIPT_KEY]: '{"authority":"somewhere"}' });
+ assert.equal(readCompletionReceipt(target), null);
+ assert.equal(target.getItem(COMPLETION_RECEIPT_KEY), null);
+});
+
+test("authority transfer receipts survive renderer restarts until dismissed", () => {
+ const target = storage();
+ const receipt = {
+ collectionId: "collection-1",
+ collectionName: "Notes",
+ direction: "hosted_to_local",
+ newMainCopy: "/Notes",
+ oldAuthority: "Hosted recovery copy",
+ applications: ["Tasks"],
+ replicas: ["Laptop"],
+ completedAt: "2026-08-22T00:00:00.000Z"
+ };
+ writeTransferReceipt(target, receipt);
+ assert.deepEqual(readTransferReceipt(target), receipt);
+ clearTransferReceipt(target);
+ assert.equal(target.getItem(TRANSFER_RECEIPT_KEY), null);
+});
+
+test("invalid authority transfer receipt data is discarded", () => {
+ const target = storage({ [TRANSFER_RECEIPT_KEY]: '{"direction":"sideways"}' });
+ assert.equal(readTransferReceipt(target), null);
+ assert.equal(target.getItem(TRANSFER_RECEIPT_KEY), null);
+});
+
+test("an interrupted local authority transfer remains resumable", () => {
+ const target = storage();
+ const progress = {
+ collectionId: "collection-1",
+ collectionName: "Notes",
+ direction: "local_to_hosted",
+ phase: "uploading"
+ };
+ writeTransferProgress(target, progress);
+ assert.deepEqual(readTransferProgress(target), progress);
+ clearTransferProgress(target);
+ assert.equal(readTransferProgress(target), null);
+});
diff --git a/apps/editor/src/App.test.tsx b/apps/editor/src/App.test.tsx
index 1142d16c8..796ac414f 100644
--- a/apps/editor/src/App.test.tsx
+++ b/apps/editor/src/App.test.tsx
@@ -991,10 +991,10 @@ describe("mdbase editor", () => {
});
render( );
- await userEvent.click(await screen.findByRole("button", { name: "Choose another collection" }));
+ await userEvent.click(await screen.findByRole("button", { name: "Connect another collection" }));
expect(authorize).toHaveBeenCalledOnce();
- expect(authorize).toHaveBeenCalledWith("choose");
+ expect(authorize).toHaveBeenCalledWith("choose", { presentation: "popup" });
});
it("authorizes the requested collection from a portal deep link", async () => {
@@ -1013,10 +1013,10 @@ describe("mdbase editor", () => {
});
render( );
- await userEvent.click(await screen.findByRole("button", { name: "Choose another collection" }));
+ await userEvent.click(await screen.findByRole("button", { name: "Connect another collection" }));
expect(authorize).toHaveBeenCalledOnce();
- expect(authorize).toHaveBeenCalledWith("selected");
+ expect(authorize).toHaveBeenCalledWith("selected", { presentation: "popup" });
});
it("returns to collection authorization when the SDK invalidates a stale grant", async () => {
@@ -1046,7 +1046,7 @@ describe("mdbase editor", () => {
expect(screen.getByText(/edit notes and move notes/i)).toBeInTheDocument();
expect(screen.getByText(/shows only what needs to be added/i)).toBeInTheDocument();
await userEvent.click(screen.getByRole("button", { name: "Update access" }));
- expect(authorize).toHaveBeenCalledWith("selected");
+ expect(authorize).toHaveBeenCalledWith("selected", { presentation: "popup" });
});
it("keeps note editing available when only optional type access is missing", async () => {
@@ -1068,7 +1068,7 @@ describe("mdbase editor", () => {
expect(await screen.findByRole("heading", { name: "Type access needed" })).toBeInTheDocument();
expect(screen.getByText(/Notes are ready/i)).toBeInTheDocument();
await userEvent.click(screen.getByRole("button", { name: "Update access" }));
- expect(authorize).toHaveBeenCalledWith("selected");
+ expect(authorize).toHaveBeenCalledWith("selected", { presentation: "popup" });
});
it("shows a dropped connection and offers an immediate retry", async () => {
diff --git a/apps/editor/src/App.tsx b/apps/editor/src/App.tsx
index 895fd0674..11910ba92 100644
--- a/apps/editor/src/App.tsx
+++ b/apps/editor/src/App.tsx
@@ -991,7 +991,7 @@ export function App({ gateway }: { gateway: CollectionGateway }) {
return;
}
setConfirmation({
- title: "Choose another collection?",
+ title: "Connect another collection?",
body: Unsaved type or creation changes will be discarded when the new collection opens. Note and property changes will finish saving first.
,
confirmLabel: "Continue",
onConfirm: connectAnotherCollection
diff --git a/apps/editor/src/ConnectApp.test.tsx b/apps/editor/src/ConnectApp.test.tsx
index 255bc623b..1ccf6dc0f 100644
--- a/apps/editor/src/ConnectApp.test.tsx
+++ b/apps/editor/src/ConnectApp.test.tsx
@@ -238,7 +238,7 @@ describe("ConnectApp", () => {
expect(await screen.findByText("No computers connected")).toBeInTheDocument();
expect(screen.getByRole("link", { name: "Open mdbase connect" })).toHaveAttribute("href", "mdbase-connect://open");
- expect(screen.getByRole("link", { name: "Install the latest release" })).toHaveAttribute("href", "https://github.com/mdbase-dev/mdbase-connect/releases/latest");
+ expect(screen.getByRole("link", { name: "Install the latest release" })).toHaveAttribute("href", "https://mdbase.dev/downloads/");
});
it("shows each pending request once and describes application access plainly", async () => {
diff --git a/apps/editor/src/ConnectApp.tsx b/apps/editor/src/ConnectApp.tsx
index 5be66dcdd..d3e5a7fa3 100644
--- a/apps/editor/src/ConnectApp.tsx
+++ b/apps/editor/src/ConnectApp.tsx
@@ -44,7 +44,7 @@ const serverUrl = new URLSearchParams(location.search).get("server")
?? import.meta.env.VITE_MDBASE_CONNECT_URL
?? "https://connect.mdbase.dev";
const management = new ConnectManagementClient(serverUrl);
-const desktopReleaseUrl = "https://github.com/mdbase-dev/mdbase-connect/releases/latest";
+const desktopReleaseUrl = "https://mdbase.dev/downloads/";
const allOperations = [
"describe", "changes", "read", "query", "list_views", "execute_view", "read_view_source", "validate",
"create", "update", "delete", "rename", "create_view_source", "update_view_source", "delete_view_source",
diff --git a/apps/editor/src/ConnectionScreens.tsx b/apps/editor/src/ConnectionScreens.tsx
index 39e56b32b..c9fb6d064 100644
--- a/apps/editor/src/ConnectionScreens.tsx
+++ b/apps/editor/src/ConnectionScreens.tsx
@@ -45,7 +45,7 @@ export function ConnectScreen({ notice, missingCapabilities = [], connections, o
{updatingAccess
? "Update access"
: connections.length
- ? "Choose another collection"
+ ? "Connect another collection"
: "Choose a collection"}
{updatingAccess
? "mdbase connect keeps the access you already approved and shows only what needs to be added."
@@ -82,7 +82,7 @@ export function CollectionSwitcher({ activeCollectionId, connections, displayNam
})}
- Choose another collection
+ Connect another collection
;
}
diff --git a/apps/editor/src/collection-authorization.ts b/apps/editor/src/collection-authorization.ts
index 6ea5f0097..994b71826 100644
--- a/apps/editor/src/collection-authorization.ts
+++ b/apps/editor/src/collection-authorization.ts
@@ -14,7 +14,7 @@ export function useCollectionAuthorization(input: {
}) {
async function authorizeCollection(target: CollectionAuthorizationTarget) {
const previous = input.gateway.sessionSnapshot();
- await input.gateway.authorize(target);
+ await input.gateway.authorize(target, { presentation: "popup" });
const next = input.gateway.sessionSnapshot();
input.setSessionSnapshot(next);
if (
diff --git a/apps/editor/src/model.ts b/apps/editor/src/model.ts
index a102b47d7..967b092a3 100644
--- a/apps/editor/src/model.ts
+++ b/apps/editor/src/model.ts
@@ -194,6 +194,7 @@ export interface CollectionGateway {
export interface CollectionAuthorizationOptions {
signal?: AbortSignal;
+ presentation?: "redirect" | "popup";
}
export type TypeDocument = CollectionTypeDocument;
diff --git a/apps/editor/tests/authorization-recovery.spec.ts b/apps/editor/tests/authorization-recovery.spec.ts
index ac374fd5c..8c1f04a90 100644
--- a/apps/editor/tests/authorization-recovery.spec.ts
+++ b/apps/editor/tests/authorization-recovery.spec.ts
@@ -196,8 +196,11 @@ test("recovers from a stale local grant without bypassing the connector", async
);
}, { configuredServerUrl: serverUrl, configuredManifestPath: manifestPath })).toBeNull();
+ const popupPromise = page.waitForEvent("popup");
await page.getByRole("button", { name: "Choose a collection" }).click();
- await expect(page).toHaveURL(/connect\.mdbase\.dev\/oauth\/authorize/);
+ const popup = await popupPromise;
+ await expect(popup).toHaveURL(/connect\.mdbase\.dev\/oauth\/authorize/);
+ await popup.close();
});
async function json(route: Route, body: unknown, status = 200): Promise {
diff --git a/apps/editor/tests/remote-authority-editor.spec.ts b/apps/editor/tests/remote-authority-editor.spec.ts
index ab8846058..b7dcf1c69 100644
--- a/apps/editor/tests/remote-authority-editor.spec.ts
+++ b/apps/editor/tests/remote-authority-editor.spec.ts
@@ -15,12 +15,16 @@ test("chooses a remote authority collection and performs CRUD through its provid
await page.goto("/");
await expect(page.getByText("Choose the collection you want to write in.")).toBeVisible();
+ const popupPromise = page.waitForEvent("popup");
await page.getByRole("button", { name: "Choose a collection" }).click();
- await expect(page).toHaveURL(/connect\.mdbase\.dev\/oauth\/authorize/);
- const collection = page.getByRole("combobox", { name: "Collection" });
+ const popup = await popupPromise;
+ await expect(popup).toHaveURL(/connect\.mdbase\.dev\/oauth\/authorize/);
+ const collection = popup.getByRole("combobox", { name: "Collection" });
await expect(collection).toHaveValue(collectionId);
await expect(collection).toContainText("Hosted writing · Hosted by mdbase");
- await page.getByRole("button", { name: "Allow access" }).click();
+ const popupClosed = popup.waitForEvent("close");
+ await popup.getByRole("button", { name: "Allow access" }).click();
+ await popupClosed;
await expect(page.getByRole("heading", { name: "Hosted writing" })).toBeVisible();
await expect(page.getByRole("textbox", { name: "Note title" })).toHaveValue("Welcome to hosted writing");
@@ -65,20 +69,28 @@ test("returns to the newly chosen remote authority when switching collections",
await authority.install();
await page.goto("/");
+ const firstPopupPromise = page.waitForEvent("popup");
await page.getByRole("button", { name: "Choose a collection" }).click();
- await expect(page).toHaveURL(/connect\.mdbase\.dev\/oauth\/authorize/);
- await page.getByRole("button", { name: "Allow access" }).click();
+ const firstPopup = await firstPopupPromise;
+ await expect(firstPopup).toHaveURL(/connect\.mdbase\.dev\/oauth\/authorize/);
+ const firstPopupClosed = firstPopup.waitForEvent("close");
+ await firstPopup.getByRole("button", { name: "Allow access" }).click();
+ await firstPopupClosed;
await expect(page.getByRole("heading", { name: "Hosted writing" })).toBeVisible();
await page.getByRole("button", {
name: "Switch collection, current collection Hosted writing"
}).click();
- await page.getByRole("button", { name: "Choose another collection" }).click();
+ const secondPopupPromise = page.waitForEvent("popup");
+ await page.getByRole("button", { name: "Connect another collection" }).click();
- await expect(page).toHaveURL(/connect\.mdbase\.dev\/oauth\/authorize/);
- const collection = page.getByRole("combobox", { name: "Collection" });
+ const secondPopup = await secondPopupPromise;
+ await expect(secondPopup).toHaveURL(/connect\.mdbase\.dev\/oauth\/authorize/);
+ const collection = secondPopup.getByRole("combobox", { name: "Collection" });
await collection.selectOption(secondCollectionId);
- await page.getByRole("button", { name: "Allow access" }).click();
+ const secondPopupClosed = secondPopup.waitForEvent("close");
+ await secondPopup.getByRole("button", { name: "Allow access" }).click();
+ await secondPopupClosed;
await expect(page).toHaveURL(new RegExp(`collection=${secondCollectionId}`));
await expect(page.getByRole("heading", { name: "Research" })).toBeVisible();
diff --git a/apps/portal/src/api.ts b/apps/portal/src/api.ts
index a34e756fe..466a369be 100644
--- a/apps/portal/src/api.ts
+++ b/apps/portal/src/api.ts
@@ -89,6 +89,10 @@ export interface PendingAuthorization {
requirements: ApplicationRequirements;
provisions: ApplicationProvisions;
notifications: ApplicationNotifications;
+ existing_access?: Array<{
+ collection_id: string;
+ operations: string[];
+ }>;
available_collections?: AvailableCollection[];
unavailable_connectors?: UnavailableConnector[];
}
diff --git a/apps/portal/src/authorization-permissions.tsx b/apps/portal/src/authorization-permissions.tsx
index f98567a59..77a1baae2 100644
--- a/apps/portal/src/authorization-permissions.tsx
+++ b/apps/portal/src/authorization-permissions.tsx
@@ -1,6 +1,22 @@
import { groupAuthorizationOperations } from "@mdbase/connect-ui/access";
import type { PendingAuthorization } from "./api";
+export function PermissionDelta({ existingAccess, collectionId, selected }: {
+ existingAccess: PendingAuthorization["existing_access"];
+ collectionId: string;
+ selected: ReadonlySet;
+}) {
+ const existing = new Set(existingAccess?.find((access) =>
+ access.collection_id === collectionId)?.operations ?? []);
+ if (existing.size === 0) return null;
+ const approved = [...selected].filter((operation) => existing.has(operation)).length;
+ const added = selected.size - approved;
+ return
+ {approved} already approved
+ {added} {added === 1 ? "action" : "actions"} added by this request
+
;
+}
+
export function PermissionCapabilitySummary({
groups,
selected,
diff --git a/apps/portal/src/authorization-view.tsx b/apps/portal/src/authorization-view.tsx
index a8c27d439..85b96e436 100644
--- a/apps/portal/src/authorization-view.tsx
+++ b/apps/portal/src/authorization-view.tsx
@@ -32,6 +32,7 @@ import {
FilePermissionSummary,
NotificationAccess,
PermissionCapabilitySummary,
+ PermissionDelta,
PermissionChoices
} from "./authorization-permissions";
import {
@@ -44,7 +45,6 @@ import {
scopeDescription
} from "./portal-model";
import { Loading, PageBrand, useSystemTheme } from "./portal-ui";
-
export function DeviceAuthorization() {
const initialCode = formatDeviceCode(new URLSearchParams(location.search).get("user_code") ?? "");
const [code, setCode] = useState(initialCode);
@@ -284,7 +284,7 @@ function DesktopContinuation({ request, onReviewHere }: {
Open mdbase connect
Review in this browser
- If the desktop app does not open, install the latest release , then return to this page. The request expires {relativeTime(request.expires_at)}.
+ If the desktop app does not open, install the current Connect release , then return to this page. The request expires {relativeTime(request.expires_at)}.
);
}
@@ -862,6 +862,7 @@ export function ApprovalForm({