feat #14740: updater and release scripts

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-06 11:37:57 +01:00
co-authored by Claude Opus 5.5
parent 345dd01147
commit 74511d791a
15 changed files with 1157 additions and 10 deletions
+119
View File
@@ -0,0 +1,119 @@
<script lang="ts">
import { onMount } from 'svelte'
import {
errorText,
getUpdate,
installUpdate,
onCallUpdated,
onRecordingState,
onUpdateAvailable,
onUpdateProgress,
type UpdateInfo,
type UpdateProgress,
} from './api'
/** How often a blocked update re-asks whether it may install now. */
const BUSY_POLL_MS = 5000
let update = $state<UpdateInfo | null>(null)
let installing = $state(false)
let progress = $state<UpdateProgress | null>(null)
let error = $state('')
async function refresh() {
try {
update = await getUpdate()
} catch {
// The banner is optional; the next event or poll tries again.
}
}
onMount(() => {
const unlisten = [
onUpdateAvailable((info) => (update = info)),
onUpdateProgress((next) => (progress = next)),
// Recording and processing end with these events.
onRecordingState(refresh),
onCallUpdated(refresh),
]
refresh()
// Not every end of a cleanup sends an event.
const poll = setInterval(() => {
if (update && !update.can_install && !installing) refresh()
}, BUSY_POLL_MS)
return () => {
clearInterval(poll)
unlisten.forEach((u) => u.then((off) => off()))
}
})
async function install() {
installing = true
progress = null
error = ''
try {
// Returns only on failure: on success the app restarts.
await installUpdate()
} catch (err) {
error = errorText(err)
refresh()
} finally {
installing = false
}
}
function megabytes(bytes: number): string {
return (bytes / 1024 / 1024).toLocaleString('de-DE', { maximumFractionDigits: 1 }) + ' MB'
}
let progressText = $derived.by(() => {
if (!progress) return 'Update wird heruntergeladen…'
if (progress.total === null) return `Update wird heruntergeladen… ${megabytes(progress.downloaded)}`
if (progress.downloaded >= progress.total) return 'Update wird installiert…'
return `Update wird heruntergeladen… ${Math.floor((progress.downloaded * 100) / progress.total)} %`
})
</script>
{#if update}
<div class="banner" role="status">
{#if installing}
<span>{progressText}</span>
{:else}
<span>Update verfügbar (v{update.version}) →</span>
<button class="btn primary small" disabled={!update.can_install} onclick={install}>
Installieren &amp; neu starten
</button>
{#if !update.can_install}
<span class="hint">Nach der laufenden Aufnahme/Verarbeitung möglich</span>
{/if}
{/if}
{#if error}
<span class="error">{error}</span>
{/if}
</div>
{/if}
<style>
.banner {
/* Spans the main window's grid. */
grid-column: 1 / -1;
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6px 10px;
padding: 8px 16px;
background: var(--primary-soft);
border-bottom: 1px solid var(--border);
font-weight: 600;
}
.hint {
color: var(--muted);
font-size: 12px;
font-weight: 400;
}
.error {
font-weight: 400;
}
</style>
+22
View File
@@ -100,6 +100,19 @@ export interface Account {
name: string
}
/** A newer version the release feed offers. */
export interface UpdateInfo {
version: string
/** `false` while a recording runs or a call is being processed. */
can_install: boolean
}
/** Download progress of an update; `total` is `null` if unknown. */
export interface UpdateProgress {
downloaded: number
total: number | null
}
export interface Levels {
mic: number
out: number
@@ -137,6 +150,9 @@ export const renameCall = (id: CallId, title: string | null) =>
export const listAccounts = () => invoke<Account[]>('list_accounts')
export const setAccount = (id: CallId, accountId: string | null) =>
invoke<void>('set_account', { id, accountId })
export const getUpdate = () => invoke<UpdateInfo | null>('get_update')
/** Resolves only on failure: on success the app restarts. */
export const installUpdate = () => invoke<void>('install_update')
export const onRecordingState = (handler: (state: RecordingState) => void): Promise<UnlistenFn> =>
listen<RecordingState>('recording-state', (event) => handler(event.payload))
@@ -148,6 +164,12 @@ export const onPromptChanged = (handler: () => void): Promise<UnlistenFn> =>
/** A call's status changed (processing started, done or failed). */
export const onCallUpdated = (handler: (id: CallId) => void): Promise<UnlistenFn> =>
listen<{ id: CallId }>('call-updated', (event) => handler(event.payload.id))
export const onUpdateAvailable = (handler: (info: UpdateInfo) => void): Promise<UnlistenFn> =>
listen<UpdateInfo>('update-available', (event) => handler(event.payload))
export const onUpdateProgress = (
handler: (progress: UpdateProgress) => void,
): Promise<UnlistenFn> =>
listen<UpdateProgress>('update-progress', (event) => handler(event.payload))
export const onLevels = (handler: (levels: Levels) => void): Promise<UnlistenFn> =>
listen<Levels>('levels', (event) => handler(event.payload))
+9
View File
@@ -26,6 +26,7 @@
import { formatDetailTime, formatMinutes } from '../lib/format'
import StatusPill from '../lib/StatusPill.svelte'
import TranscriptView from '../lib/TranscriptView.svelte'
import UpdateBanner from '../lib/UpdateBanner.svelte'
let calls = $state<CallListItem[]>([])
let loaded = $state(false)
@@ -230,6 +231,7 @@
</script>
<main class="main">
<UpdateBanner />
<aside class="sidebar">
<header class="sidebar-header">
<h1>Gespräche</h1>
@@ -367,9 +369,16 @@
.main {
display: grid;
grid-template-columns: minmax(260px, 30%) 1fr;
/* The update banner spans the first row; it is empty without one. */
grid-template-rows: auto minmax(0, 1fr);
height: 100vh;
}
.sidebar,
.detail {
grid-row: 2;
}
.sidebar {
display: flex;
flex-direction: column;