Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 速度面板任何方式关闭都把读屏焦点还给触发按钮
Dasha6bc11705d2b
diff --git a/apps/mobile/src/__tests__/runningTokenRatePopover.test.tsx b/apps/mobile/src/__tests__/runningTokenRatePopover.test.tsxindex eb289d0375..e5de6b81c3 100644--- a/apps/mobile/src/__tests__/runningTokenRatePopover.test.tsx+++ b/apps/mobile/src/__tests__/runningTokenRatePopover.test.tsx@@ -543,8 +543,20 @@ it("moves screen reader focus into the pinned card and back to the trigger, exce// Holding is a touch gesture; it never moves screen reader focus.expect(harness.focus).toEqual([]);for (const close of [- () => harness.back!(),- () => harness.card.onAccessibilityEscape(),+ async () => harness.back!(),+ async () => harness.card.onAccessibilityEscape(),+ async () => {+ await gesture("onPressIn");+ harness.press.onPress();+ },+ async () => {+ // Rotation or a fold change closes the card automatically.+ harness.viewport = {+ ...harness.viewport,+ width: harness.viewport.width + 1,+ };+ await render();+ },]) {await gesture("onPressIn");await gesture("onPress");@@ -552,7 +564,7 @@ it("moves screen reader focus into the pinned card and back to the trigger, exceawait layout();expect(harness.focus).toEqual(["session.tokenRate.card"]);await act(async () => {- close();+ await close();});expect(card()).toBeNull();expect(harness.focus).toEqual(["session.tokenRate.card", "trigger"]);diff --git a/apps/mobile/src/session/RunningTokenRatePopover.tsx b/apps/mobile/src/session/RunningTokenRatePopover.tsxindex d34f56435d..fe3b608a4f 100644--- a/apps/mobile/src/session/RunningTokenRatePopover.tsx+++ b/apps/mobile/src/session/RunningTokenRatePopover.tsx@@ -154,33 +154,33 @@ export function RunningTokenRatePopover({width: cardWidth,height: cardHeight,}),- () => setMode("closed"),+ () => {+ closedByOutsideTap.current = true;+ setMode("closed");+ },);// The card is not an accessibility modal, so the chat stays usable. Screen- // reader focus moves into it on open and back to the trigger when the user- // closes it from the trigger, back or escape; an outside tap keeps focus- // wherever that tap went.+ // reader focus moves into it on open and, however it closes, back to the+ // trigger; only an outside tap keeps focus wherever that tap went.const cardFocused = useRef(false);- const refocusTrigger = useRef(false);- const closeAndRefocus = () => {- refocusTrigger.current = true;- setMode("closed");- };+ const closedByOutsideTap = useRef(false);useEffect(() => {if (mode === "pinned") return;+ if (+ cardFocused.current &&+ !closedByOutsideTap.current &&+ triggerRef.current+ )+ AccessibilityInfo.sendAccessibilityEvent(triggerRef.current, "focus");cardFocused.current = false;- if (mode === "closed" && refocusTrigger.current) {- refocusTrigger.current = false;- if (triggerRef.current)- AccessibilityInfo.sendAccessibilityEvent(triggerRef.current, "focus");- }+ closedByOutsideTap.current = false;}, [mode]);useEffect(() => {if (mode !== "pinned") return;const subscription = BackHandler.addEventListener("hardwareBackPress",() => {- closeAndRefocus();+ setMode("closed");return true;},);@@ -261,7 +261,7 @@ export function RunningTokenRatePopover({pointerEvents={mode === "held" ? "none" : "auto"}onStartShouldSetResponder={() => true}ref={cardRef}- onAccessibilityEscape={closeAndRefocus}+ onAccessibilityEscape={() => setMode("closed")}testID="session.tokenRate.card"onLayout={(event) => {setCardHeight(event.nativeEvent.layout.height);