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
42 changes: 42 additions & 0 deletions electron/release-notes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { convert } from 'html-to-text'
import type { UpdateInfo } from 'electron-updater'

const MAX_RELEASE_NOTES_CHARS = 16_384

const htmlToText = (html: string): string => convert(html, {
wordwrap: false,
selectors: [
{ selector: 'a', options: { ignoreHref: true } },
],
})

function rawNotes(info: UpdateInfo): string | undefined {
const notes = info.releaseNotes
if (typeof notes === 'string' && notes.length > 0) return notes
if (Array.isArray(notes)) {
const parts = notes
.map((entry) => (typeof entry.note === 'string' ? entry.note : ''))
.filter((note) => note.length > 0)
return parts.length > 0 ? parts.join('\n\n') : undefined
}
return undefined
}

function looksLikeHtml(value: string): boolean {
return /<\/?[a-z][\s\S]*>/i.test(value)
}

function cap(value: string): string {
if (value.length <= MAX_RELEASE_NOTES_CHARS) return value
return `${value.slice(0, MAX_RELEASE_NOTES_CHARS)}\n…`
}

/** GitHub's feed is HTML. The modal renders notes as text, so convert first. */
export function releaseNotesFromFeed(info: UpdateInfo): string | undefined {
const raw = rawNotes(info)
if (!raw) return undefined
const bounded = cap(raw)
const text = (looksLikeHtml(bounded) ? htmlToText(bounded) : bounded).trim()
if (!text) return undefined
return cap(text)
}
10 changes: 1 addition & 9 deletions electron/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { app } from 'electron'
import { logger } from './logger'
import { preDownloadPythonForUpdate } from './python-setup'
import { getMainWindow } from './window'
import { releaseNotesFromFeed } from './release-notes'
import {
getSkippedUpdateVersion, setSkippedUpdateVersion,
getAutoCheckUpdates, setAutoCheckUpdates,
Expand All @@ -12,9 +13,6 @@ import type { UpdateStatePayload } from '../shared/electron-api-schema'

export type UpdateChannel = 'latest' | 'beta' | 'alpha'

// Cap untrusted feed notes so a huge GitHub body cannot bloat IPC / the modal.
const MAX_RELEASE_NOTES_CHARS = 16_384

// The single in-memory value of update state. Broadcast on every change.
let state: UpdateStatePayload = { status: 'idle', currentVersion: app.getVersion() }
let periodicHandle: ReturnType<typeof setInterval> | null = null
Expand All @@ -27,12 +25,6 @@ function setState(patch: Partial<UpdateStatePayload>): void {
getMainWindow()?.webContents.send('update-event', state)
}

function releaseNotesFromFeed(info: UpdateInfo): string | undefined {
if (typeof info.releaseNotes !== 'string' || info.releaseNotes.length === 0) return undefined
if (info.releaseNotes.length <= MAX_RELEASE_NOTES_CHARS) return info.releaseNotes
return `${info.releaseNotes.slice(0, MAX_RELEASE_NOTES_CHARS)}\n…`
}

export function getUpdateState(): UpdateStatePayload {
return state
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ltx-desktop",
"version": "1.2.3",
"version": "1.2.4",
"description": "LTX-2 Video Generation - Desktop App",
"type": "module",
"main": "dist-electron/main.js",
Expand Down Expand Up @@ -39,6 +39,7 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"electron-updater": "^6.8.3",
"html-to-text": "10.0.0",
"js-yaml": "^4.1.1",
"koffi": "3.1.4",
"lucide-react": "^0.400.0",
Expand Down
110 changes: 110 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading