diff --git a/docs/features.md b/docs/features.md index ac02136c..837b6677 100644 --- a/docs/features.md +++ b/docs/features.md @@ -11,7 +11,7 @@ Everything Diff Bro does, in detail. The [README](../README.md) has the short ve | **Dependencies** | A lockfile pair reads as the dependency moves it describes, not as the four thousand lines it is written in: which packages were added, removed, bumped or downgraded, the semver step of each, and — the part that matters — which of them you actually asked for rather than got carried along. `package-lock.json`, `pnpm-lock.yaml`, `yarn.lock`, `go.sum` and `composer.lock`. Nothing is fetched; every fact comes out of the file in front of you. | | **Huge files** | Past 32 MB a file is indexed by line instead of loaded, and the rows you're looking at are read from disk as you scroll — a multi-gigabyte log opens in seconds. Marked as streamed, with the few actions that need the whole text saying so rather than half-working. | | **Keep** | Saved diffs: encrypted, tagged, optionally auto-expiring. The list is nested sections, one for each level of a tag (`infra/prod` sits under `infra`), and each remembers whether it is open; starred rows sit in Favorites above them. Click into the search box (or type `#`) to scope the list to one branch. Settings ▸ Behaviour can list an item with several tags once, nested by its tags, instead of under each one. Drag a row onto another to arrange its section. **Show in folder** on a saved diff or snippet row selects the encrypted file that holds it. Your open tabs come back on the next launch, and the strip can be told to close the oldest comparison to make room for a new one. | -| **Share** | One signed file only the recipients you ticked can open, carrying the expiry you chose so every copy dies at the same moment. Give a trusted key an email address and Diff Bro opens an addressed message in your own mail app with the sealed file on the clipboard — it never sends anything itself. Keys have their own panel, opened from Security ▸ Trusted Keys ▸ Manage Trusted Keys…: your key, drawn as a small mark from its fingerprint so you recognise it again, with Email, Copy and Save beside it, and the keys you trust listed under it to rename, give an address or remove. Before the first swap the panel says how sharing starts, and a key copied out of any chat app is offered — fingerprint first — when you press Add. | +| **Share** | One signed file only the recipients you ticked can open, carrying the expiry you chose so every copy dies at the same moment. Give a trusted key an email address and Diff Bro opens an addressed message in your own mail app with the sealed file on the clipboard — it never sends anything itself. Keys have their own panel, the Keys segment at the top of the sidebar: your key, drawn as a small mark from its fingerprint so you recognise it again, with Email, Copy and Save beside it, and the keys you trust listed under it to rename, give an address or remove. Before the first swap the panel says how sharing starts, and a key copied out of any chat app is offered — fingerprint first — when you press Add. | | **Export as image** | A real screenshot of the diff view — your theme, panes and highlighting — cropped to the change and stitched if it's taller than the window. Snippets go the same way, and a Mermaid snippet leaves as its rendered diagram. | | **Snippets** | An encrypted, tagged text library. A snippet opens as a tab beside your comparisons, with its name and tags above the text (three tags, then a +N that lists the rest) and the whole window to edit in — click into it to edit in place, and Save (or Ctrl/Cmd+S) lights up once something changed; a snippet already in the library also saves itself every five seconds while you edit. A file dropped on an open snippet opens in a new tab beside it, and Format on a saved snippet asks first (Ctrl/Cmd+Z undoes it). Switch away and back without losing a half-written draft, and Compare with… puts it on the left of a new comparison. You can also drag one straight into the diff pane, from its sidebar row or its open tab (unsaved edits included); **⋯ ▸ Export as file…** (⌥⌘S) writes one to disk wherever you pick, and **File ▸ Open File as Snippet…** (⌘O, or the ⋯ in the Snippets panel's header) opens a text file as an unsaved snippet — two snippets compare like any two files, and editing one updates the comparison on screen. Per-language highlighting, live Mermaid (readable light or dark whatever the app is wearing), Markdown/Jira rendered view that you can **type straight into** — headings, nested lists, task lists, tables, strikethrough and code, with a formatting row that writes them for you, and task boxes you tick where they are drawn — and secret snippets that render as `****`, marked from a row's right-click menu. Syntax, and Rendered / Plain for Markdown and Jira, are text in the footer beside zoom; Format is in ⋯. Every editing session keeps the version it replaced — History (in ⋯, or the clock) docks beside the snippet and lists them by timestamp, each diffed against its predecessor, any of them a copy away. Name one `Standup {{today}}` and the placeholder resolves as you save — `{{now}}`, `{{week}}`, `{{weekday}}` and the rest are listed under the status bar's template tags, shown once the text holds a `{{fill-in}}`. Naming is completed inline: type a few characters and the rest of the shared head of your existing names appears ahead of the caret, Tab to take it. Drag a row onto another to arrange the library by hand, and right-click one to give it a colour (pick it again to take it off) — six of them, painted across the whole row, so a handful of snippets group by eye across whatever tags they carry. Nothing filters or searches by it; it is there to be seen. | | **Quick look-up** | A global shortcut opens a one-column search card, always the same size, over your snippets and diffs without raising the app; copy one straight to the clipboard, or capture a new one with `Ctrl/Cmd+N` — whatever you searched for becomes its name, and the body is syntax-coloured as you type in whatever language it turns out to be. | diff --git a/docs/security.md b/docs/security.md index 6f1f5330..3ada670d 100644 --- a/docs/security.md +++ b/docs/security.md @@ -260,8 +260,8 @@ sees the fingerprints (not the names) it was sealed for. **Filename integrity.** The on-disk name is a hash of the (authenticated) ciphertext, so it leaks nothing about the diff and a **renamed file is refused** on import. **Trusted keys must be named**: importing or dropping a `.diffbrokey` -prompts for a label, and adding your own key is rejected. Manage names via -**Security → Manage Trusted Keys**. +prompts for a label, and adding your own key is rejected. Manage names in the +**Keys** segment at the top of the sidebar. **No replay protection (by design).** Within its TTL a `.diffbro` file can be imported repeatedly, and a re-delivered old share is indistinguishable from a diff --git a/e2e/file-menu.spec.mjs b/e2e/file-menu.spec.mjs new file mode 100644 index 00000000..6ab548fb --- /dev/null +++ b/e2e/file-menu.spec.mjs @@ -0,0 +1,45 @@ +import { rmSync } from 'node:fs' +import { test, expect, launchApp, freshUserDataDir, firstReadyPage, openMenu } from './fixtures.mjs' + +const fileItems = async (page) => { + await page.locator('.menubar').getByRole('button', { name: 'File', exact: true }).click() + const labels = await page.locator('.menubar .menu > .dropdown > .item').allTextContents() + await page.keyboard.press('Escape') + return labels.map((l) => l.trim()) +} + +test('File offers no Next or Previous Comparison, and Ctrl+Tab still moves between tabs', async ({ + page +}) => { + const labels = await fileItems(page) + expect(labels.some((l) => /Next Comparison|Previous Comparison/.test(l))).toBe(false) + + const tabs = page.locator('.diff-tabs .tab') + const newTab = page + .locator('.diff-tabs') + .getByRole('button', { name: 'New comparison', exact: true }) + await newTab.click() + await newTab.click() + expect(await tabs.count()).toBeGreaterThanOrEqual(2) + const active = () => + tabs.evaluateAll((els) => els.findIndex((el) => el.classList.contains('active'))) + const second = await active() + await page.keyboard.press('Control+Tab') + await expect.poll(active).not.toBe(second) + await page.keyboard.press('Control+Shift+Tab') + await expect.poll(active).toBe(second) +}) + +test('File ▸ Exit quits the app outright', async () => { + const dir = freshUserDataDir() + const app = await launchApp(dir) + try { + const page = await firstReadyPage(app) + const closed = new Promise((resolve) => app.once('close', resolve)) + await openMenu(page, 'File', 'Exit') + await closed + } finally { + await app.close().catch(() => {}) + rmSync(dir, { recursive: true, force: true }) + } +}) diff --git a/e2e/fixtures.mjs b/e2e/fixtures.mjs index ebd817b3..fce91565 100644 --- a/e2e/fixtures.mjs +++ b/e2e/fixtures.mjs @@ -349,12 +349,7 @@ export { expect } // took until a CI runner to fire. export const newSnippetButton = (page) => page.locator('[data-tour="snippet-new"]') -// Keys has no segment (#144): it is reached from Security ▸ Trusted Keys. export async function showPanel(page, panel) { - if (panel === 'keys') { - if (await page.locator('.usb-panel[data-panel="keys"]').isVisible()) return - return openMenu(page, 'Security', 'Trusted Keys', 'Manage Trusted Keys…') - } const show = page.getByRole('button', { name: 'Show the sidebar' }) if (await show.count()) { await page.locator('.sidebar-strip').hover() diff --git a/e2e/keys-panel.spec.mjs b/e2e/keys-panel.spec.mjs index 2e5e067e..e0fb6858 100644 --- a/e2e/keys-panel.spec.mjs +++ b/e2e/keys-panel.spec.mjs @@ -10,9 +10,9 @@ import { showPanel } from './fixtures.mjs' -test('the toolbar carries no key buttons, and Keys is not a sidebar segment', async ({ page }) => { +test('the toolbar carries no key buttons; Keys is a sidebar segment (#263)', async ({ page }) => { await expect(page.getByRole('button', { name: 'My key' })).toHaveCount(0) - await expect(page.locator('.sidebar-nav [data-value="keys"]')).toHaveCount(0) + await expect(page.locator('.sidebar-nav [data-value="keys"]')).toHaveCount(1) }) test('before any swap, the panel shows your key and how sharing starts', async ({ page }) => { diff --git a/e2e/sealed-recipients.spec.mjs b/e2e/sealed-recipients.spec.mjs index fc168785..42e5bfef 100644 --- a/e2e/sealed-recipients.spec.mjs +++ b/e2e/sealed-recipients.spec.mjs @@ -1,4 +1,4 @@ -import { test, expect, openMenu, stubSaveDialog, turnLanOff } from './fixtures.mjs' +import { test, expect, stubSaveDialog, turnLanOff, showPanel } from './fixtures.mjs' import { generateKeyPairSync } from 'node:crypto' import { mkdtempSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' @@ -62,7 +62,7 @@ test('removing a trusted key shows what has already been sealed for it', async ( await stubSaveDialog(app, join(dir, 'sealed.diffbro')) await saveAndSeal(page, 'E2E exposure') - await openMenu(page, 'Security', 'Trusted Keys', 'Manage Trusted Keys') + await showPanel(page, 'keys') const manager = page.locator('.keys-panel') await manager.locator('li', { hasText: PEER }).getByRole('button', { name: 'Remove' }).click() @@ -87,7 +87,7 @@ test('a cancelled seal leaves no record behind', async ({ app, page }) => { }) await saveAndSeal(page, 'E2E cancelled') - await openMenu(page, 'Security', 'Trusted Keys', 'Manage Trusted Keys') + await showPanel(page, 'keys') const manager = page.locator('.keys-panel') await manager.locator('li', { hasText: PEER }).getByRole('button', { name: 'Remove' }).click() diff --git a/e2e/segmented-nav.spec.mjs b/e2e/segmented-nav.spec.mjs index 91afa074..c7b4f501 100644 --- a/e2e/segmented-nav.spec.mjs +++ b/e2e/segmented-nav.spec.mjs @@ -1,14 +1,14 @@ -import { test, expect, openMenu } from './fixtures.mjs' +import { test, expect } from './fixtures.mjs' const nav = (page) => page.locator('.sidebar-nav') const segment = (page, panel) => nav(page).locator(`[data-value="${panel}"]`) const aside = (page) => page.locator('aside.saved') -test('four places, in a fixed order, at the top of the sidebar; no rail', async ({ page }) => { +test('five places, in a fixed order, at the top of the sidebar; no rail', async ({ page }) => { const order = await nav(page) .locator('[data-value]') .evaluateAll((els) => els.map((el) => el.dataset.value)) - expect(order).toEqual(['home', 'diffs', 'snippets', 'tools']) + expect(order).toEqual(['home', 'diffs', 'snippets', 'tools', 'keys']) await expect(page.locator('.rail')).toHaveCount(0) for (const panel of order) { @@ -34,9 +34,14 @@ test('arrow keys move between the segments', async ({ page }) => { await expect(segment(page, 'snippets')).toHaveAttribute('aria-pressed', 'true') }) -test('Keys opens from the Security menu', async ({ page }) => { - await openMenu(page, 'Security', 'Trusted Keys', 'Manage Trusted Keys…') +test('Trusted keys is a segment, and no longer a menu item', async ({ page }) => { + await segment(page, 'keys').click() await expect(page.locator('.usb-panel[data-panel="keys"]')).toBeVisible() + await page.locator('.menubar').getByRole('button', { name: 'Security', exact: true }).click() + const menu = page.locator('.menubar .menu > .dropdown') + await menu.locator(':scope > .submenu > .item', { hasText: 'Trusted Keys' }).hover() + await expect(menu.locator('.flyout .item', { hasText: 'Add Trusted Key' })).toBeVisible() + await expect(menu.locator('.flyout .item', { hasText: 'Manage Trusted Keys' })).toHaveCount(0) }) test('the edge handle hides the sidebar, and the left strip brings it back', async ({ page }) => { diff --git a/e2e/sharing.spec.mjs b/e2e/sharing.spec.mjs index 40df9635..144df149 100644 --- a/e2e/sharing.spec.mjs +++ b/e2e/sharing.spec.mjs @@ -114,7 +114,7 @@ test('two peers exchange keys, share a sealed diff, and import it', async () => await expect(externalHelp).toBeHidden() // the help text clears once a diff is there // 5. Manage trusted keys on Alice: rename Bob, then remove him. - await openMenu(pageA, 'Security', 'Trusted Keys', 'Manage Trusted Keys') + await showPanel(pageA, 'keys') const mgr = pageA.locator('.keys-panel') await expect(mgr.getByText('Bob', { exact: true })).toBeVisible() await mgr.getByRole('button', { name: 'Rename' }).click() diff --git a/e2e/trusted-keys.spec.mjs b/e2e/trusted-keys.spec.mjs index c9261e45..17e69864 100644 --- a/e2e/trusted-keys.spec.mjs +++ b/e2e/trusted-keys.spec.mjs @@ -1,7 +1,14 @@ import { rmSync, writeFileSync } from 'node:fs' import { randomBytes } from 'node:crypto' import { join } from 'node:path' -import { test, expect, launchApp, freshUserDataDir, firstReadyPage, openMenu } from './fixtures.mjs' +import { + test, + expect, + launchApp, + freshUserDataDir, + firstReadyPage, + showPanel +} from './fixtures.mjs' // The single-key trust round-trip is covered in sharing.spec. This one stresses // the *manager* UI: does it stay stable and usable with a realistic org's worth @@ -33,7 +40,7 @@ test('Escape cancels an in-progress edit and leaves the list in place', async () const page = await firstReadyPage(app) try { - await openMenu(page, 'Security', 'Trusted Keys', 'Manage Trusted Keys') + await showPanel(page, 'keys') const mgr = page.locator('.keys-panel') await expect(mgr).toBeVisible() @@ -68,7 +75,7 @@ test('the trusted-keys manager stays stable with 15 keys', async () => { let page = await firstReadyPage(app) try { - await openMenu(page, 'Security', 'Trusted Keys', 'Manage Trusted Keys') + await showPanel(page, 'keys') const mgr = page.locator('.keys-panel') await expect(mgr).toBeVisible() @@ -118,7 +125,7 @@ test('the trusted-keys manager stays stable with 15 keys', async () => { await app.close() app = await launchApp(dir) page = await firstReadyPage(app) - await openMenu(page, 'Security', 'Trusted Keys', 'Manage Trusted Keys') + await showPanel(page, 'keys') const mgr2 = page.locator('.keys-panel') await expect(mgr2.locator('li.key')).toHaveCount(N - 2) await expect(mgr2.getByText('Teammate 08 — laptop')).toBeVisible() diff --git a/src/main/menu.js b/src/main/menu.js index d669a15d..bd96c59d 100644 --- a/src/main/menu.js +++ b/src/main/menu.js @@ -174,12 +174,12 @@ const fileMenu = (send, isMac) => ({ fileItem(send, 'newComparison', 'CmdOrCtrl+Shift+T', 'tab-new'), fileItem(send, 'newSnippet', null, 'open-new-snippet'), fileItem(send, 'closeComparison', 'CmdOrCtrl+Shift+W', 'tab-close'), - fileItem(send, 'nextComparison', 'Ctrl+Tab', 'tab-next'), - fileItem(send, 'prevComparison', 'Ctrl+Shift+Tab', 'tab-prev'), { type: 'separator' }, settingsItem(send), { type: 'separator' }, - isMac ? { role: 'close' } : { role: 'quit' } + ...(isMac ? [{ role: 'close' }] : []), + // Quits outright: closing the window only hides it to the tray (Windows) or the Dock (macOS). + { label: t('menu.file.exit'), click: () => app.quit() } ] }) diff --git a/src/main/menuSections.js b/src/main/menuSections.js index 7e2a2fb3..a3b7d7f6 100644 --- a/src/main/menuSections.js +++ b/src/main/menuSections.js @@ -55,10 +55,7 @@ export const securityMenu = (send) => ({ item(send, 'security.sharePublicKey', null, 'export-pubkey'), item(send, 'security.replaceKey', null, 'rotate-key') ]), - group('security.trustedKeys', [ - item(send, 'security.addTrustedKey', null, 'add-trusted-key'), - item(send, 'security.manageTrustedKeys', null, 'manage-keys') - ]), + group('security.trustedKeys', [item(send, 'security.addTrustedKey', null, 'add-trusted-key')]), { type: 'separator' }, group('security.configuration', [ item(send, 'security.backUp', null, 'config-backup'), diff --git a/src/renderer/src/App.vue b/src/renderer/src/App.vue index 58816eac..83f169e1 100644 --- a/src/renderer/src/App.vue +++ b/src/renderer/src/App.vue @@ -5,6 +5,7 @@ import { SnippetShot, useImageExportStore } from './features/imageExport' import { TourLayer } from './features/onboarding' import { usePasteToCompareStore } from './features/pasteToCompare' import { useCommands } from './composables/useCommands' +import { useTabCycleKeys } from './composables/useTabCycleKeys' import { useSettingsStore } from './stores/settingsStore' import { useWindowFileDrop } from './composables/useFileDrop' import { useSnippetDiffSync } from './composables/useSnippetDiffSync' @@ -54,6 +55,7 @@ const settings = useSettingsStore() // One side loaded: which one is still wanted. const missingSide = computed(() => (store.left ? 'right' : 'left')) const { runFromMenu, runCli } = useCommands() +useTabCycleKeys(runFromMenu) settings.initTheme() window.api.onMenuAction((action) => runFromMenu(action)) diff --git a/src/renderer/src/components/SidebarNav.vue b/src/renderer/src/components/SidebarNav.vue index 3ba0ba01..9c860766 100644 --- a/src/renderer/src/components/SidebarNav.vue +++ b/src/renderer/src/components/SidebarNav.vue @@ -1,5 +1,5 @@