Skip to content

fix(ios-e2e): wait for session root before terminate to avoid launchd race#319

Merged
auerbachb merged 2 commits into
mainfrom
issue-318-ios-smoke-terminate-race
May 1, 2026
Merged

fix(ios-e2e): wait for session root before terminate to avoid launchd race#319
auerbachb merged 2 commits into
mainfrom
issue-318-ios-smoke-terminate-race

Conversation

@auerbachb
Copy link
Copy Markdown
Owner

@auerbachb auerbachb commented May 1, 2026

Summary

  • Fixes flake in ios-e2e-smoke lane: testLaunchLoginCompleteSessionAndHistoryPersistence was failing with Failed to terminate ... :0 (or post-relaunch home-wait timeout) on macOS-26 / iOS 26 runners, while ios-e2e-critical stayed green on the same SHAs across 4 recent runs (25215904325, 25216409703, 25216402153, 25216777439).
  • Root cause: terminate() was called immediately after beginButton.tap(), racing launchd while the app was mid-navigation / audio engine startup / timer init.
  • Fix (after v1 helper-based attempt failed CI): keep direct beginButton.tap() and add an explicit waitForExistence(timeout: 20) for root.currentView.session before terminateAppReliably. v1 used tap(_:thenWaitForRoot:in:), but its tapByStableCenter stable-frame check failed on this test's specific flow (run 25218186115).

Closes #318

Test plan

  • testLaunchLoginCompleteSessionAndHistoryPersistence passes on iOS 26 simulator (verified via smoke lane green on 607af03)
  • ios-e2e-smoke lane passes on this PR (run 25218888601)
  • ios-e2e-critical lane passes on this PR
  • Smoke lane re-run twice in a row to demonstrate flake reduction (1/2 so far on 607af03; one more re-run pending)
  • Other UI tests in StillPointAppUITests unaffected (diff modifies only the one method; 9 other tests untouched)
  • No product code in ios/StillPointApp/ changed (test-only single-file diff: +5/-0)

🤖 Generated with Claude Code

… race (#318)

The smoke-lane test `testLaunchLoginCompleteSessionAndHistoryPersistence`
called `terminate()` immediately after `beginButton.tap()`, racing the
simulator's launchd while the app was mid-navigation / audio init. That
produced `Failed to terminate ... :0` failures and post-relaunch home-wait
timeouts on macos-26 / iOS 26 runners while `ios-e2e-critical` stayed
green on the same SHAs.

Use the existing `tap(_:thenWaitForRoot:in:)` helper so terminate fires
from a quiescent in-session state.

Closes #318

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented May 1, 2026

CodeAnt AI is reviewing your PR.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
still-point Ignored Ignored Preview May 1, 2026 2:49pm

Request Review

@auerbachb
Copy link
Copy Markdown
Owner Author

@cursor review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

📝 Walkthrough

Walkthrough

The UI test now waits for the session root to appear after tapping the Begin button (using the existing tap helper) before changing the launch environment and calling terminate/relaunch, preventing termination during in-flight session initialization.

Changes

Cohort / File(s) Summary
iOS UI Test Synchronization
ios/StillPointAppUITests/StillPointAppUITests.swift
Replace beginButton.tap() with tap(beginButton, thenWaitForRoot: "session", in: app) and add a comment explaining the terminate-during-init simulator/launchd race. Small test-only synchronization addition (+5/-0).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

size:M

Suggested reviewers

  • codeant-ai

Poem

🐰 I tapped with care and twitched my ear,

Waited for session so relaunch was clear.
No more races, no noisy alarm,
The simulator woke with nary a harm.
Hooray — tests hop on, calm and warm. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: waiting for session root before terminate to avoid a launchd race in iOS E2E tests.
Linked Issues check ✅ Passed The PR directly addresses issue #318 requirements by implementing the proposed fix to wait for session root before terminate, eliminating the race condition during the Begin button flow.
Out of Scope Changes check ✅ Passed The change is a test-only modification in StillPointAppUITests.swift adding explicit synchronization before terminate, with no product code changes; this is entirely within scope of the linked issue.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #318

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-318-ios-smoke-terminate-race

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeant-ai codeant-ai Bot added the size:XS This PR changes 0-9 lines, ignoring generated files label May 1, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d9e69aa. Configure here.

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented May 1, 2026

CodeAnt AI finished reviewing your PR.

…inate

The first attempt swapped `beginButton.tap()` for the
`tap(_:thenWaitForRoot:in:)` helper. That helper uses
`tapByStableCenter`, which gates on an 8s stable-frame check and
silently skips the tap when the frame is unstable. On the smoke lane
the helper retried 3x with 12s session-root waits and never
registered a session transition, failing the test.

Keep the direct `beginButton.tap()` (proven in earlier passing runs)
and add an explicit `waitForExistence(timeout: 20)` on
`root.currentView.session` before `terminateAppReliably`. Same
idle-before-terminate benefit; no change to tap semantics.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@auerbachb
Copy link
Copy Markdown
Owner Author

@cursor review

@auerbachb
Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@auerbachb
Copy link
Copy Markdown
Owner Author

@CodeAnt-AI review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

✅ Actions performed

Full review triggered.

@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented May 1, 2026

CodeAnt AI is running the review.

@auerbachb
Copy link
Copy Markdown
Owner Author

@graphite-app re-review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 607af03. Configure here.

Comment thread ios/StillPointAppUITests/StillPointAppUITests.swift
@codeant-ai codeant-ai Bot added size:XS This PR changes 0-9 lines, ignoring generated files and removed size:XS This PR changes 0-9 lines, ignoring generated files labels May 1, 2026
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented May 1, 2026

Sequence Diagram

This PR updates the smoke test flow so that after tapping Begin on the home screen, the test explicitly waits for the in-session screen to appear before terminating and relaunching the app, reducing a race with the simulator process.

sequenceDiagram
    participant Test
    participant App

    Test->>App: Launch app and perform login
    App-->>Test: Display home screen
    Test->>App: Tap Begin on home
    App-->>Test: Display session screen
    Test->>App: Wait for session root then terminate app
    Test->>App: Relaunch app and verify home and session persistence
Loading

Generated by CodeAnt AI

Comment thread ios/StillPointAppUITests/StillPointAppUITests.swift
@codeant-ai
Copy link
Copy Markdown

codeant-ai Bot commented May 1, 2026

CodeAnt AI finished running the review.

@auerbachb auerbachb merged commit ddf7b69 into main May 1, 2026
15 checks passed
auerbachb added a commit that referenced this pull request May 1, 2026
…fter-navigation race (#321)

* docs(ios-ui-tests): add Patterns and pitfalls section for terminate-after-navigation race

Documents the launchd race that PR #319 fixed: terminating right after
a navigating tap can hang the simulator with "Failed to terminate ... :0".
Records the canonical "direct .tap() + explicit waitForExistence on
root.currentView.<slug>" pattern, and explains when the existing
tap(_:thenWaitForRoot:in:) helper is appropriate vs when its
tapByStableCenter gating silently skips the tap.

Closes #320

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* docs(ios-ui-tests): address CodeRabbit nits on Patterns and pitfalls

- Add `text` language tag to the unlabeled fenced block showing the
  Failed-to-terminate output (markdownlint-friendly).
- Cite the passing CI run alongside the failing one to document both
  ends of the d9e69aaddf7b69 transition.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS smoke E2E: testLaunchLoginCompleteSessionAndHistoryPersistence flakes on terminate after Begin tap

1 participant