Skip to content

Add native macOS & iOS app, with native sign-in - #522

Draft
disnet wants to merge 8 commits into
mainfrom
claude/gallant-carson-dfx231
Draft

disnet wants to merge 8 commits into
mainfrom
claude/gallant-carson-dfx231

Conversation

@disnet

@disnet disnet commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Adds apple/, a native SwiftUI reader for macOS 14+ and iOS 17+. It also includes a small backend change so the app can sign in natively.

Backend: native sign-in handoff

The web app gets its session as an HttpOnly cookie, and the CLI gets it on a loopback port. A native app can only be reached on its custom URL scheme, and any other app on the device can register that same scheme. So the session never goes over the scheme; instead there is a PKCE-style handoff:

  1. The app starts GET /api/auth/login with native_challenge = base64url(SHA-256(verifier)). The response carries native: true to confirm the server understood the challenge. The app won't open the auth sheet without it, because an older server ignores the challenge and would finish in the web app inside the sheet.
  2. The callback stores a one-time code bound to that challenge. It redirects to skyreader://auth/callback?code=… with no cookie.
  3. The app sends { code, verifier } to POST /api/auth/native/exchange and gets back { sessionId }.

The code:

  • lives for 2 minutes;
  • is deleted on the first exchange attempt, whether or not the verifier is right;
  • is swept by the hourly cron along with expired oauth_state rows.

If the auth server returns an error during a native flow, the redirect goes back to the app scheme.

  • Needs migration 0088_native_auth_handoff.sql. It adds oauth_state.native_challenge and the native_auth_handoff table.
  • The code is in backend/src/routes/native-auth.ts. The tests are in backend/test/native-auth.spec.ts and auth-login.spec.ts. The full backend suite passes.

SkyreaderKit (Swift package, Foundation-only, tests run on Linux)

Client: covers auth, timeline, reading, bodies, subscriptions and saves.

  • 503 session_refresh_pending responses are retried with the web client's backoff.
  • A 401 signs the user out.
  • Subscription records are decoded one at a time, so a single odd record, such as one with a null feedUrl, can't hide the rest.

Library: an observable store that follows the web client's model.

  • Timeline:
    • one global since_seq + generation cursor;
    • the first load is paged, and its cursor is saved only after the last page arrives;
    • each feed keeps its newest 100 items, matching ARTICLE_WINDOW_PER_FEED, and saved items are never trimmed.
  • Backfill: a followed feed with no local items gets a one-off feeds/fetch.
    • This covers feeds followed on another device, which sit below the cursor, and feeds the server hasn't crawled yet.
    • It fetches 10 feeds per sync, rotating the starting feed.
    • An empty success is remembered; a failure is retried on the next sync.
    • This is a port of the web client's backfillMissingSubscriptions.
  • Read state:
    • local reads go into a saved queue and are sent to mark-read-bulk / mark-unread after a short debounce;
    • each change carries the time the reader acted as updatedAt;
    • changes from other devices arrive through GET /api/reading/positions, and a local change that hasn't been sent yet wins.
  • Bodies: the item's own content, else items/body, else extract.
  • Offline cache: everything is stored in Application Support/Skyreader/library.json.

Tests: 26 tests cover:

  • paging and cursor commit;
  • the read-state delta versus unsent local changes;
  • persistence and trimming;
  • backfill: the empty-versus-failed cases, and the per-sync cap and rotation;
  • lossy subscription decoding;
  • 503 retry and PATCH encoding;
  • native login and callback handling.

App

  • Sign-in: native sign-in through WebAuthenticationSession, with the session stored in the keychain.
  • Debug builds:
    • a Server picker: Production, Staging, or Local (127.0.0.1:8787 for ./scripts/dev-local.sh);
    • a sidebar label when the app isn't on production;
    • pasting a CLI session ID to sign in.
    • NSAllowsLocalNetworking permits plain HTTP to loopback.
  • Layout: three columns.
    • Sidebar: folders (from category), feeds, unread badges and a failing-feed marker. standard.site publications are shown as not yet supported.
    • Article list: unread filter, mark all/older as read, and swipe actions.
    • Reader: serif body using DESIGN.md tokens.
  • Reader safety: the WKWebView runs with JavaScript off. Clicked links open in the browser, and main-frame navigations other than the page's own are refused.
  • Saves: save and unsave from the list or reader, a Saved list, and save-a-link.
  • Feeds: add a feed from a site address (discovery), rename, move to a folder, unsubscribe.
  • Also: settings for account and sync, and macOS menu commands with shortcuts (⌘R, ⇧⌘U, ⌘D, ⌘↩).

Build and CI

  • project.yml is an XcodeGen spec. The .xcodeproj and the Info.plists are generated and gitignored.
  • .github/workflows/apple-ci.yml runs the kit tests on Linux and unsigned xcodebuild builds of both targets on macos-15, only for PRs that touch apple/.
  • Docs: apple/CLAUDE.md (including testing against a local backend), and the sign-in modes in backend/CLAUDE.md.

Testing notes

  • The macOS app has been run against a local backend, and native sign-in round-trips there. After the first sync only one feed appeared; that was the local backend's empty database, not the app. Its bugs are fixed in this PR: the missing backfill, and a list decode that one odd record could fail.
  • Native sign-in against staging or production needs this backend change deployed. Until then, debug builds can sign in to production with a CLI session ID.

Not yet

standard.site documents, highlights and notes, linkblog sharing, channels, OPML import, a share extension, an app icon, and signing/TestFlight.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WgeSghB1ro1QRmB3t28BEd

Adds apple/: a SwiftUI app for macOS 14+ and iOS 17+ generated from an
XcodeGen spec, plus SkyreaderKit, a Foundation-only Swift package with the
timeline API client and wire models. The app signs in with a pasted
session ID (debug builds only, until native OAuth), cold-starts
/api/v2/timeline over Bearer auth, and reads articles as plain text.

Apple CI runs the kit tests on Linux and unsigned xcodebuild builds of
both targets on macos-15 for PRs touching apple/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgeSghB1ro1QRmB3t28BEd
Port of frontend/src/lib/utils/tid.ts for subscription and save rkeys,
with tests pinned to the JS implementation's encoding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgeSghB1ro1QRmB3t28BEd
The macOS/iOS app starts login with native_challenge (base64url SHA-256 of
a secret it keeps). The callback stores a one-time code bound to that
challenge and redirects to skyreader://auth/callback?code=..., never the
session: a custom URL scheme can be claimed by any app on the device. The
app trades code + verifier for the session at POST
/api/auth/native/exchange. Codes live two minutes, burn on first use
whatever the verifier, and expired ones are swept with oauth_state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgeSghB1ro1QRmB3t28BEd
SkyreaderKit gains the full client (auth, timeline, reading, bodies,
subscriptions, saves) and Library: an observable store that syncs the
timeline with a global cursor, keeps read state with a persisted outbox
and the read-positions delta, trims each feed to the server's window,
and caches everything on disk for offline reading. Tests cover paging,
cursor commit, delta vs pending writes, persistence and trimming.

The app gets native sign-in through a web authentication session, a
three-column reader (folders and feeds, article list with unread
filter and swipe actions, a serif reader with JavaScript off), saves,
add/rename/move/unsubscribe feeds, save-a-link, settings, and menu
commands with keyboard shortcuts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgeSghB1ro1QRmB3t28BEd
WebKit's API is main-actor isolated; the representable's helpers weren't.
Also parenthesize a trailing closure in an if-let condition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgeSghB1ro1QRmB3t28BEd
@disnet disnet changed the title Add native macOS & iOS app (SkyreaderKit + SwiftUI) Add native macOS & iOS app, with native sign-in Sep 29, 2026
Against a backend that predates native sign-in, the auth sheet finished
in the web app instead of returning to the app. The login response now
says native: true when it accepted native_challenge, and the app refuses
to open the sheet without it, with a clear message.

Debug builds can pick Production, Staging or Local (127.0.0.1:8787) on
the sign-in screen, so a backend branch can be tested with
./scripts/dev-local.sh before it deploys; NSAllowsLocalNetworking lets
the app reach loopback over plain HTTP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgeSghB1ro1QRmB3t28BEd
A feed followed on another device sits below the global timeline cursor,
and one the server hadn't crawled has nothing to deliver, so both stayed
empty in the app. Port the web client's backfill: each sync, up to ten
followed feeds with no local items get a one-off feeds/fetch (which also
pulls an uncrawled feed through the crawler), rotating the start so a
broken feed can't hog the budget. Empty successes are remembered;
failures retry next sync.

The sidebar also marks standard.site publications, which the app can't
show yet, instead of leaving them silently empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgeSghB1ro1QRmB3t28BEd
records/list can carry a null feedUrl (some atproto source types), and a
single such record failed the whole decode, so no subscriptions synced.
Decode records one by one and skip what the app can't read.

Debug builds now label a non-production server in the sidebar: a local
backend is its own, empty database, and its missing feeds looked like a
sync bug.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgeSghB1ro1QRmB3t28BEd
@disnet
disnet marked this pull request as draft November 9, 2026 01:03

This branch has not been deployed

No deployments
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