Repository navigation
feat(onboarding): run the onboarding tour on v2 - #369
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code review summaryReviewed head: Process: an adversarial review of this PR's diff with each candidate finding independently verified before any fix, a simplify pass for medium and larger PRs, and a whole-stack review across contract conformance, authority and failure handling, data integrity, user-visible behavior and cross-PR integration. Verified findings, all fixed on this branch:
Validation: this branch builds on its own for iOS, tvOS and macOS, and its focused tests passed. The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, the macOS build and the v1 path guard. The final stack was also exercised on iOS and tvOS simulators against a v1/v2 bridge server: sign-in (password and QR), restore, browse, search, detail, favorites and watchlist, playback (direct play, transcode, subtitles, stop), audiobooks, downloads with offline playback, settings, requests, profiles, push registration and diagnostics. Server logs showed no Remaining: no open verified findings. Merge in stack order. Mergeability: 8/10 — conditional. The approach holds up and every verified finding is fixed. Conditions: this PR's CI must pass (it was pending at review time), and the owner still plans a physical-device check of the completed stack. Review by Claude Opus 5.5 ( |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5745236c46
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| guard state.tourId == body.tourId, | ||
| !(body.completed || body.skipped) || state.done else { | ||
| throw OnboardingProgressError.unexpectedReceipt |
There was a problem hiding this comment.
Validate the step recorded by progress receipts
When an intermediate progress request receives a 200 response for the same tour but with an unchanged or different last_step, this guard accepts the receipt and the view model advances while chaining its ETag, even though the requested step was not confirmed. This can leave the UI ahead of the durable server state and cause a later launch to resume at the wrong step; require state.lastStep == body.lastStep for non-terminal writes before treating the receipt as saved.
Useful? React with 👍 / 👎.
2d85bb6 to
ac2291a
Compare
5745236 to
34e0370
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34e0370ac1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| guard fresh.state.tourId == tourId else { throw OnboardingProgressError.tourChanged } | ||
| if fresh.state.done, !loadedDone { return .finishedElsewhere } | ||
| current = fresh |
There was a problem hiding this comment.
Reconcile newer server progress before writing
After a stale or unanswered write, the fresh state can contain a later nonterminal lastStep recorded by another client. This path checks only done and the tour ID, then writes the Apple client's earlier step with the fresh ETag, overwriting the newer durable resume position. Compare the returned step against the flow and adopt already-reached progress instead of issuing a regressive write.
Useful? React with 👍 / 👎.
ac2291a to
a3b7150
Compare
The onboarding tour still read its flow and state from /api/v1 and posted progress there. A 1.0 server answers those with 410, and v2 guards progress with the state's ETag, so the tour could not move to v2 by path alone. The gate also had no clear rule for errors: it had to be proven that it never opens the tour unless the server confirms it is unfinished. The tour now reads state and flow through APIv2Client.onboardingRead and keeps that session's strong ETag. Each progress step is one PUT /api/v2/onboarding/progress with If-Match, and the receipt's tag replaces the old one. The operation is non_retryable: the tag is taken before dispatch, so a 412, 428, 409 or lost reply is never re-sent. The next step the user takes reads the state again first and closes the tour if it is already finished. A finishing receipt that is not done, or that names another tour, is refused. Profile writes from the tour act only for the profile that loaded it. The gate opens the tour only on a confirmed, unfinished state and stays closed on any error, including an update-required server. Its retry of an unrenderable tour and its legacy invite skip read the state first and write under that tag. The legacy skip reads the account through APIv2Client.currentUser. SiloAPI's three v1 onboarding methods are gone, and onboardingWrite drops the redundant writer id. Stack-PR: W5-F Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A finish whose reply was lost left the tour open with an error. When the user tapped the button again, the re-read showed the tour done and the tour closed without opening the route the user had picked. A tour the server had replaced was worse: every control wrote progress, got 409 or a re-read naming another tour, and the error told the user to close a tour that had no close control. A finish now keeps its route when the re-read shows it already landed; only the write is skipped. A 409 or a re-read naming another tour closes the tour with no route and logs the cause, and the gate reads the new tour on its next check. "Continue without saving" closes the tour even when its progress write fails. The tourChanged copy no longer points to a control that does not exist. Tests cover the route after a lost finishing reply, both replaced-tour paths, and the gate's legacy invite skip for an open state, a done state, a failed state read and another account's marker. Stack-PR: W5-F Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
34e0370 to
8c8d7f8
Compare
Problem
The onboarding tour still used v1 for all three of its calls:
GET /api/v1/onboarding/flow,GET /api/v1/onboarding/stateandPOST /api/v1/onboarding/progress(inventory rows 23, 24 and 25). A 1.0 server answers v1 with 410, so the tour would stop working. Changing the paths alone is not enough. In v2, progress is aPUTguarded by the state's strongETag: the server returns 428 whenIf-Matchis missing and 412 when the tag is stale. The contract also marks the operationnon_retryable.The gate that decides whether to open the tour also needed a clear error rule (audit F54). The audit found that the legacy invite path returned "handled" on any error. The inventory asked that no error, whether update-required, 401, 412 or 428, ever open the tour. The gate now follows one rule: it opens the tour only when the server confirms the tour is not done.
Solution
OnboardingTourViewModel.loadcallsAPIv2Client.onboardingRead(surface: "phone")throughSiloAPI.shared.apiV2Client. The call reads the state and then the flow under one captured owner. It rejects a flow for a different tour and keeps the state's strongETagin anAPIv2OnboardingSession.PUT /api/v2/onboarding/progresswithIf-Matchset to the tag from the last read or receipt. The receipt then replaces the session. The view model takes the session before it sends, so a tag is never sent twice. After a 412, 428, any other error or a lost reply, the next step the user takes reads the state again before it writes. If that read shows the tour is already done, and it was not done at load, the tour closes without writing. A finish still opens the route the user picked in that case, because the finish did land. That read must come from the same owner that loaded the tour (sameCredentialIdentity).OnboardingProgressError.tourChanged). The tour then closes with no route and logs the cause, because no progress for it can be saved. The gate reads the new tour on its next check. "Continue without saving" also closes the tour when its progress write fails, so the user always has a way out.onboardingWriterefuses a receipt for another tour, and a skip or finish receipt that is notdone(OnboardingProgressError.unexpectedReceipt). The redundantwriterIDparameter and the session'sidare removed, because the caller now passes the session itself.setting_choicestep saves its value only while the profile that loaded the tour is still active. This PR does not change the profile write, which is stillSiloAPI.updateProfile. W5-E owns that write.OnboardingTourGateModelopens the tour only when a state read succeeds for the checked profile, the state is notdone, and that profile is still active. On any error it logs the cause and keeps the tour closed. That includes update-required servers, which the gate refuses before sending anything. The retry for an unrenderable tour and the legacy invite skip both read the state first. They write only if the tour is still open, using that read's tag, and they clear their marker once the server confirms the tour is done. The legacy skip now reads the account id throughAPIv2Client.currentUser()and takes the tour id from the state, so it no longer reads the flow. The gate and the view model take the API, server id and profile id as injected values so tests can supply them.SiloAPI.onboardingFlow(surface:),SiloAPI.onboardingState(),SiloAPI.postOnboardingProgress(_:), the v1 doc reference inOnboardingModels.swift, and the v1 flow test. The v1 guard counts drop:SiloAPI.swiftby 3,OnboardingInvitationTests.swiftby 2 andOnboardingModels.swiftby 1.Failure outcomes (
PUT /api/v2/onboarding/progress,non_retryable)ETag, a matching tour, anddonewhen finishing)The gate's unrenderable-tour retry and legacy invite skip are one-shot writes too. Each one runs only after a fresh state read shows the tour still open. If an earlier write landed, the server has already moved the tag on, and a write that races it gets 412 instead of being applied twice.
Validation
OnboardingInvitationTestsandOnboardingV2Tests(35 tests, 0 failures). On tvOS,OnboardingV2Testspassed (8 tests).OnboardingInvitationTestsis not in the tvOS target because the tour is#if !os(tvOS).scripts/ci/check-no-api-v1.shpassed.Tests/Support/OnboardingServerStub.swiftmodels the server onStubURLProtocol: a revisioned state,"r<revision>"tags, 428/412 checks, a write that never arrives, a write whose reply is lost after it was applied, and a replaced tour that answers 409.OnboardingV2Testscovers the wire: state then flow withX-Profile-Idandsurface, refusal of a weak tag, thePUTbody andIf-Match, one dispatch on 412 and on a lost reply, an unfinished finishing receipt, and no request after a profile switch or on an update-required server.OnboardingInvitationTestsruns the view model and gate against the stub: receipt-tag chaining, re-read after a lost reply or a stale write, a lost finishing reply that still opens the chosen route, both replaced-tour paths, "Continue without saving" when its write fails, the gate staying closed on a 503 and on an update-required server, the unrenderable-tour retry, and the legacy invite skip for an open state, a done state, a failed state read and another account's marker.Risks and follow-ups
completed: false, as v1 did. This PR does not check whether the server keepscompleted_atin that case.SiloAPI.updateProfileon v1 until W5-E. W5-E can switch this caller toAPIv2Client.updateProfile(id:patch:auth:)using the tour's owner.APIv2Client.swiftandSiloAPI.swift, in different hunks. Whichever lands second rebases.AI disclosure
Code and description written by Claude Opus 5.5 (
claude-opus-5-5) agents in Claude Code (T3 Code), orchestrated by a Claude Code workflow.Part 21 of 50 in the Apple API v2 stack. Base:
apiv2-stack/20-overlay-config-v2. Merge in order from the bottom of the stack. The plan and full index are in PR 01.🤖 Generated with Claude Code