Skip to content

feat(desktop): offer the OpenCode 2 upgrade - #64153

Merged
Hona merged 16 commits into
anomalyco:v1from
Hona:desktop-v2-upgrade
Nov 16, 2026
Merged

Hona merged 16 commits into
anomalyco:v1from
Hona:desktop-v2-upgrade

Conversation

@Hona

@Hona Hona commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

No linked issue. OpenCode 1 desktop has no path to OpenCode 2 today; the TUI got one in #54409.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

OpenCode 1 desktop now offers OpenCode 2.0, the desktop counterpart of /update in the TUI.

  • OpenCode 2 downloads in the background once OpenCode 1 is on its newest release, the way a 1.x update already downloads. A newer 1.x release still comes first.
  • Nothing installs until the user chooses: Restart to upgrade, Upgrade on quit, or Later (hidden for 7 days, like Dismiss in the TUI).
  • The card names what OpenCode 2 adds, what it keeps, and the one thing that breaks: plugins made for OpenCode 1.
  • The card opens by itself once per launch, and only right after the app starts. After that it is one click away on the titlebar update pill, in Check for updates, and in the command palette.
  • A failed download stays quiet and is retried at the next 10 minute check.
stateDiagram-v2
  [*] --> unavailable
  unavailable --> downloading: OpenCode 1 is up to date
  downloading --> ready: OpenCode 2 downloaded
  downloading --> unavailable: download failed, or a 1.x release cancels it
  ready --> unavailable: newer 1.x release found
  ready --> scheduling: Upgrade on quit
  scheduling --> scheduled: the platform installer is armed
  scheduling --> ready: arming failed
  ready --> installing: Restart to upgrade
  scheduled --> installing: Restart now
  installing --> [*]: app quits, OpenCode 2 starts
  scheduled --> [*]: app quits
Loading

OpenCode 2 desktop keeps the app ID and the signing identity, so its installer replaces OpenCode 1 in place. OpenCode 1 reads GitHub releases and OpenCode 2 publishes to its own feed, so the offer uses a second updater:

  • Own cache. Both feeds name their installers alike, so the OpenCode 2 updater downloads to <updaterCacheDirName>-major.
  • One download at a time. A 1.x release cancels the OpenCode 2 download and waits for it to end before its own starts.
  • Forward only. The offer needs a version with major 2 or higher, and downgrades are off.
  • Built on first use. While a 1.x release is the update, the second updater does not exist.
// packages/desktop/src/main/updater-controller.ts
const withdraw = async () => {
  if (major.status !== "unavailable") {
    transitionMajor({ status: "unavailable" })
    input.major?.cancelDownload()
    input.major?.disarm()
  }
  await preparing
}

On macOS only Squirrel can install, and it first fetches and verifies the archive. Both actions wait for Squirrel, so the card never confirms an upgrade that is not staged, and the servers stop only when the install can start:

// packages/desktop/src/main/updater.ts
function squirrel(updater: AppUpdater) {
  const staged = Promise.withResolvers<void>()
  electron.autoUpdater.once("update-downloaded", () => staged.resolve())
  electron.autoUpdater.once("error", staged.reject)
  return Promise.all([updater.downloadUpdate(), staged.promise])
}

The card never focuses an action that installs, so a key press meant for the prompt cannot start an upgrade. .deb, .rpm and pacman installs offer a restart only, because their password prompt must not appear after the windows have closed.

How did you verify your code works?

Each run used the released 1.19.5 app with this branch's JavaScript (Windows: an unsigned build of this branch) against the live OpenCode 2.3.0 feed.

Restart to upgrade Upgrade on quit Later
macOS 27, Apple silicon, signed app 2.3.0 running 4.5 s after the click 2.3.0 installed on quit, also 0.4 s after the confirmation no install, hidden after relaunch
Windows 11, Windows Sandbox 2.3.0 running 14.5 s after the click 2.3.0 installed 11 s after the window closed no install, hidden after relaunch
Linux AppImage, Debian 13 under WSL file matches the feed's sha512, 2.3.0 started file replaced on quit no install, hidden after relaunch
Linux .deb, Debian 13 under WSL package is 2.3.0 not offered no install, hidden after relaunch
  • Not verified: .rpm and pacman, Intel Macs, and whether OpenCode 2 reopens by itself after the .deb install.
  • The card strings are translated for all 61 locales by agents and matched to each locale's existing terms. No native speaker has reviewed them.

Screenshots / recordings

Before After
No offer. OpenCode 1 desktop stays on 1.x. The OpenCode 2.0 offer

Restart to upgrade, recorded with a simulated updater:

restart-to-upgrade.mp4

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Hona added 4 commits November 13, 2026 08:33
Copy the TUI's /update flow into the desktop app. Once OpenCode 1 is up to date, the app offers OpenCode 2.0 in a dialog with the TUI's words and its Dismiss and Upgrade choices. Dismiss hides the offer for 7 days. Upgrade downloads OpenCode 2 through a second updater that reads the OpenCode 2 feed, and Restart installs it over OpenCode 1.
Replace the two-step offer. OpenCode 2 now downloads in the background once OpenCode 1 is up to date, the way an OpenCode 1 update does. The offer opens only when the download is done, and only right after the app starts. Restart to upgrade installs at once, Upgrade on quit installs when the app quits, and Later hides the offer for 7 days.
The v1 pipeline builds the desktop app for release only, so the beta feed could never be reached.
@Hona
Hona requested a review from Brendonovich as a code owner November 16, 2026 03:12
Copilot AI balanced review requested due to automatic review settings November 16, 2026 03:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Hona added 12 commits November 16, 2026 13:25
Five rows name what OpenCode 2 adds. The config row is gone.
The OpenCode 2 updater downloads into its own cache folder, is built on the first OpenCode 2 check, never allows a downgrade and only offers a version with major 2 or higher. An OpenCode 1 release cancels an OpenCode 2 download and waits for it to end before its own download starts.

Restart to upgrade and Upgrade on quit now have installing and scheduling states, run once, and report an installer that could not start. On macOS both wait until Squirrel has staged OpenCode 2 before the servers stop or the choice is confirmed. Packages that install behind a password prompt offer a restart only.

The launch window for the offer is measured once in the main process, and a check the user asked for waits for an OpenCode 2 download in flight.
Deferred promises hold a download, a feed answer, a stop or an arming open, so each race is replayed in a fixed order: an OpenCode 1 release found while OpenCode 2 downloads, upgrade on quit chosen while a check is in flight, restart called twice, restart with a failing stage, stop or installer, the version guard, and the launch window measured once for the whole app.
With Upgrade on quit armed on Windows or Linux, the quit waits once until the servers have stopped, because the installer starts the moment the app has quit. Every other quit, and macOS, is unchanged.
On macOS, Check for Updates with every window closed found no window to send the command to. It now restores a window, which asks the updater as it starts and opens the offer itself.
Focus no longer starts on a button that installs, so a key press meant for the prompt cannot restart the app. The card shows the installing and scheduling states with its buttons disabled, hides Upgrade on quit where the package cannot do it, wraps its footer for long translations and drops the image in a narrow window.

The main process now decides whether a window opens the offer by itself, so a window that opens, reloads or changes layout later does not. The offer gives way to release notes for an OpenCode 1 update and to any dialog already open, and is checked again after the image has decoded.

The failure toast can open the install instructions, and offers a restart when the servers were already stopped.
Check now reads Downloading while OpenCode 2 downloads, and the check waits for that download before it answers. The offer then opens over Settings instead of replacing it.
The legacy titlebar has no update pill, so after the launch window nothing led to the offer. The update toast of that layout now also leads to it, with strings that already exist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants