Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/features.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 45 additions & 0 deletions e2e/file-menu.spec.mjs
Original file line number Diff line number Diff line change
@@ -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 })
}
})
5 changes: 0 additions & 5 deletions e2e/fixtures.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions e2e/keys-panel.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
6 changes: 3 additions & 3 deletions e2e/sealed-recipients.spec.mjs
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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()

Expand All @@ -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()

Expand Down
15 changes: 10 additions & 5 deletions e2e/segmented-nav.spec.mjs
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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 }) => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/sharing.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 11 additions & 4 deletions e2e/trusted-keys.spec.mjs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions src/main/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
]
})

Expand Down
5 changes: 1 addition & 4 deletions src/main/menuSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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))
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/src/components/SidebarNav.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
// The sidebar's four places as one segmented control (#144), in a fixed order.
// The sidebar's five places as one segmented control (#144, #263), in a fixed order.
import { computed, nextTick, onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useSettingsStore } from '../stores/settingsStore'
Expand All @@ -11,7 +11,8 @@ const PLACES = [
{ value: 'home', icon: 'home', labelKey: 'sidebarNav.home' },
{ value: 'diffs', icon: 'diff', labelKey: 'sidebarNav.diffs' },
{ value: 'snippets', icon: 'code', labelKey: 'sidebarNav.snippets' },
{ value: 'tools', icon: 'grid', labelKey: 'sidebarNav.tools' }
{ value: 'tools', icon: 'grid', labelKey: 'sidebarNav.tools' },
{ value: 'keys', icon: 'key', labelKey: 'sidebarNav.keys' }
]

const { t } = useI18n()
Expand Down
20 changes: 20 additions & 0 deletions src/renderer/src/composables/useTabCycleKeys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { onBeforeUnmount, onMounted } from 'vue'

/** @param {KeyboardEvent} e @returns {'tab-next'|'tab-prev'|null} */
export function tabCycleAction(e) {
if (e.key !== 'Tab' || !e.ctrlKey || e.metaKey || e.altKey) return null
return e.shiftKey ? 'tab-prev' : 'tab-next'
}

// Ctrl+Tab lost its menu entry (#263), and with it the accelerator that carried it.
export function useTabCycleKeys(run) {
const onKey = (e) => {
const action = tabCycleAction(e)
if (!action) return
e.preventDefault()
e.stopPropagation()
run(action)
}
onMounted(() => window.addEventListener('keydown', onKey, true))
onBeforeUnmount(() => window.removeEventListener('keydown', onKey, true))
}
2 changes: 2 additions & 0 deletions src/renderer/src/features/share/components/KeysPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ function sendKey(run) {
if (!keyNameProblem(label.value)) run(label.value)
else share.showShareKeyDialog = true
}
// The panel loads its own list: it opens from the nav segment as well as from Add.
onMounted(async () => {
share.refreshTrusted()
fingerprint.value = (await window.api.myFingerprint?.()) ?? ''
label.value = (await window.api.myKeyLabel?.()) ?? ''
})
Expand Down
5 changes: 1 addition & 4 deletions src/renderer/src/menuSecurity.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ export const securityItems = (run) => [
},
{
label: t('menu.security.trustedKeys'),
items: [
{ label: t('menu.security.addTrustedKey'), run: () => run('add-trusted-key') },
{ label: t('menu.security.manageTrustedKeys'), run: () => run('manage-keys') }
]
items: [{ label: t('menu.security.addTrustedKey'), run: () => run('add-trusted-key') }]
},
{ sep: true },
{
Expand Down
12 changes: 1 addition & 11 deletions src/renderer/src/menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,10 @@ const fileSection = (run) => ({
keys: `${MOD}+Shift+W`,
run: () => run('tab-close')
},
{
label: t('menu.file.nextComparison'),
keys: 'Ctrl+Tab',
run: () => run('tab-next')
},
{
label: t('menu.file.prevComparison'),
keys: 'Ctrl+Shift+Tab',
run: () => run('tab-prev')
},
{ sep: true },
{ label: t('menu.file.settings'), keys: `${MOD}+,`, run: () => run('settings') },
{ sep: true },
{ label: t('menu.file.quit'), paletteHidden: true, run: () => window.api.quit() }
{ label: t('menu.file.exit'), paletteHidden: true, run: () => window.api.quit() }
]
})

Expand Down
6 changes: 2 additions & 4 deletions src/shared/i18n/en-XA.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@
"newComparison": "[Ńéŵ Çōɱƥàřĩşōń ·øé·øé]",
"newSnippet": "[Ńéŵ Šńĩƥƥéţ ·øé·]",
"closeComparison": "[Çłōşé Çōɱƥàřĩşōń ·øé·øé]",
"nextComparison": "[Ńéẋţ Çōɱƥàřĩşōń ·øé·øé]",
"prevComparison": "[Ƥřéṽĩōūş Çōɱƥàřĩşōń ·øé·øé·ø]",
"settings": "[Šéţţĩńğş… ·øé·]",
"quit": "[Ɋūĩţ ·ø]"
"exit": "[Éẋĩţ ·ø]"
},
"edit": {
"title": "[Éđĩţ ·ø]",
Expand Down Expand Up @@ -116,7 +114,6 @@
"replaceKey": "[Řéƥłàçé Ṁŷ Ķéŷ… ·øé·ø]",
"trustedKeys": "[Ţřūşţéđ Ķéŷş ·øé·ø]",
"addTrustedKey": "[Àđđ Ţřūşţéđ Ķéŷ… ·øé·øé]",
"manageTrustedKeys": "[Ṁàńàğé Ţřūşţéđ Ķéŷş… ·øé·øé·]",
"configuration": "[Çōńƒĩğūřàţĩōń ·øé·øé]",
"backUp": "[Ɓàçķ Ūƥ… ·øé]",
"restore": "[Řéşţōřé… ·øé]"
Expand Down Expand Up @@ -863,6 +860,7 @@
"diffs": "[Đĩƒƒş ·ø]",
"snippets": "[Šńĩƥƥéţş ·øé·]",
"tools": "[Ţōōłş ·ø]",
"keys": "[Ķéŷş ·ø]",
"hide": "[Ĥĩđé ţĥé şĩđéƀàř ·øé·øé]",
"hideTip": "[Ĥĩđé ţĥé şĩđéƀàř ({mod}+Ɓ) ·øé·øé·ø]",
"show": "[Šĥōŵ ţĥé şĩđéƀàř ·øé·øé]",
Expand Down
6 changes: 2 additions & 4 deletions src/shared/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,8 @@
"newComparison": "New Comparison",
"newSnippet": "New Snippet",
"closeComparison": "Close Comparison",
"nextComparison": "Next Comparison",
"prevComparison": "Previous Comparison",
"settings": "Settings…",
"quit": "Quit"
"exit": "Exit"
},
"edit": {
"title": "Edit",
Expand Down Expand Up @@ -116,7 +114,6 @@
"replaceKey": "Replace My Key…",
"trustedKeys": "Trusted Keys",
"addTrustedKey": "Add Trusted Key…",
"manageTrustedKeys": "Manage Trusted Keys…",
"configuration": "Configuration",
"backUp": "Back Up…",
"restore": "Restore…"
Expand Down Expand Up @@ -863,6 +860,7 @@
"diffs": "Diffs",
"snippets": "Snippets",
"tools": "Tools",
"keys": "Keys",
"hide": "Hide the sidebar",
"hideTip": "Hide the sidebar ({mod}+B)",
"show": "Show the sidebar",
Expand Down
4 changes: 1 addition & 3 deletions tests/menuMap.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ export const MENU_MAP = [
'File ▸ New Comparison',
'File ▸ New Snippet',
'File ▸ Close Comparison',
'File ▸ Next Comparison',
'File ▸ Previous Comparison',
'File ▸ Settings…',
'File ▸ Exit',
'Edit ▸ Swap Sides',
'Edit ▸ Copy ▸ Diff as Patch',
'Edit ▸ Copy ▸ Diff as File',
Expand All @@ -42,7 +41,6 @@ export const MENU_MAP = [
'Security ▸ My Key ▸ Share My Public Key…',
'Security ▸ My Key ▸ Replace My Key…',
'Security ▸ Trusted Keys ▸ Add Trusted Key…',
'Security ▸ Trusted Keys ▸ Manage Trusted Keys…',
'Security ▸ Configuration ▸ Back Up…',
'Security ▸ Configuration ▸ Restore…',
'Tools ▸ Encode ▸ Base64',
Expand Down
Loading
Loading