Skip to content
5 changes: 4 additions & 1 deletion packages/app/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { ServerSDKProvider } from "@/context/server-sdk"
import { ServerSyncProvider, useServerSync } from "@/context/server-sync"
import { GlobalProvider, useGlobal } from "@/context/global"
import { HighlightsProvider } from "@/context/highlights"
import { MajorUpdateProvider } from "@/context/major-update"
import { LanguageProvider, type Locale, useLanguage } from "@/context/language"
import { LayoutProvider } from "@/context/layout"
import { ModelsProvider } from "@/context/models"
Expand Down Expand Up @@ -316,7 +317,9 @@ function SharedProviders(props: ParentProps) {
<BodyDesignClass />
<CommandProvider>
<DesktopCommands />
<HighlightsProvider>{props.children}</HighlightsProvider>
<HighlightsProvider>
<MajorUpdateProvider>{props.children}</MajorUpdateProvider>
</HighlightsProvider>
</CommandProvider>
</>
)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
159 changes: 159 additions & 0 deletions packages/app/src/components/dialog-major-update.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import { ButtonV2 } from "@opencode-ai/ui/v2/button-v2"
import { Dialog, DialogFooter, DialogHeader, DialogTitleGroup } from "@opencode-ai/ui/v2/dialog-v2"
import { useDialog } from "@opencode-ai/ui/context/dialog"
import { createEffect, For, onMount, Show } from "solid-js"
import announcementImage from "@/assets/upgrade/opencode-2-0.png"
import { ExternalLink } from "@/components/external-link"
import { useLanguage } from "@/context/language"
import type { MajorUpdaterPlatform } from "@/updater"
import { showToast } from "@/utils/toast"

export const V2_ANNOUNCEMENT_URL = "https://anoma.ly/notes/opencode-2-0"
export const MAJOR_INSTRUCTIONS = "https://opencode.ai/v2/docs"

const ROW: Record<string, { class: string; path: string }> = {
new: { class: "text-v2-text-text-accent", path: "M7 3V11M3 7H11" },
kept: { class: "text-v2-state-fg-success", path: "M3 7.4L5.8 10L11 4" },
breaks: { class: "text-v2-state-fg-warning", path: "M7 3V7.8M7 9.6V11" },
}

// The card image ships with the app and is decoded before the dialog opens. The dialog shows this same element, so
// nothing loads again and the card never paints without its image.
export function preloadMajorUpdateImage() {
const image = new Image()
image.alt = ""
image.className = "size-full object-contain"
image.src = announcementImage
return image.decode().then(
() => image,
() => image,
)
}

// The desktop offer for OpenCode 2.0. OpenCode 2 is already downloaded when this opens, so the choices are when to
// install it: now, when the app quits, or later.
export function DialogMajorUpdate(props: { major: MajorUpdaterPlatform; image?: HTMLImageElement; later: () => void }) {
const dialog = useDialog()
const language = useLanguage()
const status = () => props.major.state().status

// Solid builds this dialog from a template in another document. An image that moves between documents loads again,
// so the decoded image joins the card only once the card is in the page.
let media: HTMLDivElement | undefined
onMount(() => {
if (props.image) media?.append(props.image)
})

// A newer OpenCode 1 release withdraws the offer, so there is nothing left to choose here.
createEffect(() => {
if (status() !== "ready" && status() !== "scheduled") dialog.close()
})

const failed = () =>
showToast({
title: language.t("dialog.update.major.failed"),
description: language.t("dialog.update.major.manual", { url: MAJOR_INSTRUCTIONS }),
})
const restart = () => void props.major.restart().catch(failed)
const schedule = () =>
void props.major.schedule().then(() => {
dialog.close()
showToast({ variant: "success", icon: "circle-check", title: language.t("dialog.update.major.scheduled") })
}, failed)

return (
<Show
when={status() !== "scheduled"}
fallback={
<Dialog fit>
<DialogHeader>
<DialogTitleGroup
title={language.t("titlebar.update")}
description={
<span class="pt-1" data-component="major-update" data-status="scheduled">
{language.t("dialog.update.major.scheduled")}
</span>
}
/>
</DialogHeader>
<DialogFooter>
<ButtonV2 variant="ghost" onClick={() => dialog.close()}>
{language.t("common.close")}
</ButtonV2>
<ButtonV2 variant="contrast" autofocus onClick={restart}>
{language.t("dialog.update.major.action.restartNow")}
</ButtonV2>
</DialogFooter>
</Dialog>
}
>
<Dialog fit containerClass="!w-[min(calc(100vw-32px),720px)]">
<div class="flex w-full">
<div class="flex min-w-0 flex-1 flex-col">
<DialogHeader hideClose>
<DialogTitleGroup
title={language.t("dialog.update.major.title")}
description={
<span class="flex flex-col gap-3 pt-1" data-component="major-update" data-status="ready">
<span>{language.t("dialog.update.major.lead")}</span>
<span class="flex flex-col gap-1.5">
<For
each={[
{ kind: "new", text: language.t("dialog.update.major.new.browser") },
{ kind: "new", text: language.t("dialog.update.major.new.background") },
{ kind: "new", text: language.t("dialog.update.major.new.plugins") },
{ kind: "new", text: language.t("dialog.update.major.new.sessions") },
{ kind: "new", text: language.t("dialog.update.major.new.pair") },
{ kind: "kept", text: language.t("dialog.update.major.keeps.data") },
{ kind: "breaks", text: language.t("dialog.update.major.plugins") },
]}
>
{(item) => (
<span class="flex items-center gap-2 text-v2-text-text-base">
<svg
width="14"
height="14"
viewBox="0 0 14 14"
fill="none"
aria-hidden="true"
class={ROW[item.kind].class}
>
<path d={ROW[item.kind].path} stroke="currentColor" stroke-width="1.4" />
</svg>
{item.text}
</span>
)}
</For>
</span>
<ExternalLink href={V2_ANNOUNCEMENT_URL} class="!text-v2-text-text-accent !no-underline">
{language.t("common.learnMore")}
</ExternalLink>
</span>
}
/>
</DialogHeader>
<div class="flex-1" />
<DialogFooter>
<ButtonV2
variant="ghost"
onClick={() => {
props.later()
dialog.close()
}}
>
{language.t("desktop.updater.dialog.later")}
</ButtonV2>
<ButtonV2 variant="neutral" onClick={schedule}>
{language.t("dialog.update.major.action.quit")}
</ButtonV2>
<ButtonV2 variant="contrast" autofocus onClick={restart}>
{language.t("dialog.update.major.action.restart")}
</ButtonV2>
</DialogFooter>
</div>
<div class="w-[280px] shrink-0 self-stretch bg-[#080807]" ref={media} />
</div>
</Dialog>
</Show>
)
}
11 changes: 11 additions & 0 deletions packages/app/src/components/titlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { LayoutRoute, useLayout } from "@/context/layout"
import { usePlatform } from "@/context/platform"
import { useCommand } from "@/context/command"
import { useLanguage } from "@/context/language"
import { useMajorUpdate } from "@/context/major-update"
import { useSettings } from "@/context/settings"
import { WindowsAppMenu } from "./windows-app-menu"
import { applyPath, backPath, forwardPath } from "./titlebar-history"
Expand Down Expand Up @@ -68,6 +69,7 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
const language = useLanguage()
const settings = useSettings()
const server = useServer()
const major = useMajorUpdate()
const navigate = useNavigate()
const location = useLocation()
const params = useParams()
Expand Down Expand Up @@ -124,6 +126,15 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
const updateState = createMemo<TitlebarUpdatePillState>(() => {
const installing = props.update?.installing() ?? false
const version = props.update?.version()
// An OpenCode 1 release keeps the pill. Otherwise the pill opens the OpenCode 2.0 offer.
if (version === undefined && !installing && major.visible())
return {
visible: true,
installing: false,
label: language.t("titlebar.update"),
ariaLabel: language.t("toast.update.title"),
onInstall: () => void major.open(),
}
return {
visible: version !== undefined || installing,
installing,
Expand Down
4 changes: 4 additions & 0 deletions packages/app/src/components/updater-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createMemo } from "solid-js"
import type { UpdaterState } from "@/updater"
import { usePlatform } from "@/context/platform"
import { useLanguage } from "@/context/language"
import { useMajorUpdate } from "@/context/major-update"
import { showToast } from "@/utils/toast"

export function updaterAction(state: UpdaterState | undefined) {
Expand All @@ -25,6 +26,7 @@ export function updaterAction(state: UpdaterState | undefined) {
export function useUpdaterAction() {
const platform = usePlatform()
const language = useLanguage()
const major = useMajorUpdate()
const action = createMemo(() => updaterAction(platform.updater?.state()))

return {
Expand All @@ -35,6 +37,8 @@ export function useUpdaterAction() {
if (run !== "check") return

const state = await platform.updater?.check()
// With no OpenCode 1 release left to install, checking for updates opens the OpenCode 2.0 offer instead.
if (state?.status !== "ready" && major.offered()) return major.open()
if (state?.status === "up-to-date") {
showToast({
variant: "success",
Expand Down
24 changes: 24 additions & 0 deletions packages/app/src/context/major-update.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { describe, expect, test } from "bun:test"
import { LATER_DURATION, majorUpdateVisible } from "./major-update"

describe("major update offer", () => {
const now = Date.UTC(2026, 10, 13)

test("shows only once OpenCode 2 is downloaded", () => {
expect(majorUpdateVisible("unavailable", undefined, now)).toBe(false)
expect(majorUpdateVisible("downloading", undefined, now)).toBe(false)
expect(majorUpdateVisible("ready", undefined, now)).toBe(true)
})

test("stays hidden for a week after Later, then returns", () => {
const laterUntil = now + LATER_DURATION

expect(majorUpdateVisible("ready", laterUntil, now)).toBe(false)
expect(majorUpdateVisible("ready", laterUntil, laterUntil - 1)).toBe(false)
expect(majorUpdateVisible("ready", laterUntil, laterUntil)).toBe(true)
})

test("shows nothing once the user chose to upgrade on quit", () => {
expect(majorUpdateVisible("scheduled", undefined, now)).toBe(false)
})
})
94 changes: 94 additions & 0 deletions packages/app/src/context/major-update.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { createEffect, createMemo, onCleanup } from "solid-js"
import { createStore } from "solid-js/store"
import { createSimpleContext } from "@opencode-ai/ui/context"
import { useDialog } from "@opencode-ai/ui/context/dialog"
import { DialogMajorUpdate, preloadMajorUpdateImage } from "@/components/dialog-major-update"
import { useCommand } from "@/context/command"
import { useLanguage } from "@/context/language"
import { usePlatform } from "@/context/platform"
import type { MajorUpdateState } from "@/updater"
import { Persist, persisted } from "@/utils/persist"

export const LATER_DURATION = 7 * 24 * 60 * 60 * 1000
// The offer opens by itself only this soon after the app starts. Later than this, the user is already working.
export const LAUNCH_WINDOW = 30 * 1000

// Later hides the OpenCode 2.0 offer for a week, like Dismiss in the TUI. Closing the dialog any other way doesn't.
// Once the user chose to upgrade on quit there is nothing left to offer, so the titlebar shows nothing.
export function majorUpdateVisible(status: MajorUpdateState["status"], laterUntil: number | undefined, now: number) {
if (status !== "ready") return false
return laterUntil === undefined || now >= laterUntil
}

export const { use: useMajorUpdate, provider: MajorUpdateProvider } = createSimpleContext({
name: "MajorUpdate",
gate: false,
init: () => {
const platform = usePlatform()
const dialog = useDialog()
const command = useCommand()
const language = useLanguage()
const [store, setStore, _, ready] = persisted(
Persist.global("update.major"),
createStore({ laterUntil: undefined as number | undefined }),
)
const [state, setState] = createStore({ now: Date.now(), prompted: false })
const started = performance.now()
const clock = setInterval(() => setState("now", Date.now()), 10 * 60 * 1000)
onCleanup(() => clearInterval(clock))

const status = () => platform.updater?.major?.state().status ?? "unavailable"
const offered = () => status() === "ready" || status() === "scheduled"
const visible = createMemo(() => ready() && majorUpdateVisible(status(), store.laterUntil, state.now))

// Starts while OpenCode 2 downloads, so the image is ready long before anything opens the dialog.
const image = createMemo<Promise<HTMLImageElement> | undefined>((previous) => {
if (previous) return previous
if (status() !== "unavailable") return preloadMajorUpdateImage()
})

const open = async () => {
const major = platform.updater?.major
if (!major || !offered()) return
const element = await image()
dialog.show(() => (
<DialogMajorUpdate
major={major}
image={element}
later={() => {
const at = Date.now()
setStore("laterUntil", at + LATER_DURATION)
setState("now", at)
}}
/>
))
}

// The TUI only shows a notice. The desktop app also opens the offer once per launch, and only right after the app
// starts. A download that finishes later, or a week that runs out, brings the titlebar pill and never a dialog
// over the user's work.
createEffect(() => {
if (state.prompted || !ready() || status() !== "ready") return
setState("prompted", true)
if (!visible() || performance.now() - started > LAUNCH_WINDOW) return
void platform.updater?.major?.prompt().then((first) => {
if (first && !dialog.active) void open()
})
})

command.register("major-update", () =>
offered()
? [
{
id: "update.open",
title: language.t("toast.update.title"),
category: language.t("command.category.settings"),
onSelect: () => void open(),
},
]
: [],
)

return { status, offered, visible, open }
},
})
15 changes: 15 additions & 0 deletions packages/app/src/i18n/am.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,4 +1127,19 @@ export const dict = {
"workspace.reset.archived.many": "{{count}} ክፍለ-ጊዜዎች በማህደር ይቀመጣሉ።",
"workspace.reset.note": "ይህ workspaceን ከነባሪው ቅርንጫፍ ጋር እንዲመሳሰል ዳግም ያስጀምረዋል።",
"dialog.usageExceeded.dontShowAgain": "እንደገና አታሳይ",
"dialog.update.major.title": "OpenCode 2.0 ዝግጁ ነው",
"dialog.update.major.lead": "ቀጣዩ ዋና ስሪት ወርዷል። ዝማኔውን ለመጨረስ ዳግም ያስጀምሩ።",
"dialog.update.major.new.browser": "የውስጠ-መተግበሪያ አሳሽ",
"dialog.update.major.new.background": "ከበስተጀርባ የሚሰሩ ንዑስ ወኪሎች እና ትዕዛዞች",
"dialog.update.major.new.plugins": "መተግበሪያውን የራስዎ የሚያደርጉ የዴስክቶፕ ፕለጊኖች (የሙከራ)",
"dialog.update.major.new.sessions": "አንድ የጋራ አገልጋይ መተግበሪያውን፣ ተርሚናሉን እና ድሩን እንደተመሳሰሉ ያቆያል",
"dialog.update.major.new.pair": "ስልክ ወይም ሌላ ኮምፒውተር ያጣምሩ",
"dialog.update.major.keeps.data": "ክፍለ ጊዜዎችዎን፣ ፕሮጀክቶችዎን እና ቅንጅቶችዎን ያቆያል",
"dialog.update.major.plugins": "ለOpenCode 1 የተሰሩ ፕለጊኖች ዝማኔ ያስፈልጋቸዋል",
"dialog.update.major.scheduled": "መተግበሪያው ሲዘጋ OpenCode 2.0 ይጫናል።",
"dialog.update.major.failed": "OpenCode 2.0ን መጫን አልተቻለም።",
"dialog.update.major.manual": "OpenCode 2.0ን በእጅ ለመጫን {{url}} ይመልከቱ",
"dialog.update.major.action.quit": "ሲዘጋ አዘምን",
"dialog.update.major.action.restart": "ለማዘመን ዳግም አስጀምር",
"dialog.update.major.action.restartNow": "አሁን ዳግም አስጀምር",
}
15 changes: 15 additions & 0 deletions packages/app/src/i18n/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,21 @@ export const dict = {
"dialog.project.edit.worktree.startup.description": "يتم تشغيله بعد إنشاء مساحة عمل جديدة (شجرة عمل).",
"dialog.project.edit.worktree.startup.placeholder": "مثال: bun install",
"dialog.usageExceeded.dontShowAgain": "عدم الإظهار مرة أخرى",
"dialog.update.major.title": "OpenCode 2.0 جاهز",
"dialog.update.major.lead": "تم تنزيل الإصدار الرئيسي التالي. أعد التشغيل لإكمال الترقية.",
"dialog.update.major.new.browser": "متصفح داخل التطبيق",
"dialog.update.major.new.background": "وكلاء فرعيون وأوامر تعمل في الخلفية",
"dialog.update.major.new.plugins": "إضافات لسطح المكتب لتخصيص التطبيق على طريقتك (تجريبية)",
"dialog.update.major.new.sessions": "خادم مشترك واحد يُبقي التطبيق والمحطة الطرفية والويب متزامنة",
"dialog.update.major.new.pair": "إقران هاتف أو حاسوب آخر",
"dialog.update.major.keeps.data": "يحتفظ بجلساتك ومشاريعك وإعداداتك",
"dialog.update.major.plugins": "الإضافات المصممة لـ OpenCode 1 تحتاج إلى تحديث",
"dialog.update.major.scheduled": "سيتم تثبيت OpenCode 2.0 عند إنهاء التطبيق.",
"dialog.update.major.failed": "تعذر تثبيت OpenCode 2.0.",
"dialog.update.major.manual": "لتثبيت OpenCode 2.0 يدويًا، راجع {{url}}",
"dialog.update.major.action.quit": "الترقية عند الإنهاء",
"dialog.update.major.action.restart": "إعادة التشغيل للترقية",
"dialog.update.major.action.restartNow": "إعادة التشغيل الآن",

"context.breakdown.title": "تفصيل السياق",
"context.breakdown.note": 'تفصيل تقريبي لرموز الإدخال المميزة. يشمل "أخرى" تعريفات الأدوات والأعباء الإضافية.',
Expand Down
Loading
Loading