Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 群聊对同一条消息再次点「回复」时重新聚焦输入框
Chrisfa36b05cc791
diff --git a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsxindex b90f6a99bb..4ae51ce336 100644--- a/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx+++ b/apps/mobile/src/__tests__/BotGroupChatScreen.test.tsx@@ -17,6 +17,7 @@ const h = vi.hoisted(() => ({appStateListeners: new Set<(state: string) => void>(),closeSettings: null as null | (() => void),row: null as any,+ inputFocus: vi.fn(),inputs: {} as Record<string, any>,teammates: { rows: [] as any[], loading: false, failed: false },teammateQuery: '',@@ -181,6 +182,7 @@ vi.mock('@/session/MobileComposerInputRow', () => ({// Like the real row: the card shows the tray above the input and the toolbar below it.MobileComposerInputRow: (props: any) => {h.row = props;+ if (props.inputRef) props.inputRef.current = { focus: h.inputFocus };return el('div', { 'data-testid': 'composer-row', 'data-card': props.cardActive ? 'true' : 'false' },props.cardActive ? props.accessoryAbove : props.leading,el('span', { 'data-testid': 'placeholder' }, props.placeholder),@@ -802,6 +804,20 @@ describe('group composer', () => {expect(h.row.value).toBe('');});+ // Replying to the same message again (e.g. after the keyboard was dismissed) must focus the+ // input again; the quote id alone did not change, so the second tap used to leave it unfocused.+ it('focuses the input on every reply tap, including the same message again', async () => {+ const originalId = '22222222-2222-4222-8222-222222222222';+ await render(group({ serverBacked: true, openPlan: null, messages: [+ message(originalId, 1, { authorName: '咪咪', authorBotId: 'mimi', content: '请回复这条' }),+ ] }));+ h.inputFocus.mockClear();+ await click(`botGroup.reply.${originalId}`);+ expect(h.inputFocus).toHaveBeenCalledTimes(1);+ await click(`botGroup.reply.${originalId}`);+ expect(h.inputFocus).toHaveBeenCalledTimes(2);+ });+it.each([true, false])('locks an existing draft when dissolved without being archived (direct server %s)', async server => {h.chat.server = server;const live = group({ openPlan: null, archived: false });diff --git a/apps/mobile/src/session/BotGroupChatScreen.tsx b/apps/mobile/src/session/BotGroupChatScreen.tsxindex 4bd8ad4747..8ea4059f9b 100644--- a/apps/mobile/src/session/BotGroupChatScreen.tsx+++ b/apps/mobile/src/session/BotGroupChatScreen.tsx@@ -141,6 +141,7 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId, messageId, nconst resolveMedia = useBotGroupRemoteMedia(deviceId);const [settings, setSettings] = useState(false);const [replyTo, setReplyTo] = useState<BotGroupQuoteView | null>(null);+ const [replyFocusRequest, setReplyFocusRequest] = useState(0);const leaveAfterSettings = useRef(false);const [continuing, setContinuing] = useState(false);const [planPending, setPlanPending] = useState<PlanPending | null>(null);@@ -539,7 +540,7 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId, messageId, n<BotGroupTimeline group={group} deviceId={deviceId} online={chat.online} identityFor={identityFor}highlightId={highlightId} onLocateMessage={locateMessage}pending={chat.pending} onPendingAction={(id, action) => { void chat.pendingAction?.(id, action).catch(error => report(error, 'groupChat.composer.sendFailed')); }}- onReply={(chat.server || group.serverBacked) && !group.archived && !group.dissolvedAt ? message => setReplyTo(botGroupQuoteFromMessage(message)) : undefined}+ onReply={(chat.server || group.serverBacked) && !group.archived && !group.dissolvedAt ? message => { setReplyTo(botGroupQuoteFromMessage(message)); setReplyFocusRequest(request => request + 1); } : undefined}onMessageLayout={(id, y, height) => {previewVisibility.setLayout(id, { y, height });messagePositions.current.set(id, y);@@ -579,7 +580,7 @@ export function BotGroupChatScreen({ deviceId, deviceName, groupId, messageId, n<MainWindowActionButton density="compact" action={{ label: t('message.quote.remove'), onPress: () => setReplyTo(null), testID: 'botGroup.cancelReply' }} /></View> : null}<BotGroupComposer members={group.members} identityFor={identityFor} deviceId={deviceId} online={(chat.online || !!chat.canQueue) && !group.archived && !group.dissolvedAt}- focusKey={replyTo?.messageId}+ quoteMessageId={replyTo?.messageId} focusRequest={replyFocusRequest}running={group.round.status === 'running'} planState={botGroupComposerPlanState(openBotGroupPlan(group), group.replyMode)}divisionSupported={!chat.server && (!group.singleSpeaker || group.supportsDivision === true)} attachmentsSupported={group.supportsAttachments === true} onSend={send} onStop={stop} /></AnimatedContentHeight>diff --git a/apps/mobile/src/session/BotGroupComposer.tsx b/apps/mobile/src/session/BotGroupComposer.tsxindex 62ffc1e079..1df7a5ebfd 100644--- a/apps/mobile/src/session/BotGroupComposer.tsx+++ b/apps/mobile/src/session/BotGroupComposer.tsx@@ -75,7 +75,7 @@ type MentionOption =| { kind: 'member'; label: string; member: BotGroupMemberView };export function BotGroupComposer({- members, identityFor, deviceId, online, running, planState, attachmentsSupported, divisionSupported = true, focusKey, onSend, onStop,+ members, identityFor, deviceId, online, running, planState, attachmentsSupported, divisionSupported = true, quoteMessageId, focusRequest, onSend, onStop,}: {members: readonly BotGroupMemberView[];identityFor: BotGroupIdentityLookup;@@ -86,7 +86,10 @@ export function BotGroupComposer({/** The computer takes attachments on `send` (`BotGroupRemoteChatData.supportsAttachments`). */attachmentsSupported: boolean;divisionSupported?: boolean;- focusKey?: string;+ /** The message being replied to; part of the send intent. */+ quoteMessageId?: string;+ /** Bumped on every reply tap, so replying to the same message again still focuses the input. */+ focusRequest?: number;/** Rejects with the host's error; the draft (and its tag) come back and the attachments stay. */onSend(input: BotGroupSendInput): Promise<void>;onStop(): Promise<void>;@@ -105,7 +108,7 @@ export function BotGroupComposer({const waitForLeaveDecision = useConfirmLeaveWhileUploading(waitingUploads);const [stopping, setStopping] = useState(false);const inputRef = useRef<NativeTextInput>(null);- useEffect(() => { if (focusKey) inputRef.current?.focus(); }, [focusKey]);+ useEffect(() => { if (focusRequest) inputRef.current?.focus(); }, [focusRequest]);const textRef = useRef(text); textRef.current = text;const selectionRef = useRef({ start: 0, end: 0 });const sendingRef = useRef(false);@@ -213,7 +216,7 @@ export function BotGroupComposer({tracked: draftTracked,});// Targets, tag and attachments are part of the same send intent.- const attempt = nextBotGroupSendAttempt(attemptRef.current, draftText, draftDivision, randomUUID, attachmentIds, mentions, focusKey);+ const attempt = nextBotGroupSendAttempt(attemptRef.current, draftText, draftDivision, randomUUID, attachmentIds, mentions, quoteMessageId);attemptRef.current = attempt;release = tray.holdForSend(attachmentIds);await onSend({ text: attempt.text, mentions, clientId: attempt.clientId, division: attempt.division, attachments });