Skip to content

feat(app): Siri, Shortcuts, Control Center and Spotlight for the iOS app - #14

Merged
perminder-klair merged 7 commits into
mainfrom
feat/ios-intents
Nov 27, 2026
Merged

perminder-klair merged 7 commits into
mainfrom
feat/ios-intents

Conversation

@perminder-klair

@perminder-klair perminder-klair commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Ported from perminder-klair/subwave#2113 after the app moved here. The branch predated stream recovery (perminder-klair/subwave#2114, perminder-klair/subwave#2139) and the idle skip (#9), so the port does more than replay it:

  • usePlayer: the mount-time adoption and the App Intent tune-out now go through StreamRecovery (adopt() / tuneOut() plus endIdleSkip()) where they used the old watchdog.
  • useStationFeed: leadMsFrom() gives the buffer, and the idle skip's trim still comes off it.
  • CLAUDE.md / StationContext: both sides merged.

tsc and eslint are clean (one existing warning in onboarding.tsx), and npm test passes 571 tests (5 skipped). Opened as a draft until this is checked on a device.

Fixed after review:

  • Intent tune-ins load through the mounted player. Every tune-in from Siri, Shortcuts, Spotlight or the Control is handed over service.ts's claim, so it goes through stream-recovery.ts. It loads directly only when no player is mounted. With the player mounted, a station switch arms a tune-in that usePlayer takes when its base changes (src/intents/tune-flow.ts, tuneInOnArrival).
  • Every answer fits Siri's 20 s window. The bridge sends its deadline with each request. The song request races its POST and polls against it, and a POST still out at the deadline is said as sent, so the request isn't queued twice. "What's playing" and "Like this song" race their reads against it and cancel them when it passes, saying the station is slow to answer. POST /like is raced and cancelled the same way (likeCurrent now takes an abort signal); a like still out at the deadline is said as unconfirmed, with an ask to repeat, because a repeat like counts once (alreadyLiked).
  • "What's playing" and "Like" subtract the idle skip's trim, so they no longer name the previous song after a skip.
  • The Control's on-air state is set by intent tune-ins and tune-outs, for when no player is mounted.
  • Shared announcer, on-air state set and station read. Typed intent actions. The module's dedupe set is capped.

Summary

The iOS app gets Siri, Shortcuts, Control Center, the Action button and Spotlight. Each works with the app closed.

Ask What happens
"Hey Siri, play SUB/WAVE" / "Tune in to SUB/WAVE" tunes in to the station listened to last; on iOS 27 through Siri's audio search (.audio.playAudio) so Apple Music doesn't take it
"Play ChillWave Radio on SUB/WAVE" switches to that saved station and plays it
"Request a song on SUB/WAVE" Siri asks what to play, sends it through POST /request, reads back the DJ's answer (perminder-klair/subwave#417)
"What's playing on SUB/WAVE" / "Like this song on SUB/WAVE" the song the listener is hearing, 22 s behind the live edge
"Stop SUB/WAVE" tunes out
Control Center / Lock Screen / Action button (iOS 18) on/off toggle
Spotlight (iOS 18) each saved station, opening the app tuned to it
Watch Smart Stack, CarPlay Dashboard (iOS 26) .small Live Activity layout

Every intent is thin Swift that hands its action to JS. JS does the work with the same station store, credential vault and player the screens use, so station URLs, logins and passwords never reach Swift:

sequenceDiagram
    participant Siri as Siri / Shortcuts / Control
    participant Intent as Swift intent (targets/live-activity/_shared)
    participant Module as modules/app-intents
    participant JS as src/intents (registered in index.ts)
    Siri->>Intent: perform()
    Intent->>Module: post request (re-posts until acked: JS may still be booting)
    Module->>JS: onIntent(action, args)
    JS->>JS: tune / request / like / now playing
    JS-->>Module: reply(ok, message)
    Module-->>Intent: reply → Siri dialog or error
Loading

Things the work turned up, each fixed here:

  • An app built with Xcode 27 is killed at launch on iOS 27 without the UIScene life cycle. The fix is Expo's own expo-build-properties ios.enableSceneSupport. iOS still connects a scene for a background intent launch, so cold intents keep working.
  • EAS builds SDK 57 with Xcode 26.6, which compiles the iOS 27 Siri code out. Every iOS profile now pins macos-tahoe-26.6-xcode-27.1.
  • ActivityKit refuses a Live Activity from a background app. The tune intents are LiveActivityIntents, and the JS reply waits for the card, so a Siri tune-in still gets one.
  • usePlayer adopts audio it didn't start. That covers a cold start (mount-time check), an intent's tune-out (no reconnect), and a station switch from Siri (streamBelongsTo).

Evidence

  • Before: a Release build from Xcode 27 crashed at launch on the iOS 27 simulator (_UIApplicationEvaluateRuntimeIssueForNoSceneLifecycleAdoption), and there were no App Intents beyond the Live Activity heart.
    After, iPad on iOS 27.2 (Release, development-signed), app closed:

    20:24:20.28  SpringBoard  Bootstrapping app<com.getsubwave.app> background-user-initiated
    20:24:23.14  SUBWAVE      Invoking PlayStationAudioIntent.perform()      ← "Hey Siri, play SUB/WAVE"
    20:24:23.94  SUBWAVE      AVPlayer timeControlStatus=2                    ← audio
    20:24:23.97  liveactivitiesd  Requester is targeted by an activity request assertion
    

    "Hey Siri, play ChillWave Radio on SUB/WAVE" with SUB/WAVE active: the store shows ChillWave made active at the intent's timestamp.

  • Simulator, iOS 27 and 18.5, Release, app closed each time:

    • Shortcuts "Tune in" plays and starts the card.
    • "Tune out" stops with no reconnect in 12 s.
    • The control flips on and off and follows in-app play.
    • "Request a song" against a local stand-in station reads back the DJ's acknowledgement; a 429 is spoken in the station's words.
    • "What's playing", asked the second /now-playing changed, named the song still in the listener's ears.
    • A Spotlight tap and a per-station Shortcuts tile both switched station.
    • The Debug dev client launches and reloads under scenes.
  • Tests: npm run lint is clean and npm test passes 571 tests (576 with 5 skipped), 52 of them new: intent-tune, intent-request, intent-on-air, intent-stations, announcer and api.

Merge Danger

Door: two-way

Every piece reverts cleanly. Nothing here is destructive: the new App Group keys and Spotlight entries are rebuilt on every station change and go with the app.

Blast Radius: app-launch

  • Startup: the scene life cycle changes how the iOS app starts. Ship it to TestFlight before production.
  • Untested hardware: Cast, AirPlay, CarPlay and the watch weren't run on hardware with the new launch path.
  • Native code: this needs a new binary. OTA can't deliver it, and the next iOS build is the carrier.
  • Android: not run on Android. The JS changes in usePlayer, StationContext and useStationFeed are shared, and the native calls are no-ops there. The feed refactor (heard-track.ts) keeps the same rule. The new usePlayer paths only act when audio started outside the hook, which Android has no route to yet.

Ported from perminder-klair/subwave#2113, rebased onto stream recovery
(#2114/#2139) and the idle skip (#9).
… read

One announcer for the tune-out, station-switch and like subscribers; one
on-air state set for the intent tune-in, usePlayer's mount-time adoption and
"what's playing"; one store-and-credentials read for StationContext and the
intents; one usePlayer tune-out for RemotePause, an intent and a vanished
route. StreamRecovery.adopt's doc names the intent path.
A Siri, Shortcuts, Spotlight or Control tune-in loaded the stream itself even
with the player mounted, outside stream-recovery.ts: beside a backoff's
queued reload, with no idle skip, and on a switch with a teardown recovery
could read as a failure and answer by reloading the old station.

Every tune-in now goes over service.ts's own claim (playOnMountedPlayer) and
loads directly only when no player is mounted. A switch with the player
mounted writes the store and arms a tune-in for the new base
(tuneInOnArrival); usePlayer takes it when StationContext hands it the new
station and tunes in through StreamRecovery in place of the stop. The
decisions move to tune-flow.ts so scripts/intent-tune.test.ts can drive
them. Intent tune-ins and tune-outs set the Control's on-air state for when
no player is mounted, log to the playback log, and cut their waits to a
deadline the bridge will send (deadline.ts, a conservative fallback until
then).
The bridge gives up on JS 20 s after an intent starts, up to 10 s of it
spent on a cold boot, while a song request could spend 16 s on its POST and
10 s more polling: Siri said the app didn't respond for a request the
station took, and the listener asked again.

The bridge now sends its deadline with each request and the module passes
it to JS, which keeps a margin for the reply (deadline.ts). The song
request races its POST and each poll against it and stops polling an
interval early; a POST still out at the deadline is said as sent, since an
error would queue it twice. The tune-in's waits were cut to it in the
previous commit.

Also: intent actions are an enum on the Swift side and a union in JS, and
the module's dedupe set keeps only the last 32 tokens.
After an idle skip the listener is nearer the live edge by what it shed, up
to about 17 s on a 22 s buffer, but heardTrack measured "what's playing"
and "like this song" from the whole buffer and named the previous song
for that long.

usePlayer now writes the trim to heard-track.ts beside PlayerScreen's
leadTrimMs, loadAndPlay clears it, and on-air.ts and useStationFeed both
take the lead from listenerLeadMs.
perminder-klair added a commit that referenced this pull request Nov 27, 2026
A pick from the car's list, a voice search and a prepared pick's Play all
tune in through tune-flow.ts, as Siri's do: handed to the mounted player, and
so to StreamRecovery, whenever one is mounted, and loaded directly only with
none (tuneInByName sits in tune-flow since the rebase onto the fixed #14).
TESTING.md's Android Auto check now covers a pick with the phone app open;
CLAUDE.md names the car beside the App Intents.
The like intent ignored the deadline: its /now-playing and /state reads and
POST /like could each run 16 s, past the bridge's window, so Siri said the
app didn't respond.

likeHeard (on-air-reply.ts, pure and tested) races both steps against the
deadline and aborts the reads there. A station too slow to say what's on
gets no like. A like still unanswered at the deadline is a failure that
asks for a repeat, unlike the song request: a repeat like counts once
(alreadyLiked), where saying "liked" for one that never landed would lose
it.
perminder-klair added a commit that referenced this pull request Nov 27, 2026
A pick from the car's list, a voice search and a prepared pick's Play all
tune in through tune-flow.ts, as Siri's do: handed to the mounted player, and
so to StreamRecovery, whenever one is mounted, and loaded directly only with
none (tuneInByName sits in tune-flow since the rebase onto the fixed #14).
TESTING.md's Android Auto check now covers a pick with the phone app open;
CLAUDE.md names the car beside the App Intents.
… late like

"What's playing" now races its /now-playing and /state reads against the
deadline the bridge sends, aborts them when it passes, and says the station
is slow to answer, the way "like this song" already did. Both go through
one inTime helper in on-air-reply.ts.

likeCurrent takes an optional abort signal, so POST /like is cancelled at
the deadline instead of finishing in the background. The reply is still
"didn't confirm": the station may have counted it before the cancel, and
a repeat answers alreadyLiked.
perminder-klair added a commit that referenced this pull request Nov 27, 2026
A pick from the car's list, a voice search and a prepared pick's Play all
tune in through tune-flow.ts, as Siri's do: handed to the mounted player, and
so to StreamRecovery, whenever one is mounted, and loaded directly only with
none (tuneInByName sits in tune-flow since the rebase onto the fixed #14).
TESTING.md's Android Auto check now covers a pick with the phone app open;
CLAUDE.md names the car beside the App Intents.
@perminder-klair
perminder-klair marked this pull request as ready for review November 27, 2026 18:37
@perminder-klair
perminder-klair merged commit cf3e429 into main Nov 27, 2026
2 checks passed
perminder-klair added a commit that referenced this pull request Nov 27, 2026
A pick from the car's list, a voice search and a prepared pick's Play all
tune in through tune-flow.ts, as Siri's do: handed to the mounted player, and
so to StreamRecovery, whenever one is mounted, and loaded directly only with
none (tuneInByName sits in tune-flow since the rebase onto the fixed #14).
TESTING.md's Android Auto check now covers a pick with the phone app open;
CLAUDE.md names the car beside the App Intents.
perminder-klair added a commit that referenced this pull request Nov 27, 2026
* feat(app): Android Auto station list

Ported from perminder-klair/subwave#2136.

* fix(app): Android Auto review fixes: dead session token, caller check, prepare

- MediaBrowserBridge clears its token when MusicService is destroyed and
  tells browse services through a ready/ended listener; a browse service
  still holding a released session's token (MediaBrowserServiceCompat takes
  one) answers no root, so the car's next bind gets a fresh one.
- SubwaveBrowseService gives a root only to the car, the Assistant and the
  system (CarCallers, after Google's media sample's PackageValidator).
- A prepare (playWhenReady false) no longer plays: the patch passes the flag
  and src/intents/car-picks.ts holds the pick until the next Play.
- A refused or failed car pick is a plog line instead of a swallowed error.
- npm test checks the car-connect task name and matchStations' generic words
  and shortest term against their native twins.
- TESTING.md: the bridge and the background-setup bypass in the
  architecture-critical section; a session-restart and release-build check in
  the Android Auto checklist.

* test(app): Android Auto picks reach the mounted player through tune-flow

A pick from the car's list, a voice search and a prepared pick's Play all
tune in through tune-flow.ts, as Siri's do: handed to the mounted player, and
so to StreamRecovery, whenever one is mounted, and loaded directly only with
none (tuneInByName sits in tune-flow since the rebase onto the fixed #14).
TESTING.md's Android Auto check now covers a pick with the phone app open;
CLAUDE.md names the car beside the App Intents.
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