diff options
| author | Adam <[email protected]> | 2025-12-18 04:26:17 -0600 |
|---|---|---|
| committer | Adam <[email protected]> | 2025-12-18 04:26:21 -0600 |
| commit | e37a75a411c584d3e463662a0219fd342d4247ab (patch) | |
| tree | eb3944722e942b3244c4f13466855fca712bc3c6 /packages/desktop/src/pages | |
| parent | 194ff4919cd1e68caaaa8336da0b13b815c74072 (diff) | |
| download | opencode-e37a75a411c584d3e463662a0219fd342d4247ab.tar.gz opencode-e37a75a411c584d3e463662a0219fd342d4247ab.zip | |
feat(desktop): custom update toast
Diffstat (limited to 'packages/desktop/src/pages')
| -rw-r--r-- | packages/desktop/src/pages/layout.tsx | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/packages/desktop/src/pages/layout.tsx b/packages/desktop/src/pages/layout.tsx index 540c5d778..fccb6d595 100644 --- a/packages/desktop/src/pages/layout.tsx +++ b/packages/desktop/src/pages/layout.tsx @@ -1,4 +1,15 @@ -import { createEffect, createMemo, createSignal, For, Match, ParentProps, Show, Switch, type JSX } from "solid-js" +import { + createEffect, + createMemo, + createSignal, + For, + Match, + onMount, + ParentProps, + Show, + Switch, + type JSX, +} from "solid-js" import { DateTime } from "luxon" import { A, useNavigate, useParams } from "@solidjs/router" import { useLayout, getAvatarColors } from "@/context/layout" @@ -28,7 +39,7 @@ import { } from "@thisbeyond/solid-dnd" import type { DragEvent } from "@thisbeyond/solid-dnd" import { useProviders } from "@/hooks/use-providers" -import { Toast } from "@opencode-ai/ui/toast" +import { showToast, Toast } from "@opencode-ai/ui/toast" import { useGlobalSDK } from "@/context/global-sdk" import { useNotification } from "@/context/notification" import { Binary } from "@opencode-ai/util/binary" @@ -46,14 +57,6 @@ export default function Layout(props: ParentProps) { let scrollContainerRef: HTMLDivElement | undefined - function scrollToSession(sessionId: string) { - if (!scrollContainerRef) return - const element = scrollContainerRef.querySelector(`[data-session-id="${sessionId}"]`) - if (element) { - element.scrollIntoView({ block: "center", behavior: "smooth" }) - } - } - const params = useParams() const globalSDK = useGlobalSDK() const globalSync = useGlobalSync() @@ -65,6 +68,30 @@ export default function Layout(props: ParentProps) { const dialog = useDialog() const command = useCommand() + onMount(async () => { + if (platform.checkUpdate && platform.update) { + const { updateAvailable, version } = await platform.checkUpdate() + if (updateAvailable) { + showToast({ + persistent: true, + icon: "download", + title: "Update available", + description: `A new version of OpenCode (${version}) is now available to install.`, + actions: [ + { + label: "Install and restart", + onClick: () => platform!.update!(), + }, + { + label: "Not yet", + onClick: "dismiss", + }, + ], + }) + } + } + }) + function flattenSessions(sessions: Session[]): Session[] { const childrenMap = new Map<string, Session[]>() for (const session of sessions) { @@ -87,6 +114,14 @@ export default function Layout(props: ParentProps) { return result } + function scrollToSession(sessionId: string) { + if (!scrollContainerRef) return + const element = scrollContainerRef.querySelector(`[data-session-id="${sessionId}"]`) + if (element) { + element.scrollIntoView({ block: "center", behavior: "smooth" }) + } + } + const currentSessions = createMemo(() => { if (!params.dir) return [] const directory = base64Decode(params.dir) |
