Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 读屏焦点发给面板内可访问的首个文字
Dashfc4308dcda23
diff --git a/apps/mobile/src/__tests__/runningTokenRatePopover.test.tsx b/apps/mobile/src/__tests__/runningTokenRatePopover.test.tsxindex e5de6b81c3..acb1dd97bc 100644--- a/apps/mobile/src/__tests__/runningTokenRatePopover.test.tsx+++ b/apps/mobile/src/__tests__/runningTokenRatePopover.test.tsx@@ -67,7 +67,11 @@ vi.mock("react-native", () => {},useWindowDimensions: () => harness.window,ScrollView: view,- Text: view,+ Text: (props: any) => {+ // Text is an accessibility element by default; plain Views are not.+ if (props.ref) props.ref.current = { testID: `text:${props.children}` };+ return view(props);+ },StyleSheet: { create: (s: unknown) => s },Pressable: (props: any) => {harness.press = props;@@ -562,12 +566,15 @@ it("moves screen reader focus into the pinned card and back to the trigger, exceawait gesture("onPress");await layout();await layout();- expect(harness.focus).toEqual(["session.tokenRate.card"]);+ expect(harness.focus).toEqual(["text:session.screen.currentRate"]);await act(async () => {await close();});expect(card()).toBeNull();- expect(harness.focus).toEqual(["session.tokenRate.card", "trigger"]);+ expect(harness.focus).toEqual([+ "text:session.screen.currentRate",+ "trigger",+ ]);harness.focus = [];}await gesture("onPressIn");@@ -575,5 +582,5 @@ it("moves screen reader focus into the pinned card and back to the trigger, exceawait layout();await act(async () => harness.outsideTap!.onOutsideTap());expect(card()).toBeNull();- expect(harness.focus).toEqual(["session.tokenRate.card"]);+ expect(harness.focus).toEqual(["text:session.screen.currentRate"]);});diff --git a/apps/mobile/src/components/AppText.tsx b/apps/mobile/src/components/AppText.tsxindex f54d63ecf6..a2d15dd1e7 100644--- a/apps/mobile/src/components/AppText.tsx+++ b/apps/mobile/src/components/AppText.tsx@@ -16,8 +16,8 @@ import { useTheme } from '@/theme/ThemeProvider';*/export const MAX_FONT_SIZE_MULTIPLIER = 1.2;-export function Text(props: TextProps) {- return <RNText maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER} {...props} />;+export function Text({ ref, ...props }: TextProps & { ref?: Ref<RNText> }) {+ return <RNText ref={ref} maxFontSizeMultiplier={MAX_FONT_SIZE_MULTIPLIER} {...props} />;}/** ref 直接透传给原生 TextInput(React 19 ref-as-prop),`focus()` 等命令式调用不受影响。 */diff --git a/apps/mobile/src/session/RunningTokenRatePopover.tsx b/apps/mobile/src/session/RunningTokenRatePopover.tsxindex fe3b608a4f..9b948c1cf2 100644--- a/apps/mobile/src/session/RunningTokenRatePopover.tsx+++ b/apps/mobile/src/session/RunningTokenRatePopover.tsx@@ -7,6 +7,7 @@ import {StyleSheet,View,useWindowDimensions,+ type Text as RNText,} from "react-native";import { Text } from "@/components/AppText";import Svg, { Circle, Path } from "react-native-svg";@@ -76,7 +77,8 @@ export function RunningTokenRatePopover({const insets = useSafeAreaInsets();const anchorRef = useRef<View>(null);const triggerRef = useRef<View>(null);- const cardRef = useRef<View>(null);+ // Plain Views are not accessibility elements; focus the card's first label.+ const cardFocusTarget = useRef<RNText>(null);const [anchor, setAnchor] = useState({ x: 0, y: 0, width: 0, height: 0 });const [cardHeight, setCardHeight] = useState(0);const measureAnchor = () =>@@ -260,14 +262,20 @@ export function RunningTokenRatePopover({<ViewpointerEvents={mode === "held" ? "none" : "auto"}onStartShouldSetResponder={() => true}- ref={cardRef}onAccessibilityEscape={() => setMode("closed")}testID="session.tokenRate.card"onLayout={(event) => {setCardHeight(event.nativeEvent.layout.height);- if (mode === "pinned" && !cardFocused.current && cardRef.current) {+ if (+ mode === "pinned" &&+ !cardFocused.current &&+ cardFocusTarget.current+ ) {cardFocused.current = true;- AccessibilityInfo.sendAccessibilityEvent(cardRef.current, "focus");+ AccessibilityInfo.sendAccessibilityEvent(+ cardFocusTarget.current,+ "focus",+ );}}}style={[@@ -288,7 +296,9 @@ export function RunningTokenRatePopover({><View style={styles.top}><View style={styles.metric}>- <Text style={styles.label}>{t("session.screen.currentRate")}</Text>+ <Text ref={cardFocusTarget} style={styles.label}>+ {t("session.screen.currentRate")}+ </Text><Text style={styles.value}>{formatTokenRate(recent)}{" "}<Text style={styles.label}>