The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import type { DesktopBridge, DesktopUpdateState } from "@t3tools/contracts"; |
| 2 | import { msg, T } from "gt-react"; |
| 3 | import { ArrowRightIcon } from "lucide-react"; |
| 4 | |
| 5 | import { |
| 6 | getDesktopUpdateDownloadedVersion, |
| 7 | getDesktopUpdateReleaseUrl, |
| 8 | } from "./desktopUpdate.logic"; |
| 9 | import { m } from "../i18n/messages"; |
| 10 | import { toastManager } from "./ui/toast"; |
| 11 | |
| 12 | type DesktopUpdateShell = Pick<DesktopBridge, "openExternal">; |
| 13 | |
| 14 | export async function openDesktopUpdateReleaseNotes( |
| 15 | shell: DesktopUpdateShell | undefined, |
| 16 | releaseUrl: string, |
| 17 | ): Promise<void> { |
| 18 | try { |
| 19 | if (shell && (await shell.openExternal(releaseUrl))) return; |
| 20 | } catch {} |
| 21 | toastManager.add({ type: "error", title: m(msg("Unable to open release notes")) }); |
| 22 | } |
| 23 | |
| 24 | function ReleaseNotesLink({ |
| 25 | shell, |
| 26 | releaseUrl, |
| 27 | }: { |
| 28 | shell: DesktopUpdateShell; |
| 29 | releaseUrl: string; |
| 30 | }) { |
| 31 | return ( |
| 32 | <button |
| 33 | className="ml-2 inline cursor-pointer text-muted-foreground underline decoration-dotted underline-offset-4 transition-colors hover:text-foreground" |
| 34 | onClick={() => { |
| 35 | void openDesktopUpdateReleaseNotes(shell, releaseUrl); |
| 36 | }} |
| 37 | type="button" |
| 38 | > |
| 39 | <T>Read more</T> |
| 40 | <ArrowRightIcon |
| 41 | aria-hidden |
| 42 | className="ml-1 inline size-3 -rotate-45 align-[-0.125em]" |
| 43 | strokeWidth={2.25} |
| 44 | /> |
| 45 | </button> |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | export function showDesktopUpdateDownloadedToast( |
| 50 | shell: DesktopUpdateShell, |
| 51 | state: DesktopUpdateState, |
| 52 | ): void { |
| 53 | const releaseUrl = getDesktopUpdateReleaseUrl(getDesktopUpdateDownloadedVersion(state)); |
| 54 | toastManager.add({ |
| 55 | type: "success", |
| 56 | title: m(msg("Update downloaded")), |
| 57 | description: ( |
| 58 | <> |
| 59 | <T>Restart the app from the update button to install it.</T> |
| 60 | {releaseUrl ? <ReleaseNotesLink releaseUrl={releaseUrl} shell={shell} /> : null} |
| 61 | </> |
| 62 | ), |
| 63 | }); |
| 64 | } |