Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): 用 hideKeyboardAccessoryView 去掉会话输入框的键盘导航条,撤销 #390 (#410)

Dash68ce5e8bc20f
diff --git a/apps/mobile/src/session/ComposerRichInput.tsx b/apps/mobile/src/session/ComposerRichInput.tsx
index 5727d87266..a4dcde40d7 100644
--- a/apps/mobile/src/session/ComposerRichInput.tsx
+++ b/apps/mobile/src/session/ComposerRichInput.tsx
@@ -1,5 +1,5 @@
import { forwardRef, useCallback, useEffect, useMemo, useRef } from 'react';
-import { StyleSheet } from 'react-native';
+import { Platform, StyleSheet } from 'react-native';
import { WebView, type WebViewMessageEvent } from 'react-native-webview';
import { File, Paths } from 'expo-file-system';
import * as Clipboard from 'expo-clipboard';
@@ -362,6 +362,14 @@ export const ComposerRichInput = forwardRef<ComposerRichInputHandle, ComposerRic
accessibilityHint={accessibilityHint}
accessibilityLabel={accessibilityLabel}
allowFileAccess={false}
+ // iOS 给 WKWebView 里的可编辑区域挂一条系统表单导航条(上一项 / 下一项 /
+ // 完成),iOS 26 起画成键盘上方的独立浮动胶囊。composer 只有这一个字段,
+ // 前后导航恒为禁用态,整条对用户没有任何价值却占掉一行。RN TextInput
+ // 没有这条,所以只有会话页这个富文本输入框会出现。
+ //
+ // 仅 iPhone:iPad 上同一个 accessory view 承载撤销 / 重做 / 粘贴等真实
+ // 编辑能力(本 app app.json 声明了 supportsTablet),清掉是功能回退。
+ hideKeyboardAccessoryView={Platform.OS === 'ios' && !Platform.isPad}
javaScriptEnabled
keyboardDisplayRequiresUserAction={false}
onMessage={handleMessage}
diff --git a/dependency-patches/README.md b/dependency-patches/README.md
index 136f8caebd..fe53f8d4a4 100644
--- a/dependency-patches/README.md
+++ b/dependency-patches/README.md
@@ -10,7 +10,7 @@
| 依赖 | 用途 |
| --- | --- |
-| `[email protected]` | 优化移动端粘贴图片的处理时序,将耗时的解码、压缩和写盘移出 UI 线程,并补充加载中与失败事件;同时在 iPhone 上清空被接管输入框的 iOS `inputAssistantItem`,去掉系统在键盘上方多挂的一条只有禁用态上下箭头和「完成」的表单导航条(iPad 的辅助条含撤销/重做/粘贴等实际功能,保持不动)。 |
+| `[email protected]` | 优化移动端粘贴图片的处理时序,将耗时的解码、压缩和写盘移出 UI 线程,并补充加载中与失败事件。 |
| `harmonyos-sans-sc-webfont-splitted` | 移除依赖按语言全局覆盖 `font-family` 的规则,由 Cindy 自己决定界面字体。 |
| `[email protected]` | 回移 Yoga 对 `display: none` 与 `display: contents` 测量过程的布局状态修复,避免 Fabric 布局阶段因错误的 owner 关系触发断言崩溃(上游 `6fa330693fba313a2fe1121545c1efd558b60983`、`2546ce4d8219050fcd1bf432c7c830c9fd70c9af`)。移动端 iOS 通过 `expo-build-properties` 的 `buildReactNativeFromSource` 编译该补丁,不能改回预编译 RN Core。 |
| `[email protected]` | 修复 iOS 长文本渲染闪烁、布局性能、文本选择与选择手柄滚动等问题,并支持自定义选择菜单操作。 |
diff --git a/dependency-patches/[email protected] b/dependency-patches/[email protected]
index 403bbde141..031d091e74 100644
--- a/dependency-patches/[email protected]
+++ b/dependency-patches/[email protected]
@@ -159,65 +159,10 @@ index 4c430a252ef3e938622e6c56421ed283c6167913..4d5c561a5d117e7459cb0f83ca1c213c
type: "unsupported";
};
diff --git a/ios/ExpoPasteInputView.swift b/ios/ExpoPasteInputView.swift
-index 39b2302ed42bdd56db6084e333b9581e08c18689..4479d6d3dd64350355008689871132d893d2716f 100644
+index 39b2302ed42bdd56db6084e333b9581e08c18689..c08b8ba08ebb9650d7a013ac7257dc58832f8c3d 100644
--- a/ios/ExpoPasteInputView.swift
+++ b/ios/ExpoPasteInputView.swift
-@@ -38,6 +38,8 @@ class ExpoPasteInputView: ExpoView {
- private weak var observedTextView: UITextView?
- private var isSanitizingAttachments: Bool = false
- private var originalAdaptiveImageGlyphSupport: Bool?
-+ private var originalLeadingBarButtonGroups: [UIBarButtonItemGroup]?
-+ private var originalTrailingBarButtonGroups: [UIBarButtonItemGroup]?
- private let gifTypes: Set<String> = ["com.compuserve.gif", "public.gif", "image/gif"]
- private let webpTypes: Set<String> = ["org.webmproject.webp", "public.webp", "image/webp"]
- // Track which classes have been swizzled (once per class, never unswizzle)
-@@ -145,6 +147,27 @@ class ExpoPasteInputView: ExpoView {
- originalAdaptiveImageGlyphSupport = nil
- }
-
-+ // Recent iOS versions attach the system form-navigation shortcuts bar to
-+ // the inputs this wrapper takes over, drawn since iOS 26 as a standalone
-+ // floating capsule above the keyboard. A single-field composer therefore
-+ // gets an extra row holding nothing but permanently disabled prev/next
-+ // chevrons and a Done checkmark. Drop both groups so the bar goes away.
-+ // This must be an empty array — a UIBarButtonItemGroup with no items
-+ // hides the buttons but keeps the bar itself taking up space. Reported on
-+ // iOS 27; does not reproduce on the iOS 26.5 iPhone simulator.
-+ //
-+ // iPhone only: on iPad the shortcuts bar is a permanent part of the
-+ // keyboard and carries real editing affordances (undo/redo, paste,
-+ // formatting), so clearing it there would take away working functionality
-+ // rather than an empty row. restoreTextInput() keys off the saved groups
-+ // being non-nil, so skipping the capture here also skips the restore.
-+ if UIDevice.current.userInterfaceIdiom == .phone {
-+ originalLeadingBarButtonGroups = view.inputAssistantItem.leadingBarButtonGroups
-+ originalTrailingBarButtonGroups = view.inputAssistantItem.trailingBarButtonGroups
-+ view.inputAssistantItem.leadingBarButtonGroups = []
-+ view.inputAssistantItem.trailingBarButtonGroups = []
-+ }
-+
- if let textView = view as? UITextView {
- observeTextViewChanges(for: textView)
- } else {
-@@ -162,6 +185,17 @@ class ExpoPasteInputView: ExpoView {
- }
- originalAdaptiveImageGlyphSupport = nil
-
-+ // Fabric recycles backing text views across TextInput instances, so hand
-+ // the shortcuts bar back exactly as we found it.
-+ if let originalLeadingBarButtonGroups {
-+ view.inputAssistantItem.leadingBarButtonGroups = originalLeadingBarButtonGroups
-+ }
-+ if let originalTrailingBarButtonGroups {
-+ view.inputAssistantItem.trailingBarButtonGroups = originalTrailingBarButtonGroups
-+ }
-+ originalLeadingBarButtonGroups = nil
-+ originalTrailingBarButtonGroups = nil
-+
- if let textView = view as? UITextView,
- observedTextView === textView {
- stopObservingTextView()
-@@ -252,77 +286,20 @@ class ExpoPasteInputView: ExpoView {
+@@ -252,77 +252,20 @@ class ExpoPasteInputView: ExpoView {
}
let pasteboard = UIPasteboard.general
@@ -309,7 +254,7 @@ index 39b2302ed42bdd56db6084e333b9581e08c18689..4479d6d3dd64350355008689871132d8
return // Don't call original paste for images
}
-@@ -550,12 +527,80 @@ class ExpoPasteInputView: ExpoView {
+@@ -550,7 +493,12 @@ class ExpoPasteInputView: ExpoView {
emitImagesAsync(for: mediaPayloads)
}
@@ -319,19 +264,14 @@ index 39b2302ed42bdd56db6084e333b9581e08c18689..4479d6d3dd64350355008689871132d8
+ // happen on the background queue.
private func emitImagesAsync(for payloads: [MediaPayload]) {
+ emitImagesLoading(count: payloads.count)
-+ mediaProcessingQueue.async { [weak self] in
-+ guard let self else {
-+ return
-+ }
-+
-+ let uris = self.temporaryFileURIs(for: payloads)
-+
-+ DispatchQueue.main.async { [weak self] in
-+ guard let self else {
-+ return
-+ }
-+
-+ if uris.isEmpty {
+ mediaProcessingQueue.async { [weak self] in
+ guard let self else {
+ return
+@@ -564,7 +512,70 @@ class ExpoPasteInputView: ExpoView {
+ }
+
+ if uris.isEmpty {
+- self.handleUnsupportedPaste()
+ // A placeholder was already emitted — resolve it as failed instead
+ // of the generic unsupported event so JS can retract the cards.
+ self.emitImagesLoadFailed()
@@ -374,11 +314,11 @@ index 39b2302ed42bdd56db6084e333b9581e08c18689..4479d6d3dd64350355008689871132d8
+ // UIPasteboard keeps no history, so the original data is gone — resolve
+ // the placeholder as failed instead of mis-attaching the wrong image.
+ let capturedChangeCount = UIPasteboard.general.changeCount
- mediaProcessingQueue.async { [weak self] in
- guard let self else {
- return
- }
-
++ mediaProcessingQueue.async { [weak self] in
++ guard let self else {
++ return
++ }
++
+ guard UIPasteboard.general.changeCount == capturedChangeCount else {
+ DispatchQueue.main.async { [weak self] in
+ self?.emitImagesLoadFailed()
@@ -387,19 +327,19 @@ index 39b2302ed42bdd56db6084e333b9581e08c18689..4479d6d3dd64350355008689871132d8
+ }
+
+ let payloads = self.collectPasteboardMediaPayloads()
- let uris = self.temporaryFileURIs(for: payloads)
-
- DispatchQueue.main.async { [weak self] in
-@@ -564,7 +609,7 @@ class ExpoPasteInputView: ExpoView {
- }
-
- if uris.isEmpty {
-- self.handleUnsupportedPaste()
++ let uris = self.temporaryFileURIs(for: payloads)
++
++ DispatchQueue.main.async { [weak self] in
++ guard let self else {
++ return
++ }
++
++ if uris.isEmpty {
+ self.emitImagesLoadFailed()
return
}
-@@ -700,8 +745,11 @@ class ExpoPasteInputView: ExpoView {
+@@ -700,8 +711,11 @@ class ExpoPasteInputView: ExpoView {
return true
}
@@ -413,7 +353,7 @@ index 39b2302ed42bdd56db6084e333b9581e08c18689..4479d6d3dd64350355008689871132d8
let pasteboard = UIPasteboard.general
let staticImageTypes = [
-@@ -832,15 +880,7 @@ class ExpoPasteInputView: ExpoView {
+@@ -832,15 +846,7 @@ class ExpoPasteInputView: ExpoView {
staticImagePayloads.append(.image(image))
}
@@ -430,7 +370,7 @@ index 39b2302ed42bdd56db6084e333b9581e08c18689..4479d6d3dd64350355008689871132d8
}
/// Detects if the given data is a GIF by checking for GIF87a or GIF89a header
-@@ -922,6 +962,23 @@ class ExpoPasteInputView: ExpoView {
+@@ -922,6 +928,23 @@ class ExpoPasteInputView: ExpoView {
])
}
@@ -454,7 +394,7 @@ index 39b2302ed42bdd56db6084e333b9581e08c18689..4479d6d3dd64350355008689871132d8
private func temporaryFileURIs(for payloads: [MediaPayload]) -> [String] {
var uris: [String] = []
-@@ -1013,15 +1070,6 @@ class ExpoPasteInputView: ExpoView {
+@@ -1013,15 +1036,6 @@ class ExpoPasteInputView: ExpoView {
stopMonitoring()
stopObservingTextView()
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index eff4dd83f0..aea2084941 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -16,7 +16,7 @@ overrides:
patchedDependencies:
- hash: d3eb498564b85f9db254b4ccc74c3398d8f45706a8dd2e37f194f22992a00387
+ hash: 53be555646735a171c1624f074ef30e5ca897a7b8893724bc2d0d51682f769d8
path: dependency-patches/[email protected]
harmonyos-sans-sc-webfont-splitted:
hash: 272e3ded46880ee2f9eaff39327b8465de6df4072271de03caf73950e6e57822
@@ -600,7 +600,7 @@ importers:
version: 56.0.22([email protected])([email protected](patch_hash=9442031604caa9cd185e0b2be6867055459fc3a6d2781296027989db098f972d)(@babel/[email protected])(@react-native/[email protected](@babel/[email protected]))(@types/[email protected])([email protected]))([email protected])([email protected])
expo-paste-input:
specifier: 0.2.2
- version: 0.2.2(patch_hash=d3eb498564b85f9db254b4ccc74c3398d8f45706a8dd2e37f194f22992a00387)([email protected])([email protected](patch_hash=9442031604caa9cd185e0b2be6867055459fc3a6d2781296027989db098f972d)(@babel/[email protected])(@react-native/[email protected](@babel/[email protected]))(@types/[email protected])([email protected]))([email protected])
+ version: 0.2.2(patch_hash=53be555646735a171c1624f074ef30e5ca897a7b8893724bc2d0d51682f769d8)([email protected])([email protected](patch_hash=9442031604caa9cd185e0b2be6867055459fc3a6d2781296027989db098f972d)(@babel/[email protected])(@react-native/[email protected](@babel/[email protected]))(@types/[email protected])([email protected]))([email protected])
expo-router:
specifier: ^56.2.11
version: 56.2.15(600de089274a49ab6ec9549ee6c8284a)
@@ -17020,7 +17020,7 @@ snapshots:
- supports-color
- typescript
- [email protected](patch_hash=d3eb498564b85f9db254b4ccc74c3398d8f45706a8dd2e37f194f22992a00387)([email protected])([email protected](patch_hash=9442031604caa9cd185e0b2be6867055459fc3a6d2781296027989db098f972d)(@babel/[email protected])(@react-native/[email protected](@babel/[email protected]))(@types/[email protected])([email protected]))([email protected]):
+ [email protected](patch_hash=53be555646735a171c1624f074ef30e5ca897a7b8893724bc2d0d51682f769d8)([email protected])([email protected](patch_hash=9442031604caa9cd185e0b2be6867055459fc3a6d2781296027989db098f972d)(@babel/[email protected])(@react-native/[email protected](@babel/[email protected]))(@types/[email protected])([email protected]))([email protected]):
dependencies:
expo: 56.0.16(bedb3dfb85b4bb5081482612eab0a2c6)
react: 19.2.3