Let an AI model use a real iPhone with a $7 ESP32: AirPlay eyes, USB HID hands, any OpenAI-compatible vision model. No Mac, no developer account, no jailbreak.
Drive Island waiting and planning text from model response progress
Henryc12039631ee4
diff --git a/docs/island-phase-text-2026-10-16.md b/docs/island-phase-text-2026-10-16.mdnew file mode 100644index 0000000..6650464--- /dev/null+++ b/docs/island-phase-text-2026-10-16.md@@ -0,0 +1,9 @@+# Explicit Dynamic Island phase text++Source HEAD: 7c7b656e02382f0f42d5d2ab8e52a548b2f4b73a. Isolated branch: codex/island-phase-text. Existing untracked ios/fastlane/ was not changed. Separate build output; no live data copied.++- Model queries emit Waiting before the request and Planning (planner) or Thinking (actor) only after the first nonempty reasoning/content event. Headers, role-only chunks, and heartbeat comments do not count as content. Nonstreaming JSON can only report receiving when its body completes.+- Timeout retry stays Retrying until the new response starts. Empty-response retries return to Waiting. Progress callbacks are removed when the query ends.+- Full labels say Waiting for the model to respond, Thinking through my plan, and Thinking about my next move. Minimal presentation gets an explicit localized Wait / Plan / Think / Retry label, plus Look / Tap / Type / Swipe / Draw / Home / Back and terminal/help labels. It no longer infers every pending state from the face mood.+- Running expanded/lock-screen activities show the human-readable status rather than raw per-step thought/coordinate text. Replay data remains available inside the app.+- 80 simulator tests passed. Coverage includes SSE heartbeat/reasoning/content progress, planner versus actor phases, callback cleanup, and distinct minimal labels. Signed device build passed. Live Activity rendering with concurrent screen mirroring remains subject to iOS sizing/update scheduling; this change does not claim hardware visual verification.diff --git a/ios/AgentActivity/AgentActivityWidget.swift b/ios/AgentActivity/AgentActivityWidget.swiftindex 6db274c..286a70a 100644--- a/ios/AgentActivity/AgentActivityWidget.swift+++ b/ios/AgentActivity/AgentActivityWidget.swift@@ -41,7 +41,7 @@ struct AgentLiveActivity: Widget {Text(since, style: .timer).monospacedDigit().font(.footnote).accessibilityLabel("Waiting time")}- if s.line != s.labelFull {+ if s.line != s.labelFull && (s.phase != .running || s.finished) {Text(verbatim: s.line).font(.footnote).foregroundStyle(.secondary).lineLimit(2)}if s.phase == .running {@@ -68,8 +68,8 @@ struct AgentLiveActivity: Widget {} else {VStack(spacing: 0) {Eyes(state: s).frame(width: 16, height: 16)- Text(s.mood == .thinking ? "Think" : s.mood == .acting ? "Act" : s.finished ? "End" : "Wait")- .font(.caption2).foregroundStyle(.white).lineLimit(1)+ Text(verbatim: s.minimalLabel ?? s.label)+ .font(.caption2).foregroundStyle(.white).lineLimit(1).minimumScaleFactor(0.8)}.frame(width: 36).accessibilityLabel(Text(verbatim: s.labelFull))@@ -175,7 +175,9 @@ private struct LockScreenView: View {if !s.finished && !s.labelFull.isEmpty {Says(state: s, full: true).font(.subheadline.weight(.semibold))}- Text(verbatim: s.line).font(.subheadline).foregroundStyle(.secondary).lineLimit(2)+ if s.phase != .running || s.finished {+ Text(verbatim: s.line).font(.subheadline).foregroundStyle(.secondary).lineLimit(2)+ }if s.finished {Label(s.mood == .success ? "Done · tap to review" : "Ended · tap to review",systemImage: s.mood == .success ? "checkmark.circle.fill" : "play.circle")diff --git a/ios/AgentActivity/Localizable.xcstrings b/ios/AgentActivity/Localizable.xcstringsindex 167ed6c..12c9f59 100644--- a/ios/AgentActivity/Localizable.xcstrings+++ b/ios/AgentActivity/Localizable.xcstrings@@ -616,6 +616,166 @@}}}+ },+ "Look" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "查看"+ }+ }+ }+ },+ "Thinking about my next move…" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "正在思考下一步…"+ }+ }+ }+ },+ "Waiting for the model to respond…" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "正在等待模型回复…"+ }+ }+ }+ },+ "Planning…" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "正在规划…"+ }+ }+ }+ },+ "Thinking through my plan…" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "正在构思我的计划…"+ }+ }+ }+ },+ "Plan" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "规划"+ }+ }+ }+ },+ "Retry" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "重试"+ }+ }+ }+ },+ "You" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "等你"+ }+ }+ }+ },+ "Tap" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "点击"+ }+ }+ }+ },+ "Type" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "输入"+ }+ }+ }+ },+ "Key" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "按键"+ }+ }+ }+ },+ "Swipe" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "滑动"+ }+ }+ }+ },+ "Draw" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "绘制"+ }+ }+ }+ },+ "Home" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "主页"+ }+ }+ }+ },+ "Back" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "返回"+ }+ }+ }+ },+ "Waiting for the screen…" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "正在等待屏幕变化…"+ }+ }+ }}},"version" : "1.0"diff --git a/ios/IPhoneAgent.xcodeproj/project.pbxproj b/ios/IPhoneAgent.xcodeproj/project.pbxprojindex a4c7f90..779aa7c 100644--- a/ios/IPhoneAgent.xcodeproj/project.pbxproj+++ b/ios/IPhoneAgent.xcodeproj/project.pbxproj@@ -88,6 +88,7 @@B86BD0431A675EC2681E03A7 /* AgentActivityWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86452ED01E883A6E57BB13E4 /* AgentActivityWidget.swift */; };B9B15030A9EEC21B4512533B /* HotspotJoin.swift in Sources */ = {isa = PBXBuildFile; fileRef = C12C6B350F7AFD555CE0B8EA /* HotspotJoin.swift */; };BB3C60862112DB87D3555158 /* LLMClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCDA925D0FFD42810895573C /* LLMClient.swift */; };+ BCDC103484DE3B2E0EEB3331 /* ModelResponseProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B66A62AA77E063E8DFDD52B /* ModelResponseProgress.swift */; };BD09EA4793C0B09297190CD9 /* BoardProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DFECC30B2ADEB1BB69072EC /* BoardProtocol.swift */; };C4F3ADB5189E27B999BDDF83 /* TouchProbe.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5099810C37BB0AD66EDC8C8 /* TouchProbe.swift */; };CED032EC090264C33AD7D1D1 /* Prompts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B2B975DEE7BC511DC51441F /* Prompts.swift */; };@@ -186,6 +187,7 @@56CC3C0A640902A2CD3F8387 /* ProviderFields.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProviderFields.swift; sourceTree = "<group>"; };5754C9233BF0BA12F8EB78D7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };5962900FEB08728899160DD1 /* DemoRecorder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoRecorder.swift; sourceTree = "<group>"; };+ 5B66A62AA77E063E8DFDD52B /* ModelResponseProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelResponseProgress.swift; sourceTree = "<group>"; };607F9EBBC39E74507B73F751 /* H264Decoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = H264Decoder.swift; sourceTree = "<group>"; };65736EFE5D5C4AF40EDC5F92 /* AutoCalibrator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoCalibrator.swift; sourceTree = "<group>"; };6DCAEE3FDF94357F8875E473 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };@@ -420,6 +422,7 @@DAEFE87504F77098EF0AEFFC /* ModelConnectionCheck.swift */,D8A02583BE955659071F3172 /* ModelProvider.swift */,96A8E3AF04195B586F10EDC4 /* ModelRequestFailure.swift */,+ 5B66A62AA77E063E8DFDD52B /* ModelResponseProgress.swift */,05DA6345A40715C8BD2AED6C /* Notifier.swift */,541D1A2837E5F270700EAF55 /* Redactor.swift */,B1B84B4F1C81E697ACB30630 /* RunShare.swift */,@@ -672,6 +675,7 @@2CF0D6C8101BF02E0EDF44E2 /* ModelPicker.swift in Sources */,A5A78F1B4D15D843B8932932 /* ModelProvider.swift in Sources */,FC0BD528A254726D869FDF5B /* ModelRequestFailure.swift in Sources */,+ BCDC103484DE3B2E0EEB3331 /* ModelResponseProgress.swift in Sources */,38112BBE7634E2E538DBA9D0 /* ModelSelectionView.swift in Sources */,7F412478410DC75BC26A0D5C /* ModelSettingsView.swift in Sources */,E663D7886455DD700AF2469A /* ModelTestTimingView.swift in Sources */,diff --git a/ios/IPhoneAgent/Agent/AgentLoop.swift b/ios/IPhoneAgent/Agent/AgentLoop.swiftindex 13ef0eb..d2805e8 100644--- a/ios/IPhoneAgent/Agent/AgentLoop.swift+++ b/ios/IPhoneAgent/Agent/AgentLoop.swift@@ -58,7 +58,7 @@ extension Pointer: Gestures {}var onStep: (() -> Void)?/// What the agent is busy with between steps, for the Dynamic Island (looking, thinking, about to act).var onDoing: ((Doing) -> Void)?- enum Doing { case looking, thinking, retrying, acting(JObject) }+ enum Doing { case looking, waiting, planning, thinking, retrying, acting(JObject) }/// Hints from a saved intent's checklist, appended to the actor's system prompt (empty = the original prompt).var hints: [String] = []/// "Needs your help": asked when the actor gives up or errors repeat; nil = end the run as before.@@ -145,7 +145,15 @@ extension Pointer: Gestures {}}guard let screen, screen.live else { throw BlindError() } // never let the model act blindlet frame = screen.frame, started = now()- onDoing?(retryTimeout ? .thinking : .retrying)+ onDoing?(retryTimeout ? .waiting : .retrying)+ let reporting = llm as? ModelProgressReporting+ reporting?.onProgress = { [weak self] progress in+ switch progress {+ case .waiting: self?.onDoing?(retryTimeout ? .waiting : .retrying)+ case .receiving: self?.onDoing?(role == "planner" ? .planning : .thinking)+ }+ }+ defer { reporting?.onProgress = nil }let reply: ChatResultdo {reply = try await llm.chat(system: system, text: prompt, image: frame,diff --git a/ios/IPhoneAgent/App/IslandStatus.swift b/ios/IPhoneAgent/App/IslandStatus.swiftindex dba3d80..de0153a 100644--- a/ios/IPhoneAgent/App/IslandStatus.swift+++ b/ios/IPhoneAgent/App/IslandStatus.swift@@ -8,47 +8,69 @@ struct IslandStatus: Equatable {var short: Stringvar full: Stringvar look: CGPoint?+ var minimal: String? = nilvar waits: Bool { look == nil }static let compactLimit = 16static var looking: Self {- Self(short: String(localized: "Looking…"), full: String(localized: "Looking at the screen…"), look: nil)+ Self(short: String(localized: "Looking…"), full: String(localized: "Looking at the screen…"), look: nil, minimal: String(localized: "Look"))}static var thinking: Self {- Self(short: String(localized: "Thinking…"), full: String(localized: "Thinking…"), look: nil)+ Self(short: String(localized: "Thinking…"), full: String(localized: "Thinking about my next move…"), look: nil, minimal: String(localized: "Think"))+ }++ static var waiting: Self {+ Self(short: String(localized: "Waiting…"), full: String(localized: "Waiting for the model to respond…"),+ look: nil, minimal: String(localized: "Wait"))+ }++ static var planning: Self {+ Self(short: String(localized: "Planning…"), full: String(localized: "Thinking through my plan…"),+ look: nil, minimal: String(localized: "Plan"))}static var retrying: Self {- Self(short: String(localized: "Retrying…"), full: String(localized: "The model timed out. Trying once more…"), look: nil)+ Self(short: String(localized: "Retrying…"), full: String(localized: "The model timed out. Trying once more…"), look: nil, minimal: String(localized: "Retry"))}static var help: Self {- Self(short: String(localized: "Need help"), full: String(localized: "Need your help"), look: .zero)+ Self(short: String(localized: "Need help"), full: String(localized: "Need your help"), look: .zero, minimal: String(localized: "Help"))}static var yourTurn: Self {- Self(short: String(localized: "Your turn"), full: String(localized: "Your turn"), look: CGPoint(x: 0, y: 0.6))+ Self(short: String(localized: "Your turn"), full: String(localized: "Your turn"), look: CGPoint(x: 0, y: 0.6), minimal: String(localized: "You"))}/// The end of a run, from its outcome's mood.static func ended(_ mood: Mood) -> Self {switch mood {- case .success: return Self(short: String(localized: "Done!"), full: String(localized: "Done!"), look: .zero)- case .failure: return Self(short: String(localized: "Didn't finish"), full: String(localized: "Didn't finish"), look: .zero)- default: return Self(short: String(localized: "Stopped"), full: String(localized: "Stopped"), look: .zero)+ case .success: return Self(short: String(localized: "Done!"), full: String(localized: "Done!"), look: .zero, minimal: String(localized: "Done"))+ case .failure: return Self(short: String(localized: "Didn't finish"), full: String(localized: "Didn't finish"), look: .zero, minimal: String(localized: "Error"))+ default: return Self(short: String(localized: "Stopped"), full: String(localized: "Stopped"), look: .zero, minimal: String(localized: "Stop"))}}/// About to do `act` (its thought, if any, names the target: "… so I tap the Clock app").static func acting(_ act: JObject) -> Self {let look = gaze(act)+ let minimal: String+ switch act["action"]?.str {+ case "tap": minimal = String(localized: "Tap")+ case "type": minimal = String(localized: "Type")+ case "key": minimal = String(localized: "Key")+ case "swipe": minimal = String(localized: "Swipe")+ case "path", "circle": minimal = String(localized: "Draw")+ case "home": minimal = String(localized: "Home")+ case "back": minimal = String(localized: "Back")+ default: minimal = String(localized: "Wait")+ }func say(_ verb: (String) -> String, _ bare: String, _ what: String?) -> Self {- guard let what, !what.isEmpty else { return Self(short: bare, full: bare, look: look) }+ guard let what, !what.isEmpty else { return Self(short: bare, full: bare, look: look, minimal: minimal) }let room = compactLimit - verb("").count- return Self(short: verb(clip(what, room)), full: verb(clip(what, 28)), look: look)+ return Self(short: verb(clip(what, room)), full: verb(clip(what, 28)), look: look, minimal: minimal)}switch act["action"]?.str {case "tap":@@ -64,15 +86,15 @@ struct IslandStatus: Equatable {} else {label = look.y > 0 ? String(localized: "Swiping down") : String(localized: "Swiping up")}- return Self(short: label, full: label, look: look)+ return Self(short: label, full: label, look: look, minimal: minimal)case "path", "circle":- return Self(short: String(localized: "Drawing…"), full: String(localized: "Drawing…"), look: look)+ return Self(short: String(localized: "Drawing…"), full: String(localized: "Drawing…"), look: look, minimal: minimal)case "home":- return Self(short: String(localized: "Going home"), full: String(localized: "Going to the Home Screen"), look: look)+ return Self(short: String(localized: "Going home"), full: String(localized: "Going to the Home Screen"), look: look, minimal: minimal)case "back":- return Self(short: String(localized: "Going back"), full: String(localized: "Going back"), look: look)+ return Self(short: String(localized: "Going back"), full: String(localized: "Going back"), look: look, minimal: minimal)default:- return Self(short: String(localized: "Waiting…"), full: String(localized: "Waiting…"), look: look)+ return Self(short: String(localized: "Waiting…"), full: String(localized: "Waiting for the screen…"), look: nil, minimal: minimal)}}diff --git a/ios/IPhoneAgent/App/LiveActivity.swift b/ios/IPhoneAgent/App/LiveActivity.swiftindex 093b55e..faccc5f 100644--- a/ios/IPhoneAgent/App/LiveActivity.swift+++ b/ios/IPhoneAgent/App/LiveActivity.swift@@ -92,6 +92,7 @@ import Foundationif status.waits {if state.label != status.short || state.waitingSince == nil { state.waitingSince = Date() }} else { state.waitingSince = nil }+ state.minimalLabel = status.minimal ?? status.shortstate.label = status.shortstate.labelFull = status.fullif let look = status.look {diff --git a/ios/IPhoneAgent/App/RunSession.swift b/ios/IPhoneAgent/App/RunSession.swiftindex 1639a69..06df547 100644--- a/ios/IPhoneAgent/App/RunSession.swift+++ b/ios/IPhoneAgent/App/RunSession.swift@@ -137,6 +137,8 @@ extension AppModel {guard agent.running, help == nil else { return }switch d {case .looking: live.show(.looking, mood: .thinking)+ case .waiting: live.show(.waiting, mood: .thinking)+ case .planning: live.show(.planning, mood: .thinking)case .thinking: live.show(.thinking, mood: .thinking)case .retrying: live.show(.retrying, mood: .thinking)case .acting(let act): live.show(.acting(act), mood: .acting)diff --git a/ios/IPhoneAgent/Localizable.xcstrings b/ios/IPhoneAgent/Localizable.xcstringsindex c205e7c..dfcbb7f 100644--- a/ios/IPhoneAgent/Localizable.xcstrings+++ b/ios/IPhoneAgent/Localizable.xcstrings@@ -1823,7 +1823,7 @@"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "归位"+ "value" : "主页"}}}@@ -5347,6 +5347,126 @@}}}+ },+ "Look" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "查看"+ }+ }+ }+ },+ "Thinking about my next move…" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "正在思考下一步…"+ }+ }+ }+ },+ "Waiting for the model to respond…" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "正在等待模型回复…"+ }+ }+ }+ },+ "Planning…" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "正在规划…"+ }+ }+ }+ },+ "Thinking through my plan…" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "正在构思我的计划…"+ }+ }+ }+ },+ "Plan" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "规划"+ }+ }+ }+ },+ "You" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "等你"+ }+ }+ }+ },+ "Tap" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "点击"+ }+ }+ }+ },+ "Type" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "输入"+ }+ }+ }+ },+ "Key" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "按键"+ }+ }+ }+ },+ "Draw" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "绘制"+ }+ }+ }+ },+ "Waiting for the screen…" : {+ "localizations" : {+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "正在等待屏幕变化…"+ }+ }+ }}},"version" : "1.0"diff --git a/ios/IPhoneAgent/Services/LLMClient.swift b/ios/IPhoneAgent/Services/LLMClient.swiftindex 70dc4a7..35211b6 100644--- a/ios/IPhoneAgent/Services/LLMClient.swift+++ b/ios/IPhoneAgent/Services/LLMClient.swift@@ -38,7 +38,8 @@ struct LLMError: LocalizedError {/// Client for any OpenAI-compatible chat endpoint (vision models). Port of llm.py, with streaming:/// Cloudflare cuts requests that send nothing for ~100 s, so replies are streamed (SSE). A server that/// ignores `stream` and answers with plain JSON works too.-@MainActor final class LLMClient: ChatModel {+@MainActor final class LLMClient: ChatModel, ModelProgressReporting {+ var onProgress: ((ModelResponseProgress) -> Void)?static let tokenParams = ["max_tokens", "max_completion_tokens"]let model: String@@ -88,6 +89,7 @@ struct LLMError: LocalizedError {private func once(system: String, text: String, images: [Data], maxTokens: Int,temperature: Double) async throws -> ChatResult {+ onProgress?(.waiting)var content: [[String: Any]] = images.map {["type": "image_url", "image_url": ["url": "data:image/jpeg;base64," + $0.base64EncodedString()]]}@@ -173,10 +175,12 @@ struct LLMError: LocalizedError {for try await b in bytes { raw.append(b) }var result = try Self.message(raw)result.responseSeconds = responseSeconds+ if !result.text.isEmpty || result.reasoningChars > 0 { onProgress?(.receiving) }return (status, result, "")}var result = ChatResult(text: "", firstToken: nil, total: 0)result.responseSeconds = responseSeconds+ var reportedReceiving = falsefor try await line in bytes.lines {guard line.hasPrefix("data:") else { continue }let payload = line.dropFirst(5).trimmingCharacters(in: .whitespaces)@@ -186,7 +190,12 @@ struct LLMError: LocalizedError {let choice = (json["choices"] as? [[String: Any]])?.firstlet delta = choice?["delta"] as? [String: Any]Self.note(json, choice, into: &result)- result.reasoningChars += Self.reasoning(delta).count+ let reasoning = Self.reasoning(delta)+ if !reportedReceiving, !reasoning.isEmpty || !(delta?["content"] as? String ?? "").isEmpty {+ reportedReceiving = true+ onProgress?(.receiving)+ }+ result.reasoningChars += reasoning.countguard let piece = delta?["content"] as? String, !piece.isEmpty else { continue }if result.firstToken == nil { result.firstToken = now() - started }result.text += piecediff --git a/ios/IPhoneAgent/Services/ModelResponseProgress.swift b/ios/IPhoneAgent/Services/ModelResponseProgress.swiftnew file mode 100644index 0000000..aed224e--- /dev/null+++ b/ios/IPhoneAgent/Services/ModelResponseProgress.swift@@ -0,0 +1,8 @@+import Foundation++/// Transport progress, not a guess based on elapsed time or HTTP headers.+enum ModelResponseProgress: Equatable { case waiting, receiving }++@MainActor protocol ModelProgressReporting: AnyObject {+ var onProgress: ((ModelResponseProgress) -> Void)? { get set }+}diff --git a/ios/IPhoneAgentTests/AgentTests.swift b/ios/IPhoneAgentTests/AgentTests.swiftindex fa85191..c339f00 100644--- a/ios/IPhoneAgentTests/AgentTests.swift+++ b/ios/IPhoneAgentTests/AgentTests.swift@@ -26,6 +26,30 @@ import XCTestXCTAssertTrue(agent.steps.isEmpty)}+ func testPlannerAndActorHaveDistinctPendingAndReceivingStates() async throws {+ let model = ProgressModel()+ let agent = AgentLoop(phone: nil, screen: FakeScreen(), actor: model, planner: model, trace: nil)+ var states: [String] = []+ agent.onDoing = {+ switch $0 {+ case .waiting: states.append("waiting")+ case .planning: states.append("planning")+ case .thinking: states.append("thinking")+ default: break+ }+ }+ try await agent.replan()+ XCTAssertEqual(states.last, "planning")+ XCTAssertEqual(states.first, "waiting")+ XCTAssertNil(model.onProgress)+ states = []+ _ = try await agent.nextActions()+ XCTAssertEqual(states.first, "waiting")+ XCTAssertEqual(states.last, "thinking")+ XCTAssertFalse(states.contains("planning"))+ XCTAssertNil(model.onProgress)+ }+func testParseSingleAction() throws {let acts = try Actions.parseActions("THINK: The Search pill is visible, so I tap it.\nDO: tap 500 814")XCTAssertEqual(acts, [["thought": .str("The Search pill is visible, so I tap it."), "thought_zh": .str(""),@@ -206,3 +230,13 @@ import XCTestreturn ChatResult(text: "1. Observe the screen", total: 0)}}++@MainActor private final class ProgressModel: ChatModel, ModelProgressReporting {+ let model = "progress-test"+ var onProgress: ((ModelResponseProgress) -> Void)?+ func chat(system: String, text: String, image: Data?, maxTokens: Int, temperature: Double) async throws -> ChatResult {+ onProgress?(.waiting)+ onProgress?(.receiving)+ return ChatResult(text: "THINK: Wait for the screen\nDO: wait", total: 0)+ }+}diff --git a/ios/IPhoneAgentTests/IslandTests.swift b/ios/IPhoneAgentTests/IslandTests.swiftindex 93cb7b1..2503734 100644--- a/ios/IPhoneAgentTests/IslandTests.swift+++ b/ios/IPhoneAgentTests/IslandTests.swift@@ -12,6 +12,14 @@ import XCTestXCTAssertEqual(IslandStatus.gaze(up), CGPoint(x: 0, y: -1))}+ func testMinimalTextKeepsPendingPlanningThinkingAndRetryDistinct() {+ let states = [IslandStatus.waiting, .planning, .thinking, .retrying]+ XCTAssertEqual(states.compactMap(\.minimal), ["Wait", "Plan", "Think", "Retry"])+ XCTAssertTrue(states.allSatisfy(\.waits))+ XCTAssertEqual(IslandStatus.acting(["action": .str("swipe")]).minimal, "Swipe")+ XCTAssertEqual(IslandStatus.acting(["action": .str("wait")]).minimal, "Wait")+ }+func testTargetFromThought() {XCTAssertEqual(IslandStatus.target("I am on the home screen. I tap the Search pill to find Clock."), "Search")XCTAssertEqual(IslandStatus.target("My last tap opened Alarms. I tap + to add an alarm."), "+")diff --git a/ios/IPhoneAgentTests/LLMTests.swift b/ios/IPhoneAgentTests/LLMTests.swiftindex c0a253e..8dfe27f 100644--- a/ios/IPhoneAgentTests/LLMTests.swift+++ b/ios/IPhoneAgentTests/LLMTests.swift@@ -104,6 +104,21 @@ final class StubProtocol: URLProtocol {}}+ func testProgressWaitsThroughKeepalivesAndStartsOnReasoning() async throws {+ let llm = client("progress")+ var progress: [ModelResponseProgress] = []+ llm.onProgress = { progress.append($0) }+ StubProtocol.respond = { _ in+ (200, "text/event-stream", ": heartbeat\n\n"+ + "data: {\"choices\":[{\"delta\":{\"role\":\"assistant\"}}]}\n\n"+ + "data: {\"choices\":[{\"delta\":{\"reasoning\":\"planning\"}}]}\n\n"+ + "data: {\"choices\":[{\"delta\":{\"content\":\"Red\"}}]}\n\n"+ + "data: [DONE]\n\n")+ }+ _ = try await llm.chat(system: "test", text: "test")+ XCTAssertEqual(progress, [.waiting, .receiving])+ }+func client(_ model: String, extra: [String: Any] = [:], tokenParam: String = "auto") -> LLMClient {let config = URLSessionConfiguration.ephemeralconfig.protocolClasses = [StubProtocol.self]diff --git a/ios/Shared/AgentActivity.swift b/ios/Shared/AgentActivity.swiftindex 37b2e3c..6cbad9a 100644--- a/ios/Shared/AgentActivity.swift+++ b/ios/Shared/AgentActivity.swift@@ -17,6 +17,7 @@ struct AgentActivityAttributes: ActivityAttributes {var since = Date() // recording start, for the timervar label = "" // what the character says, compact island ("Thinking…", "Tapping Clock")var labelFull = "" // the same, longer, for the expanded island and the Lock Screen+ var minimalLabel: String? // explicit phase, not inferred from the facevar waitingSince: Date? // system-rendered elapsed timer, even between app updatesvar lookX = 0.0 // where the eyes look, -1...1 (darting while it waits, toward the pointer's target)var lookY = 0.0