Skip to content

feat(updates): prompt when a new release ships, with optional install - #88

Merged
SPhillips1337 merged 2 commits into
mainfrom
ag/update-prompt
Nov 11, 2026
Merged

SPhillips1337 merged 2 commits into
mainfrom
ag/update-prompt

Conversation

@SPhillips1337

Copy link
Copy Markdown
Contributor

Summary

About 8 seconds after launch, ZeroG checks for a newer release and shows a popup if there is one. Nothing downloads until the user clicks.

Build What the popup offers
Windows installer (NSIS), AppImage Download & install (electron-updater, hash-checked against latest.yml) → Restart & install
Portable .exe, .deb Open download page (GitHub latest-release lookup)
Dev / npm-installed No check
  • Later hides it for this launch; Skip this version is saved. Settings → Updates has the startup toggle, Check now, and "stop skipping". A check started from Settings always shows its answer.
  • Install mode falls back to the download-page popup if a release has no readable latest.yml. This matters for the first release: the existing v1.0.0 has none.
  • Release notes are never rendered. The renderer can't pass a URL. Main opens only a release page re-validated against github.com/HappyMonkeyAI/ZeroGTerm/releases/....
  • New dependency: electron-updater 6.8.11. It's loaded only in installable builds.
  • release.yml now uploads latest.yml, latest-linux.yml and the .exe.blockmap, and fails if a manifest doesn't name the tagged version and a file that is present.

Verification

  • npm run typecheck ✅, npm run build ✅, npm test ✅ (68 files, 1229 passed). New tests/update.test.ts: 26 tests covering mode detection, version ordering, URL validation, popup rules, and the service state machine with a fake updater.
  • Packaged NSIS locally (-c.npmRebuild=false, because node-pty's gyp rebuild fails on this machine). Output: latest.yml names ZeroGTerminal-1.0.0-Setup.exe with its sha512, and resources/app-update.yml points at this repo.
  • Live runs of an unpacked build stamped v0.9.0, with an isolated --user-data-dir, driven over CDP:
    • Against real GitHub: v1.0.0 has no latest.yml, so it fell back and showed "Version 1.0.0 is available" with Open download page.
    • Against a local server hosting the NSIS build: Download → downloading 0→100% → hash verified → Restart & install shown. Not clicked; the process was killed and the cache removed.
  • Not verified: the actual restart-and-install, Linux AppImage/deb, and the CI workflow change (runs on the next tag).

🤖 Generated with Claude Code

A few seconds after launch (Settings > Updates can turn this off) the
app checks for a newer release and shows a popup. Nothing downloads
until the user chooses to.

- NSIS install and AppImage: electron-updater downloads and verifies
  the release against its latest.yml, then "Restart & install".
- Portable exe and .deb cannot replace themselves, so they look up the
  latest GitHub release and offer the download page instead. Install
  mode falls back to this when a release has no readable manifest.
- Later hides the popup for this launch; Skip this version persists.
  A check started from Settings always shows its answer.
- Unpackaged (dev, npm) runs never check.
- Release workflow now uploads latest.yml, latest-linux.yml and the
  installer blockmap, and verifies each manifest names this version
  and a file beside it.

Release notes are never rendered; only the version and a release-page
link, which main re-validates against the project's releases path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

This PR adds a well-structured update-check feature with good security discipline: network-supplied URLs are re-validated before being passed to shell.openExternal, the renderer never receives raw URLs, and electron-updater is loaded lazily. The state machine design and fallback from install to notify mode are sound.

Three issues need addressing before merge:

  1. Silenced fallback error (src/main/update-service.ts): When the installer check fails and the subsequent lookUpRelease() call also fails, the error shown to the user is the installer's original error, not the lookup failure. Add a check for fallback.status === 'error' to surface the correct error.

  2. URL not fully sanitized (src/shared/update.ts): safeReleaseUrl validates host and path but preserves query strings and fragments from the network response before passing the URL to shell.openExternal. Strip parsed.search and parsed.hash before returning.

  3. Multi-line sed capture breaks CI (.github/workflows/release.yml): sed -n 's/^path: //p' matches all path: lines in latest.yml, producing a multi-line string that fails the [[ -f "release-assets/${target}" ]] check. This will block every release publication. Pipe through | head -1 to capture only the primary installer path.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment on lines +108 to +110
const fallback = await this.lookUpRelease();
if (fallback.status === 'available') return this.set({ ...fallback, mode: 'notify' });
return this.set({ status: 'error', ...this.base(), message: shortError(error) });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 Logic Error: When installer() or checkForUpdates() throws and the subsequent lookUpRelease() also fails (returning { status: 'error' }), the error message shown to the user is taken from the original installer error (shortError(error)) rather than the lookup error. This means a network failure in lookUpRelease is silently swallowed and misattributed to the installer. The user sees an error about the installer even when the real problem was the GitHub API call that happened second.

Suggested change
const fallback = await this.lookUpRelease();
if (fallback.status === 'available') return this.set({ ...fallback, mode: 'notify' });
return this.set({ status: 'error', ...this.base(), message: shortError(error) });
const fallback = await this.lookUpRelease();
if (fallback.status === 'available') return this.set({ ...fallback, mode: 'notify' });
if (fallback.status === 'error') return this.set(fallback);
return this.set({ status: 'error', ...this.base(), message: shortError(error) });

Comment thread src/shared/update.ts
Comment on lines +122 to +123
if (parsed.username || parsed.password) return RELEASES_URL;
return parsed.toString();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 Security Vulnerability: safeReleaseUrl validates the protocol, host, and pathname but then returns parsed.toString(), which preserves any query string and fragment from the network-supplied URL. A crafted html_url like passes all checks. Strip the search and hash before returning to ensure only a clean, predictable URL reachesshell.openExternal`.1

Suggested change
if (parsed.username || parsed.password) return RELEASES_URL;
return parsed.toString();
if (parsed.username || parsed.password) return RELEASES_URL;
parsed.search = '';
parsed.hash = '';
return parsed.toString();

Footnotes

  1. CWE-601: URL Redirection to Untrusted Site ('Open Redirect') - https://cwe.mitre.org/data/definitions/601.html ↩

Comment thread .github/workflows/release.yml Outdated
for manifest in release-assets/latest.yml release-assets/latest-linux.yml; do
[[ -f "$manifest" ]]
grep -qx "version: ${package_version}" "$manifest"
target="$(sed -n 's/^path: //p' "$manifest")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 Logic Error: sed -n 's/^path: //p' will print all lines starting with path: in the manifest, not just the first. A latest.yml manifest contains multiple path: entries (the installer and its .blockmap), so $target will be a multi-line string. The subsequent [[ -n "$target" && -f "release-assets/${target}" ]] will then fail because release-assets/<multi-line-string> is not a valid file path, causing every release publication to fail. Use head -1 or grep -m1 to capture only the first path.

Suggested change
target="$(sed -n 's/^path: //p' "$manifest")"
target="$(sed -n 's/^path: //p' "$manifest" | head -1)"

…nifest path

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@SPhillips1337
SPhillips1337 merged commit 5b277ee into main Nov 11, 2026
2 checks passed
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.

1 participant