Repository navigation
Expose an extension's own update status to its client (host API 1.64.0) - #450
Merged
Merged
Conversation
## 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
…us-api # Conflicts: # server/host-api/version.js # server/host-api/version.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, ornull. 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.commitsis how many commits behindbranchthe install is (the early-adopter branch when the install opted in). It is0when up to date, andcappedmeans "at least this many" (counts stop at 50).nullfor a built-in or hand-placed extension, before the first check, after a failed one, and with Automatic updates Off.api.updateStatus.onChange(fn)callsfnwith a fresh copy (ornull) 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.extUpdateStatusForinpublic/update-panel.jsworks the status out from the data the Extensions rows use.public/app.jspasses it to the slots base api and notifies listeners when that data or the Automatic updates mode changes.HOST_API_VERSIONgoes to 1.64.0. An extension that still loads on older boards checkstypeof api.updateStatus === 'function'and shows nothing without it; otherwise it declares^1.64.0. Documented indocs/extensions.md.Verification
npm test: 5163 pass, 0 fail.Made with Agent Wrangler and the PortSwigger/wrangler-squared extension