From dbf8a38d1ea3a0d99ee3c010ef8e1c80a600b115 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Thu, 19 Nov 2026 15:46:46 +0800 Subject: [PATCH 1/8] ci(ios): build the simulator app and test streaming UI --- .github/workflows/check.yml | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e51f28d..1b6d465 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -56,15 +56,45 @@ jobs: src/apps/mobile/android/app/build/test-results/ if-no-files-found: ignore ios: - runs-on: macos-latest + runs-on: macos-26 + env: + IOS_SIMULATOR_DESTINATION: platform=iOS Simulator,name=iPhone 17 Pro Max,OS=latest steps: - uses: actions/checkout@v5 + - uses: actions/setup-node@v4 + with: + node-version: '22' - uses: actions/setup-java@v5 with: distribution: temurin java-version: '21' - uses: gradle/actions/setup-gradle@v4 - - run: ./gradlew compileKotlinIosSimulatorArm64 --no-daemon + - name: Build shared iOS XCFramework + run: ./gradlew compileKotlinIosSimulatorArm64 :core-feature:assembleOpenBitFunMobileCoreDebugXCFramework --no-daemon working-directory: src/apps/mobile/shared - run: ./Testing/run-pure-swift-tests.sh working-directory: src/apps/mobile/ios + - name: Build iOS app and UI tests + working-directory: src/apps/mobile/ios + run: | + xcodebuild -project OpenBitFun.xcodeproj -scheme OpenBitFun -configuration Debug \ + -destination "$IOS_SIMULATOR_DESTINATION" \ + -derivedDataPath "$RUNNER_TEMP/OpenBitFunDerivedData" \ + build-for-testing + - name: Run StreamingPresentationUITests + working-directory: src/apps/mobile/ios + run: | + xcodebuild -project OpenBitFun.xcodeproj -scheme OpenBitFun -configuration Debug \ + -destination "$IOS_SIMULATOR_DESTINATION" \ + -derivedDataPath "$RUNNER_TEMP/OpenBitFunDerivedData" \ + -resultBundlePath "$RUNNER_TEMP/StreamingPresentationUITests.xcresult" \ + -parallel-testing-enabled NO -testLanguage zh-Hans -testRegion CN \ + -only-testing:OpenBitFunUITests/StreamingPresentationUITests \ + test-without-building + - name: Upload iOS UI test results on failure + if: failure() + uses: actions/upload-artifact@v6 + with: + name: ios-streaming-ui-test-results + path: ${{ runner.temp }}/StreamingPresentationUITests.xcresult + if-no-files-found: ignore From fb9604d08b1fa999ab3b3729b53f271c3754c5f1 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Thu, 19 Nov 2026 15:52:26 +0800 Subject: [PATCH 2/8] test(ios): assert delayed session navigation in the current shell --- .../RemoteCodeSessionSendUITests.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift index 21ccd62..7b68339 100644 --- a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift +++ b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift @@ -1010,15 +1010,15 @@ final class StreamingPresentationUITests: XCTestCase { app.launch() let open = app.buttons["fixture.openDelayed"] XCTAssertTrue(open.waitForExistence(timeout: 15)) - let status = app.descendants(matching: .any)["conversation.connectionStatus"].firstMatch - XCTAssertTrue(status.exists) - XCTAssertEqual(status.frame.height, 48, accuracy: 1) + let initial = app.descendants(matching: .any)["conversation.session.fixture"].firstMatch + let loading = app.descendants(matching: .any)["conversation.loading"].firstMatch + XCTAssertTrue(initial.exists) + XCTAssertFalse(loading.exists) open.tap() let detail = app.descendants(matching: .any)["conversation.session.delayed"].firstMatch XCTAssertTrue(detail.waitForExistence(timeout: 2)) - let loading = app.descendants(matching: .any)["conversation.loading"].firstMatch + XCTAssertFalse(initial.exists) XCTAssertTrue(loading.waitForExistence(timeout: 2)) - XCTAssertFalse(status.exists, "The connection strip must not compete with the loading skeleton") app.buttons["fixture.bindTarget"].tap() XCTAssertTrue(detail.exists, "Binding the selected device must preserve pending navigation") XCTAssertTrue(loading.waitForExistence(timeout: 2)) From b0f55c1e37dc2410b9c33d68d763d64f11e98d1a Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Thu, 19 Nov 2026 15:56:08 +0800 Subject: [PATCH 3/8] test(ios): wait for the streamed answer to enter the viewport --- .../ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift index 7b68339..90d1471 100644 --- a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift +++ b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift @@ -1150,7 +1150,8 @@ final class StreamingPresentationUITests: XCTestCase { let folded = NSPredicate { _, _ in !thought.exists } expectation(for: folded, evaluatedWith: nil) waitForExpectations(timeout: 5) - XCTAssertTrue(answer.isHittable) + XCTAssertTrue(answer.wait(for: \.isHittable, toEqual: true, timeout: 5), + "The answer should scroll into view after the thinking block folds") XCTAssertTrue(app.staticTexts["Stream finished"].waitForExistence(timeout: 10)) XCTAssertTrue(answer.isHittable) let capture = XCTAttachment(screenshot: app.screenshot()) From 6bcd77aeb51965588c7a38b4a3a5ff66898a1578 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Thu, 19 Nov 2026 16:02:00 +0800 Subject: [PATCH 4/8] ci(ios): create the simulator with its matching Xcode runtime --- .github/workflows/check.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1b6d465..f4808ca 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -58,9 +58,17 @@ jobs: ios: runs-on: macos-26 env: - IOS_SIMULATOR_DESTINATION: platform=iOS Simulator,name=iPhone 17 Pro Max,OS=latest + DEVELOPER_DIR: /Applications/Xcode_26.5.app/Contents/Developer steps: - uses: actions/checkout@v5 + - name: Create iPhone simulator + run: | + xcodebuild -version + xcrun simctl list runtimes + simulator_id=$(xcrun simctl create 'OpenBitFun CI' \ + com.apple.CoreSimulator.SimDeviceType.iPhone-17-Pro-Max \ + com.apple.CoreSimulator.SimRuntime.iOS-26-5) + echo "IOS_SIMULATOR_DESTINATION=platform=iOS Simulator,id=$simulator_id" >> "$GITHUB_ENV" - uses: actions/setup-node@v4 with: node-version: '22' From 390ac7cd3f28ef84a78781053ee20a32699b5f84 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Thu, 19 Nov 2026 16:08:13 +0800 Subject: [PATCH 5/8] test(ios): drive thinking and answer phases explicitly --- .../Features/Chat/ChatTimelineView.swift | 1 + .../DesignSystem/MobileDesignGallery.swift | 39 ++++++++++++------- .../RemoteCodeSessionSendUITests.swift | 8 ++-- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/apps/mobile/ios/OpenBitFun/Features/Chat/ChatTimelineView.swift b/src/apps/mobile/ios/OpenBitFun/Features/Chat/ChatTimelineView.swift index 8fffd0a..20f0e8c 100644 --- a/src/apps/mobile/ios/OpenBitFun/Features/Chat/ChatTimelineView.swift +++ b/src/apps/mobile/ios/OpenBitFun/Features/Chat/ChatTimelineView.swift @@ -618,6 +618,7 @@ private struct ThinkingBlock: View { .foregroundStyle(OpenBitFunTheme.muted) .lineSpacing(MobileDesignTypography.bodyLarge.lineSpacing) .textSelection(.enabled) + .accessibilityIdentifier("thinking.content.\(partID)") } } // Match Harmony: preserve manual toggles during one thinking phase, diff --git a/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift b/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift index 8ba87a3..dd5e791 100644 --- a/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift +++ b/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift @@ -92,6 +92,7 @@ struct StreamingRegressionView: View { @State private var olderCount = 0 @State private var historyCount = 40 @State private var historyRequests = 0 + private let showsThinkingControls = ProcessInfo.processInfo.arguments.contains("--thinking-regression") var body: some View { VStack(spacing: 0) { @@ -117,6 +118,19 @@ struct StreamingRegressionView: View { model.timelineRows = history model.remoteHasMoreMessages = true }.accessibilityIdentifier("fixture.shortHistory") + if showsThinkingControls { + HStack { + Button("Show answer") { + showThinkingRegression(answerVisible: true, live: true) + }.accessibilityIdentifier("fixture.showThinkingAnswer") + Button("Finish stream") { + showThinkingRegression(answerVisible: true, live: false) + model.isSending = false + finished = true + }.accessibilityIdentifier("fixture.finishThinkingAnswer") + } + .disabled(!model.isSending) + } if ProcessInfo.processInfo.arguments.contains("--open-loading-regression") { HStack { Button("Open delayed session") { @@ -219,19 +233,8 @@ struct StreamingRegressionView: View { finished = true return } - if ProcessInfo.processInfo.arguments.contains("--thinking-regression") { - var thought = "" - for index in 1...12 { - thought += "Thinking segment \(index): checking chronology and viewport stability.\nCheck input.\nCheck output.\nCheck viewport.\nCheck ordering.\n\n" - model.timelineRows = history + [thinkingRow(thought: thought, answer: "", live: true)] - do { try await Task.sleep(nanoseconds: 350_000_000) } catch { return } - } - do { try await Task.sleep(nanoseconds: 3_000_000_000) } catch { return } - model.timelineRows = history + [thinkingRow(thought: thought, answer: "ANSWER-AFTER-THINKING", live: true)] - do { try await Task.sleep(nanoseconds: 2_000_000_000) } catch { return } - model.timelineRows = history + [thinkingRow(thought: thought, answer: "ANSWER-AFTER-THINKING", live: false)] - model.isSending = false - finished = true + if showsThinkingControls { + showThinkingRegression(answerVisible: false, live: true) return } var body = "" @@ -284,12 +287,18 @@ struct StreamingRegressionView: View { ], streaming: false, typing: false, showRetry: false, error: nil) } - private func thinkingRow(thought: String, answer: String, live: Bool) -> MobileConversationRow { + // Keep each stage visible until the UI test advances the fixture. + private func showThinkingRegression(answerVisible: Bool, live: Bool) { + let thought = (1...12).map { index in + "Thinking segment \(index): checking chronology and viewport stability.\nCheck input.\nCheck output.\nCheck viewport.\nCheck ordering.\n\n" + }.joined() + let answer = answerVisible ? "ANSWER-AFTER-THINKING" : "" var blocks: [MobileTimelineBlock] = [.thinking(id: "thought", text: thought, streaming: answer.isEmpty && live)] if !answer.isEmpty { blocks.append(.text(id: "answer", text: answer, streaming: live)) } - return MobileConversationRow(id: live ? "thinking-live" : "thinking-final", kind: "ASSISTANT", text: answer, + let row = MobileConversationRow(id: live ? "thinking-live" : "thinking-final", kind: "ASSISTANT", text: answer, thinking: thought, images: [], tools: [], blocks: blocks, streaming: live, typing: false, showRetry: false, error: nil, live: live) + model.timelineRows = history + [row] } private var history: [MobileConversationRow] { diff --git a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift index 90d1471..7d0ffd0 100644 --- a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift +++ b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift @@ -1142,18 +1142,20 @@ final class StreamingPresentationUITests: XCTestCase { let start = app.buttons["fixture.send"] XCTAssertTrue(start.waitForExistence(timeout: 15)) start.tap() - let thought = app.staticTexts.containing(NSPredicate(format: "label CONTAINS %@", "Thinking segment 12")).firstMatch + let thought = app.staticTexts["thinking.content.thought"] XCTAssertTrue(thought.waitForExistence(timeout: 10)) XCTAssertGreaterThan(thought.frame.height, app.scrollViews.firstMatch.frame.height) - let answer = app.staticTexts.containing(NSPredicate(format: "label CONTAINS %@", "ANSWER-AFTER-THINKING")).firstMatch + app.buttons["fixture.showThinkingAnswer"].tap() + let answer = app.staticTexts["ANSWER-AFTER-THINKING"] XCTAssertTrue(answer.waitForExistence(timeout: 10)) let folded = NSPredicate { _, _ in !thought.exists } expectation(for: folded, evaluatedWith: nil) waitForExpectations(timeout: 5) XCTAssertTrue(answer.wait(for: \.isHittable, toEqual: true, timeout: 5), "The answer should scroll into view after the thinking block folds") + app.buttons["fixture.finishThinkingAnswer"].tap() XCTAssertTrue(app.staticTexts["Stream finished"].waitForExistence(timeout: 10)) - XCTAssertTrue(answer.isHittable) + XCTAssertTrue(answer.wait(for: \.isHittable, toEqual: true, timeout: 5)) let capture = XCTAttachment(screenshot: app.screenshot()) capture.lifetime = .keepAlways add(capture) From ea9f9382516b87b3bbab5b6f190a1a74cc7a4203 Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Thu, 19 Nov 2026 16:29:59 +0800 Subject: [PATCH 6/8] test(ios): isolate delayed session navigation from chat history --- .../DesignSystem/MobileDesignGallery.swift | 11 +++++++++-- .../RemoteCodeSessionSendUITests.swift | 17 ++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift b/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift index dd5e791..8826da3 100644 --- a/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift +++ b/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift @@ -93,6 +93,7 @@ struct StreamingRegressionView: View { @State private var historyCount = 40 @State private var historyRequests = 0 private let showsThinkingControls = ProcessInfo.processInfo.arguments.contains("--thinking-regression") + private let showsDelayedOpenControls = ProcessInfo.processInfo.arguments.contains("--open-loading-regression") var body: some View { VStack(spacing: 0) { @@ -131,7 +132,7 @@ struct StreamingRegressionView: View { } .disabled(!model.isSending) } - if ProcessInfo.processInfo.arguments.contains("--open-loading-regression") { + if showsDelayedOpenControls { HStack { Button("Open delayed session") { model.remoteExpectedDeviceKey = "account:fixture-device" @@ -149,6 +150,8 @@ struct StreamingRegressionView: View { model.finishRemoteConversationOpenIfReady(timelineSessionID: "delayed") }.accessibilityIdentifier("fixture.finishLoading") } + .buttonStyle(.bordered) + .font(.footnote) } if ProcessInfo.processInfo.arguments.contains("--history-pagination-regression") { Text("History requests: \(historyRequests)").accessibilityIdentifier("fixture.historyRequests") @@ -191,7 +194,11 @@ struct StreamingRegressionView: View { model.connectionPhase = .reconnecting } model.selectedSessionID = "fixture" - model.timelineRows = ProcessInfo.processInfo.arguments.contains("--card-regression") ? [cardRow] : history + if showsDelayedOpenControls { + model.timelineRows = [row(id: "previous", text: "PREVIOUS-SESSION", live: false)] + } else { + model.timelineRows = ProcessInfo.processInfo.arguments.contains("--card-regression") ? [cardRow] : history + } if ProcessInfo.processInfo.arguments.contains("--message-metadata-regression") { let failed = MobileTimelineTool(id: "fetch", name: "WebFetch", phase: "FAILED", kind: "WEB", operation: "FETCH_URL", target: "example.com", filePath: "", fileLabel: "", diff --git a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift index 7d0ffd0..aeef3e6 100644 --- a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift +++ b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift @@ -1010,20 +1010,19 @@ final class StreamingPresentationUITests: XCTestCase { app.launch() let open = app.buttons["fixture.openDelayed"] XCTAssertTrue(open.waitForExistence(timeout: 15)) - let initial = app.descendants(matching: .any)["conversation.session.fixture"].firstMatch - let loading = app.descendants(matching: .any)["conversation.loading"].firstMatch - XCTAssertTrue(initial.exists) - XCTAssertFalse(loading.exists) + let initial = app.otherElements["conversation.session.fixture"] + XCTAssertTrue(initial.staticTexts["PREVIOUS-SESSION"].exists) open.tap() - let detail = app.descendants(matching: .any)["conversation.session.delayed"].firstMatch - XCTAssertTrue(detail.waitForExistence(timeout: 2)) + let detail = app.otherElements["conversation.session.delayed"] + XCTAssertTrue(detail.waitForExistence(timeout: 10), "Navigation must occur before the device binds") XCTAssertFalse(initial.exists) - XCTAssertTrue(loading.waitForExistence(timeout: 2)) + let loading = detail.otherElements["conversation.loading"] + XCTAssertTrue(loading.waitForExistence(timeout: 5)) app.buttons["fixture.bindTarget"].tap() XCTAssertTrue(detail.exists, "Binding the selected device must preserve pending navigation") - XCTAssertTrue(loading.waitForExistence(timeout: 2)) + XCTAssertTrue(loading.exists) app.buttons["fixture.finishLoading"].tap() - XCTAssertTrue(app.staticTexts["LOADED-SESSION"].waitForExistence(timeout: 3)) + XCTAssertTrue(detail.staticTexts["LOADED-SESSION"].waitForExistence(timeout: 5)) XCTAssertFalse(loading.exists) } From 1e2642c19549fb8a0762574b4d14166a2c47968f Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Thu, 19 Nov 2026 16:37:39 +0800 Subject: [PATCH 7/8] test(ios): retain streaming coverage and synchronize UI interactions --- .../DesignSystem/MobileDesignGallery.swift | 46 ++++++++++++------- .../RemoteCodeSessionSendUITests.swift | 21 +++++---- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift b/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift index 8826da3..e7c38c7 100644 --- a/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift +++ b/src/apps/mobile/ios/OpenBitFun/Features/DesignSystem/MobileDesignGallery.swift @@ -86,14 +86,22 @@ struct MobileDesignGallery: View { #if DEBUG /// Deterministic native rendering fixture. It never opens a remote transport. struct StreamingRegressionView: View { + private enum ThinkingPhase { + case waiting, readyForAnswer, answering + } + @StateObject private var model = MobileAppModel(sessions: [], selectedSessionID: "fixture", messages: [], connectCore: false) @State private var generation = 0 @State private var finished = false @State private var olderCount = 0 @State private var historyCount = 40 @State private var historyRequests = 0 + @State private var thinkingPhase = ThinkingPhase.waiting private let showsThinkingControls = ProcessInfo.processInfo.arguments.contains("--thinking-regression") private let showsDelayedOpenControls = ProcessInfo.processInfo.arguments.contains("--open-loading-regression") + private let thinkingSegments = (1...12).map { index in + "Thinking segment \(index): checking chronology and viewport stability.\nCheck input.\nCheck output.\nCheck viewport.\nCheck ordering.\n\n" + } var body: some View { VStack(spacing: 0) { @@ -103,6 +111,7 @@ struct StreamingRegressionView: View { model.composerSendGeneration &+= 1 model.isSending = true finished = false + thinkingPhase = .waiting generation += 1 }.accessibilityIdentifier("fixture.send") Button("Reset session") { @@ -110,6 +119,7 @@ struct StreamingRegressionView: View { model.selectedSessionID = UUID().uuidString model.timelineRows = history model.isSending = false + thinkingPhase = .waiting }.accessibilityIdentifier("fixture.reset") } Button("Short history") { @@ -118,19 +128,25 @@ struct StreamingRegressionView: View { olderCount = 0 model.timelineRows = history model.remoteHasMoreMessages = true + thinkingPhase = .waiting }.accessibilityIdentifier("fixture.shortHistory") if showsThinkingControls { HStack { Button("Show answer") { - showThinkingRegression(answerVisible: true, live: true) - }.accessibilityIdentifier("fixture.showThinkingAnswer") + showThinkingRegression(thought: thinkingSegments.joined(), answerVisible: true, live: true) + thinkingPhase = .answering + } + .disabled(thinkingPhase != .readyForAnswer) + .accessibilityIdentifier("fixture.showThinkingAnswer") Button("Finish stream") { - showThinkingRegression(answerVisible: true, live: false) + showThinkingRegression(thought: thinkingSegments.joined(), answerVisible: true, live: false) model.isSending = false finished = true - }.accessibilityIdentifier("fixture.finishThinkingAnswer") + thinkingPhase = .waiting + } + .disabled(thinkingPhase != .answering) + .accessibilityIdentifier("fixture.finishThinkingAnswer") } - .disabled(!model.isSending) } if showsDelayedOpenControls { HStack { @@ -194,11 +210,7 @@ struct StreamingRegressionView: View { model.connectionPhase = .reconnecting } model.selectedSessionID = "fixture" - if showsDelayedOpenControls { - model.timelineRows = [row(id: "previous", text: "PREVIOUS-SESSION", live: false)] - } else { - model.timelineRows = ProcessInfo.processInfo.arguments.contains("--card-regression") ? [cardRow] : history - } + model.timelineRows = ProcessInfo.processInfo.arguments.contains("--card-regression") ? [cardRow] : history if ProcessInfo.processInfo.arguments.contains("--message-metadata-regression") { let failed = MobileTimelineTool(id: "fetch", name: "WebFetch", phase: "FAILED", kind: "WEB", operation: "FETCH_URL", target: "example.com", filePath: "", fileLabel: "", @@ -241,7 +253,13 @@ struct StreamingRegressionView: View { return } if showsThinkingControls { - showThinkingRegression(answerVisible: false, live: true) + var thought = "" + for segment in thinkingSegments { + do { try await Task.sleep(nanoseconds: 350_000_000) } catch { return } + thought += segment + showThinkingRegression(thought: thought, answerVisible: false, live: true) + } + thinkingPhase = .readyForAnswer return } var body = "" @@ -294,11 +312,7 @@ struct StreamingRegressionView: View { ], streaming: false, typing: false, showRetry: false, error: nil) } - // Keep each stage visible until the UI test advances the fixture. - private func showThinkingRegression(answerVisible: Bool, live: Bool) { - let thought = (1...12).map { index in - "Thinking segment \(index): checking chronology and viewport stability.\nCheck input.\nCheck output.\nCheck viewport.\nCheck ordering.\n\n" - }.joined() + private func showThinkingRegression(thought: String, answerVisible: Bool, live: Bool) { let answer = answerVisible ? "ANSWER-AFTER-THINKING" : "" var blocks: [MobileTimelineBlock] = [.thinking(id: "thought", text: thought, streaming: answer.isEmpty && live)] if !answer.isEmpty { blocks.append(.text(id: "answer", text: answer, streaming: live)) } diff --git a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift index aeef3e6..3e61a01 100644 --- a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift +++ b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift @@ -956,11 +956,13 @@ final class StreamingPresentationUITests: XCTestCase { XCTAssertTrue(timestamps.firstMatch.waitForExistence(timeout: 15)) XCTAssertEqual(timestamps.count, 2) let summary = app.buttons["tool.summary.read"] - XCTAssertTrue(summary.exists) - XCTAssertFalse(app.buttons["tool.toggle.fetch"].exists) - summary.tap() - app.buttons["tool.toggle.fetch"].tap() - XCTAssertTrue(app.staticTexts["HTTP 404"].waitForExistence(timeout: 3)) + let failure = app.buttons["tool.toggle.fetch"] + XCTAssertTrue(summary.wait(for: \.isHittable, toEqual: true, timeout: 5)) + XCTAssertFalse(failure.exists) + summary.coordinate(withNormalizedOffset: CGVector(dx: 0.98, dy: 0.5)).tap() + XCTAssertTrue(failure.wait(for: \.isHittable, toEqual: true, timeout: 10)) + failure.tap() + XCTAssertTrue(app.staticTexts["HTTP 404"].waitForExistence(timeout: 5)) let capture = XCTAttachment(screenshot: app.screenshot()) capture.name = "Message times and expandable tool failure" capture.lifetime = .keepAlways @@ -1009,9 +1011,9 @@ final class StreamingPresentationUITests: XCTestCase { app.launchArguments = ["--streaming-regression", "--fixture-shell", "--open-loading-regression", "--status-regression"] app.launch() let open = app.buttons["fixture.openDelayed"] - XCTAssertTrue(open.waitForExistence(timeout: 15)) + XCTAssertTrue(open.wait(for: \.isHittable, toEqual: true, timeout: 15)) let initial = app.otherElements["conversation.session.fixture"] - XCTAssertTrue(initial.staticTexts["PREVIOUS-SESSION"].exists) + XCTAssertTrue(initial.waitForExistence(timeout: 10)) open.tap() let detail = app.otherElements["conversation.session.delayed"] XCTAssertTrue(detail.waitForExistence(timeout: 10), "Navigation must occur before the device binds") @@ -1141,10 +1143,13 @@ final class StreamingPresentationUITests: XCTestCase { let start = app.buttons["fixture.send"] XCTAssertTrue(start.waitForExistence(timeout: 15)) start.tap() + let showAnswer = app.buttons["fixture.showThinkingAnswer"] + XCTAssertTrue(showAnswer.wait(for: \.isEnabled, toEqual: true, timeout: 20)) let thought = app.staticTexts["thinking.content.thought"] XCTAssertTrue(thought.waitForExistence(timeout: 10)) + XCTAssertTrue(thought.label.contains("Thinking segment 12")) XCTAssertGreaterThan(thought.frame.height, app.scrollViews.firstMatch.frame.height) - app.buttons["fixture.showThinkingAnswer"].tap() + showAnswer.tap() let answer = app.staticTexts["ANSWER-AFTER-THINKING"] XCTAssertTrue(answer.waitForExistence(timeout: 10)) let folded = NSPredicate { _, _ in !thought.exists } From a238d076f4ffdc8f02e68ab3ad7da54030f4501b Mon Sep 17 00:00:00 2001 From: wgqqqqq Date: Thu, 19 Nov 2026 17:03:32 +0800 Subject: [PATCH 8/8] test(ios): tap visible controls for card disclosure --- .../RemoteCodeSessionSendUITests.swift | 67 ++++++++++++------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift index 3e61a01..f059e40 100644 --- a/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift +++ b/src/apps/mobile/ios/OpenBitFunUITests/RemoteCodeSessionSendUITests.swift @@ -957,12 +957,12 @@ final class StreamingPresentationUITests: XCTestCase { XCTAssertEqual(timestamps.count, 2) let summary = app.buttons["tool.summary.read"] let failure = app.buttons["tool.toggle.fetch"] - XCTAssertTrue(summary.wait(for: \.isHittable, toEqual: true, timeout: 5)) + XCTAssertTrue(summary.exists) XCTAssertFalse(failure.exists) - summary.coordinate(withNormalizedOffset: CGVector(dx: 0.98, dy: 0.5)).tap() + tapDisclosure(summary, expanded: false) XCTAssertTrue(failure.wait(for: \.isHittable, toEqual: true, timeout: 10)) - failure.tap() - XCTAssertTrue(app.staticTexts["HTTP 404"].waitForExistence(timeout: 5)) + tapToolRow(failure) + XCTAssertTrue(app.staticTexts["HTTP 404"].waitForExistence(timeout: 10)) let capture = XCTAttachment(screenshot: app.screenshot()) capture.name = "Message times and expandable tool failure" capture.lifetime = .keepAlways @@ -1036,8 +1036,8 @@ final class StreamingPresentationUITests: XCTestCase { XCTAssertTrue(task.waitForExistence(timeout: 15)) XCTAssertFalse(app.staticTexts["LIVE-CHILD-THOUGHT"].exists) XCTAssertFalse(app.buttons["subagent.toggle.empty"].isEnabled, "Empty tasks must not offer disclosure") - task.tap() - XCTAssertTrue(app.staticTexts["LIVE-CHILD-THOUGHT"].waitForExistence(timeout: 3)) + tapDisclosure(task, expanded: false) + XCTAssertTrue(app.staticTexts["LIVE-CHILD-THOUGHT"].waitForExistence(timeout: 10)) XCTAssertFalse(app.staticTexts["OLD-CHILD-THOUGHT"].exists) XCTAssertFalse(app.staticTexts["PARENT-SUMMARY-MUST-NOT-REPEAT"].exists) let preview = app.staticTexts["subagent.output.child-output"] @@ -1049,15 +1049,18 @@ final class StreamingPresentationUITests: XCTestCase { XCTAssertTrue(app.buttons["tool.toggle.child-two"].exists) XCTAssertFalse(app.buttons["tool.summary.child-one"].exists) XCTAssertFalse(app.staticTexts["NESTED-OUTPUT"].exists) - app.buttons["subagent.toggle.nested"].tap() - XCTAssertTrue(app.staticTexts["NESTED-OUTPUT"].exists) - app.buttons["subagent.toggle.nested"].tap() + let nested = app.buttons["subagent.toggle.nested"] + let nestedOutput = app.staticTexts["NESTED-OUTPUT"] + tapDisclosure(nested, expanded: false) + XCTAssertTrue(nestedOutput.waitForExistence(timeout: 10)) + tapDisclosure(nested, expanded: true) + XCTAssertTrue(nestedOutput.waitForNonExistence(timeout: 10)) app.buttons["fixture.send"].tap() XCTAssertTrue(task.label.contains("失败"), "Host failures must remain visible in the subtask header") XCTAssertTrue(preview.exists, "Completing keeps the manually opened subtask open") XCTAssertFalse(app.staticTexts["LIVE-CHILD-THOUGHT"].exists) - app.buttons["thinking.toggle.child-old"].tap() - XCTAssertTrue(app.staticTexts["OLD-CHILD-THOUGHT"].exists) + tapDisclosure(app.buttons["thinking.toggle.child-old"], expanded: false) + XCTAssertTrue(app.staticTexts["OLD-CHILD-THOUGHT"].waitForExistence(timeout: 10)) } func testCardsMatchHarmonyExpansionAndOrdering() { @@ -1066,13 +1069,14 @@ final class StreamingPresentationUITests: XCTestCase { app.launch() let task = app.buttons["subagent.toggle.task"] XCTAssertTrue(task.waitForExistence(timeout: 15)) - XCTAssertFalse(app.staticTexts["TASK-BODY"].exists, "Running tasks start collapsed") - task.tap() - XCTAssertTrue(app.staticTexts["TASK-BODY"].waitForExistence(timeout: 3)) + let taskBody = app.staticTexts["TASK-BODY"] + XCTAssertFalse(taskBody.exists, "Running tasks start collapsed") + tapDisclosure(task, expanded: false) + XCTAssertTrue(taskBody.waitForExistence(timeout: 10)) app.buttons["fixture.send"].tap() - XCTAssertTrue(app.staticTexts["TASK-BODY"].exists, "Status updates preserve the user's expansion") - task.tap() - XCTAssertFalse(app.staticTexts["TASK-BODY"].exists) + XCTAssertTrue(taskBody.exists, "Status updates preserve the user's expansion") + tapDisclosure(task, expanded: true) + XCTAssertTrue(taskBody.waitForNonExistence(timeout: 10)) let summary = app.buttons["tool.summary.one"] XCTAssertTrue(summary.exists) XCTAssertFalse(app.buttons["tool.toggle.one"].exists) @@ -1080,29 +1084,29 @@ final class StreamingPresentationUITests: XCTestCase { XCTAssertFalse(app.buttons["thinking.toggle.before"].exists) XCTAssertTrue(app.buttons["tool.toggle.running"].exists) XCTAssertTrue(app.buttons["tool.toggle.failed"].exists) - summary.tap() + tapDisclosure(summary, expanded: false) let one = app.buttons["tool.toggle.one"] let two = app.buttons["tool.toggle.two"] - XCTAssertTrue(one.waitForExistence(timeout: 3)) + XCTAssertTrue(one.waitForExistence(timeout: 10)) let before = app.buttons["thinking.toggle.before"] let between = app.buttons["thinking.toggle.between"] XCTAssertTrue(before.exists && between.exists) XCTAssertLessThan(before.frame.minY, one.frame.minY) XCTAssertLessThan(one.frame.minY, between.frame.minY) XCTAssertLessThan(between.frame.minY, two.frame.minY) - one.tap() - XCTAssertTrue(app.staticTexts["OUTPUT-one"].waitForExistence(timeout: 3)) - two.tap() - XCTAssertTrue(app.staticTexts["OUTPUT-two"].waitForExistence(timeout: 3)) + tapToolRow(one) + XCTAssertTrue(app.staticTexts["OUTPUT-one"].waitForExistence(timeout: 10)) + tapToolRow(two) + XCTAssertTrue(app.staticTexts["OUTPUT-two"].waitForExistence(timeout: 10)) XCTAssertFalse(app.staticTexts["OUTPUT-one"].exists, "Only one tool detail is expanded") XCTAssertLessThan(one.frame.minY, two.frame.minY) app.buttons["fixture.send"].tap() - XCTAssertTrue(app.buttons["tool.toggle.three"].waitForExistence(timeout: 3), + XCTAssertTrue(app.buttons["tool.toggle.three"].waitForExistence(timeout: 10), "Appending a completed tool must preserve the open summary") XCTAssertTrue(app.staticTexts["OUTPUT-two"].exists, "Appending tools must preserve the selected detail") - summary.tap() - XCTAssertFalse(one.exists) + tapDisclosure(summary, expanded: true) + XCTAssertTrue(one.waitForNonExistence(timeout: 10)) XCTAssertFalse(app.staticTexts["OUTPUT-two"].exists) XCTAssertTrue(app.staticTexts["ANSWER-AFTER-ACTIVITY"].isHittable) let capture = XCTAttachment(screenshot: app.screenshot()) @@ -1110,6 +1114,17 @@ final class StreamingPresentationUITests: XCTestCase { add(capture) } + private func tapDisclosure(_ button: XCUIElement, expanded: Bool) { + let chevron = button.images[expanded ? "chevron.up" : "chevron.down"] + XCTAssertTrue(chevron.waitForExistence(timeout: 10)) + chevron.tap() + } + + private func tapToolRow(_ button: XCUIElement) { + XCTAssertTrue(button.wait(for: \.isHittable, toEqual: true, timeout: 10)) + button.coordinate(withNormalizedOffset: CGVector(dx: 0.05, dy: 0.5)).tap() + } + func testSentUserBubbleStaysVisibleBeforeReply() { let app = XCUIApplication() app.launchArguments = ["--streaming-regression", "--user-bubble-regression"]