fix(ios): keep sending and live sync quiet unless recovery is needed

Generated-by: Maka (ChatGPT)
diff --git a/products/maka/ios-shell/app/Entry.tsx b/products/maka/ios-shell/app/Entry.tsx
index e90e9ec..b283c5f 100644
--- a/products/maka/ios-shell/app/Entry.tsx
+++ b/products/maka/ios-shell/app/Entry.tsx
@@ -615,6 +615,8 @@
   const quotedLine = signal<string | null>(null);
   const defaultDelivery = signal<'steer' | 'queue'>('steer');
   const queuedMessages = signal<string[]>([]);
+  const catalogError = signal<string | null>(null);
+  const watchError = signal<string | null>(null);
   const diffTitle = signal('platform/remote-client/src/client.rs');
   const diffLines = signal<DiffLineItem[]>(PREVIEW_DIFF_LINES);
   const diffTruncatedNotice = signal<string | null>(null);
@@ -710,7 +712,8 @@
   const isSessionStillCurrent = (gen: number, epoch: string, sGen: number, sessionId: string) =>
     isHostStillCurrent(gen, epoch) && sGen === sessionSyncGen && activeSession()?.id === sessionId;
 
-  const stopWatchSubscription = () => {
+  const stopWatchSubscription = (clearError = true) => {
+    if (clearError) watchError.set(null);
     if (watchSub) {
       const id = watchSub.subscriptionId;
       watchSub = null;
@@ -726,7 +729,8 @@
     }
   };
 
-  const stopCatalogSubscription = () => {
+  const stopCatalogSubscription = (clearError = true) => {
+    if (clearError) catalogError.set(null);
     if (catalogSub) {
       const id = catalogSub.subscriptionId;
       catalogSub = null;
@@ -934,7 +938,7 @@
     epoch: string,
     sGen: number,
   ) => {
-    stopWatchSubscription();
+    stopWatchSubscription(false);
     subOpenSeq += 1;
     const subId = 'watch:' + sessionId + ':' + String(sGen) + ':' + String(subOpenSeq);
     const slot: SubSlot = {
@@ -959,11 +963,13 @@
           return;
         }
         slot.generation = handle.generation;
+        watchError.set(null);
       },
       (err: Error) => {
-        if (watchSub === slot) watchSub = null;
+        if (watchSub !== slot) return;
+        watchSub = null;
         if (isSessionStillCurrent(gen, epoch, sGen, sessionId)) {
-          statusBanner.set('实时会话订阅失败(可点右上角“同步”重试): ' + err.message);
+          watchError.set('实时会话订阅失败: ' + err.message);
         }
       },
     );
@@ -1032,7 +1038,7 @@
     titleQuery = catalogQuery(),
     qGen = catalogQueryGen,
   ) => {
-    stopCatalogSubscription();
+    stopCatalogSubscription(false);
     subOpenSeq += 1;
     const subId =
       'catalog:' + epoch + ':' + String(gen) + ':' + String(qGen) + ':' + String(subOpenSeq);
@@ -1066,11 +1072,13 @@
           return;
         }
         slot.generation = handle.generation;
+        catalogError.set(null);
       },
       (err: Error) => {
-        if (catalogSub === slot) catalogSub = null;
+        if (catalogSub !== slot) return;
+        catalogSub = null;
         if (isHostStillCurrent(gen, epoch) && qGen === catalogQueryGen) {
-          statusBanner.set('会话目录订阅失败(可点“同步”重试): ' + err.message);
+          catalogError.set('会话目录订阅失败: ' + err.message);
         }
       },
     );
@@ -1103,6 +1111,7 @@
     epoch = hostState().active?.epoch ?? '',
   ) => {
     if (!epoch || !isHostStillCurrent(gen, epoch)) return;
+    catalogError.set(null);
     catalogQueryGen += 1;
     const qGen = catalogQueryGen;
     catalogSubReceivedForQuery = false;
@@ -1554,8 +1563,8 @@
       const slot = catalogSub;
       slot.ended = true;
       catalogSub = null;
-      if (payload.error && isHostStillCurrent(slot.hostGen, slot.hostEpoch)) {
-        statusBanner.set('会话目录同步中断: ' + payload.error);
+      if (isHostStillCurrent(slot.hostGen, slot.hostEpoch)) {
+        catalogError.set('会话目录同步中断' + (payload.error ? ': ' + payload.error : ''));
       }
     }
     if (matchesSubSlot(goalSub, payload.subscriptionId, payload.generation) && goalSub) {
@@ -1567,12 +1576,11 @@
       slot.ended = true;
       watchSub = null;
       if (
-        payload.error &&
         slot.sessionGen !== undefined &&
         slot.sessionId !== undefined &&
         isSessionStillCurrent(slot.hostGen, slot.hostEpoch, slot.sessionGen, slot.sessionId)
       ) {
-        statusBanner.set('会话流式订阅中断: ' + payload.error);
+        watchError.set('会话流式订阅中断' + (payload.error ? ': ' + payload.error : ''));
       }
     }
   });
@@ -1893,6 +1901,18 @@
     route.set('chat');
   };
 
+  const retrySubscriptions = () => {
+    const active = hostState().active;
+    if (!active || !hasAgentEndpoint(active)) return;
+    if (catalogError() !== null && !catalogSub) {
+      startCatalogSubscription(hostSyncGen, active.epoch);
+    }
+    const sess = activeSession();
+    if (watchError() !== null && sess && !watchSub) {
+      startWatchSubscription(sess.id, watchCursor, hostSyncGen, active.epoch, sessionSyncGen);
+    }
+  };
+
   const runVerifyLiveRpc = () => {
     const active = hostState().active;
     if (!active) {
@@ -1925,7 +1945,6 @@
             return;
           }
           applyCatalogPage(page, false);
-          statusBanner.set('实时同步完成 · ' + String((page.sessions ?? []).length) + ' 个会话');
         },
         (err: Error) => {
           busy.set(false);
@@ -2536,22 +2555,24 @@
                 </Text>
               </View>
 
-              <View
-                role="button"
-                accessibilityLabel="Verify live Host RPC"
-                onPress={runVerifyLiveRpc}
-                style={{
-                  minWidth: 40,
-                  minHeight: 36,
-                  paddingHorizontal: 9,
-                  borderRadius: 18,
-                  backgroundColor: palette().rowHover,
-                  alignItems: 'center',
-                  justifyContent: 'center',
-                }}
-              >
-                <Text style={{ fontSize: 12.5, color: palette().ink2 }}>同步</Text>
-              </View>
+              <If when={catalogError() !== null || watchError() !== null}>
+                <View
+                  role="button"
+                  accessibilityLabel="Retry subscriptions"
+                  onPress={retrySubscriptions}
+                  style={{
+                    minWidth: 40,
+                    minHeight: 36,
+                    paddingHorizontal: 9,
+                    borderRadius: 18,
+                    backgroundColor: palette().rowHover,
+                    alignItems: 'center',
+                    justifyContent: 'center',
+                  }}
+                >
+                  <Text style={{ fontSize: 12.5, color: palette().ink2 }}>重试</Text>
+                </View>
+              </If>
             </View>
           </View>
 
@@ -2629,6 +2650,29 @@
             </View>
           </If>
 
+          <If when={catalogError() !== null}>
+            <View
+              style={{
+                paddingHorizontal: 16,
+                paddingVertical: 8,
+                backgroundColor: palette().accentSoft,
+              }}
+            >
+              <Text style={{ fontSize: 12.5, color: palette().ink }}>{catalogError()}</Text>
+            </View>
+          </If>
+          <If when={watchError() !== null}>
+            <View
+              style={{
+                paddingHorizontal: 16,
+                paddingVertical: 8,
+                backgroundColor: palette().accentSoft,
+              }}
+            >
+              <Text style={{ fontSize: 12.5, color: palette().ink }}>{watchError()}</Text>
+            </View>
+          </If>
+
           {/* Scrollable Chat Viewport + Right-Edge Turn Navigation Rail */}
           <View style={{ flex: 1, minHeight: 0, position: 'relative' }}>
             <Scroll
@@ -3088,26 +3132,6 @@
                   {formatBackendPill(currentBackend()) + ' ▾'}
                 </Text>
               </View>
-
-              <If when={activeRunId() !== null}>
-                <View
-                  role="button"
-                  accessibilityLabel="Toggle steer or queue delivery"
-                  onPress={() =>
-                    defaultDelivery.set(defaultDelivery() === 'steer' ? 'queue' : 'steer')
-                  }
-                  style={{
-                    paddingHorizontal: 10,
-                    paddingVertical: 5,
-                    borderRadius: 12,
-                    backgroundColor: palette().surface2,
-                  }}
-                >
-                  <Text style={{ fontSize: 11.5, color: palette().ink2 }}>
-                    {defaultDelivery() === 'steer' ? '立即纠偏' : '排队发送'}
-                  </Text>
-                </View>
-              </If>
             </View>
           </If>
 
diff --git a/products/maka/ios-shell/tests/ios_shell_behaviors.rs b/products/maka/ios-shell/tests/ios_shell_behaviors.rs
index 384adf6..5a050eb 100644
--- a/products/maka/ios-shell/tests/ios_shell_behaviors.rs
+++ b/products/maka/ios-shell/tests/ios_shell_behaviors.rs
@@ -823,6 +823,11 @@
         Arc::new(std::sync::Mutex::new(Vec::new()));
     let recorded_sends: Arc<std::sync::Mutex<Vec<(String, String)>>> =
         Arc::new(std::sync::Mutex::new(Vec::new()));
+    let watch_break = Arc::new(Notify::new());
+    let catalog_break = Arc::new(Notify::new());
+    let watch_opens = Arc::new(std::sync::atomic::AtomicUsize::new(0));
+    let catalog_opens = Arc::new(std::sync::atomic::AtomicUsize::new(0));
+    let list_calls = Arc::new(std::sync::atomic::AtomicUsize::new(0));
     let watch_cancelled = Arc::new(AtomicBool::new(false));
     let watch_cancel_notify = Arc::new(Notify::new());
     let perm_resolved = Arc::new(AtomicBool::new(false));
@@ -850,6 +855,11 @@
         requested_permissions: Permissions,
         answers: Arc<std::sync::Mutex<Vec<(String, InteractionAnswer)>>>,
         sends: Arc<std::sync::Mutex<Vec<(String, String)>>>,
+        watch_break: Arc<Notify>,
+        catalog_break: Arc<Notify>,
+        watch_opens: Arc<std::sync::atomic::AtomicUsize>,
+        catalog_opens: Arc<std::sync::atomic::AtomicUsize>,
+        list_calls: Arc<std::sync::atomic::AtomicUsize>,
         watch_cancelled: Arc<AtomicBool>,
         watch_cancel_notify: Arc<Notify>,
         perm_resolved: Arc<AtomicBool>,
@@ -936,6 +946,11 @@
             let requested_permissions = self.requested_permissions.clone();
             let answers = self.answers.clone();
             let sends = self.sends.clone();
+            let watch_break = self.watch_break.clone();
+            let catalog_break = self.catalog_break.clone();
+            let watch_opens = self.watch_opens.clone();
+            let catalog_opens = self.catalog_opens.clone();
+            let list_calls = self.list_calls.clone();
             let watch_cancelled = self.watch_cancelled.clone();
             let watch_cancel_notify = self.watch_cancel_notify.clone();
             let perm_resolved = self.perm_resolved.clone();
@@ -980,6 +995,7 @@
                         })
                     }
                     "list" => {
+                        list_calls.fetch_add(1, Ordering::SeqCst);
                         let _req: List = serde_json::from_value(input)
                             .map_err(|e| HandlerError::from(e.to_string()))?;
                         to_val(&SessionPage {
@@ -991,6 +1007,11 @@
                         })
                     }
                     "catalog" => {
+                        let seq = catalog_opens.fetch_add(1, Ordering::SeqCst);
+                        let mut session = session;
+                        if seq > 0 {
+                            session.title = "重连后的新目录项".into();
+                        }
                         let _req: List = serde_json::from_value(input)
                             .map_err(|e| HandlerError::from(e.to_string()))?;
                         let page = serde_json::to_value(&SessionPage {
@@ -1005,8 +1026,10 @@
                             .emit(page)
                             .await
                             .map_err(|e| HandlerError::from(e.to_string()))?;
-                        context.scope().cancellation.cancelled().await;
-                        Ok(HandlerValue::Json(Value::Null))
+                        tokio::select! {
+                            _ = catalog_break.notified() => Err(HandlerError::from("catalog-test-interruption")),
+                            _ = context.scope().cancellation.cancelled() => Ok(HandlerValue::Json(Value::Null)),
+                        }
                     }
                     "observe" => {
                         let _req: SessionRead = serde_json::from_value(input)
@@ -1113,6 +1136,32 @@
                         let req: Watch = serde_json::from_value(input)
                             .map_err(|e| HandlerError::from(e.to_string()))?;
                         assert_eq!(req.session_id, "sess-quic-01");
+                        watch_opens.fetch_add(1, Ordering::SeqCst);
+                        // Opening the selected session can replace its initial watch.
+                        // Only the resume cursor can unlock the data after the break.
+                        if req.after == 12 {
+                            context
+                                .emit(
+                                    serde_json::to_value(&DeliveryPage::Queue {
+                                        queue: Queue {
+                                            revision: 3,
+                                            entries: vec![QueueEntry {
+                                                origin: None,
+                                                message_id: "q-2".into(),
+                                                kind: QueueKind::Followup,
+                                                preview: "重连后收到的消息".into(),
+                                            }],
+                                        },
+                                    })
+                                    .unwrap(),
+                                )
+                                .await
+                                .map_err(|e| HandlerError::from(e.to_string()))?;
+                            context.scope().cancellation.cancelled().await;
+                            watch_cancelled.store(true, Ordering::SeqCst);
+                            watch_cancel_notify.notify_waiters();
+                            return Ok(HandlerValue::Json(Value::Null));
+                        }
                         assert_eq!(req.after, 10, "watch must resume from Observation.through");
 
                         // 1. Real DeliveryPage::Events with Delivery + DeliveryFact::Delta
@@ -1265,7 +1314,10 @@
                             .await
                             .map_err(|e| HandlerError::from(e.to_string()))?;
 
-                        context.scope().cancellation.cancelled().await;
+                        tokio::select! {
+                            _ = watch_break.notified() => return Err(HandlerError::from("watch-test-interruption")),
+                            _ = context.scope().cancellation.cancelled() => {},
+                        }
                         watch_cancelled.store(true, Ordering::SeqCst);
                         watch_cancel_notify.notify_waiters();
                         Ok(HandlerValue::Json(Value::Null))
@@ -1564,6 +1616,11 @@
         let contract_clone = agent_contract.clone();
         let answers_clone = recorded_answers.clone();
         let sends_clone = recorded_sends.clone();
+        let wb_clone = watch_break.clone();
+        let cb_clone = catalog_break.clone();
+        let wo_clone = watch_opens.clone();
+        let co_clone = catalog_opens.clone();
+        let lc_clone = list_calls.clone();
         let wc_clone = watch_cancelled.clone();
         let wcn_clone = watch_cancel_notify.clone();
         let perm_clone = perm_resolved.clone();
@@ -1577,6 +1634,11 @@
                     let root_id = root_id_for_service.clone();
                     let answers = answers_clone.clone();
                     let sends = sends_clone.clone();
+                    let watch_break = wb_clone.clone();
+                    let catalog_break = cb_clone.clone();
+                    let watch_opens = wo_clone.clone();
+                    let catalog_opens = co_clone.clone();
+                    let list_calls = lc_clone.clone();
                     let watch_cancelled = wc_clone.clone();
                     let watch_cancel_notify = wcn_clone.clone();
                     let perm_resolved = perm_clone.clone();
@@ -1600,6 +1662,11 @@
                                         requested_permissions,
                                         answers,
                                         sends,
+                                        watch_break,
+                                        catalog_break,
+                                        watch_opens,
+                                        catalog_opens,
+                                        list_calls,
                                         watch_cancelled,
                                         watch_cancel_notify,
                                         perm_resolved,
@@ -1762,6 +1829,9 @@
         );
     }
 
+    assert!(app.press("label:Toggle steer or queue delivery").is_err());
+    assert!(app.press("label:Retry subscriptions").is_err());
+
     // 6. Send real Steer message -> Host deserializes real AgentSend!
     app.type_text("label:Chat composer input", "按刚才的方案直接改")
         .unwrap();
@@ -1786,8 +1856,27 @@
     app.wait_for("text:运行中").unwrap();
     app.press("label:Back from automations").unwrap();
 
-    // 9. Disconnect Host -> Host watch subscription cancels promptly!
+    // Each failed stream is retried independently and delivers fresh data.
+    let lists_before = list_calls.load(Ordering::SeqCst);
+    let catalogs_before = catalog_opens.load(Ordering::SeqCst);
+    watch_break.notify_one();
+    app.wait_for("text:/会话流式订阅中断/").unwrap();
+    app.press("label:Retry subscriptions").unwrap();
+    app.wait_for("text:/重连后收到的消息/").unwrap();
+    assert_eq!(catalog_opens.load(Ordering::SeqCst), catalogs_before);
+    assert_eq!(list_calls.load(Ordering::SeqCst), lists_before);
+    assert!(!app.shows("text:/会话流式订阅中断/"));
+    assert!(app.shows("已连接 Studio Agent Host"));
+
+    let watches_before = watch_opens.load(Ordering::SeqCst);
+    catalog_break.notify_one();
+    app.wait_for("text:/会话目录同步中断/").unwrap();
+    app.press("label:Retry subscriptions").unwrap();
     app.press("label:Open drawer").unwrap();
+    app.wait_for("label:Session 重连后的新目录项").unwrap();
+    assert_eq!(watch_opens.load(Ordering::SeqCst), watches_before);
+    assert_eq!(list_calls.load(Ordering::SeqCst), lists_before);
+    // 9. Disconnect Host -> Host watch subscription cancels promptly!
     app.press("label:Settings").unwrap();
     app.press("label:Disconnect active host").unwrap();