Harden simulator launch-arg tooling against stale nav routes - #101
Open
saksham2001 wants to merge 1 commit into
Open
Harden simulator launch-arg tooling against stale nav routes#101saksham2001 wants to merge 1 commit into
saksham2001 wants to merge 1 commit into
Conversation
Launching with -seedDemo YES -openWorkout YES could leave the NavigationPath holding duplicate/stale activityDetail entries: the root .task re-fires when the root Group swaps content (onboarding to main tabs), so reseed + push could run more than once per process, and a later SeedData.clearAll wiped the sessions that earlier route entries pointed at. Back then appeared dead because pops landed on identical stale copies. - Guard the launch-arg block with a didRunLaunchArgs @State flag so reseed + push runs at most once per process; liveWorkout.recover() and deep-link routing still run on every task pass. - Reset the NavigationPath before pushing the openWorkout route so Back always returns to the dashboard. - Upgrade ActivityDetailView's missing-session fallback to a full-screen ContentUnavailableView with an explicit Back to Dashboard action, so a stale id is never a dead-end page. Only affects DEBUG/simulator tooling paths, not production flows.
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.
Summary
Launching the simulator with
-seedDemo YES -openWorkout YEScould leave the rootNavigationPathholding duplicate/staleAppRoute.activityDetail(id)entries, which made the Back button look dead — each pop landed on another identical detail page, and entries whose session had been wiped by a later reseed rendered as a near-blank screen.Two causes, both in DEBUG/simulator tooling paths:
.taskinRootAppViewre-fires when the rootGroupswaps content (onboarding → main tabs), so the reseed-and-push block could run more than once per process. The second pass'sSeedData.clearAllthen wiped the sessions that already-pushed routes pointed at.openWorkouthandler appended onto whatever was already on the stack, so stale copies accumulated.Changes:
PulseLoop/Views/RootViews.swift— guard the launch-arg block behind a newdidRunLaunchArgs@Stateflag so reseed + push run at most once per process.liveWorkout.recover()androuteDeepLinkIfNeeded()deliberately stay outside the guard so they still run on every task pass (scene re-activation, Live Activity deep links).PulseLoop/Views/RootViews.swift— resetpathto a freshNavigationPath()before pushing theopenWorkoutroute, so Back always returns to the dashboard rather than to a leftover detail route.PulseLoop/Views/RecordViews.swift— replaceActivityDetailView's one-lineEmptyStateViewfallback with a full-screenContentUnavailableView(icon, description, and an explicit Back to Dashboard button), so a stale id is never a blank dead-end page.No production flow changes: the guarded block only runs for the
seedDemo/openWorkout/openRecordlaunch args, and theActivityDetailViewfallback is the pre-existing missing-session branch, just made usable.Related issues
N/A — found while smoke-testing with demo-data launch args.
Type of change
How was this tested?
PulseLoopTests)⌘Uin Xcode)-seedDemo YES, no hardware)Note: the patch was originally authored in an environment without Xcode and was never run. All simulator verification below was done separately by the agent that opened this PR, not by the original author.
Verified on iPhone 16 Pro (iOS 18.6), Debug build:
Executed 756 tests, with 0 failures(** TEST SUCCEEDED **).Groupgenuinely swaps onboarding → main tabs): with the guard reverted,-seedDemo YES -openWorkout YESneeded two or more Back taps and still sat on an identical detail page — the reported symptom. With the fix, one Back tap lands on the dashboard.-seedDemo YES -openWorkout YES(5 process launches): detail opens each time, one Back tap → dashboard.ActivityDetailView(sessionId:)against an empty store with an id that resolves to nothing — shows the full-screen "Workout not found" card with the Back to Dashboard action instead of a blank page (screenshot below).line_length(143 > 140) on theopenWorkoutcondition line, caused purely by the extra indentation of the guarded block. The SwiftLint workflow does not run--strict, so this annotates but does not fail CI.Privacy & data
Screenshots / recordings
Missing-session fallback (
ContentUnavailableView), rendered against an empty store — a centredfigure.run.circleicon, the Workout not found title, the "no longer in local storage" description, and an accent-coloured Back to Dashboard button, filling the screen onPulseColors.background. (Image to be attached; it was captured locally rather than uploaded by the automation that opened this PR.)Checklist