Repository navigation
Works offline: detect it from the service worker, tag listings, filter by it - #21
Merged
Merged
Conversation
…r by it The inspector now finds the app's service worker (the URL the page registers, the manifest's serviceworker.src, a small linked registration script, then /sw.js, /service-worker.js, /serviceworker.js, /sw.min.js), fetches it with safeFetch (same origin, 1 MB, 5 s) and classifies it: offline when it is Workbox or has a fetch handler that uses the Cache API. A new recommended check "Works offline" says why when it is not. - migration 0011: apps.features text[] (GIN), offline_reason, features_checked_at - set on submit, refresh, saasrow import and release-detect's daily re-read - daemon job feature-backfill: 6 never-checked listings every 2 minutes - ?feature=offline on /api/v1/apps and /apps; a Works offline chip on browse (keeps q, category, sort, publisher), a link on home, a tag on cards and the details page; shape() carries features, offline, offline_reason - CLI 0.6.0: search/browse --offline; MCP 0.6.0: search_apps feature/offline - sw.js VERSION v5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Anthony asked: when a listing is created, work out whether the PWA works offline and tag it as a feature the store can filter by.
Detection (
apps/web/src/inspect.js)serviceWorkerUrls()parsesnavigator.serviceWorker.register('<url>')(minified andnew URL(...)forms too). Only same-origin URLs count.detectOffline()tries candidates in this order: what the page registers, the manifest'sserviceworker.src, one small same-origin registration script (for example vite-plugin-pwa'sregisterSW.js), then/sw.js,/service-worker.js,/serviceworker.jsand/sw.min.js. It makes at most 4 fetches throughsafeFetch, each capped at 1 MB and 5 s. An SPA's catch-allindex.htmlis not accepted as a worker.classifyServiceWorker()returns offline for Workbox, or for a fetch handler that uses the Cache API. A pass-through fetch handler, a push-only worker or no worker at all givesfalse. The reason is stored.Storage
Migration
0011_app_features.sqladdsapps.features text[]with a GIN index, plusoffline_reasonandfeatures_checked_at. These are set on submit, on refresh, on the saasrow import, and during release-detect's daily re-read. A new daemon job,feature-backfill, re-inspects 6 never-checked listings every 2 minutes.Surfaces
GET /api/v1/apps?feature=offline(aliasoffline=1). An unknown feature returns 400.shape()now includesfeatures,offlineandoffline_reason.pwamart search|browse --offline. MCP 0.6.0:search_appstakesfeatureoroffline.sw.jsVERSION is bumped to v5.Tests
test/offline.test.jscover the classifier and the URL parser.notesapp is offline-capable andtodoonly passes requests through. The tests check the filter, the browse chip, the tags and the backfill. All 94 pass against Postgres 16.🤖 Generated with Claude Code