diff --git a/apps/desktop/src/electron/SourceUpdater.test.ts b/apps/desktop/src/electron/SourceUpdater.test.ts new file mode 100644 index 0000000000000..6f659451fcd6b --- /dev/null +++ b/apps/desktop/src/electron/SourceUpdater.test.ts @@ -0,0 +1,262 @@ +import { assert, describe, it } from "@effect/vitest"; +import type { SourceUpdateConfig, SourceUpdateMessage } from "@t3tools/shared/sourceUpdate"; +import * as Effect from "effect/Effect"; +import * as Exit from "effect/Exit"; +import * as Option from "effect/Option"; + +import * as ElectronUpdater from "./ElectronUpdater.ts"; +import * as SourceUpdater from "./SourceUpdater.ts"; + +const config: SourceUpdateConfig = { + checkout: "/repo", + outputDir: "/repo/release", +}; + +interface FakeHostOptions { + readonly buildCommit?: string | undefined; + /** stdout lines by subcommand; messages are JSON lines, strings are log lines. */ + readonly output: Record>; + readonly exitCode?: number; + readonly stderr?: string; +} + +function makeFakeHost(options: FakeHostOptions) { + const runs: Array> = []; + const detached: Array> = []; + let quits = 0; + const host: SourceUpdater.SourceUpdateHost = { + config, + configPath: "/app/Contents/Resources/source-update.json", + buildCommit: Option.fromNullishOr( + "buildCommit" in options ? options.buildCommit : "abcdef123456", + ), + appBundle: "/Applications/T3 Code.app", + arch: "arm64", + pid: 4242, + run: (args, onLine) => + Effect.sync(() => { + runs.push(args); + for (const line of options.output[args[0] ?? ""] ?? []) { + onLine(typeof line === "string" ? line : JSON.stringify(line)); + } + return { exitCode: options.exitCode ?? 0, stderr: options.stderr ?? "" }; + }), + spawnDetached: (args) => + Effect.sync(() => { + detached.push(args); + }), + quit: Effect.sync(() => { + quits += 1; + }), + }; + return { host, runs, detached, quits: () => quits }; +} + +const collectEvents = (updater: ElectronUpdater.ElectronUpdater["Service"]) => + Effect.gen(function* () { + const events: Array<{ readonly name: string; readonly payload: unknown }> = []; + for (const name of [ + "checking-for-update", + "update-available", + "update-not-available", + "download-progress", + "update-downloaded", + ]) { + yield* updater.on(name, (payload: unknown) => { + events.push({ name, payload }); + }); + } + return events; + }); + +describe("SourceUpdater", () => { + it.effect("offers the branch's new commits as a stable-channel version", () => + Effect.scoped( + Effect.gen(function* () { + const fake = makeFakeHost({ + output: { + describe: [ + "[source-update] fetching", + { + type: "update", + target: "0123456789abcdef0123456789abcdef01234567", + version: "0.1.13-source.20261204.4821", + releaseDate: "2026-12-04T10:00:00.000Z", + releaseNotes: "- feat: one\n- fix: two", + commitCount: 2, + url: "https://github.com/TrogonStack/t3code/commit/0123456789abcdef0123456789abcdef01234567", + }, + ], + }, + }); + const updater = SourceUpdater.make(fake.host); + const events = yield* collectEvents(updater); + + yield* updater.checkForUpdates; + + assert.deepEqual(fake.runs, [ + ["describe", "--config", fake.host.configPath, "--from", "abcdef123456"], + ]); + assert.deepEqual(events, [ + { name: "checking-for-update", payload: undefined }, + { + name: "update-available", + payload: { + version: "0.1.13-source.20261204.4821", + releaseNotes: [ + { + version: "0.1.13-source.20261204.4821", + note: "- feat: one\n- fix: two", + url: "https://github.com/TrogonStack/t3code/commit/0123456789abcdef0123456789abcdef01234567", + }, + ], + releaseName: "T3 Code 0.1.13-source.20261204.4821", + releaseDate: "2026-12-04T10:00:00.000Z", + }, + }, + ]); + }), + ), + ); + + it.effect("reports no update when the build already has the branch's head", () => + Effect.scoped( + Effect.gen(function* () { + const fake = makeFakeHost({ + output: { describe: [{ type: "up-to-date", target: "abcdef123456" }] }, + }); + const updater = SourceUpdater.make(fake.host); + const events = yield* collectEvents(updater); + yield* updater.checkForUpdates; + assert.deepEqual( + events.map((event) => event.name), + ["checking-for-update", "update-not-available"], + ); + }), + ), + ); + + it.effect("fails the check with the script's own error line", () => + Effect.scoped( + Effect.gen(function* () { + const fake = makeFakeHost({ + output: { describe: [{ type: "error", message: "git fetch failed: no network" }] }, + exitCode: 1, + stderr: "ignored when the script explains itself", + }); + const updater = SourceUpdater.make(fake.host); + const exit = yield* Effect.exit(updater.checkForUpdates); + assert.isTrue(Exit.isFailure(exit)); + const error = Exit.isFailure(exit) ? exit.cause : undefined; + assert.include(String(error), "git fetch failed: no network"); + }), + ), + ); + + it.effect("refuses to check a build that records no commit", () => + Effect.scoped( + Effect.gen(function* () { + const fake = makeFakeHost({ buildCommit: undefined, output: {} }); + const updater = SourceUpdater.make(fake.host); + const exit = yield* Effect.exit(updater.checkForUpdates); + assert.isTrue(Exit.isFailure(exit)); + assert.deepEqual(fake.runs, []); + }), + ), + ); + + it.effect("rebuilds the offered commit, relaying progress, then installs the staged app", () => + Effect.scoped( + Effect.gen(function* () { + const fake = makeFakeHost({ + output: { + describe: [ + { + type: "update", + target: "0123456789abcdef0123456789abcdef01234567", + version: "0.1.13-source.20261204.4821", + releaseDate: "2026-12-04T10:00:00.000Z", + releaseNotes: "- feat: one", + commitCount: 1, + }, + ], + update: [ + { type: "progress", percent: 10, step: "rebasing" }, + "{ not a message", + { type: "progress", percent: 90, step: "staging" }, + { + type: "built", + app: "/repo/release/app/T3 Code.app", + version: "0.1.13-source.20261204.4821", + }, + ], + }, + }); + const updater = SourceUpdater.make(fake.host); + const events = yield* collectEvents(updater); + + yield* updater.checkForUpdates; + yield* updater.downloadUpdate; + yield* updater.quitAndInstall({ isSilent: true, isForceRunAfter: true }); + + assert.deepEqual(fake.runs[1], [ + "update", + "--config", + fake.host.configPath, + "--from", + "abcdef123456", + "--target", + "0123456789abcdef0123456789abcdef01234567", + "--version", + "0.1.13-source.20261204.4821", + "--arch", + "arm64", + ]); + assert.deepEqual(events.slice(2), [ + { name: "download-progress", payload: { percent: 10 } }, + { name: "download-progress", payload: { percent: 90 } }, + { + name: "update-downloaded", + payload: { + version: "0.1.13-source.20261204.4821", + downloadedFile: "/repo/release/app/T3 Code.app", + }, + }, + ]); + assert.equal(fake.detached.length, 1); + const install = fake.detached[0]!; + assert.deepEqual(install.slice(0, 7), [ + "install", + "--pid", + "4242", + "--current", + "/Applications/T3 Code.app", + "--staged", + "/repo/release/app/T3 Code.app", + ]); + assert.equal(install[7], "--backup-dir"); + assert.match(install[8]!, /^\/repo\/release\/backup-\d{8}T\d{6}$/); + assert.equal(install[9], "--relaunch"); + assert.equal(fake.quits(), 1); + }), + ), + ); + + it.effect("refuses to build or install without an offer or a staged app", () => + Effect.scoped( + Effect.gen(function* () { + const fake = makeFakeHost({ output: {} }); + const updater = SourceUpdater.make(fake.host); + const download = yield* Effect.exit(updater.downloadUpdate); + assert.isTrue(Exit.isFailure(download)); + const install = yield* Effect.exit( + updater.quitAndInstall({ isSilent: true, isForceRunAfter: true }), + ); + assert.isTrue(Exit.isFailure(install)); + assert.deepEqual(fake.runs, []); + assert.deepEqual(fake.detached, []); + assert.equal(fake.quits(), 0); + }), + ), + ); +}); diff --git a/apps/desktop/src/electron/SourceUpdater.ts b/apps/desktop/src/electron/SourceUpdater.ts new file mode 100644 index 0000000000000..6ef85cb3759f8 --- /dev/null +++ b/apps/desktop/src/electron/SourceUpdater.ts @@ -0,0 +1,398 @@ +// @effect-diagnostics nodeBuiltinImport:off -- Starts the checkout's update script outside the Effect runtime, as ElectronUpdater runs its shell commands. +import * as NodeChildProcess from "node:child_process"; +import * as NodeFS from "node:fs"; +import * as NodePath from "node:path"; + +import { + SOURCE_UPDATE_CONFIG_FILE, + type SourceUpdateConfig, + SourceUpdateConfigJson, + type SourceUpdateMessage, + SourceUpdateMessageJson, +} from "@t3tools/shared/sourceUpdate"; +import * as DateTime from "effect/DateTime"; +import * as Effect from "effect/Effect"; +import * as Layer from "effect/Layer"; +import * as Option from "effect/Option"; +import * as Schema from "effect/Schema"; +import * as Electron from "electron"; + +import * as ElectronUpdater from "./ElectronUpdater.ts"; + +/** Reported as the updater channel in errors; the build itself stays on the stable channel. */ +const SOURCE_UPDATE_CHANNEL = "source"; + +export class SourceUpdateScriptError extends Schema.TaggedError()( + "SourceUpdateScriptError", + { + step: Schema.String, + detail: Schema.String, + }, +) { + override get message(): string { + return `source update ${this.step} failed: ${this.detail}`; + } +} + +export interface SourceUpdateScriptResult { + readonly exitCode: number; + readonly stderr: string; +} + +/** What the updater needs from the app and the machine; tests fake it. */ +export interface SourceUpdateHost { + readonly config: SourceUpdateConfig; + readonly configPath: string; + /** The commit the running app was built from, as the build wrote it into package.json. */ + readonly buildCommit: Option.Option; + /** The installed bundle the rebuilt app replaces. */ + readonly appBundle: string; + readonly arch: string; + readonly pid: number; + /** Runs `scripts/source-update.ts ` in the checkout; each stdout line goes to `onLine`. */ + readonly run: ( + args: ReadonlyArray, + onLine: (line: string) => void, + ) => Effect.Effect; + /** Starts the script detached, so it outlives the app it replaces. */ + readonly spawnDetached: ( + args: ReadonlyArray, + ) => Effect.Effect; + readonly quit: Effect.Effect; +} + +const decodeMessage = Schema.decodeUnknownEffect(SourceUpdateMessageJson); +const decodeConfig = Schema.decodeUnknownEffect(SourceUpdateConfigJson); +const decodeBuildPackage = Schema.decodeUnknownEffect( + Schema.fromJsonString(Schema.Struct({ t3codeCommitHash: Schema.optional(Schema.String) })), +); + +const parseMessage = (line: string): Option.Option => + line.startsWith("{") ? Effect.runSync(decodeMessage(line).pipe(Effect.option)) : Option.none(); + +const ignored = (name: string) => + Effect.fn(`SourceUpdater.${name}`)(function () { + return Effect.void; + }); + +type Listener = (...args: Array) => void; + +/** @public */ +export const make = (host: SourceUpdateHost): ElectronUpdater.ElectronUpdater["Service"] => { + const listeners = new Map>(); + const emit = (eventName: string, ...args: Array) => { + for (const listener of listeners.get(eventName) ?? []) listener(...args); + }; + let offer = Option.none<{ readonly target: string; readonly version: string }>(); + let built = Option.none<{ readonly app: string; readonly version: string }>(); + + // The last result line decides the outcome; progress lines feed the state as a download would. + const runScript = Effect.fn("SourceUpdater.runScript")(function* ( + step: string, + args: ReadonlyArray, + ) { + let result = Option.none(); + let failure = Option.none(); + const { exitCode, stderr } = yield* host.run([step, ...args], (line) => { + Option.match(parseMessage(line), { + onNone: () => {}, + onSome: (message) => { + if (message.type === "progress") { + emit("download-progress", { percent: message.percent }); + } else if (message.type === "error") { + failure = Option.some(message.message); + } else { + result = Option.some(message); + } + }, + }); + }); + if (Option.isSome(failure)) { + return yield* new SourceUpdateScriptError({ step, detail: failure.value }); + } + if (exitCode !== 0) { + const tail = stderr.trim(); + return yield* new SourceUpdateScriptError({ + step, + detail: tail.length > 0 ? `exit code ${exitCode}: ${tail}` : `exit code ${exitCode}`, + }); + } + return yield* Option.match(result, { + onNone: () => new SourceUpdateScriptError({ step, detail: "the script reported no result" }), + onSome: Effect.succeed, + }); + }); + + const describe = Effect.gen(function* () { + emit("checking-for-update"); + const from = yield* Option.match(host.buildCommit, { + onNone: () => + new SourceUpdateScriptError({ + step: "describe", + detail: "the running build records no commit hash", + }), + onSome: Effect.succeed, + }); + const message = yield* runScript("describe", ["--config", host.configPath, "--from", from]); + switch (message.type) { + case "up-to-date": + offer = Option.none(); + emit("update-not-available"); + return; + case "update": + offer = Option.some({ target: message.target, version: message.version }); + emit("update-available", { + version: message.version, + // With a forge URL the notes link to the commit instead of a release tag. + releaseNotes: + message.url === undefined + ? message.releaseNotes + : [{ version: message.version, note: message.releaseNotes, url: message.url }], + // Naming the version keeps the notes through releaseNotesOfOfferedVersion. + releaseName: `T3 Code ${message.version}`, + releaseDate: message.releaseDate, + }); + return; + default: + return yield* new SourceUpdateScriptError({ + step: "describe", + detail: `unexpected result ${message.type}`, + }); + } + }); + + const rebuild = Effect.gen(function* () { + const from = Option.getOrUndefined(host.buildCommit); + const target = Option.getOrUndefined(offer); + if (from === undefined || target === undefined) { + return yield* new SourceUpdateScriptError({ + step: "update", + detail: "no update was found to build", + }); + } + const message = yield* runScript("update", [ + "--config", + host.configPath, + "--from", + from, + "--target", + target.target, + "--version", + target.version, + "--arch", + host.arch, + ]); + if (message.type !== "built") { + return yield* new SourceUpdateScriptError({ + step: "update", + detail: `unexpected result ${message.type}`, + }); + } + built = Option.some({ app: message.app, version: message.version }); + emit("update-downloaded", { version: message.version, downloadedFile: message.app }); + }); + + const installStaged = Effect.fn("SourceUpdater.installStaged")(function* (relaunch: boolean) { + const staged = Option.getOrUndefined(built); + if (staged === undefined) { + return yield* new SourceUpdateScriptError({ + step: "install", + detail: "no rebuilt app is staged", + }); + } + const now = yield* DateTime.now; + const stamp = DateTime.formatIso(now).replaceAll(/[-:]/g, "").slice(0, 15); + yield* host.spawnDetached([ + "install", + "--pid", + String(host.pid), + "--current", + host.appBundle, + "--staged", + staged.app, + "--backup-dir", + NodePath.join(host.config.outputDir, `backup-${stamp}`), + ...(relaunch ? ["--relaunch"] : []), + ]); + // The ordinary quit runs the shutdown; the detached installer waits for the process to end. + yield* host.quit; + }); + + return ElectronUpdater.ElectronUpdater.of({ + setFeedURL: ignored("setFeedURL"), + setAutoDownload: ignored("setAutoDownload"), + setAutoInstallOnAppQuit: ignored("setAutoInstallOnAppQuit"), + setChannel: ignored("setChannel"), + setAllowPrerelease: ignored("setAllowPrerelease"), + allowDowngrade: Effect.succeed(false), + setAllowDowngrade: ignored("setAllowDowngrade"), + setFullChangelog: ignored("setFullChangelog"), + setDisableDifferentialDownload: ignored("setDisableDifferentialDownload"), + checkForUpdates: describe.pipe( + Effect.mapError( + (cause) => + new ElectronUpdater.ElectronUpdaterCheckForUpdatesError({ + channel: SOURCE_UPDATE_CHANNEL, + cause, + }), + ), + ), + downloadUpdate: rebuild.pipe( + Effect.mapError( + (cause) => + new ElectronUpdater.ElectronUpdaterDownloadUpdateError({ + channel: SOURCE_UPDATE_CHANNEL, + cause, + }), + ), + ), + quitAndInstall: Effect.fn("SourceUpdater.quitAndInstall")(function ({ + isSilent, + isForceRunAfter, + }) { + return installStaged(isForceRunAfter).pipe( + Effect.mapError( + (cause) => + new ElectronUpdater.ElectronUpdaterQuitAndInstallError({ + channel: SOURCE_UPDATE_CHANNEL, + isSilent, + isForceRunAfter, + cause, + }), + ), + ); + }), + on: Effect.fn("SourceUpdater.on")(function (eventName, listener) { + const untyped = listener as unknown as Listener; + return Effect.acquireRelease( + Effect.sync(() => { + const eventListeners = listeners.get(eventName) ?? new Set(); + eventListeners.add(untyped); + listeners.set(eventName, eventListeners); + }), + () => + Effect.sync(() => { + listeners.get(eventName)?.delete(untyped); + }), + ).pipe(Effect.asVoid); + }), + }); +}; + +const readBuildCommit = (appPath: string): Option.Option => { + try { + const raw = NodeFS.readFileSync(NodePath.join(appPath, "package.json"), "utf8"); + const parsed = Effect.runSync(decodeBuildPackage(raw).pipe(Effect.option)); + return Option.flatMap(parsed, (manifest) => Option.fromNullishOr(manifest.t3codeCommitHash)); + } catch { + return Option.none(); + } +}; + +const makeNodeHost = (config: SourceUpdateConfig, configPath: string): SourceUpdateHost => { + const shell = config.shell ?? process.env.SHELL ?? "/bin/sh"; + // A login shell gives the script the user's PATH, so their Node version manager applies. + const shellArgs = (args: ReadonlyArray) => [ + "-lc", + 'exec "$0" "$@"', + "node", + "scripts/source-update.ts", + ...args, + ]; + const scriptError = (args: ReadonlyArray, error: unknown) => + new SourceUpdateScriptError({ + step: args[0] ?? "", + detail: error instanceof Error ? error.message : String(error), + }); + return { + config, + configPath, + buildCommit: readBuildCommit(Electron.app.getAppPath()), + appBundle: NodePath.resolve(process.resourcesPath, "..", ".."), + // oxlint-disable-next-line t3code/no-global-process-runtime -- The node host runs outside the Effect runtime, like ElectronUpdater's process spawns. + arch: process.arch, + pid: process.pid, + run: (args, onLine) => + Effect.callback((resume) => { + const child = NodeChildProcess.spawn(shell, shellArgs(args), { + cwd: config.checkout, + env: process.env, + stdio: ["ignore", "pipe", "pipe"], + }); + let pending = ""; + child.stdout.on("data", (chunk: Buffer | string) => { + pending += String(chunk); + let newline = pending.indexOf("\n"); + while (newline >= 0) { + onLine(pending.slice(0, newline)); + pending = pending.slice(newline + 1); + newline = pending.indexOf("\n"); + } + }); + let stderr = ""; + child.stderr.on("data", (chunk: Buffer | string) => { + stderr = `${stderr}${String(chunk)}`.slice(-4000); + }); + child.once("error", (error) => { + resume(Effect.fail(scriptError(args, error))); + }); + child.once("close", (code) => { + if (pending.length > 0) onLine(pending); + resume(Effect.succeed({ exitCode: code ?? 1, stderr })); + }); + return Effect.sync(() => { + child.kill(); + }); + }), + spawnDetached: (args) => + Effect.try({ + try: () => { + const child = NodeChildProcess.spawn(shell, shellArgs(args), { + cwd: config.checkout, + env: process.env, + detached: true, + stdio: "ignore", + }); + child.unref(); + }, + catch: (error) => scriptError(args, error), + }), + quit: Effect.sync(() => { + Electron.app.quit(); + }), + }; +}; + +const readConfig = (configPath: string): Option.Option => { + try { + const raw = NodeFS.readFileSync(configPath, "utf8"); + return Effect.runSync(decodeConfig(raw).pipe(Effect.option)); + } catch { + return Option.none(); + } +}; + +// Electron sets resourcesPath; tests and the server run this module without it. +const resourcesConfigPath = (): Option.Option => + typeof process.resourcesPath === "string" + ? Option.some(NodePath.join(process.resourcesPath, SOURCE_UPDATE_CONFIG_FILE)) + : Option.none(); + +/** The configured label for update copy, such as "Trogon fork"; none outside a source build. */ +export const readSourceUpdateLabel = (): Option.Option => + resourcesConfigPath().pipe( + Option.flatMap(readConfig), + Option.flatMap((config) => Option.fromNullishOr(config.label?.trim() || undefined)), + ); + +/** electron-updater for feed builds; the checkout's update script for a build that carries source-update.json. */ +export const layer = Layer.sync(ElectronUpdater.ElectronUpdater, () => + Option.match(resourcesConfigPath(), { + onNone: () => ElectronUpdater.make, + onSome: (configPath) => + Option.match(readConfig(configPath), { + onNone: () => ElectronUpdater.make, + onSome: (config) => make(makeNodeHost(config, configPath)), + }), + }), +); diff --git a/apps/desktop/src/i18n/translations/de.json b/apps/desktop/src/i18n/translations/de.json index 7a53c49be3e09..609c4dff80384 100644 --- a/apps/desktop/src/i18n/translations/de.json +++ b/apps/desktop/src/i18n/translations/de.json @@ -114,14 +114,21 @@ "8cfcc2b2943aae3e": "Passkey auswählen", "936b24e87270b744": "Nightly", "e0b83984bb26f730": "Stable", + "7899be6b2ab267c9": "Nach Updates suchen...", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "Du bist auf dem neuesten Stand!", "8fad8b3d58041567": ["T3 Code ", ["version"], " ist derzeit die neueste verfügbare Version."], "bc180ba81f137d59": "Update verfügbar", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "Eine neue Version von T3 Code ist verfügbar.", "e63b9fa18a099b0c": ["T3 Code ", ["version"], " ist verfügbar."], "ea99dc48faea2f7d": ["Du verwendest T3 Code ", ["version"], "."], "716c7a6c7bba40ad": "Herunterladen", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "Später", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "Update wird heruntergeladen", "c9d7dc5db1cde9e3": "Eine neue Version von T3 Code wird bereits heruntergeladen.", "5145d26d268fab9c": ["T3 Code ", ["version"], " wird bereits heruntergeladen."], @@ -147,7 +154,6 @@ "21f3082feec7a4a3": "Updates nicht verfügbar", "f50c240922fc42a6": "Automatische Updates sind derzeit nicht verfügbar.", "461d2709ee66419a": ["Über ", ["appName"]], - "7899be6b2ab267c9": "Nach Updates suchen...", "87111169e6f002e4": "Einstellungen...", "4a68edd86ac8138e": "Dienste", "ea5807311cde5ccb": [["appName"], " ausblenden"], diff --git a/apps/desktop/src/i18n/translations/en.json b/apps/desktop/src/i18n/translations/en.json index f088c4567bab0..722a100691851 100644 --- a/apps/desktop/src/i18n/translations/en.json +++ b/apps/desktop/src/i18n/translations/en.json @@ -112,14 +112,21 @@ "8cfcc2b2943aae3e": "Choose a passkey", "936b24e87270b744": "Nightly", "e0b83984bb26f730": "Stable", + "7899be6b2ab267c9": "Check for Updates...", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "You're up to date!", "8fad8b3d58041567": ["T3 Code ", ["version"], " is currently the newest version available."], "bc180ba81f137d59": "Update available", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "A new version of T3 Code is available.", "e63b9fa18a099b0c": ["T3 Code ", ["version"], " is available."], "ea99dc48faea2f7d": ["You're running T3 Code ", ["version"], "."], "716c7a6c7bba40ad": "Download", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "Later", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "Update downloading", "c9d7dc5db1cde9e3": "A new version of T3 Code is already downloading.", "5145d26d268fab9c": ["T3 Code ", ["version"], " is already downloading."], @@ -145,7 +152,6 @@ "21f3082feec7a4a3": "Updates unavailable", "f50c240922fc42a6": "Automatic updates are not available right now.", "461d2709ee66419a": ["About ", ["appName"]], - "7899be6b2ab267c9": "Check for Updates...", "87111169e6f002e4": "Settings...", "4a68edd86ac8138e": "Services", "ea5807311cde5ccb": ["Hide ", ["appName"]], diff --git a/apps/desktop/src/i18n/translations/es.json b/apps/desktop/src/i18n/translations/es.json index e578bbd7ed262..4fdaab9b61c60 100644 --- a/apps/desktop/src/i18n/translations/es.json +++ b/apps/desktop/src/i18n/translations/es.json @@ -116,14 +116,21 @@ "8cfcc2b2943aae3e": "Elige una llave de acceso", "936b24e87270b744": "Nightly", "e0b83984bb26f730": "Estable", + "7899be6b2ab267c9": "Buscar actualizaciones...", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "¡Estás al día!", "8fad8b3d58041567": ["T3 Code ", ["version"], " es la versión más reciente disponible."], "bc180ba81f137d59": "Actualización disponible", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "Hay una nueva versión de T3 Code disponible.", "e63b9fa18a099b0c": ["T3 Code ", ["version"], " está disponible."], "ea99dc48faea2f7d": ["Estás usando T3 Code ", ["version"], "."], "716c7a6c7bba40ad": "Descargar", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "Más tarde", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "Descargando actualización", "c9d7dc5db1cde9e3": "Ya se está descargando una nueva versión de T3 Code.", "5145d26d268fab9c": ["Ya se está descargando T3 Code ", ["version"], "."], @@ -149,7 +156,6 @@ "21f3082feec7a4a3": "Actualizaciones no disponibles", "f50c240922fc42a6": "Las actualizaciones automáticas no están disponibles ahora mismo.", "461d2709ee66419a": ["Acerca de ", ["appName"]], - "7899be6b2ab267c9": "Buscar actualizaciones...", "87111169e6f002e4": "Ajustes...", "4a68edd86ac8138e": "Servicios", "ea5807311cde5ccb": ["Ocultar ", ["appName"]], diff --git a/apps/desktop/src/i18n/translations/fr.json b/apps/desktop/src/i18n/translations/fr.json index 17fab8b45f683..04a365ec94c8b 100644 --- a/apps/desktop/src/i18n/translations/fr.json +++ b/apps/desktop/src/i18n/translations/fr.json @@ -119,14 +119,21 @@ "8cfcc2b2943aae3e": "Choisir une clé d’accès", "936b24e87270b744": "Nightly", "e0b83984bb26f730": "Stable", + "7899be6b2ab267c9": "Rechercher des mises à jour...", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "Vous êtes à jour !", "8fad8b3d58041567": ["T3 Code ", ["version"], " est actuellement la version la plus récente."], "bc180ba81f137d59": "Mise à jour disponible", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "Une nouvelle version de T3 Code est disponible.", "e63b9fa18a099b0c": ["T3 Code ", ["version"], " est disponible."], "ea99dc48faea2f7d": ["Vous utilisez T3 Code ", ["version"], "."], "716c7a6c7bba40ad": "Télécharger", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "Plus tard", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "Téléchargement de la mise à jour", "c9d7dc5db1cde9e3": "Une nouvelle version de T3 Code est déjà en cours de téléchargement.", "5145d26d268fab9c": ["T3 Code ", ["version"], " est déjà en cours de téléchargement."], @@ -152,7 +159,6 @@ "21f3082feec7a4a3": "Mises à jour indisponibles", "f50c240922fc42a6": "Les mises à jour automatiques ne sont pas disponibles pour le moment.", "461d2709ee66419a": ["À propos de ", ["appName"]], - "7899be6b2ab267c9": "Rechercher des mises à jour...", "87111169e6f002e4": "Paramètres...", "4a68edd86ac8138e": "Services", "ea5807311cde5ccb": ["Masquer ", ["appName"]], diff --git a/apps/desktop/src/i18n/translations/ja.json b/apps/desktop/src/i18n/translations/ja.json index 2a5cacb283887..a84bf8f158006 100644 --- a/apps/desktop/src/i18n/translations/ja.json +++ b/apps/desktop/src/i18n/translations/ja.json @@ -120,14 +120,21 @@ "8cfcc2b2943aae3e": "パスキーを選択", "936b24e87270b744": "Nightly", "e0b83984bb26f730": "安定版", + "7899be6b2ab267c9": "更新を確認...", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "最新の状態です", "8fad8b3d58041567": ["T3 Code ", ["version"], " が現在利用できる最新バージョンです。"], "bc180ba81f137d59": "更新があります", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "T3 Code の新しいバージョンを利用できます。", "e63b9fa18a099b0c": ["T3 Code ", ["version"], " を利用できます。"], "ea99dc48faea2f7d": ["T3 Code ", ["version"], " を実行しています。"], "716c7a6c7bba40ad": "ダウンロード", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "後で", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "更新をダウンロード中", "c9d7dc5db1cde9e3": "T3 Code の新しいバージョンはすでにダウンロード中です。", "5145d26d268fab9c": ["T3 Code ", ["version"], " はすでにダウンロード中です。"], @@ -153,7 +160,6 @@ "21f3082feec7a4a3": "更新を利用できません", "f50c240922fc42a6": "現在、自動更新は利用できません。", "461d2709ee66419a": [["appName"], " について"], - "7899be6b2ab267c9": "更新を確認...", "87111169e6f002e4": "設定...", "4a68edd86ac8138e": "サービス", "ea5807311cde5ccb": [["appName"], " を隠す"], diff --git a/apps/desktop/src/i18n/translations/ko.json b/apps/desktop/src/i18n/translations/ko.json index b48a285855b56..e6f4d51a0163f 100644 --- a/apps/desktop/src/i18n/translations/ko.json +++ b/apps/desktop/src/i18n/translations/ko.json @@ -114,14 +114,21 @@ "8cfcc2b2943aae3e": "패스키 선택", "936b24e87270b744": "Nightly", "e0b83984bb26f730": "Stable", + "7899be6b2ab267c9": "업데이트 확인...", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "최신 버전입니다!", "8fad8b3d58041567": ["T3 Code ", ["version"], "이(가) 현재 사용 가능한 최신 버전입니다."], "bc180ba81f137d59": "업데이트 사용 가능", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "새 버전의 T3 Code를 사용할 수 있습니다.", "e63b9fa18a099b0c": ["T3 Code ", ["version"], "을(를) 사용할 수 있습니다."], "ea99dc48faea2f7d": ["T3 Code ", ["version"], "을(를) 실행 중입니다."], "716c7a6c7bba40ad": "다운로드", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "나중에", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "업데이트 다운로드 중", "c9d7dc5db1cde9e3": "새 버전의 T3 Code를 이미 다운로드하고 있습니다.", "5145d26d268fab9c": ["T3 Code ", ["version"], "을(를) 이미 다운로드하고 있습니다."], @@ -147,7 +154,6 @@ "21f3082feec7a4a3": "업데이트를 사용할 수 없음", "f50c240922fc42a6": "지금은 자동 업데이트를 사용할 수 없습니다.", "461d2709ee66419a": [["appName"], " 정보"], - "7899be6b2ab267c9": "업데이트 확인...", "87111169e6f002e4": "설정...", "4a68edd86ac8138e": "서비스", "ea5807311cde5ccb": [["appName"], " 가리기"], diff --git a/apps/desktop/src/i18n/translations/pl.json b/apps/desktop/src/i18n/translations/pl.json index 7ea9fba9902d8..0b68916b52818 100644 --- a/apps/desktop/src/i18n/translations/pl.json +++ b/apps/desktop/src/i18n/translations/pl.json @@ -112,14 +112,21 @@ "8cfcc2b2943aae3e": "Wybierz klucz dostępu", "936b24e87270b744": "Nightly", "e0b83984bb26f730": "Stabilna", + "7899be6b2ab267c9": "Sprawdź aktualizacje...", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "Masz najnowszą wersję!", "8fad8b3d58041567": ["T3 Code ", ["version"], " to obecnie najnowsza dostępna wersja."], "bc180ba81f137d59": "Dostępna aktualizacja", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "Dostępna jest nowa wersja T3 Code.", "e63b9fa18a099b0c": ["Dostępny jest T3 Code ", ["version"], "."], "ea99dc48faea2f7d": ["Korzystasz z T3 Code ", ["version"], "."], "716c7a6c7bba40ad": "Pobierz", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "Później", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "Pobieranie aktualizacji", "c9d7dc5db1cde9e3": "Nowa wersja T3 Code już się pobiera.", "5145d26d268fab9c": ["T3 Code ", ["version"], " już się pobiera."], @@ -145,7 +152,6 @@ "21f3082feec7a4a3": "Aktualizacje niedostępne", "f50c240922fc42a6": "Automatyczne aktualizacje są obecnie niedostępne.", "461d2709ee66419a": ["O aplikacji ", ["appName"]], - "7899be6b2ab267c9": "Sprawdź aktualizacje...", "87111169e6f002e4": "Ustawienia...", "4a68edd86ac8138e": "Usługi", "ea5807311cde5ccb": ["Ukryj ", ["appName"]], diff --git a/apps/desktop/src/i18n/translations/pt-BR.json b/apps/desktop/src/i18n/translations/pt-BR.json index a65b44217e3af..1e27bb68adc02 100644 --- a/apps/desktop/src/i18n/translations/pt-BR.json +++ b/apps/desktop/src/i18n/translations/pt-BR.json @@ -115,14 +115,21 @@ "8cfcc2b2943aae3e": "Escolha uma chave de acesso", "936b24e87270b744": "Nightly", "e0b83984bb26f730": "Estável", + "7899be6b2ab267c9": "Verificar atualizações...", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "Você está atualizado!", "8fad8b3d58041567": ["O T3 Code ", ["version"], " é a versão mais recente disponível."], "bc180ba81f137d59": "Atualização disponível", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "Há uma nova versão do T3 Code disponível.", "e63b9fa18a099b0c": ["O T3 Code ", ["version"], " está disponível."], "ea99dc48faea2f7d": ["Você está usando o T3 Code ", ["version"], "."], "716c7a6c7bba40ad": "Baixar", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "Depois", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "Baixando atualização", "c9d7dc5db1cde9e3": "Uma nova versão do T3 Code já está sendo baixada.", "5145d26d268fab9c": ["O T3 Code ", ["version"], " já está sendo baixado."], @@ -148,7 +155,6 @@ "21f3082feec7a4a3": "Atualizações indisponíveis", "f50c240922fc42a6": "As atualizações automáticas não estão disponíveis no momento.", "461d2709ee66419a": ["Sobre o ", ["appName"]], - "7899be6b2ab267c9": "Verificar atualizações...", "87111169e6f002e4": "Configurações...", "4a68edd86ac8138e": "Serviços", "ea5807311cde5ccb": ["Ocultar ", ["appName"]], diff --git a/apps/desktop/src/i18n/translations/ru.json b/apps/desktop/src/i18n/translations/ru.json index 185acaff4dc35..8059b60e45047 100644 --- a/apps/desktop/src/i18n/translations/ru.json +++ b/apps/desktop/src/i18n/translations/ru.json @@ -115,14 +115,21 @@ "8cfcc2b2943aae3e": "Выберите ключ доступа", "936b24e87270b744": "Nightly", "e0b83984bb26f730": "Стабильный", + "7899be6b2ab267c9": "Проверить обновления...", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "У вас последняя версия!", "8fad8b3d58041567": ["T3 Code ", ["version"], " — новейшая доступная версия."], "bc180ba81f137d59": "Доступно обновление", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "Доступна новая версия T3 Code.", "e63b9fa18a099b0c": ["Доступна версия T3 Code ", ["version"], "."], "ea99dc48faea2f7d": ["У вас T3 Code ", ["version"], "."], "716c7a6c7bba40ad": "Скачать", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "Позже", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "Загрузка обновления", "c9d7dc5db1cde9e3": "Новая версия T3 Code уже загружается.", "5145d26d268fab9c": ["T3 Code ", ["version"], " уже загружается."], @@ -148,7 +155,6 @@ "21f3082feec7a4a3": "Обновления недоступны", "f50c240922fc42a6": "Автоматические обновления сейчас недоступны.", "461d2709ee66419a": ["О приложении ", ["appName"]], - "7899be6b2ab267c9": "Проверить обновления...", "87111169e6f002e4": "Настройки...", "4a68edd86ac8138e": "Службы", "ea5807311cde5ccb": ["Скрыть ", ["appName"]], diff --git a/apps/desktop/src/i18n/translations/sv.json b/apps/desktop/src/i18n/translations/sv.json index 60fa15e0be961..8d39365526d95 100644 --- a/apps/desktop/src/i18n/translations/sv.json +++ b/apps/desktop/src/i18n/translations/sv.json @@ -116,14 +116,21 @@ "8cfcc2b2943aae3e": "Välj en lösenordsnyckel", "936b24e87270b744": "Nightly", "e0b83984bb26f730": "Stable", + "7899be6b2ab267c9": "Sök efter uppdateringar...", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "Du har den senaste versionen!", "8fad8b3d58041567": ["T3 Code ", ["version"], " är den senaste tillgängliga versionen."], "bc180ba81f137d59": "Uppdatering tillgänglig", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "En ny version av T3 Code är tillgänglig.", "e63b9fa18a099b0c": ["T3 Code ", ["version"], " är tillgänglig."], "ea99dc48faea2f7d": ["Du kör T3 Code ", ["version"], "."], "716c7a6c7bba40ad": "Ladda ned", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "Senare", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "Uppdateringen laddas ner", "c9d7dc5db1cde9e3": "En ny version av T3 Code laddas redan ner.", "5145d26d268fab9c": ["T3 Code ", ["version"], " laddas redan ner."], @@ -149,7 +156,6 @@ "21f3082feec7a4a3": "Uppdateringar är inte tillgängliga", "f50c240922fc42a6": "Automatiska uppdateringar är inte tillgängliga just nu.", "461d2709ee66419a": ["Om ", ["appName"]], - "7899be6b2ab267c9": "Sök efter uppdateringar...", "87111169e6f002e4": "Inställningar...", "4a68edd86ac8138e": "Tjänster", "ea5807311cde5ccb": ["Dölj ", ["appName"]], diff --git a/apps/desktop/src/i18n/translations/zh.json b/apps/desktop/src/i18n/translations/zh.json index fcc1095830d15..a4d1a160086f9 100644 --- a/apps/desktop/src/i18n/translations/zh.json +++ b/apps/desktop/src/i18n/translations/zh.json @@ -99,14 +99,21 @@ "8cfcc2b2943aae3e": "选择通行密钥", "936b24e87270b744": "Nightly 版", "e0b83984bb26f730": "稳定版", + "7899be6b2ab267c9": "检查更新…", + "b18b21d234ba4ed7": ["Check for ", ["label"], " Updates..."], "401d077e95c45668": "已是最新版本!", "8fad8b3d58041567": ["T3 Code ", ["version"], " 已是最新版本。"], "bc180ba81f137d59": "有可用更新", + "af85beca2b69cc9c": [["label"], " update available"], "a26766a65f6111e3": "T3 Code 有新版本可用。", "e63b9fa18a099b0c": ["T3 Code ", ["version"], " 可用。"], "ea99dc48faea2f7d": ["你当前运行的是 T3 Code ", ["version"], "。"], "716c7a6c7bba40ad": "下载", + "6c33c72c86c2086e": ["Update ", ["label"]], "e821adbeb7085e2f": "稍后", + "ced452a1ef2dabeb": [["label"], " update failed"], + "4f1a59d3f809844f": "The update stopped before anything was installed.", + "f8134a994f291d41": "Check the desktop log for details.", "6b1b0f96f8c91702": "正在下载更新", "c9d7dc5db1cde9e3": "T3 Code 的新版本已在下载中。", "5145d26d268fab9c": ["T3 Code ", ["version"], " 已在下载中。"], @@ -132,7 +139,6 @@ "21f3082feec7a4a3": "更新不可用", "f50c240922fc42a6": "目前无法自动更新。", "461d2709ee66419a": ["关于 ", ["appName"]], - "7899be6b2ab267c9": "检查更新…", "87111169e6f002e4": "设置…", "4a68edd86ac8138e": "服务", "ea5807311cde5ccb": ["隐藏 ", ["appName"]], diff --git a/apps/desktop/src/main.ts b/apps/desktop/src/main.ts index 8c32805a94463..d6f6fb6de53b5 100644 --- a/apps/desktop/src/main.ts +++ b/apps/desktop/src/main.ts @@ -31,8 +31,8 @@ import * as ElectronProtocol from "./electron/ElectronProtocol.ts"; import * as ElectronSafeStorage from "./electron/ElectronSafeStorage.ts"; import * as ElectronShell from "./electron/ElectronShell.ts"; import * as ElectronTheme from "./electron/ElectronTheme.ts"; -import * as ElectronUpdater from "./electron/ElectronUpdater.ts"; import * as ElectronWindow from "./electron/ElectronWindow.ts"; +import * as SourceUpdater from "./electron/SourceUpdater.ts"; import * as DesktopApp from "./app/DesktopApp.ts"; import * as DesktopAppActivation from "./app/DesktopAppActivation.ts"; import * as DesktopWebLinks from "./app/DesktopWebLinks.ts"; @@ -139,7 +139,7 @@ const layerElectron = Layer.mergeAll( ElectronSafeStorage.layer, ElectronShell.layer, ElectronTheme.layer, - ElectronUpdater.layer, + SourceUpdater.layer, ElectronWindow.layer, DesktopIpc.layer(Electron.ipcMain).pipe(Layer.provide(ElectronWindow.layer)), ); diff --git a/apps/desktop/src/updates/releaseNotes.ts b/apps/desktop/src/updates/releaseNotes.ts index bf874062b7d7e..ae4fa57a772e2 100644 --- a/apps/desktop/src/updates/releaseNotes.ts +++ b/apps/desktop/src/updates/releaseNotes.ts @@ -209,11 +209,13 @@ export function normalizeDesktopUpdateReleaseNotes( const note = extractReleaseNoteItems(entry.note); if (note.totalItems === 0 && !note.stats) return []; const releasedAt = resolveReleasedAt(entry.version, fallbackVersion, releaseDate); + const { url } = entry as { readonly url?: unknown }; return [ { version: entry.version, ...note, ...(releasedAt ? { releasedAt } : {}), + ...(typeof url === "string" ? { url } : {}), }, ]; }); diff --git a/apps/desktop/src/window/DesktopApplicationMenu.ts b/apps/desktop/src/window/DesktopApplicationMenu.ts index 79d7367bbcea3..c974a33f186b5 100644 --- a/apps/desktop/src/window/DesktopApplicationMenu.ts +++ b/apps/desktop/src/window/DesktopApplicationMenu.ts @@ -12,6 +12,7 @@ import { makeComponentLogger } from "../app/DesktopObservability.ts"; import * as ElectronApp from "../electron/ElectronApp.ts"; import * as ElectronDialog from "../electron/ElectronDialog.ts"; import * as ElectronMenu from "../electron/ElectronMenu.ts"; +import * as SourceUpdater from "../electron/SourceUpdater.ts"; import * as DesktopEnvironment from "../app/DesktopEnvironment.ts"; import { applyLanguage, m, onLocaleChange } from "../i18n/messages.ts"; import * as DesktopClientSettings from "../settings/DesktopClientSettings.ts"; @@ -74,9 +75,16 @@ const trackLabel = (channel: DesktopUpdateChannel) => ? m(msg({ context: "release track" })`Nightly`) : m(msg({ context: "release track" })`Stable`); +const checkForUpdatesLabel = () => + Option.match(SourceUpdater.readSourceUpdateLabel(), { + onNone: () => m(msg("Check for Updates...")), + onSome: (label) => m(msg`Check for ${{ label }} Updates...`), + }); + const checkForUpdatesFromMenu = Effect.gen(function* () { const updates = yield* DesktopUpdates.DesktopUpdates; const electronDialog = yield* ElectronDialog.ElectronDialog; + const sourceLabel = SourceUpdater.readSourceUpdateLabel(); const result = yield* updates.check("menu"); const updateState = result.state; @@ -92,17 +100,37 @@ const checkForUpdatesFromMenu = Effect.gen(function* () { } else if (updateState.status === "available") { const { response } = yield* electronDialog.showMessageBox({ type: "info", - title: m(msg("Update available")), + title: Option.match(sourceLabel, { + onNone: () => m(msg("Update available")), + onSome: (label) => m(msg`${{ label }} update available`), + }), message: updateState.availableVersion === null ? m(msg("A new version of T3 Code is available.")) : m(msg`T3 Code ${{ version: updateState.availableVersion }} is available.`), detail: m(msg`You're running T3 Code ${{ version: updateState.currentVersion }}.`), - buttons: [m(msg({ context: "button, downloads an app update" })`Download`), m(msg("Later"))], + buttons: [ + Option.match(sourceLabel, { + onNone: () => m(msg({ context: "button, downloads an app update" })`Download`), + onSome: (label) => m(msg`Update ${{ label }}`), + }), + m(msg("Later")), + ], defaultId: 0, cancelId: 1, }); - if (response === 0) yield* updates.download; + if (response === 0) { + const downloaded = yield* updates.download; + if (downloaded.state.errorContext === "download" && Option.isSome(sourceLabel)) { + yield* electronDialog.showMessageBox({ + type: "warning", + title: m(msg`${{ label: sourceLabel.value }} update failed`), + message: m(msg("The update stopped before anything was installed.")), + detail: downloaded.state.message ?? m(msg("Check the desktop log for details.")), + buttons: [m(msg("OK"))], + }); + } + } } else if (updateState.status === "downloading") { yield* electronDialog.showMessageBox({ type: "info", @@ -231,7 +259,7 @@ export const make = Effect.gen(function* () { submenu: [ { role: "about", label: m(msg`About ${{ appName: environment.displayName }}`) }, { - label: m(msg("Check for Updates...")), + label: checkForUpdatesLabel(), click: checkForUpdatesClick, }, { type: "separator" }, @@ -408,7 +436,7 @@ export const make = Effect.gen(function* () { label: m(msg({ context: "menu bar title" })`Help`), submenu: [ { - label: m(msg("Check for Updates...")), + label: checkForUpdatesLabel(), click: checkForUpdatesClick, }, ], diff --git a/apps/web/src/components/desktopUpdate.logic.test.ts b/apps/web/src/components/desktopUpdate.logic.test.ts index 601527e51a201..7a4731d9c6029 100644 --- a/apps/web/src/components/desktopUpdate.logic.test.ts +++ b/apps/web/src/components/desktopUpdate.logic.test.ts @@ -7,6 +7,9 @@ import { getDesktopUpdateReleaseHistoryUrl, getDesktopUpdateActionError, getDesktopUpdateReleaseUrl, + getDesktopUpdateSourceLabel, + getReleaseNoteCommitSha, + getSourceBuildLabel, installDesktopUpdate, resolveDesktopUpdateButtonAction, } from "./desktopUpdate.logic"; @@ -177,3 +180,29 @@ describe("canCheckForUpdate", () => { ).toBe(true); }); }); + +describe("getDesktopUpdateSourceLabel", () => { + it("names the source only for a build that rebuilds from its checkout", () => { + const sourceState = { ...baseState, currentVersion: "0.1.13-source.20261204.4821" }; + expect(getDesktopUpdateSourceLabel(sourceState, "Trogon fork")).toBe("Trogon fork"); + expect(getDesktopUpdateSourceLabel(sourceState, "")).toBe("source"); + expect(getDesktopUpdateSourceLabel(baseState, "Trogon fork")).toBeNull(); + expect(getDesktopUpdateSourceLabel(null, "Trogon fork")).toBeNull(); + }); + + it("reads the short sha out of a commit link", () => { + expect( + getReleaseNoteCommitSha("https://github.com/TrogonStack/t3code/commit/dc69adc3091234"), + ).toBe("dc69adc"); + expect( + getReleaseNoteCommitSha("https://github.com/pingdotgg/t3code/releases/tag/v1"), + ).toBeNull(); + expect(getReleaseNoteCommitSha(undefined)).toBeNull(); + }); + + it("names the source of an offered version the same way", () => { + expect(getSourceBuildLabel("0.1.13-source.20261205.4822", "Trogon fork")).toBe("Trogon fork"); + expect(getSourceBuildLabel("0.1.14", "Trogon fork")).toBeNull(); + expect(getSourceBuildLabel(null, "Trogon fork")).toBeNull(); + }); +}); diff --git a/apps/web/src/components/desktopUpdate.logic.ts b/apps/web/src/components/desktopUpdate.logic.ts index 2b1a22fdd78e2..f1d94f235c0ce 100644 --- a/apps/web/src/components/desktopUpdate.logic.ts +++ b/apps/web/src/components/desktopUpdate.logic.ts @@ -5,6 +5,7 @@ import type { DesktopUpdateState, } from "@t3tools/contracts"; import { desktopUpdateChannelOf } from "@t3tools/shared/cliRelease"; +import { isSourceBuildVersion } from "@t3tools/shared/sourceUpdate"; import { msg } from "gt-react"; import { m, type MessageResolver } from "../i18n/messages"; @@ -31,6 +32,30 @@ function desktopReleaseRepositoryUrl(repository: string | undefined): string { return `https://github.com/${releaseRepository}/releases`; } +/** A build that updates by rebuilding from its checkout names that source in its update copy. */ +export function getDesktopUpdateSourceLabel( + state: DesktopUpdateState | null, + label: string | undefined = import.meta.env.T3CODE_DESKTOP_SOURCE_UPDATE_LABEL, +): string | null { + if (!state || !isSourceBuildVersion(state.currentVersion)) return null; + return label?.trim() || "source"; +} + +/** The short sha a note's commit link points at; null for a release link. */ +export function getReleaseNoteCommitSha(url: string | undefined): string | null { + const match = url === undefined ? null : /\/commit\/([0-9a-f]{7,40})\/?$/.exec(url); + return match === null ? null : match[1]!.slice(0, 7); +} + +/** Names the source a version was, or will be, built from; null for a release-feed version. */ +export function getSourceBuildLabel( + version: string | null, + label: string | undefined = import.meta.env.T3CODE_DESKTOP_SOURCE_UPDATE_LABEL, +): string | null { + if (version === null || !isSourceBuildVersion(version)) return null; + return label?.trim() || "source"; +} + /** The download RPC can beat the updater's downloadedVersion event; fall back to the requested version. */ export function getDesktopUpdateDownloadedVersion(state: DesktopUpdateState): string | null { return state.downloadedVersion ?? state.availableVersion; @@ -286,8 +311,12 @@ export function getDesktopUpdateIdleTooltip( if (disabledReason) { return { title: resolve(msg("Updates unavailable")), detail: disabledReason }; } + const label = getDesktopUpdateSourceLabel(state); return { - title: resolve(msg("Check for updates")), + title: + label === null + ? resolve(msg("Check for updates")) + : resolve(msg`Check for ${{ label }} updates`), // A failed check leaves no offer to show, so the idle button says why. detail: state?.status === "error" ? getDesktopUpdateButtonTooltip(state, resolve) : null, }; diff --git a/apps/web/src/components/desktopUpdate.toast.tsx b/apps/web/src/components/desktopUpdate.toast.tsx index 77904b23b7910..a2caa37863ef2 100644 --- a/apps/web/src/components/desktopUpdate.toast.tsx +++ b/apps/web/src/components/desktopUpdate.toast.tsx @@ -50,7 +50,10 @@ export function showDesktopUpdateDownloadedToast( shell: DesktopUpdateShell, state: DesktopUpdateState, ): void { - const releaseUrl = getDesktopUpdateReleaseUrl(getDesktopUpdateDownloadedVersion(state)); + const downloadedVersion = getDesktopUpdateDownloadedVersion(state); + const releaseUrl = + state.releaseNotes.find((note) => note.version === downloadedVersion)?.url ?? + getDesktopUpdateReleaseUrl(downloadedVersion); toastManager.add({ type: "success", title: m(msg("Update downloaded")), diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx index ed43cbdfc53e9..930c108f1eede 100644 --- a/apps/web/src/components/settings/SettingsPanels.tsx +++ b/apps/web/src/components/settings/SettingsPanels.tsx @@ -46,6 +46,7 @@ import { getDesktopUpdateButtonTooltip, getDesktopUpdateDisabledReason, getDesktopUpdateInstallConfirmationMessage, + getDesktopUpdateSourceLabel, installDesktopUpdate, isDesktopUpdateButtonDisabled, resolveDesktopUpdateButtonAction, @@ -332,7 +333,11 @@ function AboutVersionSection() { ? !canCheckForUpdate(updateState) : isDesktopUpdateButtonDisabled(updateState); - const actionLabel: Record = { download: gt`Download`, install: gt`Install` }; + const sourceLabel = getDesktopUpdateSourceLabel(updateState); + const actionLabel: Record = { + download: sourceLabel === null ? gt`Download` : gt`Update ${{ label: sourceLabel }}`, + install: gt`Install`, + }; const statusLabel: Record = { checking: gt`Checking…`, downloading: gt`Downloading…`, @@ -340,10 +345,16 @@ function AboutVersionSection() { ...(appOffTrack ? {} : { "up-to-date": gt`Up to Date` }), }; const buttonLabel = - actionLabel[action] ?? statusLabel[updateState?.status ?? ""] ?? gt`Check for Updates`; + actionLabel[action] ?? + statusLabel[updateState?.status ?? ""] ?? + (sourceLabel === null + ? gt`Check for Updates` + : gt`Check for ${{ label: sourceLabel }} Updates`); const description = action === "download" || action === "install" - ? gt`Update available.` + ? sourceLabel === null + ? gt`Update available.` + : gt`${{ label: sourceLabel }} update available.` : (getDesktopUpdateDisabledReason(updateState, updatesDenial, messages) ?? gt`Current version of the application.`); diff --git a/apps/web/src/components/sidebar/SidebarUpdatePill.tsx b/apps/web/src/components/sidebar/SidebarUpdatePill.tsx index 2c410b6a15b30..f50f87ce0a386 100644 --- a/apps/web/src/components/sidebar/SidebarUpdatePill.tsx +++ b/apps/web/src/components/sidebar/SidebarUpdatePill.tsx @@ -22,6 +22,7 @@ import { getDesktopUpdateDownloadedVersion, getDesktopUpdateIdleTooltip, getDesktopUpdateInstallConfirmationMessage, + getDesktopUpdateSourceLabel, installDesktopUpdate, isDesktopUpdateButtonDisabled, resolveDesktopUpdateButtonAction, @@ -262,6 +263,7 @@ function SidebarUpdateControl() { isDownloading, showCheckIcon, }); + const sourceLabel = getDesktopUpdateSourceLabel(state); const idleTooltip = !showUpdateDetails && !showCheckIcon ? getDesktopUpdateIdleTooltip(state, updatesDenial, messages) @@ -274,7 +276,10 @@ function SidebarUpdateControl() { : gt`Update available` : showCheckIcon ? gt`Checking for updates…` - : (idleTooltip?.title ?? gt`Check for updates`); + : (idleTooltip?.title ?? + (sourceLabel === null + ? gt`Check for updates` + : gt`Check for ${{ label: sourceLabel }} updates`)); const disabled = showCheckIcon ? true : runsEverything diff --git a/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx b/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx index 489115e1c85c4..55cf34e9a620e 100644 --- a/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx +++ b/apps/web/src/components/sidebar/SidebarUpdateReleaseNotes.tsx @@ -7,6 +7,7 @@ import { getDesktopUpdateDownloadedVersion, getDesktopUpdateReleaseHistoryUrl, getDesktopUpdateReleaseUrl, + getReleaseNoteCommitSha, } from "../desktopUpdate.logic"; import type { MessageResolver } from "../../i18n/messages"; import { formatRelativeTimeLabel } from "../../timestampFormat"; @@ -85,19 +86,22 @@ export function SidebarUpdateReleaseNotes({
{state.releaseNotes.map((releaseNote, index) => { - const releaseUrl = getDesktopUpdateReleaseUrl(releaseNote.version); + const releaseUrl = releaseNote.url ?? getDesktopUpdateReleaseUrl(releaseNote.version); const omittedItemCount = Math.max(0, releaseNote.totalItems - releaseNote.items.length); + const commitSha = getReleaseNoteCommitSha(releaseNote.url); const linkLabel = releaseNote.stats ?? - (omittedItemCount === 0 - ? gt`View release on GitHub` - : gt`${plural( - { count: omittedItemCount }, - { - one: part`${{ count: omittedItemCount }} more change on GitHub`, - other: part`${{ count: omittedItemCount }} more changes on GitHub`, - }, - )}`); + (commitSha !== null + ? gt`View commit ${{ sha: commitSha }} on GitHub` + : omittedItemCount === 0 + ? gt`View release on GitHub` + : gt`${plural( + { count: omittedItemCount }, + { + one: part`${{ count: omittedItemCount }} more change on GitHub`, + other: part`${{ count: omittedItemCount }} more changes on GitHub`, + }, + )}`); const generated = releaseNote.stats !== undefined || releaseNote.intro !== undefined; return ( diff --git a/apps/web/src/components/sidebar/UpdateEverythingDialog.tsx b/apps/web/src/components/sidebar/UpdateEverythingDialog.tsx index 832d55cf22755..8a0f56cbbb5e5 100644 --- a/apps/web/src/components/sidebar/UpdateEverythingDialog.tsx +++ b/apps/web/src/components/sidebar/UpdateEverythingDialog.tsx @@ -19,6 +19,7 @@ import { Button } from "../ui/button"; import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "../ui/collapsible"; import { MiddleTruncate } from "../ui/middle-truncate"; import { ScrollArea } from "../ui/scroll-area"; +import { getSourceBuildLabel } from "../desktopUpdate.logic"; import type { RestartingMachine, UpdateEverythingRow } from "./updateEverything.logic"; const isRunning = (status: string) => @@ -133,6 +134,7 @@ function UpdateEverythingDialogContent({ const updating = rows.filter((row) => row.app !== null || row.providers.length > 0); const skipped = rows.filter((row) => row.skipped !== null); const hasNothingToUpdate = title === undefined && updating.length === 0; + const sourceLabel = getSourceBuildLabel(version); const hasBody = notes.length > 0 || updating.length > 0 || skipped.length > 0; return ( @@ -167,6 +169,7 @@ function UpdateEverythingDialogContent({ ) : ( <> T3 Code {version} + {sourceLabel === null ? null : ` (${sourceLabel})`} )} {version !== null && providerCount > 0 ? " · " : null} diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index a58c37dbaa94a..b56f3982cb6c7 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -8350,6 +8350,7 @@ "592fa6b64e637926": "Automatische Updates sind in diesem Build nicht verfügbar.", "21f3082feec7a4a3": "Updates nicht verfügbar", "785d723afe13e35d": "Nach Updates suchen", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "Versionshinweise können nicht geöffnet werden", "bb8efb117b692fd9": "Update heruntergeladen", "cfd874b32f0c1855": "Mehr erfahren", @@ -18738,9 +18739,12 @@ "3ef224a6d1edb064": "Es konnte nicht nach Updates gesucht werden", "3bd99f4244a51051": "Suche nach Updates fehlgeschlagen.", "a2574f8f3909bcee": "Herunterladen", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "Aktuell", "93a0de7f3ff8287b": "Nach Updates suchen", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "Update verfügbar.", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "Aktuelle Version der Anwendung.", "57c78e9c8d07f649": [ ["policy"], @@ -21030,6 +21034,7 @@ "18600b36873c0a35": "T3-Code-Startseite", "b1b6544a2908aef6": "Issues", "883cb1fd1467ce6f": "Nutzung", + "5d951bbad16901a1": "Angeheftet", "263a68303cccdf1c": ["Aktionen für ", ["name"]], "a19edfd5d4a6b98f": "Zurückgestellte Projekte", "c64146b03c0ca385": "Projekt wieder aktivieren", @@ -21147,7 +21152,6 @@ } ] ], - "5d951bbad16901a1": "Angeheftet", "c44f94c59e5d5430": [ [ "count", @@ -21250,6 +21254,7 @@ "9dd53d8800e2c835": "Intel-Build auf Apple Silicon", "e5c53813e256fccc": "heute", "9775810a912ece0a": ["vor ", ["days"], " T."], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "Release auf GitHub ansehen", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index c0801591dc497..5d30024bc2215 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -8146,6 +8146,7 @@ "592fa6b64e637926": "Automatic updates are not available in this build.", "21f3082feec7a4a3": "Updates unavailable", "785d723afe13e35d": "Check for updates", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "Unable to open release notes", "bb8efb117b692fd9": "Update downloaded", "cfd874b32f0c1855": "Read more", @@ -18461,9 +18462,12 @@ "3ef224a6d1edb064": "Could not check for updates", "3bd99f4244a51051": "Update check failed.", "a2574f8f3909bcee": "Download", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "Up to Date", "93a0de7f3ff8287b": "Check for Updates", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "Update available.", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "Current version of the application.", "57c78e9c8d07f649": [ ["policy"], @@ -20690,6 +20694,7 @@ "18600b36873c0a35": "T3 Code home", "b1b6544a2908aef6": "Issues", "883cb1fd1467ce6f": "Usage", + "5d951bbad16901a1": "Pinned", "263a68303cccdf1c": ["Actions for ", ["name"]], "a19edfd5d4a6b98f": "Snoozed projects", "c64146b03c0ca385": "Unsnooze project", @@ -20806,7 +20811,6 @@ } ] ], - "5d951bbad16901a1": "Pinned", "c44f94c59e5d5430": [ [ "count", @@ -20909,6 +20913,7 @@ "9dd53d8800e2c835": "Intel build on Apple Silicon", "e5c53813e256fccc": "today", "9775810a912ece0a": [["days"], "d ago"], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "View release on GitHub", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index 553aebed411c7..567230aeb6100 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -8296,6 +8296,7 @@ "592fa6b64e637926": "Las actualizaciones automáticas no están disponibles en esta compilación.", "21f3082feec7a4a3": "Actualizaciones no disponibles", "785d723afe13e35d": "Buscar actualizaciones", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "No se pueden abrir las notas de la versión", "bb8efb117b692fd9": "Actualización descargada", "cfd874b32f0c1855": "Más información", @@ -18679,9 +18680,12 @@ "3ef224a6d1edb064": "No se pudo buscar actualizaciones", "3bd99f4244a51051": "Falló la búsqueda de actualizaciones.", "a2574f8f3909bcee": "Descargar", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "Actualizado", "93a0de7f3ff8287b": "Buscar actualizaciones", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "Actualización disponible.", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "Versión actual de la aplicación.", "57c78e9c8d07f649": [ ["policy"], @@ -20948,6 +20952,7 @@ "18600b36873c0a35": "Inicio de T3 Code", "b1b6544a2908aef6": "Issues", "883cb1fd1467ce6f": "Uso", + "5d951bbad16901a1": "Fijados", "263a68303cccdf1c": ["Acciones de ", ["name"]], "a19edfd5d4a6b98f": "Proyectos pospuestos", "c64146b03c0ca385": "Dejar de posponer el proyecto", @@ -21065,7 +21070,6 @@ } ] ], - "5d951bbad16901a1": "Fijados", "c44f94c59e5d5430": [ [ "count", @@ -21168,6 +21172,7 @@ "9dd53d8800e2c835": "Compilación para Intel en Apple Silicon", "e5c53813e256fccc": "hoy", "9775810a912ece0a": ["hace ", ["days"], " d"], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "Ver la versión en GitHub", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index dc6eafc5fd606..3a602bfcc34be 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -8343,6 +8343,7 @@ "592fa6b64e637926": "Les mises à jour automatiques ne sont pas disponibles dans cette version.", "21f3082feec7a4a3": "Mises à jour indisponibles", "785d723afe13e35d": "Rechercher des mises à jour", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "Impossible d’ouvrir les notes de version", "bb8efb117b692fd9": "Mise à jour téléchargée", "cfd874b32f0c1855": "En savoir plus", @@ -18779,9 +18780,12 @@ "3ef224a6d1edb064": "Impossible de rechercher des mises à jour", "3bd99f4244a51051": "La recherche de mises à jour a échoué.", "a2574f8f3909bcee": "Télécharger", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "À jour", "93a0de7f3ff8287b": "Rechercher des mises à jour", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "Mise à jour disponible.", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "Version actuelle de l’application.", "57c78e9c8d07f649": [ ["policy"], @@ -21068,6 +21072,7 @@ "18600b36873c0a35": "Accueil T3 Code", "b1b6544a2908aef6": "Tickets", "883cb1fd1467ce6f": "Utilisation", + "5d951bbad16901a1": "Épinglés", "263a68303cccdf1c": ["Actions pour ", ["name"]], "a19edfd5d4a6b98f": "Projets reportés", "c64146b03c0ca385": "Annuler le report du projet", @@ -21185,7 +21190,6 @@ } ] ], - "5d951bbad16901a1": "Épinglés", "c44f94c59e5d5430": [ [ "count", @@ -21288,6 +21292,7 @@ "9dd53d8800e2c835": "Build Intel sur Apple Silicon", "e5c53813e256fccc": "aujourd’hui", "9775810a912ece0a": ["il y a ", ["days"], " j"], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "Voir la version sur GitHub", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index c23913779a564..0d7c4b4505d05 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -7836,6 +7836,7 @@ "592fa6b64e637926": "このビルドでは自動更新を利用できません。", "21f3082feec7a4a3": "更新を利用できません", "785d723afe13e35d": "更新を確認", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "リリースノートを開けません", "bb8efb117b692fd9": "更新をダウンロードしました", "cfd874b32f0c1855": "詳細を読む", @@ -17837,9 +17838,12 @@ "3ef224a6d1edb064": "更新を確認できませんでした", "3bd99f4244a51051": "更新の確認に失敗しました。", "a2574f8f3909bcee": "ダウンロード", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "最新です", "93a0de7f3ff8287b": "更新を確認", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "更新があります。", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "アプリケーションの現在のバージョン。", "57c78e9c8d07f649": [ ["policy"], @@ -20095,6 +20099,7 @@ "18600b36873c0a35": "T3 Code ホーム", "b1b6544a2908aef6": "Issue", "883cb1fd1467ce6f": "使用量", + "5d951bbad16901a1": "ピン留め済み", "263a68303cccdf1c": [["name"], " の操作"], "a19edfd5d4a6b98f": "スヌーズ中のプロジェクト", "c64146b03c0ca385": "プロジェクトのスヌーズを解除", @@ -20200,7 +20205,6 @@ } ] ], - "5d951bbad16901a1": "ピン留め済み", "c44f94c59e5d5430": [ [ "count", @@ -20302,6 +20306,7 @@ "9dd53d8800e2c835": "Apple Silicon 上の Intel ビルド", "e5c53813e256fccc": "今日", "9775810a912ece0a": [["days"], " 日前"], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "GitHub でリリースを表示", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index abdf8ec656ffc..ff3614b730c27 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -7740,6 +7740,7 @@ "592fa6b64e637926": "이 빌드에서는 자동 업데이트를 사용할 수 없습니다.", "21f3082feec7a4a3": "업데이트를 사용할 수 없음", "785d723afe13e35d": "업데이트 확인", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "릴리스 노트를 열 수 없습니다", "bb8efb117b692fd9": "업데이트 다운로드됨", "cfd874b32f0c1855": "자세히 보기", @@ -17731,9 +17732,12 @@ "3ef224a6d1edb064": "업데이트를 확인할 수 없습니다", "3bd99f4244a51051": "업데이트 확인에 실패했습니다.", "a2574f8f3909bcee": "다운로드", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "최신 상태", "93a0de7f3ff8287b": "업데이트 확인", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "업데이트가 있습니다.", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "애플리케이션의 현재 버전입니다.", "57c78e9c8d07f649": [ ["policy"], @@ -19950,6 +19954,7 @@ "18600b36873c0a35": "T3 Code 홈", "b1b6544a2908aef6": "이슈", "883cb1fd1467ce6f": "사용량", + "5d951bbad16901a1": "고정됨", "263a68303cccdf1c": [["name"], " 작업"], "a19edfd5d4a6b98f": "다시 알림이 설정된 프로젝트", "c64146b03c0ca385": "프로젝트 다시 알림 해제", @@ -20055,7 +20060,6 @@ } ] ], - "5d951bbad16901a1": "고정됨", "c44f94c59e5d5430": [ [ "count", @@ -20157,6 +20161,7 @@ "9dd53d8800e2c835": "Apple Silicon의 Intel 빌드", "e5c53813e256fccc": "오늘", "9775810a912ece0a": [["days"], "일 전"], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "GitHub에서 릴리스 보기", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/i18n/translations/pl.json b/apps/web/src/i18n/translations/pl.json index 186830b27fccb..de25d62e1b758 100644 --- a/apps/web/src/i18n/translations/pl.json +++ b/apps/web/src/i18n/translations/pl.json @@ -9181,6 +9181,7 @@ "592fa6b64e637926": "Automatyczne aktualizacje nie są dostępne w tej wersji.", "21f3082feec7a4a3": "Aktualizacje niedostępne", "785d723afe13e35d": "Sprawdź aktualizacje", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "Nie można otworzyć informacji o wydaniu", "bb8efb117b692fd9": "Aktualizacja pobrana", "cfd874b32f0c1855": "Czytaj więcej", @@ -20105,9 +20106,12 @@ "3ef224a6d1edb064": "Nie udało się sprawdzić aktualizacji", "3bd99f4244a51051": "Sprawdzenie aktualizacji nie powiodło się.", "a2574f8f3909bcee": "Pobierz", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "Aktualne", "93a0de7f3ff8287b": "Sprawdź aktualizacje", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "Dostępna aktualizacja.", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "Bieżąca wersja aplikacji.", "57c78e9c8d07f649": [ ["policy"], @@ -22455,6 +22459,7 @@ "18600b36873c0a35": "Strona główna T3 Code", "b1b6544a2908aef6": "Zgłoszenia", "883cb1fd1467ce6f": "Użycie", + "5d951bbad16901a1": "Przypięty", "263a68303cccdf1c": ["Akcje dla ", ["name"]], "a19edfd5d4a6b98f": "Uśpione projekty", "c64146b03c0ca385": "Wybudź projekt", @@ -22620,7 +22625,6 @@ } ] ], - "5d951bbad16901a1": "Przypięty", "c44f94c59e5d5430": [ [ "count", @@ -22735,6 +22739,7 @@ "9dd53d8800e2c835": "Wersja Intel na Apple Silicon", "e5c53813e256fccc": "dziś", "9775810a912ece0a": [["days"], " dni temu"], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "Zobacz wydanie na GitHubie", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index aa6b7f99c6ac9..af1d6e7cc47ae 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -8324,6 +8324,7 @@ "592fa6b64e637926": "Atualizações automáticas não estão disponíveis nesta versão.", "21f3082feec7a4a3": "Atualizações indisponíveis", "785d723afe13e35d": "Verificar atualizações", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "Não foi possível abrir as notas da versão", "bb8efb117b692fd9": "Atualização baixada", "cfd874b32f0c1855": "Saiba mais", @@ -18709,9 +18710,12 @@ "3ef224a6d1edb064": "Não foi possível verificar atualizações", "3bd99f4244a51051": "A verificação de atualizações falhou.", "a2574f8f3909bcee": "Baixar", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "Atualizado", "93a0de7f3ff8287b": "Verificar atualizações", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "Atualização disponível.", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "Versão atual do aplicativo.", "57c78e9c8d07f649": [ ["policy"], @@ -20976,6 +20980,7 @@ "18600b36873c0a35": "Início do T3 Code", "b1b6544a2908aef6": "Issues", "883cb1fd1467ce6f": "Uso", + "5d951bbad16901a1": "Fixadas", "263a68303cccdf1c": ["Ações de ", ["name"]], "a19edfd5d4a6b98f": "Projetos adiados", "c64146b03c0ca385": "Cancelar adiamento do projeto", @@ -21093,7 +21098,6 @@ } ] ], - "5d951bbad16901a1": "Fixadas", "c44f94c59e5d5430": [ [ "count", @@ -21196,6 +21200,7 @@ "9dd53d8800e2c835": "Build Intel no Apple Silicon", "e5c53813e256fccc": "hoje", "9775810a912ece0a": ["há ", ["days"], " d"], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "Ver versão no GitHub", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index 90ca88fd228d8..aa524e0d3ffa2 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -9107,6 +9107,7 @@ "592fa6b64e637926": "Автоматические обновления недоступны в этой сборке.", "21f3082feec7a4a3": "Обновления недоступны", "785d723afe13e35d": "Проверить обновления", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "Не удалось открыть примечания к выпуску", "bb8efb117b692fd9": "Обновление скачано", "cfd874b32f0c1855": "Подробнее", @@ -19964,9 +19965,12 @@ "3ef224a6d1edb064": "Не удалось проверить обновления", "3bd99f4244a51051": "Проверка обновлений не удалась.", "a2574f8f3909bcee": "Скачать", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "Обновлений нет", "93a0de7f3ff8287b": "Проверить обновления", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "Доступно обновление.", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "Текущая версия приложения.", "57c78e9c8d07f649": [ ["policy"], @@ -22314,6 +22318,7 @@ "18600b36873c0a35": "Главная T3 Code", "b1b6544a2908aef6": "Issues", "883cb1fd1467ce6f": "Использование", + "5d951bbad16901a1": "Закреплённые", "263a68303cccdf1c": ["Действия для ", ["name"]], "a19edfd5d4a6b98f": "Отложенные проекты", "c64146b03c0ca385": "Отменить отсрочку проекта", @@ -22479,7 +22484,6 @@ } ] ], - "5d951bbad16901a1": "Закреплённые", "c44f94c59e5d5430": [ [ "count", @@ -22599,6 +22603,7 @@ "9dd53d8800e2c835": "Сборка Intel на Apple Silicon", "e5c53813e256fccc": "сегодня", "9775810a912ece0a": [["days"], " д назад"], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "Открыть релиз на GitHub", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index c5d1424abb7c9..ecaa7527b7e71 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -8242,6 +8242,7 @@ "592fa6b64e637926": "Automatiska uppdateringar är inte tillgängliga i den här versionen.", "21f3082feec7a4a3": "Uppdateringar är inte tillgängliga", "785d723afe13e35d": "Sök efter uppdateringar", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "Det gick inte att öppna versionsinformationen", "bb8efb117b692fd9": "Uppdateringen har laddats ned", "cfd874b32f0c1855": "Läs mer", @@ -18589,9 +18590,12 @@ "3ef224a6d1edb064": "Kunde inte söka efter uppdateringar", "3bd99f4244a51051": "Sökningen efter uppdateringar misslyckades.", "a2574f8f3909bcee": "Ladda ned", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "Uppdaterad", "93a0de7f3ff8287b": "Sök efter uppdateringar", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "Uppdatering tillgänglig.", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "Programmets aktuella version.", "57c78e9c8d07f649": [ ["policy"], @@ -20860,6 +20864,7 @@ "18600b36873c0a35": "T3 Code start", "b1b6544a2908aef6": "Ärenden", "883cb1fd1467ce6f": "Användning", + "5d951bbad16901a1": "Fäst", "263a68303cccdf1c": ["Åtgärder för ", ["name"]], "a19edfd5d4a6b98f": "Snoozade projekt", "c64146b03c0ca385": "Avsluta snooze för projektet", @@ -20976,7 +20981,6 @@ } ] ], - "5d951bbad16901a1": "Fäst", "c44f94c59e5d5430": [ [ "count", @@ -21079,6 +21083,7 @@ "9dd53d8800e2c835": "Intel-version på Apple Silicon", "e5c53813e256fccc": "i dag", "9775810a912ece0a": ["för ", ["days"], " d sedan"], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "Visa versionen på GitHub", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index 014cc8c3b76d3..fd01a68a2999b 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -7553,6 +7553,7 @@ "592fa6b64e637926": "此版本不支持自动更新。", "21f3082feec7a4a3": "更新不可用", "785d723afe13e35d": "检查更新", + "dac7ea2d3cbeae58": ["Check for ", ["label"], " updates"], "f1db4339a19ab6c7": "无法打开发行说明", "bb8efb117b692fd9": "已下载更新", "cfd874b32f0c1855": "了解更多", @@ -17426,9 +17427,12 @@ "3ef224a6d1edb064": "无法检查更新", "3bd99f4244a51051": "检查更新失败。", "a2574f8f3909bcee": "下载", + "6c33c72c86c2086e": ["Update ", ["label"]], "4785cb44c3a35f8c": "已是最新版本", "93a0de7f3ff8287b": "检查更新", + "d1bbabc60e6631a9": ["Check for ", ["label"], " Updates"], "68898ceffcc969e0": "有可用更新。", + "3379bf14722ff0dc": [["label"], " update available."], "074d225fd9ccdd66": "应用的当前版本。", "57c78e9c8d07f649": [["policy"], " 无法使用 Nightly 版本;切换到 Stable 以继续获取更新。"], "ca076b96fd7c5815": [["policy"], " 无法使用 Nightly 版本。"], @@ -19603,6 +19607,7 @@ "18600b36873c0a35": "T3 Code 首页", "b1b6544a2908aef6": "issue", "883cb1fd1467ce6f": "用量", + "5d951bbad16901a1": "已置顶", "263a68303cccdf1c": [["name"], " 的操作"], "a19edfd5d4a6b98f": "已暂缓的项目", "c64146b03c0ca385": "取消暂缓项目", @@ -19704,7 +19709,6 @@ } ] ], - "5d951bbad16901a1": "已置顶", "c44f94c59e5d5430": [ [ "count", @@ -19807,6 +19811,7 @@ "9dd53d8800e2c835": "Apple Silicon 上的 Intel 版本", "e5c53813e256fccc": "今天", "9775810a912ece0a": [["days"], " 天前"], + "6085199b1bba6a73": ["View commit ", ["sha"], " on GitHub"], "1e6116e85bb1f518": "在 GitHub 上查看发行说明", "bc16a7ddd4f105fc": [ [ diff --git a/apps/web/src/vite-env.d.ts b/apps/web/src/vite-env.d.ts index 307b9c5d8284d..2c11ef3525a0e 100644 --- a/apps/web/src/vite-env.d.ts +++ b/apps/web/src/vite-env.d.ts @@ -15,6 +15,7 @@ interface ImportMetaEnv { readonly VITE_RELAY_OTLP_TRACES_DATASET: string; readonly VITE_RELAY_OTLP_TRACES_TOKEN: string; readonly T3CODE_DESKTOP_UPDATE_REPOSITORY: string; + readonly T3CODE_DESKTOP_SOURCE_UPDATE_LABEL: string; readonly APP_VERSION: string; } diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index 2247dfb1f162b..643964edffe07 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -47,6 +47,8 @@ const configuredDesktopUpdateRepository = process.env.T3CODE_DESKTOP_UPDATE_REPOSITORY?.trim() || process.env.GITHUB_REPOSITORY?.trim() || ""; +const configuredDesktopSourceUpdateLabel = + process.env.T3CODE_DESKTOP_SOURCE_UPDATE_LABEL?.trim() || ""; const configuredHostedAppUrl = (() => { const explicitHostedAppUrl = process.env.VITE_HOSTED_APP_URL?.trim(); if (explicitHostedAppUrl) { @@ -457,6 +459,9 @@ export default defineConfig(({ command, mode }) => { "import.meta.env.T3CODE_DESKTOP_UPDATE_REPOSITORY": JSON.stringify( configuredDesktopUpdateRepository, ), + "import.meta.env.T3CODE_DESKTOP_SOURCE_UPDATE_LABEL": JSON.stringify( + configuredDesktopSourceUpdateLabel, + ), "import.meta.env.VITE_RELEASE_CHANNEL": JSON.stringify(configuredReleaseChannel), "import.meta.env.APP_VERSION": JSON.stringify(configuredAppVersion), }, diff --git a/docs/fork/0051-the-update-button-rebuilds-from-source.md b/docs/fork/0051-the-update-button-rebuilds-from-source.md new file mode 100644 index 0000000000000..4d198bc4e2b55 --- /dev/null +++ b/docs/fork/0051-the-update-button-rebuilds-from-source.md @@ -0,0 +1,30 @@ +# 0051: The update button rebuilds a local build from its checkout + +- PR: [TrogonStack/t3code#290](https://github.com/TrogonStack/t3code/pull/290) +- Status: active + +## What you can do now + +- Build the macOS app from a checkout of this fork and keep it current from inside the app. The + update pill checks the fork's `main` branch for commits the running build lacks, and lists + their subjects as the release notes. +- Click Update to rebase the checkout's branch onto those commits, rebuild the app, stage it and + run your own checks on the staged bundle. Restart puts the rebuilt app in place of the running + one and keeps the previous bundle beside the build output. +- Name paths that a person must read before they ship, such as telemetry or build scripts. An + incoming change under one of them stops the update and says which files to read. +- Keep local commits on top of `main`. The checkout's branch is rebased, not replaced. + +## Why + +This fork publishes no signed releases, so the stock updater has nothing to offer a local build. +Its users run the app they built, and the only way to pick up a merged pull request was a manual +pull, build and reinstall. The app already has a check, download and restart flow, so a local +build now drives that flow with git and the build script instead of a release feed. + +## Upstream considerations + +Not a candidate as is: upstream ships signed builds through a release feed. The desktop change is +one new updater implementation picked when the build carries `source-update.json`, and one line +in the main process wiring, so a sync rarely touches it. The build script gains four small hooks +that stage the configuration; a conflict there is a few lines. diff --git a/docs/fork/README.md b/docs/fork/README.md index eb264e60661d1..7f3a530e0938a 100644 --- a/docs/fork/README.md +++ b/docs/fork/README.md @@ -73,3 +73,5 @@ Each entry uses these sections: active, [#208](https://github.com/TrogonStack/t3code/pull/208) - **0050** [Pullfrog reviews pull requests](./0050-pullfrog-reviews-pull-requests.md) active, [#276](https://github.com/TrogonStack/t3code/pull/276) +- **0051** [The update button rebuilds a local build from its checkout](./0051-the-update-button-rebuilds-from-source.md) + active, [#290](https://github.com/TrogonStack/t3code/pull/290) diff --git a/docs/operations/00_development.md b/docs/operations/00_development.md index a2f4fe782b021..0ae13f5bec311 100644 --- a/docs/operations/00_development.md +++ b/docs/operations/00_development.md @@ -124,6 +124,73 @@ vp run dist:desktop:win Run `vp run dist:desktop:artifact --help` for `--arch`, `--signed`, and `--keep-stage`. +### Build and install the macOS app + +`mise run dev:desktop` starts the app from source. To get an app bundle you can keep in +`/Applications`, build the artifacts instead: + +```sh +vp run dist:desktop:dmg --arch arm64 --output-dir release +``` + +The command writes `release/T3-Code--arm64.dmg` and a `.zip` with the same bundle. Open +the `.dmg` and drag the app to `/Applications`, or extract the `.zip` there: + +```sh +ditto -x -k release/T3-Code--arm64.zip /Applications +``` + +A local build carries an ad hoc signature, so it runs without a developer certificate. Pass +`--arch x64` on an Intel Mac. The build pins the Node version in `engines.node`, so run it with that +version. + +### Keep a local macOS build current from inside the app (fork) + +A build made with `T3CODE_DESKTOP_SOURCE_UPDATE_CONFIG` set checks its own git checkout for new +commits instead of a release feed. The update pill then offers the commits merged to the +configured branch, and Update rebases the checkout's branch onto them, rebuilds, stages the app, +runs your checks and swaps the installed bundle on restart. The feature is macOS only. + +1. Write a `source-update.json` outside the repository. `checkout` is the repository, `outputDir` + is where builds land. Relative paths resolve against the file. The other keys are optional: + `remote` and `branch` (default `origin` and `main`), `build` (the build command, with + `{arch}`, `{outputDir}` and `{version}` filled in), `install` (runs when the incoming commits + change a manifest or the lockfile), `verify` (commands run on the staged app with `{app}` filled + in; a failure stops the update), `reviewPaths` (git pathspecs a person must read first; a change + under one stops the update), `shell` (the login shell that runs the commands) and `label` (names + the source in the update copy, as in "Check for Trogon fork Updates"). Each placeholder is + filled in as one shell-quoted word, so do not put quotes around it. + + ```json + { + "checkout": "/Users/me/dev/t3code", + "outputDir": "/Users/me/dev/t3code-builds", + "build": "mise x node@26.13.1 -- pnpm exec vp run dist:desktop:dmg --arch {arch} --output-dir {outputDir}", + "verify": ["node /Users/me/dev/checks/verify-bundle.mjs {app}"], + "reviewPaths": ["pnpm-lock.yaml", "apps/server/src/telemetry/**", "scripts/**"] + } + ``` + +2. Build and stage the app once by hand: + + ```sh + vp run desktop:source-update build --config /Users/me/source-update.json + ``` + + The build gets a version such as `0.1.13-source.20261204.4821`: the manifest version, the UTC + day of the branch commit it was built from, and the number of commits in that commit's history. + The staged bundle lands in `/app`. Move it to `/Applications` yourself the first + time. + +3. From then on, the app's update pill does the rest. The checkout must be on a branch with no + uncommitted changes. The previous bundle moves to `/backup-