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
5 changes: 5 additions & 0 deletions .changeset/auto-updates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'lyra': minor
---

Lyra now keeps itself up to date: when a new release is out on GitHub it downloads in the background and installs the next time Lyra restarts, with a "Restart to update" row in Activity if you'd rather not wait. Settings → About has a new Updates section where you can choose Automatically, Ask first (the old behaviour) or Only when I check, see whether you're on the latest version, and check now. Macs without a signed build still open the releases page instead of downloading.
1 change: 1 addition & 0 deletions apps/lyra/src/main/diagnosticsText.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const settings: Settings = {
micDeviceId: null,
hotkey: 'Alt+Space',
launchAtLogin: false,
updates: 'auto',
micPrompt: { enabled: false, ignoredApps: [] },
meetingPrompt: false,
audioRetentionDays: 30,
Expand Down
1 change: 1 addition & 0 deletions apps/lyra/src/main/ipcSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const SettingsPatchSchema = z
micDeviceId: field.micDeviceId.exactOptional(),
hotkey: field.hotkey.exactOptional(),
launchAtLogin: field.launchAtLogin.exactOptional(),
updates: field.updates.exactOptional(),
micPrompt: field.micPrompt.exactOptional(),
meetingPrompt: field.meetingPrompt.exactOptional(),
audioRetentionDays: field.audioRetentionDays.exactOptional(),
Expand Down
1 change: 1 addition & 0 deletions apps/lyra/src/main/meeting/writers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe('chooseWriter', () => {
micDeviceId: null,
hotkey: 'Alt+Space',
launchAtLogin: false,
updates: 'auto',
micPrompt: { enabled: false, ignoredApps: [] },
meetingPrompt: false,
audioRetentionDays: null,
Expand Down
2 changes: 2 additions & 0 deletions apps/lyra/src/main/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export function defaultSettings(): Settings {
micDeviceId: null,
hotkey: 'CommandOrControl+Shift+Space',
launchAtLogin: false,
// On: it only fetches Lyra's own releases, and installs on the next restart, never mid-session.
updates: 'auto',
micPrompt: { enabled: false, ignoredApps: [] },
// On: it only asks, never records, and runs on this computer (see meetingApps.ts).
meetingPrompt: true,
Expand Down
1 change: 1 addition & 0 deletions apps/lyra/src/main/settingsFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('retentionUnread', () => {
micDeviceId: null,
hotkey: 'Alt+Space',
launchAtLogin: false,
updates: 'auto',
micPrompt: { enabled: false, ignoredApps: [] },
meetingPrompt: true,
audioRetentionDays: 30,
Expand Down
15 changes: 15 additions & 0 deletions apps/lyra/src/main/tasks/smoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,21 @@ export async function runUiSmoke(win: BrowserWindow): Promise<void> {
if (!Array.isArray(modelStates) || modelStates.some((entry) => !['semanticSearch', 'localNotes'].includes(entry.feature) || typeof entry.model !== 'string')) {
fail('model status: ' + JSON.stringify(modelStates))
}
// Updates: a test run never updates, so a check answers "unavailable" and fetches nothing;
// the mode is a setting, and an unknown one is refused.
await window.api.checkForUpdates()
const updateStatus = await new Promise((resolve) => {
const stop = window.api.onUpdateStatus((status) => {
stop()
resolve(status)
})
})
if (updateStatus.state !== 'unavailable') fail('update status in a test run: ' + JSON.stringify(updateStatus))
const updatesBefore = (await window.api.getSettings()).updates
if (updatesBefore !== 'auto') fail('updates default: ' + JSON.stringify(updatesBefore))
if ((await window.api.updateSettings({ updates: 'notify' })).updates !== 'notify') fail('updates: notify not saved')
if ((await window.api.updateSettings({ updates: 'sometimes' })).updates !== 'notify') fail('updates took an unknown mode')
await window.api.updateSettings({ updates: updatesBefore })
const stopModelStatus = window.api.onModelStatus(() => {})
if (typeof stopModelStatus !== 'function') fail('onModelStatus returned no unsubscribe')
stopModelStatus()
Expand Down
56 changes: 56 additions & 0 deletions apps/lyra/src/main/updatePolicy.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { describe, expect, it } from 'vitest'
import { autoDownloads, checkMayStart, checksOnItsOwn, shownInActivity } from './updatePolicy'

describe('autoDownloads', () => {
it('downloads on its own only in auto mode, where the app can replace itself', () => {
expect(autoDownloads('auto', true)).toBe(true)
expect(autoDownloads('auto', false)).toBe(false)
expect(autoDownloads('notify', true)).toBe(false)
expect(autoDownloads('off', true)).toBe(false)
})
})

describe('checksOnItsOwn', () => {
it('checks on a timer unless updates are off', () => {
expect(checksOnItsOwn('auto')).toBe(true)
expect(checksOnItsOwn('notify')).toBe(true)
expect(checksOnItsOwn('off')).toBe(false)
})
})

describe('checkMayStart', () => {
it('starts from a settled state', () => {
expect(checkMayStart('idle')).toBe(true)
expect(checkMayStart('latest')).toBe(true)
expect(checkMayStart('available')).toBe(true)
expect(checkMayStart('error')).toBe(true)
})

it('never interrupts a check, a download or an update waiting to install', () => {
expect(checkMayStart('checking')).toBe(false)
expect(checkMayStart('downloading')).toBe(false)
expect(checkMayStart('ready')).toBe(false)
expect(checkMayStart('unavailable')).toBe(false)
})
})

describe('shownInActivity', () => {
it('keeps a background download quiet until it is ready', () => {
expect(shownInActivity('available', true)).toBe(false)
expect(shownInActivity('downloading', true)).toBe(false)
expect(shownInActivity('ready', true)).toBe(true)
})

it('shows the progress of a download the person started', () => {
expect(shownInActivity('available', false)).toBe(true)
expect(shownInActivity('downloading', false)).toBe(true)
})

it('always shows a failure and never a check or an up-to-date app', () => {
expect(shownInActivity('error', true)).toBe(true)
expect(shownInActivity('error', false)).toBe(true)
expect(shownInActivity('checking', false)).toBe(false)
expect(shownInActivity('latest', false)).toBe(false)
expect(shownInActivity('idle', false)).toBe(false)
})
})
57 changes: 57 additions & 0 deletions apps/lyra/src/main/updatePolicy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import type { UpdateMode } from '../shared/settings'
import type { UpdateStatus } from '../shared/types'

/**
* Whether an update downloads as soon as one is found. Only in `auto`, and only where it can be
* installed in place: an unsigned Mac build can't replace itself, so its person is sent to the
* releases page instead, and downloading first would only waste the bandwidth.
*/
export function autoDownloads(mode: UpdateMode, canInstallInPlace: boolean): boolean {
return mode === 'auto' && canInstallInPlace
}

/** Whether Lyra looks for updates on a timer, not only when asked. */
export function checksOnItsOwn(mode: UpdateMode): boolean {
return mode !== 'off'
}

/**
* Whether a new check may start now. Not while one is running, a download is under way or an
* update waits to be installed (checking again would only find the same release), nor in a
* development build.
*/
export function checkMayStart(state: UpdateStatus['state']): boolean {
switch (state) {
case 'idle':
case 'latest':
case 'available':
case 'error':
return true
case 'unavailable':
case 'checking':
case 'downloading':
case 'ready':
return false
}
}

/**
* Whether Activity lists this status. A download Lyra started on its own stays out of sight until
* it's ready to install (docs/STATES.md: automatic work you didn't ask for shows nothing while it
* works); one the person started shows its progress.
*/
export function shownInActivity(state: UpdateStatus['state'], background: boolean): boolean {
switch (state) {
case 'available':
case 'downloading':
return !background
case 'ready':
case 'error':
return true
case 'unavailable':
case 'idle':
case 'checking':
case 'latest':
return false
}
}
Loading
Loading