From 60a64fe39dcb04eb105148549364366f9d128388 Mon Sep 17 00:00:00 2001 From: Lakshmi Tanmay Date: Sun, 27 Sep 2026 19:48:35 +0530 Subject: [PATCH 1/2] feat: combine GitHub sync settings --- src/lib/components/settings-dialog.svelte | 76 ++++++++++------------- src/lib/components/settings-types.ts | 2 - src/routes/page-controller.svelte.ts | 23 ++----- 3 files changed, 37 insertions(+), 64 deletions(-) diff --git a/src/lib/components/settings-dialog.svelte b/src/lib/components/settings-dialog.svelte index db6ae87..5506e71 100644 --- a/src/lib/components/settings-dialog.svelte +++ b/src/lib/components/settings-dialog.svelte @@ -98,8 +98,6 @@ { id: 'themes', label: 'Themes' }, { id: 'shortcuts', label: 'Keyboard shortcuts' }, { id: 'github', label: 'Backup & sync' }, - { id: 'repository', label: 'Sync repository' }, - { id: 'backup', label: 'Sync status' }, { id: 'storage', label: 'Storage choices' }, { id: 'transfer', label: 'Import & export' }, { id: 'vault', label: 'Vault' } @@ -140,7 +138,7 @@ ); $effect(() => { - if (section === 'repository' && connected && isOnline && !repositoriesLoaded) void loadRepositories(); + if (section === 'github' && connected && isOnline && !repositoriesLoaded) void loadRepositories(); if (section === 'storage' && !usage && usageState === 'idle') void loadUsage(); }); @@ -444,22 +442,33 @@
{githubUser.name || githubUser.login}@{githubUser.login} - +
- {:else} -
- - Local only{githubMessage || 'Sign in to enable GitHub backup and cross-device sync.'} - +
- {/if} - {:else if section === 'repository'} -

Sync repository

- {#if !connected} -

Sign in with GitHub to choose where this vault is backed up for cross-device restore.

- {:else} + {#if backupMessage} +

+ {backupMessage} + {#if backupCommitUrl}View commit {/if} +

+ {/if} +

Sync repository

“{vaultName}” backs up on its own. Only private repositories with write access can be used, and notes are written under the directory below.

@@ -491,34 +500,15 @@
- {/if} - {:else if section === 'backup'} -

Backup and sync status

- {#if !githubBackup} -

“{vaultName}” has no repository yet. Choose one in the Repository section to enable backups for this repository alone.

{:else} -
-
Repository
{githubBackup.owner}/{githubBackup.repository}
-
GitHub account
@{githubBackup.githubAccountLogin || 'Needs re-selection'}
-
Branch
{githubBackup.branch}
-
Directory
{githubBackup.directory || 'repository root'}
-
Last backup
{formatDate(githubBackup.lastBackedUpAt)}
-
Last commit
{githubBackup.lastCommitSha ? githubBackup.lastCommitSha.slice(0, 7) : 'None yet'}
-
Pending changes
{pendingBackupCount === 0 ? 'Up to date' : `${pendingBackupCount} ${pendingBackupCount === 1 ? 'change' : 'changes'}`}
-
- {/if} - {#if backupMessage} -

- {backupMessage} - {#if backupCommitUrl}View commit {/if} -

+
+ + Local only{githubMessage || 'Sign in to enable GitHub backup and cross-device sync.'} + +
{/if} -
- - -
{:else if section === 'storage'}

Storage choices

Onyx always keeps a working vault on this device. Add a folder for accessible local files or GitHub for an off-device backup you can restore elsewhere.

@@ -559,7 +549,7 @@
GitHub backup and syncOptional off-device history for restoring this vault on another device.

{connected ? githubBackup ? `Backing up to ${githubBackup.owner}/${githubBackup.repository}.` : 'Signed in. Choose a private repository to finish setup.' : 'Not enabled. Your local vault continues to work normally.'}

-
+
diff --git a/src/lib/components/settings-types.ts b/src/lib/components/settings-types.ts index 55c65d6..208ffab 100644 --- a/src/lib/components/settings-types.ts +++ b/src/lib/components/settings-types.ts @@ -3,8 +3,6 @@ export type SettingsSection = | "themes" | "shortcuts" | "github" - | "repository" - | "backup" | "storage" | "transfer" | "vault"; diff --git a/src/routes/page-controller.svelte.ts b/src/routes/page-controller.svelte.ts index 23145b7..e624887 100644 --- a/src/routes/page-controller.svelte.ts +++ b/src/routes/page-controller.svelte.ts @@ -1051,25 +1051,10 @@ Press \`${commandPaletteShortcut}\` for the command palette, \`${saveShortcut}\` group: "Settings", label: "GitHub backup & sync settings", icon: CloudUpload, - keywords: "account sign in backup cross device", + keywords: + "account sign in backup cross device repository branch directory remote status history commit pending changes", run: () => openSettings("github"), }, - { - id: "settings-repository", - group: "Settings", - label: "Sync repository settings", - icon: FolderOutput, - keywords: "github repository branch directory remote", - run: () => openSettings("repository"), - }, - { - id: "settings-backup", - group: "Settings", - label: "Sync status settings", - icon: CloudDownload, - keywords: "backup history commit pending changes", - run: () => openSettings("backup"), - }, { id: "storage", group: "Settings", @@ -1387,7 +1372,7 @@ Press \`${commandPaletteShortcut}\` for the command palette, \`${saveShortcut}\` if (!isOnline || !vault || backupState === "backing-up") return; if (markdown !== lastSavedMarkdown && !(await saveDraft())) return; if (!githubBackup) { - void openSettings("repository").catch(() => undefined); + void openSettings("github").catch(() => undefined); return; } await runBackup(githubBackup); @@ -1433,7 +1418,7 @@ Press \`${commandPaletteShortcut}\` for the command palette, \`${saveShortcut}\` backupState = "idle"; backupCommitUrl = ""; backupMessage = `Backups now target ${state.owner}/${state.repository}.`; - settingsSection = "backup"; + settingsSection = "github"; } catch (error) { showBackupError(error); } From 49075be16639853b0bec3bd3e2f97966006dac28 Mon Sep 17 00:00:00 2001 From: Lakshmi Tanmay Date: Sun, 27 Sep 2026 19:48:42 +0530 Subject: [PATCH 2/2] test: cover the combined sync settings --- src/routes/page.svelte.e2e.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/routes/page.svelte.e2e.ts b/src/routes/page.svelte.e2e.ts index e908389..935f7e3 100644 --- a/src/routes/page.svelte.e2e.ts +++ b/src/routes/page.svelte.e2e.ts @@ -484,8 +484,6 @@ test("opens every settings section from the command palette", async ({ page }) = ["settings-themes", "Theme settings", "Themes"], ["shortcuts", "Keyboard shortcuts", "Keyboard shortcuts"], ["settings-github", "GitHub backup & sync settings", "Backup & sync"], - ["settings-repository", "Sync repository settings", "Sync repository"], - ["settings-backup", "Sync status settings", "Sync status"], ["storage", "Storage choices", "Storage choices"], ["settings-transfer", "Import & export settings", "Import & export"], ["settings-vault", "Vault settings", "Vault"], @@ -804,6 +802,9 @@ test("keeps the editor usable and pauses GitHub features offline", async ({ cont page.getByText("GitHub settings are paused until your connection returns."), ).toBeVisible(); await expect(page.getByRole("button", { name: "Sign in with GitHub" })).toBeDisabled(); + await expect(page.getByRole("button", { name: "Sync repository", exact: true })).toHaveCount(0); + await expect(page.getByRole("button", { name: "Sync status", exact: true })).toHaveCount(0); + await expect(page.getByLabel("Repository", { exact: true })).toHaveCount(0); await page.getByRole("button", { name: "Close settings" }).click(); const editor = page.getByRole("textbox", { name: "Markdown editor" }); @@ -1910,9 +1911,12 @@ test("binds a backup repository to the authenticated GitHub account", async ({ p await page.goto("/"); await expect(page.getByText("@octocat").first()).toBeVisible({ timeout: 12_000 }); await page.getByRole("button", { name: "Settings", exact: true }).click(); - await page.getByRole("button", { name: "Sync repository", exact: true }).click(); + await page.getByRole("button", { name: "Backup & sync", exact: true }).click(); await page.getByLabel("Repository", { exact: true }).selectOption("octocat/onyx-vault"); await page.getByRole("button", { name: "Use this repository" }).click(); + await expect(page.getByRole("heading", { name: "Sync status" })).toBeVisible(); + await expect(page.getByRole("button", { name: "Sync repository", exact: true })).toHaveCount(0); + await expect(page.getByRole("button", { name: "Sync status", exact: true })).toHaveCount(0); account = { id: 2, login: "hubot" }; await page.evaluate(() => window.dispatchEvent(new Event("online"))); @@ -1974,7 +1978,7 @@ test("refuses to upload a backup when its repository is public", async ({ page } await page.goto("/"); await expect(page.getByText("@octocat").first()).toBeVisible({ timeout: 12_000 }); await page.getByRole("button", { name: "Settings", exact: true }).click(); - await page.getByRole("button", { name: "Sync repository", exact: true }).click(); + await page.getByRole("button", { name: "Backup & sync", exact: true }).click(); await page.getByLabel("Repository", { exact: true }).selectOption("octocat/onyx-vault"); await page.getByRole("button", { name: "Use this repository" }).click(); @@ -2166,7 +2170,7 @@ test("restores a selected GitHub commit into the local vault", async ({ page }) await page.keyboard.press("ControlOrMeta+S"); await waitForBlockedVaultWrite(page); await page.getByRole("button", { name: "Settings", exact: true }).click(); - await page.getByRole("button", { name: "Sync status" }).click(); + await page.getByRole("button", { name: "Backup & sync", exact: true }).click(); await page.getByRole("button", { name: "Restore a commit" }).click(); await expect(page.getByRole("dialog", { name: "Choose a backup commit" })).toBeHidden({ timeout: 200,