Repository navigation
Open a Plex title from another app's launch params - #853
Conversation
A launch with params {"plex":{"server":"<machineIdentifier>","ratingKey":"12345","action":"open"}}
opens that title: `open` (the default) lands on its detail page with
Home alone underneath, `play` starts it where Resume would. `server` is
optional; unknown keys are ignored; a launch without a `plex` object is
unchanged. A bad key, a server that never appears or a malformed object
leaves Home in place and logs a `deeplink:` line. Sign-in, the profile
picker and onboarding are never interrupted.
Only a cold launch carries the link: main.c hands argv[1] to
plx_platform::tv::launch. A warm launch's params go to the registerApp
subscription LG's SDL holds, which the app cannot hold itself (measured
on webOS 9.2.2: an anonymous client is refused, the app-id name is
taken, LSCallFromApplication is unprivileged), so callers close the app
first. docs/launch-links.md is the caller's contract.
app::deeplink waits for Home at the root, unwinds the stack to it,
requests the item and hands the landing to the shared MenuPlayAwait,
which learns to open instead of play and to leave the stack alone on a
miss. The route tests' loopback PMS servers become one in
bridge_test_support.
ac2226b to
df197bc
Compare
SAM sends a relaunch's parameters only to the registerApp subscriber, LG's SDL, whose handler raises the window and never reads them. It fetches each reply's payload through HELPER_HLunaServiceMessage, an exported pointer slot filled from libhelpers.so.2 inside SDL_Init and reloaded on every call. boot wraps that slot: a relaunch payload goes to tv::launch and is returned unchanged, so SDL still raises the window. No new Luna registration. The slot is swapped with an atomic store after the original is published, since SDL's Luna thread may be reading it. The firmware inventories have the slot from webOS 7.4 on. Where it is absent (4.x to 6.x), only cold launches carry links, as before, and docs/launch-links.md keeps the close-first fallback for callers. deeplink::tick takes payloads every frame; tv::launch keeps an atomic flag so a frame with nothing waiting skips the lock. The tap logs each relaunch's size, thread and whether it carried parameters.
| Some(serde_json::Value::Number(n)) if n.is_u64() => n.to_string(), | ||
| _ => return Parsed::Bad, | ||
| }; | ||
| if rk.is_empty() || rk.len() > 20 || !rk.bytes().all(|b| b.is_ascii_digit()) { |
There was a problem hiding this comment.
Could we make this accept ASCII letters and dashes as well as digits, with a longer bound?
I maintain a fork that puts a Jellyfin server behind the same Client surface, and its rating keys are the server's item GUIDs (32 hex digits, sometimes with dashes), so this check refuses every link to one of its items. Letters, digits and dashes still rule out anything that could change the request path (/, ?, &, %, ..), so Plex keys behave exactly as now:
| if rk.is_empty() || rk.len() > 20 || !rk.bytes().all(|b| b.is_ascii_digit()) { | |
| if rk.is_empty() || rk.len() > 64 || !rk.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'-') { |
The "digits only" wording in the module doc and in docs/launch-links.md would change with it.d.
…lifecycle state() Co-Authored-By: Claude Opus 5.5 <[email protected]>
…perseded) ForegroundInput::Superseded(Successor) with the state table on claim, and a Retire effect for a LoadPending exit; replace_with_new_playback is replaced by Superseded(Playback). exit_player sends Superseded(Exit) first, so a refused restore (Prepared) no longer survives an exit and blocks playback_may_run. The existing replacement_play_retires_failed_foreground_owner_and_lands test asserted the old behaviour (Prepared after Exit, and after the replacement request); those two asserts are deliberately rewritten to Idle. Its replacement half still pins that the replacement lands. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… state per the table; player guide Co-Authored-By: Claude Opus 5.5 <[email protected]>
Four tests that fail on the merged PR plxnative#853 tree: a_link_waits_under_the_consent_sheet, a_link_with_a_server_survives_sign_in, a_serverless_link_that_waited_across_sign_in_is_dropped (route rig) and a_link_waits_for_the_foreground (run.rs rig). The route rig gains once()/frames(). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd the background PR plxnative#853's link now follows B1 of the board plan: - Login root = wait (marks that the link crossed a sign-in), no longer a drop; - a surface up (consent sheet) or a backgrounded window = wait; - a link naming a server resolves against the new account's roster after sign-in, 15 s from the first frame the root is Home; - a server-less link that crossed a sign-in is dropped with 'deeplink: dropped (signed in after the link arrived; it names no server)'. Shape: private DeepLink(LinkState) written only by step(), link_inputs() as the one reader, a LinkRoster port, effects as existing Fx values (Log, Nav SelectTab, Store RequestDetail) performed by perform(); only the MenuPlayAwait arm stays an app-loop write. The landing is otherwise unchanged (B2 replaces it). The detail request now goes through the dispatcher, one frame later than the direct run. Deliberate rewrites under the Login = wait decision: - deeplink.rs the_gate_waits_behind_the_picker_and_drops_without_an_account becomes the link_step_* table tests; - no_account_signed_in_drops_the_link_and_leaves_sign_in_alone becomes a_link_with_no_account_waits_through_sign_in. Rig::run now calls deeplink::frame; the run.rs test also runs held detail fetches. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…naServiceMessage The tap wrapped whatever pointer HELPER_HLunaServiceMessage held and later called it as a function. It now installs only when the slot equals the address of HLunaServiceMessage from the already-mapped libhelpers.so.2 (RTLD_NOLOAD); otherwise it logs and leaves SDL alone. slot_holds is pure; test relaunch_slot_must_hold_libhelpers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The step gains a Leaving state (bounded at LEAVE_WAIT_MS), session_stands in its env and leaves_playback in its output. It emits Fx::App(AppFx::Player(PlayerReq::Exit)) through the dispatcher, so the existing exit ritual (and Superseded(Exit)) retires the session; it never pops the player by nav. Rig::run in deeplink_route_tests passes session_stands=false. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o compile) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ck claims nothing (B3) did_foreground_with_link steps the link first and picks DidForeground or the new DidForegroundSuperseded from its output (leaves_playback); the parent reads no child's state. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… wait's deadline (B4) menu_play_tick's landed and Season branches ask content::clear_engine_for_play before play_loaded_hero: a held engine keeps the wait armed, and at the wait's own deadline a link logs 'not opened (engine busy)' while a card press opens the page. The red tests as first committed forced the preview phase directly, which preview::halt resets to Idle (no preview session, no engine), so they could not hold; they now hold a real Abandoning through two test-support seams (preview::hold_load_for_test, route::mark_preview_for_test) that make retire() find the preview's Load not yet returned. Observed red again on the unfixed input.rs with these tests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ayback does not Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s relaunch must not displace a pending link (red) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…payloads queue; tap slot alignment The Exit no longer drains while the window is hidden (it now goes out at the DID step, with DidForegroundSuperseded). launch.rs keeps a bounded queue and the frame folds it to the last real link, so a link-less relaunch cannot erase a pending link. tap_relaunch_payloads refuses a misaligned slot. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks a lot @thewillwilson, this is merged! I pushed a few changes onto your branch before landing it: the link now waits through sign-in, under sheets and while the app is in the background, it stops playback the same way the STOP key does, and the warm-launch hook only installs if SDL's slot holds libhelpers' HLunaServiceMessage. I can't test the warm path here (my set is on webOS 4.5), so if you get a chance on your 9.2.2, a quick check that a relaunch link still works would be great. |
* Release notes and audit for v0.9.0 Action-required evaluation (README trigger list, read from the PRs, grep not run on a built tree): no hits that need a reader action. Launch links (#853) add an inbound surface (any app that can launch apps), stated in What's new; the 3.4 image cache writes to /media/developer/temp (#667); crash/error reports gain fixed-value fields with POLICY_VERSION unchanged (#632), stated under Changed; Watchlist and PMS notifications use hosts the app already reaches. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Release notes v0.9.0: coverage and accuracy pass Note: correct the Collections surfaces (no TYPE menu; collection shelf headings live on Home and a library's Recommended page), the Watchlist hold-menu rows, the launch-link sign-in behaviour and platform-release numbering, the notification-feed sentence and the per-profile settings list (no stale "nine"). Add #832, #808, #750/#762, #709 (#628), #641, #647, #793, #871, #877 (#679), #876 and the key-press frame work; credit RichiL10 and Shakil Choudhury. #862 moves from Known issues to the webOS 3.x lines as fixed by #578; the 3.9.3 source-build report (#700) is kept in Compatibility. Compatibility links reports, not reporters' profiles. Audit: #862 provenance (attributed usage-report reading, no counts), contributor list wording. Action-required section: not owed. The README grep over v0.8.0..origin/main (rust-modules/src src ci) hits only CI tooling, test-only loopback listeners and fixture tokens, and the dev-only /tmp/plxnative-trackmemory trigger; the audit's PR-by-PR reading in "Deliberately not done" stands. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Release audit v0.9.0: name the toolchain by its pin file, not its version Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…te (#977) The player's foreground lifecycle (ForegroundLifecycle, media/src/player/lifecycle.rs) now has one writer, step(&ForegroundEvent, &mut Vec<ForegroundEffect>) -> Handled. Its fifteen pub mutators and its pub state field are gone; step 3 of the Sans-IO series (docs/sans-io.md). Behaviour is preserved and no ledger or pin changes. Eight events replace the mutators: Park{saved_ns, viewer_paused}, ParkFlight, Input, PrepareAnswered, LoadAnswered, FlightStale, LoadStatus and ClockAnswered. A new PlayKeyOffPlayer input folds discard_started_state + claim(PlayKey) into one event. AfterLoad, Launched and DropFlight are new effects; Retire stays separate, so the #853 tables are unchanged. The pause flag arrives as a value on Park, so clock_for_suspend_now (which read the transport's global) is deleted and the machine reads no global, clock or IO. Callers read the private state through awaiting_load, claimable_clock, pending_flight and pending_load_attempt. drive_foreground, poll_foreground_flight, poll_foreground_load and park_pending_foreground_flight share one loop: a single Option<ForegroundEvent> slot, effects run through the ForegroundActuator, the one answering effect's answer fed back as the next event (debug_assert: at most one per step), no allocation on a frame that only polls. Two orderings change, unobservable to the actuator (it holds only the adapter and repause_at): LoadAnswered's Failed/AlreadyRunning/Terminal arms run after_load after the state write, and ParkFlight runs suspend_bufferfeed after the park. Tests: every_state_meets_every_event_as_the_table_says (8 state kinds x 29 events; every cell pins Handled, next state, effects in order and next_id; unlisted cells must be unchanged) and play_off_player_is_one_event. Existing driver, flight, claim_hold and lifecycle_regression tests changed only in spelling or added assertions. On the dev TV against a mock server, background then foreground while playing saved at 35 s, resumed at 31 s with one restore Load and played to EOS; the decoder-release path was not reached on the set (covered by the hostsim test a_decoder_released_by_the_pipeline_parks_until_the_next_press_restores_it). Closes #976 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Open a Plex title from another app's launch
Another app on the television can now open a specific title in PlxNative by passing it in the launch params. One example is a launcher's Continue Watching row.
ratingKey(required): a string or a number, digits only.server(optional): the server'smachineIdentifier. Without it, the signed-in current server is used.action(optional):open(the default) lands on the detail page.playstarts the title where Resume would.plexobject behaves exactly as before.deeplink:line. It never crashes and shows nothing on screen.The full contract for callers is in
docs/launch-links.md.Cold and warm launches
SAM passes a cold start's params as
argv[1], andmain.chands them toplx_platform::tv::launch.A warm launch is different. SAM delivers it as a
relaunchevent to theregisterAppsubscription, which LG's SDL holds. SDL brings the window forward and drops the params. I measured on webOS 9.2.2 (LG C2) whether the app could hold that subscription itself. It can't:LSRegister(NULL)client withcannot find caller id.LSCallFromApplicationis refused as not privileged (-1031).LG's
libSDL2reads each Luna reply's payload throughHELPER_HLunaServiceMessage. That is an exported pointer slot, filled fromlibhelpers.so.2insideSDL_Initand re-read on every call. Right afterSDL_Init,app::bootwraps that slot. A relaunch payload goes totv::launchand is returned unchanged, so SDL still raises the window. There is no new Luna registration.appinfo.jsonkeepshandlesRelaunch: false.The firmware inventories have the slot from webOS 7.4 on, and not on 4.x to 6.x. Where it is missing, boot logs that and only cold launches carry links. For that case,
docs/launch-links.mdtells callers to close the app first, pause briefly, then launch.The slot is replaced with an atomic store after the original is published, because SDL's Luna thread may be reading it.
tv::launchkeeps an atomic flag, so a frame with nothing waiting skips the lock.How it works
app::deeplink::ticktakes each payload as it arrives (the cold one, then any relaunch) and parsesparameters.plex. A relaunch without aplexobject leaves a waiting link alone. It waits until Home is the stack's root, then:nav_select_tab;RequestDetail;That wait is
MenuPlayAwait, which gainsfor_link. A link's wait opens the item rather than playing it whenactionisopen. On a miss it logs and leaves the stack alone, instead of opening a page that may not exist. The wait keeps its 12 s ceiling, settled-failure check and player guard, so the link path doesn't duplicate any of them.The two route-test loopback PMS servers are now one,
bridge_test_support::Pms.Tests
deeplinkunit tests:play;deeplink_route_tests, which run production frames against a loopback PMS:menu_play_season_testsis unchanged apart from using the sharedPms.Verification
cd400f1b:openfor a known key goes Home, then that title's detail page. Back returns to Home, and Resume has focus.deeplink: not opened, rk=… (not returned).serverresolves:openwith the server'smachineIdentifierlands on that show's detail page.action: "play"with a named server goes Home, then straight to the player on the show's next episode.relaunch tap: installed. On the same process (no restart):plexobject left the app where it was.plx_plex::plex::id_of_machine.No
Makefile, Cargo,build.rs, workflow or module-layer changes, so there is no build-bench table.