Skip to content

Expose an extension's own update status to its client (host API 1.64.0) - #450

Merged
charlie-ps merged 3 commits into
mainfrom
extension-update-status-api
Nov 6, 2026
Merged

charlie-ps merged 3 commits into
mainfrom
extension-update-status-api

Conversation

@charlie-ps

Copy link
Copy Markdown
Contributor

Summary

Adds api.updateStatus() to the per-extension client api (public/slots.js), so an extension can show how far its own install is behind the branch it tracks.

  • api.updateStatus() returns { behind, commits, capped, branch, checkedAt } for the calling extension only, or null. It reads the same data as the extension's row in the Extensions panel: the background update check (Automatic updates in Notify or Auto), with this tab's latest Check all on top.
    • commits is how many commits behind branch the install is (the early-adopter branch when the install opted in). It is 0 when up to date, and capped means "at least this many" (counts stop at 50).
    • null for a built-in or hand-placed extension, before the first check, after a failed one, and with Automatic updates Off.
    • It takes no argument, so an extension cannot read another extension's entry. It returns a copy, so changing it does not change board state.
  • api.updateStatus.onChange(fn) calls fn with a fresh copy (or null) when the value changes, deduped, and returns an unsubscribe function. Subscriptions are dropped with the extension, and a listener that throws is reported and kept.
  • A new extUpdateStatusFor in public/update-panel.js works the status out from the data the Extensions rows use. public/app.js passes it to the slots base api and notifies listeners when that data or the Automatic updates mode changes.
  • HOST_API_VERSION goes to 1.64.0. An extension that still loads on older boards checks typeof api.updateStatus === 'function' and shows nothing without it; otherwise it declares ^1.64.0. Documented in docs/extensions.md.

Verification

  • npm test: 5163 pass, 0 fail.
  • New tests cover behind, up to date, capped and each null case, Check all taking precedence over the background check, the api reading only the caller's own entry, and onChange dedupe, isolation and teardown.

Made with Agent Wrangler and the PortSwigger/wrangler-squared extension

## Summary

Adds `api.updateStatus()` to the per-extension client api (`public/slots.js`), so an extension can show how far its own install is behind the branch it tracks.

- **`api.updateStatus()`** returns `{ behind, commits, capped, branch, checkedAt }` for the calling extension only, or `null`. It reads the same data as the extension's row in the Extensions panel: the background update check (Automatic updates in Notify or Auto), with this tab's latest Check all on top.
  - `commits` is how many commits behind `branch` the install is (the early-adopter branch when the install opted in). It is `0` when up to date, and `capped` means "at least this many" (counts stop at 50).
  - `null` for a built-in or hand-placed extension, before the first check, after a failed one, and with Automatic updates Off.
  - It takes no argument, so an extension cannot read another extension's entry. It returns a copy, so changing it does not change board state.
- **`api.updateStatus.onChange(fn)`** calls `fn` with a fresh copy (or `null`) when the value changes, deduped, and returns an unsubscribe function. Subscriptions are dropped with the extension, and a listener that throws is reported and kept.
- The status lookup the Extensions rows already use is moved into a shared `extUpdateStatusFor` in `public/update-panel.js`, and `public/app.js` passes it to the slots base api and notifies on `config` and `ext-update-status` frames.
- `HOST_API_VERSION` goes to **1.64.0**. An extension that still loads on older boards checks `typeof api.updateStatus === 'function'` and shows nothing without it; otherwise it declares `^1.64.0`. Documented in `docs/extensions.md`.

## Verification

- `npm test`: 5163 pass, 0 fail.
- New tests cover behind, up to date, capped and each null case, Check all taking precedence over the background check, the api reading only the caller's own entry, and onChange dedupe, isolation and teardown.

Made with Agent Wrangler and the PortSwigger/wrangler-squared extension
@charlie-ps
charlie-ps merged commit 20bd23e into main Nov 6, 2026
2 checks passed
@charlie-ps
charlie-ps deleted the extension-update-status-api branch November 6, 2026 11:56
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